cybernatedArt commited on
Commit
d7119c4
1 Parent(s): 921a918

initial commit

Browse files
Files changed (1) hide show
  1. app.py +21 -28
app.py CHANGED
@@ -1,30 +1,20 @@
 
1
  import gradio as gr
2
- import tensorflow as tf
3
- import numpy as np
4
- import requests
5
-
6
- model = tf.keras.models.load_model('model_2.h5')
7
-
8
- #function
9
- def example(image):
10
- image = image.reshape(-1, 256, 256, 3)
11
- prediction = model.predict(image).flatten()
12
- #return {class_names[i]: float(prediction[i]) for i in range(4)}
13
- class_names = ['Acne and Rosacea Photos', 'Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions', 'Atopic Dermatitis Photos',
14
- 'Bullous Disease Photos', 'Cellulitis Impetigo and other Bacterial Infections', 'Eczema Photos', 'Exanthems and Drug Eruptions',
15
- 'Hair Loss Photos Alopecia and other Hair Diseases', 'Herpes HPV and other STDs Photos', 'Light Diseases and Disorders of Pigmentation',
16
- 'Lupus and other Connective Tissue diseases', 'Melanoma Skin Cancer Nevi and Moles', 'Nail Fungus and other Nail Disease',
17
- 'Poison Ivy Photos and other Contact Dermatitis', 'Psoriasis pictures Lichen Planus and related diseases',
18
- 'Scabies Lyme Disease and other Infestations and Bites', 'Seborrheic Keratoses and other Benign Tumors', 'Systemic Disease',
19
- 'Tinea Ringworm Candidiasis and other Fungal Infections', 'Urticaria Hives', 'Vascular Tumors', 'Vasculitis Photos',
20
- 'Warts Molluscum and other Viral Infections']
21
- return {class_names[i]: float(prediction[i]) for i in range(23)}
22
-
23
-
24
- # initializing the input component
25
- image = gr.inputs.Image(shape = (256, 256))
26
- # initializing the output component
27
- label = gr.outputs.Label(num_top_classes = 4)
28
 
29
  # launching the interface
30
 
@@ -41,8 +31,11 @@ examples = [
41
  ]
42
 
43
  # launching the interface
44
- gr.Interface( fn=example,inputs = image,outputs = label,capture_session = True,
 
 
 
45
  title=title,
46
  description= description,
47
  examples = examples
48
- ).launch(share=True,inbrowser=True)
 
1
+ from fastai.vision.all import *
2
  import gradio as gr
3
+
4
+
5
+ # Cargamos el learner
6
+ learn = load_learner('Pickle_SD_Model.pkl')
7
+
8
+ # Definimos las etiquetas de nuestro modelo
9
+ labels = learn.dls.vocab
10
+
11
+
12
+ # Definimos una función que se encarga de llevar a cabo las predicciones
13
+ def predict(img):
14
+ img = PILImage.create(img)
15
+ pred,pred_idx,probs = learn.predict(img)
16
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
17
+
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # launching the interface
20
 
 
31
  ]
32
 
33
  # launching the interface
34
+ gr.Interface( fn=predict,
35
+ inputs = gr.inputs.Image(shape=(256, 256)),
36
+ outputs = gr.outputs.Label(num_top_classes=3),
37
+ capture_session = True,
38
  title=title,
39
  description= description,
40
  examples = examples
41
+ ).launch(share=True)