Skip to content

Commit

Permalink
Merge pull request #762 from Aditijainnn/Picture_Animater
Browse files Browse the repository at this point in the history
Picture animater
  • Loading branch information
sanjay-kv authored Jul 16, 2024
2 parents bf2f31c + dc82b13 commit c48ed32
Show file tree
Hide file tree
Showing 15 changed files with 3,339 additions and 0 deletions.
Binary file added Picture Animater/Input Image/Amy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Picture Animater/Output Image/AmyOP.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Picture Animater/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Animate Me!

## About the Project:
- It is a simple OpenCV project that converts input image to a cartoon equivalent
- Unlike the classical approach, Image Quantization is used to differentiate regions

## How to Use:
- Add your image to the [Input Folder](https://github.com/Sidhved/ML-ProjectKart/tree/main/Animate%20Me!/Input%20Image) and/or change the corresponding image address in the [Animate_Me.py](https://github.com/Sidhved/ML-ProjectKart/blob/main/Animate%20Me!/Animate_Me.py)
- A window with the output image will pop up (You can also find the image saved in the [Output Folder](https://github.com/Sidhved/ML-ProjectKart/tree/main/Animate%20Me!/Output%20Image))
- To learn about the intermediary steps, run the [Animate_Me.ipynb](https://github.com/Sidhved/ML-ProjectKart/blob/main/Animate%20Me!/Animate_Me.ipynb)

## Further Work / Improvements:
- Can convert into an API with self adjusting Edge Parameters
- Could be worked upon to create a real-time filter used on different social media platforms
- Connect with me through [LinkedIn](https://www.linkedin.com/in/sidhved-warik/) or Follow me on [GitHub](https://github.com/Sidhved) to discuss about future work

## Example
Original Image<br>
![Input Image](https://github.com/Sidhved/ML-ProjectKart/blob/main/Animate%20Me!/Input%20Image/Amy.jpg)
<br>Output Image<br>
![Output Image](https://github.com/Sidhved/ML-ProjectKart/blob/main/Animate%20Me!/Output%20Image/AmyOP.jpeg)<br>
329 changes: 329 additions & 0 deletions Picture Animater/animate_me.ipynb

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions Picture Animater/animate_me.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#Importing Necessary Libraries
import cv2
import numpy as np
import matplotlib.pyplot as plt

#Reading Image and Converting into required format
img = cv2.imread("Input Image\Amy.jpg") #Change the address according to source image
imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

#Identifying Edges
edges = cv2.Canny(imgRGB, 300, 300)

#Applying median blur to obtain edges of even density and continuity
gray = cv2.cvtColor(imgRGB, cv2.COLOR_BGR2GRAY)
gray1 = cv2.medianBlur(gray, 5)
edges = cv2.adaptiveThreshold(gray1, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 5)

#Magic Function - Color Quantization
def color_quantization(img, k):
data = np.float32(img).reshape((-1, 3))
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 1.0)
ret, label, center = cv2.kmeans(data, k, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
result = center[label.flatten()]
result = result.reshape(img.shape)
return result

#Quantized Image with discrete color patterns
img_1 = color_quantization(imgRGB, 7)

#Smoothening sharp region tranistion
blurred = cv2.medianBlur(img_1, 5)

#Finally, Adding the Edges to complete the cartoonification
cartoon = cv2.bitwise_and(blurred, blurred, mask=edges)
cv2.imshow("Cartoon Output", cartoon)
cv2.waitKey()
fileName = "Output Image/AmyOP.jpeg" #insert desired image name here
cv2.imwrite(fileName, cartoon)
1 change: 1 addition & 0 deletions Skin Cancer Prediction/Dataset_Link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://drive.google.com/file/d/1xLfSQUGDl8ezNNbUkpuHOYvSpTyxVhCs/view
1,068 changes: 1,068 additions & 0 deletions Skin Cancer Prediction/Melanoma_SkinCancer_Detection.ipynb

Large diffs are not rendered by default.

1,851 changes: 1,851 additions & 0 deletions Skin Cancer Prediction/Practice_Model/PracticeModels.ipynb

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions Skin Cancer Prediction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Melanoma Skin Cancer Detection

In cancer, there are over 200 different forms. Out of 200, melanoma is the deadliest form of skin cancer. The diagnostic procedure for melanoma starts with clinical screening, followed by dermoscopic analysis and histopathological examination. Melanoma skin cancer is highly curable if it gets identified at the early stages. The first step of Melanoma skin cancer diagnosis is to conduct a visual examination of the skin's affected area. Dermatologists take the dermatoscopic images of the skin lesions by the high-speed camera, which have an accuracy of 65-80% in the melanoma diagnosis without any additional technical support. With further visual examination by cancer treatment specialists and dermatoscopic images, the overall prediction rate of melanoma diagnosis raised to 75-84% accuracy. The project aims to build an automated classification system based on image processing techniques to classify skin cancer using skin lesions images.


## Dataset
The dataset consists of 2357 images of malignant and benign oncological diseases, which were formed from the International Skin Imaging Collaboration (ISIC). All images were sorted according to the classification taken with ISIC, and all subsets were divided into the same number of images.


## CNN Architecture Design
To classify skin cancer using skin lesions images. To achieve higher accuracy and results on the classification task, I have built custom CNN model.

- Rescalling Layer - To rescale an input in the [0, 255] range to be in the [0, 1] range.
- Convolutional Layer - Convolutional layers apply a convolution operation to the input, passing the result to the next layer. A convolution converts all the pixels in its receptive field into a single value. For example, if you would apply a convolution to an image, you will be decreasing the image size as well as bringing all the information in the field together into a single pixel.
- Pooling Layer - Pooling layers are used to reduce the dimensions of the feature maps. Thus, it reduces the number of parameters to learn and the amount of computation performed in the network. The pooling layer summarises the features present in a region of the feature map generated by a convolution layer.
- Dropout Layer - The Dropout layer randomly sets input units to 0 with a frequency of rate at each step during training time, which helps prevent overfitting.
- Flatten Layer - Flattening is converting the data into a 1-dimensional array for inputting it to the next layer. We flatten the output of the convolutional layers to create a single long feature vector. And it is connected to the final classification model, which is called a fully-connected layer.
- Dense Layer - The dense layer is a neural network layer that is connected deeply, which means each neuron in the dense layer receives input from all neurons of its previous layer.
- Activation Function(ReLU) - The rectified linear activation function or ReLU for short is a piecewise linear function that will output the input directly if it is positive, otherwise, it will output zero.The rectified linear activation function overcomes the vanishing gradient problem, allowing models to learn faster and perform better.
- Activation Function(Softmax) - The softmax function is used as the activation function in the output layer of neural network models that predict a multinomial probability distribution. The main advantage of using Softmax is the output probabilities range. The range will 0 to 1, and the sum of all the probabilities will be equal to one.


## References
Melanoma Skin Cancer from https://www.cancer.org/cancer/melanoma-skin-cancer/about/what-is-melanoma.html

Introduction to CNN from https://www.analyticsvidhya.com/blog/2021/05/convolutional-neural-networks-cnn/

Image classification using CNN from https://www.analyticsvidhya.com/blog/2020/02/learn-image-classification-cnn-convolutional-neural-networks-3-datasets/

Efficient way to build CNN architecture from https://towardsdatascience.com/a-guide-to-an-efficient-way-to-build-neural-network-architectures-part-ii-hyper-parameter-42efca01e5d7
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c48ed32

Please sign in to comment.