Spaces:
Runtime error
Runtime error
cybernatedArt
commited on
Commit
•
5b27df7
1
Parent(s):
d6eccad
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
import
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
import requests
|
5 |
+
from tensorflow.keras.models import load_model
|
6 |
+
|
7 |
+
|
8 |
+
model = tf.keras.models.load_model('/model_2.h5')
|
9 |
+
|
10 |
+
#function
|
11 |
+
def example(image):
|
12 |
+
image = image.reshape(-1, 256, 256, 3)
|
13 |
+
prediction = model.predict(image).flatten()
|
14 |
+
#return {class_names[i]: float(prediction[i]) for i in range(4)}
|
15 |
+
class_names = ['Acne and Rosacea Photos', 'Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions', 'Atopic Dermatitis Photos', 'Bullous Disease Photos', 'Cellulitis Impetigo and other Bacterial Infections', 'Eczema Photos', 'Exanthems and Drug Eruptions', 'Hair Loss Photos Alopecia and other Hair Diseases', 'Herpes HPV and other STDs Photos', 'Light Diseases and Disorders of Pigmentation', 'Lupus and other Connective Tissue diseases', 'Melanoma Skin Cancer Nevi and Moles', 'Nail Fungus and other Nail Disease', 'Poison Ivy Photos and other Contact Dermatitis', 'Psoriasis pictures Lichen Planus and related diseases', 'Scabies Lyme Disease and other Infestations and Bites', 'Seborrheic Keratoses and other Benign Tumors', 'Systemic Disease', 'Tinea Ringworm Candidiasis and other Fungal Infections', 'Urticaria Hives', 'Vascular Tumors', 'Vasculitis Photos', 'Warts Molluscum and other Viral Infections']
|
16 |
+
return {class_names[i]: float(prediction[i]) for i in range(23)}
|
17 |
+
|
18 |
+
|
19 |
+
# initializing the input component
|
20 |
+
image = gr.inputs.Image(shape = (256, 256))
|
21 |
+
# initializing the output component
|
22 |
+
label = gr.outputs.Label(num_top_classes = 4)
|
23 |
+
|
24 |
+
|
25 |
+
# launching the interface
|
26 |
+
gr.Interface(fn = example,
|
27 |
+
inputs = image,
|
28 |
+
outputs = label,
|
29 |
+
capture_session = True,
|
30 |
+
title="SKIN DISEASE PREDICTION",
|
31 |
+
description= "An ResNet50 model.",
|
32 |
+
theme = "darkhuggingface"
|
33 |
+
).launch(share=True)
|