syaha commited on
Commit
0c1346f
1 Parent(s): 89ff8e6

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from tensorflow.keras.models import load_model
3
+ import numpy as np
4
+ import tensorflow as tf
5
+
6
+ model = load_model("skin_cancer_model.h5")
7
+
8
+ def predict_image(image):
9
+ img = tf.image.resize(image, (224, 224))
10
+ img = np.expand_dims(img, axis=0) / 255.0
11
+
12
+ prediction = model.predict(img)
13
+ predicted_class = np.argmax(prediction, axis=1)[0]
14
+
15
+ class_names = ['akiec', 'bcc', 'bkl', 'df', 'nv', 'vasc', 'mel']
16
+ disease_info = {
17
+ 'akiec': "Actinic Keratoses and Intraepithelial Carcinoma (pre-cancerous lesion)",
18
+ 'bcc': "Basal Cell Carcinoma (a common type of skin cancer)",
19
+ 'bkl': "Benign Keratosis (non-cancerous lesion)",
20
+ 'df': "Dermatofibroma (benign skin lesion)",
21
+ 'nv': "Melanocytic Nevus (a common mole)",
22
+ 'vasc': "Vascular Lesions (benign lesion of blood vessels)",
23
+ 'mel': "Melanoma (most dangerous type of skin cancer)"
24
+ }
25
+
26
+ return f"{class_names[predicted_class]}: {disease_info[class_names[predicted_class]]}"
27
+
28
+ iface = gr.Interface(fn=predict_image, inputs="image", outputs="text")
29
+ iface.launch()