alok94 commited on
Commit
f49f32e
·
1 Parent(s): bb8ae88

Upload 6 files

Browse files

training commit

Files changed (4) hide show
  1. .gitignore +165 -0
  2. app.py +408 -0
  3. requirements.txt +16 -0
  4. skin_cancer_model.h5 +3 -0
.gitignore ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Inserted by me
2
+ digit_model.h5
3
+ digit_model.keras
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+
11
+ # C extensions
12
+ *.so
13
+
14
+ # Distribution / packaging
15
+ .Python
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ wheels/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ .pybuilder/
81
+ target/
82
+
83
+ # Jupyter Notebook
84
+ .ipynb_checkpoints
85
+
86
+ # IPython
87
+ profile_default/
88
+ ipython_config.py
89
+
90
+ # pyenv
91
+ # For a library or package, you might want to ignore these files since the code is
92
+ # intended to run in multiple environments; otherwise, check them in:
93
+ # .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ #Pipfile.lock
101
+
102
+ # poetry
103
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
104
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
105
+ # commonly ignored for libraries.
106
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
107
+ #poetry.lock
108
+
109
+ # pdm
110
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
111
+ #pdm.lock
112
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
113
+ # in version control.
114
+ # https://pdm.fming.dev/#use-with-ide
115
+ .pdm.toml
116
+
117
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
118
+ __pypackages__/
119
+
120
+ # Celery stuff
121
+ celerybeat-schedule
122
+ celerybeat.pid
123
+
124
+ # SageMath parsed files
125
+ *.sage.py
126
+
127
+ # Environments
128
+ .env
129
+ .venv
130
+ env/
131
+ venv/
132
+ ENV/
133
+ env.bak/
134
+ venv.bak/
135
+
136
+ # Spyder project settings
137
+ .spyderproject
138
+ .spyproject
139
+
140
+ # Rope project settings
141
+ .ropeproject
142
+
143
+ # mkdocs documentation
144
+ /site
145
+
146
+ # mypy
147
+ .mypy_cache/
148
+ .dmypy.json
149
+ dmypy.json
150
+
151
+ # Pyre type checker
152
+ .pyre/
153
+
154
+ # pytype static type analyzer
155
+ .pytype/
156
+
157
+ # Cython debug symbols
158
+ cython_debug/
159
+
160
+ # PyCharm
161
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
162
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
164
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
165
+ #.idea/
app.py ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import system libs
2
+ import os
3
+ import time
4
+ import shutil
5
+ import itertools
6
+
7
+ # import data handling tools
8
+ import cv2
9
+ import numpy as np
10
+ import pandas as pd
11
+ import seaborn as sns
12
+ sns.set_style('darkgrid')
13
+ import matplotlib.pyplot as plt
14
+ import gradio as gr
15
+
16
+ # import Deep learning Libraries
17
+ import tensorflow as tf
18
+ from tensorflow import keras
19
+ from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation, Dropout, BatchNormalization
20
+ from tensorflow.keras.models import Model, load_model, Sequential
21
+ from tensorflow.keras.preprocessing.image import ImageDataGenerator
22
+ from sklearn.metrics import confusion_matrix, classification_report
23
+ from sklearn.model_selection import train_test_split
24
+ from tensorflow.keras.optimizers import Adam, Adamax
25
+ from tensorflow.keras import regularizers
26
+ from tensorflow.keras.metrics import categorical_crossentropy
27
+ from tensorflow.keras.utils import to_categorical
28
+ from PIL import Image
29
+ from sklearn.model_selection import train_test_split
30
+
31
+
32
+ # Ignore Warnings
33
+ import warnings
34
+ warnings.filterwarnings("ignore")
35
+ print ('modules loaded')
36
+ #---Training-----------------------------
37
+ # ! pip install -q kaggle
38
+ # from google.colab import files
39
+
40
+ # files.upload()
41
+ # ! mkdir ~/.kaggle
42
+
43
+ # ! cp kaggle.json ~/.kaggle/
44
+ # ! chmod 600 ~/.kaggle/kaggle.json
45
+ # ! kaggle datasets list
46
+ # !kaggle datasets download -d kmader/skin-cancer-mnist-ham10000
47
+ # ! mkdir kaggle
48
+ # ! unzip skin-cancer-mnist-ham10000.zip -d kaggle
49
+ # data_dir = '/content/kaggle/hmnist_28_28_RGB.csv'
50
+ # data = pd.read_csv(data_dir)
51
+ # print(data.shape)
52
+ # data.head()
53
+
54
+ # Label = data["label"]
55
+ # Data = data.drop(columns=["label"])
56
+ # print(data.shape)
57
+ # Data.head()
58
+
59
+ # from imblearn.over_sampling import RandomOverSampler
60
+
61
+ # oversample = RandomOverSampler()
62
+ # Data, Label = oversample.fit_resample(Data, Label)
63
+ # print(Data.shape)
64
+ # Data = np.array(Data).reshape(-1,28, 28,3)
65
+ # print('Shape of Data :', Data.shape)
66
+
67
+ # Label = np.array(Label)
68
+ # Label
69
+ # classes = {4: ('nv', ' melanocytic nevi'),
70
+ # 6: ('mel', 'melanoma'),
71
+ # 2 :('bkl', 'benign keratosis-like lesions'),
72
+ # 1:('bcc' , ' basal cell carcinoma'),
73
+ # 5: ('vasc', ' pyogenic granulomas and hemorrhage'),
74
+ # 0: ('akiec', 'Actinic keratoses and intraepithelial carcinomae'),
75
+ # 3: ('df', 'dermatofibroma')}
76
+
77
+
78
+
79
+ # X_train , X_test , y_train , y_test = train_test_split(Data , Label , test_size = 0.25 , random_state = 49)
80
+
81
+ # print(f'X_train shape: {X_train.shape}\nX_test shape: {X_test.shape}')
82
+ # print(f'y_train shape: {y_train.shape}\ny_test shape: {y_test.shape}')
83
+
84
+ # y_train = to_categorical(y_train)
85
+ # y_test = to_categorical(y_test)
86
+
87
+ # datagen = ImageDataGenerator(rescale=(1./255)
88
+ # ,rotation_range=10
89
+ # ,zoom_range = 0.1
90
+ # ,width_shift_range=0.1
91
+ # ,height_shift_range=0.1)
92
+
93
+ # testgen = ImageDataGenerator(rescale=(1./255))
94
+
95
+ # from keras.callbacks import ReduceLROnPlateau
96
+
97
+ # learning_rate_reduction = ReduceLROnPlateau(monitor='val_accuracy'
98
+ # , patience = 2
99
+ # , verbose=1
100
+ # ,factor=0.5
101
+ # , min_lr=0.00001)
102
+
103
+ # model = keras.models.Sequential()
104
+
105
+ # # Create Model Structure
106
+ # model.add(keras.layers.Input(shape=[28, 28, 3]))
107
+ # model.add(keras.layers.Conv2D(32, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
108
+ # model.add(keras.layers.MaxPooling2D())
109
+ # model.add(keras.layers.BatchNormalization())
110
+
111
+ # model.add(keras.layers.Conv2D(64, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
112
+ # model.add(keras.layers.Conv2D(64, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
113
+ # model.add(keras.layers.MaxPooling2D())
114
+ # model.add(keras.layers.BatchNormalization())
115
+
116
+ # model.add(keras.layers.Conv2D(128, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
117
+ # model.add(keras.layers.Conv2D(128, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
118
+ # model.add(keras.layers.MaxPooling2D())
119
+ # model.add(keras.layers.BatchNormalization())
120
+
121
+ # model.add(keras.layers.Conv2D(256, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
122
+ # model.add(keras.layers.Conv2D(256, (3, 3), activation='relu', padding='same', kernel_initializer='he_normal'))
123
+ # model.add(keras.layers.MaxPooling2D())
124
+
125
+ # model.add(keras.layers.Flatten())
126
+
127
+ # model.add(keras.layers.Dropout(rate=0.2))
128
+ # model.add(keras.layers.Dense(units=256, activation='relu', kernel_initializer='he_normal'))
129
+ # model.add(keras.layers.BatchNormalization())
130
+
131
+ # model.add(keras.layers.Dense(units=128, activation='relu', kernel_initializer='he_normal'))
132
+ # model.add(keras.layers.BatchNormalization())
133
+
134
+ # model.add(keras.layers.Dense(units=64, activation='relu', kernel_initializer='he_normal'))
135
+ # model.add(keras.layers.BatchNormalization())
136
+
137
+ # model.add(keras.layers.Dense(units=32, activation='relu', kernel_initializer='he_normal', kernel_regularizer=keras.regularizers.L1L2()))
138
+ # model.add(keras.layers.BatchNormalization())
139
+
140
+ # model.add(keras.layers.Dense(units=7, activation='softmax', kernel_initializer='glorot_uniform', name='classifier'))
141
+
142
+ # model.compile(Adamax(learning_rate= 0.001), loss= 'categorical_crossentropy', metrics= ['accuracy'])
143
+
144
+ # model.summary()
145
+
146
+ # history = model.fit(X_train ,
147
+ # y_train ,
148
+ # epochs=25 ,
149
+ # batch_size=128,
150
+ # validation_data=(X_test , y_test) ,
151
+ # callbacks=[learning_rate_reduction])
152
+
153
+ # def plot_training(hist):
154
+ # tr_acc = hist.history['accuracy']
155
+ # tr_loss = hist.history['loss']
156
+ # val_acc = hist.history['val_accuracy']
157
+ # val_loss = hist.history['val_loss']
158
+ # index_loss = np.argmin(val_loss)
159
+ # val_lowest = val_loss[index_loss]
160
+ # index_acc = np.argmax(val_acc)
161
+ # acc_highest = val_acc[index_acc]
162
+
163
+ # plt.figure(figsize= (20, 8))
164
+ # plt.style.use('fivethirtyeight')
165
+ # Epochs = [i+1 for i in range(len(tr_acc))]
166
+ # loss_label = f'best epoch= {str(index_loss + 1)}'
167
+ # acc_label = f'best epoch= {str(index_acc + 1)}'
168
+
169
+ # plt.subplot(1, 2, 1)
170
+ # plt.plot(Epochs, tr_loss, 'r', label= 'Training loss')
171
+ # plt.plot(Epochs, val_loss, 'g', label= 'Validation loss')
172
+ # plt.scatter(index_loss + 1, val_lowest, s= 150, c= 'blue', label= loss_label)
173
+ # plt.title('Training and Validation Loss')
174
+ # plt.xlabel('Epochs')
175
+ # plt.ylabel('Loss')
176
+ # plt.legend()
177
+
178
+ # plt.subplot(1, 2, 2)
179
+ # plt.plot(Epochs, tr_acc, 'r', label= 'Training Accuracy')
180
+ # plt.plot(Epochs, val_acc, 'g', label= 'Validation Accuracy')
181
+ # plt.scatter(index_acc + 1 , acc_highest, s= 150, c= 'blue', label= acc_label)
182
+ # plt.title('Training and Validation Accuracy')
183
+ # plt.xlabel('Epochs')
184
+ # plt.ylabel('Accuracy')
185
+ # plt.legend()
186
+
187
+ # plt.tight_layout
188
+ # plt.show()
189
+
190
+ # plot_training(history)
191
+
192
+ # train_score = model.evaluate(X_train, y_train, verbose= 1)
193
+ # test_score = model.evaluate(X_test, y_test, verbose= 1)
194
+
195
+ # print("Train Loss: ", train_score[0])
196
+ # print("Train Accuracy: ", train_score[1])
197
+ # print('-' * 20)
198
+ # print("Test Loss: ", test_score[0])
199
+ # print("Test Accuracy: ", test_score[1])
200
+
201
+ # y_true = np.array(y_test)
202
+ # y_pred = model.predict(X_test)
203
+
204
+ # y_pred = np.argmax(y_pred , axis=1)
205
+ # y_true = np.argmax(y_true , axis=1)
206
+
207
+ # classes_labels = []
208
+ # for key in classes.keys():
209
+ # classes_labels.append(key)
210
+
211
+ # print(classes_labels)
212
+
213
+ # # Confusion matrix
214
+ # cm = cm = confusion_matrix(y_true, y_pred, labels=classes_labels)
215
+
216
+ # plt.figure(figsize= (10, 10))
217
+ # plt.imshow(cm, interpolation= 'nearest', cmap= plt.cm.Blues)
218
+ # plt.title('Confusion Matrix')
219
+ # plt.colorbar()
220
+
221
+ # tick_marks = np.arange(len(classes))
222
+ # plt.xticks(tick_marks, classes, rotation= 45)
223
+ # plt.yticks(tick_marks, classes)
224
+
225
+
226
+ # thresh = cm.max() / 2.
227
+ # for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])):
228
+ # plt.text(j, i, cm[i, j], horizontalalignment= 'center', color= 'white' if cm[i, j] > thresh else 'black')
229
+
230
+ # plt.tight_layout()
231
+ # plt.ylabel('True Label')
232
+ # plt.xlabel('Predicted Label')
233
+
234
+ # plt.show()
235
+
236
+ # #Save the model
237
+ # model.save('skin_cancer_model.h5')
238
+
239
+ # converter = tf.lite.TFLiteConverter.from_keras_model(model)
240
+ # tflite_model = converter.convert()
241
+
242
+ # print("model converted")
243
+
244
+ # # Save the model.
245
+ # with open('skin_cancer_model.tflite', 'wb') as f:
246
+ # f.write(tflite_model)
247
+
248
+ #Training End------------------------------------------
249
+
250
+ skin_classes = {4: ('nv', ' melanocytic nevi'),
251
+ 6: ('mel', 'melanoma'),
252
+ 2 :('bkl', 'benign keratosis-like lesions'),
253
+ 1:('bcc' , ' basal cell carcinoma'),
254
+ 5: ('vasc', ' pyogenic granulomas and hemorrhage'),
255
+ 0: ('akiec', 'Actinic keratoses and intraepithelial carcinomae'),
256
+ 3: ('df', 'dermatofibroma')}
257
+
258
+ #Use saved model
259
+ loaded_model = tf.keras.models.load_model('skin_cancer_model.h5', compile=False)
260
+ loaded_model.compile(Adamax(learning_rate= 0.001), loss= 'categorical_crossentropy', metrics= ['accuracy'])
261
+
262
+ def predict_digit(image):
263
+ if image is not None:
264
+
265
+ #Use saved model
266
+ loaded_model = tf.keras.models.load_model('skin_cancer_model.h5', compile=False)
267
+ loaded_model.compile(Adamax(learning_rate= 0.001), loss= 'categorical_crossentropy', metrics= ['accuracy'])
268
+ img = image.resize((28, 28))
269
+ img_array = tf.keras.preprocessing.image.img_to_array(img)
270
+ img_array = tf.expand_dims(img_array, 0)
271
+ print(img_array)
272
+
273
+
274
+
275
+ predictions = loaded_model.predict(img_array)
276
+ print(predictions)
277
+ #class_labels = [] # data classes
278
+ score = tf.nn.softmax(predictions[0])*100
279
+
280
+
281
+ print(score)
282
+ print(skin_classes[np.argmax(score)])
283
+ simple = pd.DataFrame(
284
+ {
285
+ "skin condition": ["akiec", "bcc", "bkl", "df", "nv", "vasc", "mel"],
286
+ "probability": score,
287
+ "full skin condition": [ 'Actinic keratoses',
288
+ ' basal cell carcinoma',
289
+ 'benign keratosis-like lesions',
290
+ 'dermatofibroma',
291
+ ' melanocytic nevi',
292
+ ' pyogenic granulomas and hemorrhage',
293
+ 'melanoma'],
294
+ }
295
+ )
296
+
297
+
298
+
299
+
300
+ predicted_skin_condition=skin_classes[np.argmax(score)][1]+" ("+ skin_classes[np.argmax(score)][0]+")"
301
+ return predicted_skin_condition, gr.BarPlot.update(
302
+ simple,
303
+ x="skin condition",
304
+ y="probability",
305
+ x_title="Skin Condition",
306
+ y_title="Classification Probabilities",
307
+ title="Skin Cancer Classification Probability",
308
+ tooltip=["full skin condition", "probability"],
309
+ vertical=False,
310
+ y_lim=[0, 100],
311
+ color="full skin condition"
312
+ )
313
+
314
+ else:
315
+ simple_empty = pd.DataFrame(
316
+ {
317
+ "skin condition": ["akiec", "bcc", "bkl", "df", "nv", "vasc", "mel"],
318
+ "probability": [0,0,0,0,0,0,0],
319
+ "full skin condition": [ 'Actinic keratoses',
320
+ ' basal cell carcinoma',
321
+ 'benign keratosis-like lesions',
322
+ 'dermatofibroma',
323
+ ' melanocytic nevi',
324
+ ' pyogenic granulomas and hemorrhage',
325
+ 'melanoma'],
326
+ }
327
+ )
328
+
329
+ return " ", gr.BarPlot.update(
330
+ simple_empty,
331
+ x="skin condition",
332
+ y="probability",
333
+ x_title="Digits",
334
+ y_title="Identification Probabilities",
335
+ title="Identification Probability",
336
+ tooltip=["full skin condition", "probability"],
337
+ vertical=False,
338
+ y_lim=[0, 100],
339
+
340
+ )
341
+
342
+ skin_images = [
343
+ ("skin_image/mel.jpg",'mel'),
344
+ ("skin_image/nv3.jpg",'nv'),
345
+ ("skin_image/bkl.jpg",'bkl'),
346
+ ("skin_image/df.jpg",'df'),
347
+ ("skin_image/akiec.jpg",'akiec'),
348
+ ("skin_image/bcc.jpg",'bcc'),
349
+ ("skin_image/vasc.jpg",'vasc'),
350
+ ("skin_image/nv2.jpg",'nv'),
351
+ ("skin_image/akiec2.jpg",'akiec'),
352
+ ("skin_image/bkl2.jpg",'bkl'),
353
+ ("skin_image/nv.jpg",'nv'),
354
+
355
+ ]
356
+
357
+ def image_from_gallary(evt: gr.SelectData):
358
+ print(evt.index)
359
+ return skin_images[evt.index][0]
360
+
361
+
362
+
363
+ css='''
364
+ #title_head{
365
+ text-align: center;
366
+ text-weight: bold;
367
+ text-size:30px;
368
+ }
369
+ #name_head{
370
+ text-align: center;
371
+ }
372
+ '''
373
+
374
+ with gr.Blocks(css=css) as demo:
375
+
376
+
377
+ with gr.Row():
378
+ with gr.Column():
379
+ gr.Markdown("<h1>Skin Cancer Classifier</h1>", elem_id='title_head')
380
+ gr.Markdown("<h2>By Alok</h2>", elem_id="name_head")
381
+ with gr.Row():
382
+ with gr.Column():
383
+ gr.Markdown("<h3>Browse or Select from given Image</h3>", elem_id='info')
384
+ with gr.Row():
385
+ img_upload=gr.Image(type="pil")
386
+ with gr.Row():
387
+ with gr.Column():
388
+ clear=gr.ClearButton(img_upload)
389
+ with gr.Column():
390
+ btn=gr.Button("Identify")
391
+ gry=gr.Gallery(value=skin_images, columns=3, rows=2, show_label=True)
392
+
393
+ with gr.Column():
394
+ gr.Markdown("Most probable skin condition")
395
+ label=gr.Label("")
396
+ gr.Markdown("Other possible values")
397
+ bar = gr.BarPlot()
398
+
399
+
400
+ btn.click(predict_digit,inputs=[img_upload],outputs=[label,bar])
401
+ gry.select(image_from_gallary, outputs=img_upload)
402
+
403
+
404
+
405
+
406
+ demo.launch(debug=True)
407
+
408
+
requirements.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ tensorflow
2
+ keras
3
+
4
+ scikit_learn<1.3.0
5
+ seaborn==0.12.2
6
+
7
+
8
+ gradio
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
skin_cancer_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9679368b2f6da9e936c2b9306044d7b90e887189ee279d643c86aede2b844f75
3
+ size 15456152