cybernatedArt commited on
Commit
5b27df7
1 Parent(s): d6eccad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -28
app.py CHANGED
@@ -1,29 +1,33 @@
1
  import gradio as gr
2
- from fastai import *
3
- from fastai.vision.all import *
4
-
5
- import pathlib
6
- plt = platform.system()
7
- if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
8
-
9
- learn = load_learner('Pickle_SD_Model.pkl')
10
-
11
- labels = learn.dls.vocab
12
-
13
- set_label = gr.outputs.Textbox(label="Predicted Class")
14
-
15
- set_prob = gr.outputs.Label(num_top_classes=4, label="Predicted Probability Per Class")
16
-
17
-
18
- def predict(img):
19
- img = PILImage.create(img)
20
- pred,pred_idx,probs = learn.predict(img)
21
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
22
-
23
- title = "Tomato Disease Classifier"
24
- description = "Classify Tomato Disease from leaf"
25
- interpretation='default'
26
-
27
- enable_queue=True
28
-
29
- gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(256,256)), outputs=gr.outputs.Label(num_top_classes=4) ).launch(share=True)
 
 
 
 
 
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)