Spaces:
Runtime error
Runtime error
cybernatedArt
commited on
Commit
·
191f9fb
1
Parent(s):
9d3cbb9
Update app.py
Browse files
app.py
CHANGED
@@ -1,51 +1,36 @@
|
|
1 |
-
import requests
|
2 |
-
import tensorflow as tf
|
3 |
-
from tensorflow import keras
|
4 |
-
from keras.models import Sequential, load_model
|
5 |
-
from tensorflow.keras.models import Sequential
|
6 |
-
from tensorflow.keras.layers import Activation, Dense, BatchNormalization, Conv2D, MaxPool2D, Dropout, Flatten
|
7 |
-
from tensorflow.keras.optimizers import Adam
|
8 |
-
from tensorflow.keras.metrics import categorical_crossentropy
|
9 |
-
from tensorflow.keras.preprocessing.image import ImageDataGenerator, load_img, array_to_img, img_to_array
|
10 |
-
from tensorflow.keras import datasets, layers, models
|
11 |
-
|
12 |
-
import pandas as pd
|
13 |
-
import numpy as np
|
14 |
-
|
15 |
import gradio as gr
|
|
|
16 |
|
17 |
-
|
18 |
-
model=load_model(load_file)
|
19 |
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
def classify_image(inp):
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
gr.Interface(
|
44 |
-
fn=classify_image,
|
45 |
-
inputs= image,
|
46 |
-
title = 'Prediction of Diabetic Retinopathy (DR)',
|
47 |
-
description = 'Demo for predicting the probability of having Diabetic Retinopathy. This version is currently using a DenseNet Model.',
|
48 |
-
article = explanation,
|
49 |
-
outputs=label,
|
50 |
-
theme = "peach"
|
51 |
-
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
|
4 |
+
path_to_model = "model_2.h5"
|
|
|
5 |
|
6 |
+
model = tf.keras.models.load_model(path_to_model)
|
7 |
|
8 |
+
labels = ['Acne and Rosacea Photos',
|
9 |
+
'Actinic Keratosis Basal Cell Carcinoma and other Malignant Lesions',
|
10 |
+
'Atopic Dermatitis Photos', 'Bullous Disease Photos',
|
11 |
+
'Cellulitis Impetigo and other Bacterial Infections',
|
12 |
+
'Eczema Photos', 'Exanthems and Drug Eruptions', 'Hair Loss Photos Alopecia and other Hair Diseases',
|
13 |
+
'Herpes HPV and other STDs Photos', 'Light Diseases and Disorders of Pigmentation',
|
14 |
+
'Lupus and other Connective Tissue diseases',
|
15 |
+
'Melanoma Skin Cancer Nevi and Moles', 'Nail Fungus and other Nail Disease',
|
16 |
+
'Poison Ivy Photos and other Contact Dermatitis',
|
17 |
+
'Psoriasis pictures Lichen Planus and related diseases', 'Scabies Lyme Disease and other Infestations and Bites',
|
18 |
+
'Seborrheic Keratoses and other Benign Tumors', 'Systemic Disease',
|
19 |
+
'Tinea Ringworm Candidiasis and other Fungal Infections',
|
20 |
+
'Urticaria Hives', 'Vascular Tumors', 'Vasculitis Photos', 'Warts Molluscum and other Viral Infections']
|
21 |
|
22 |
def classify_image(inp):
|
23 |
+
inp = inp.reshape((-1, 256, 256, 3))
|
24 |
+
prediction = model.predict(inp).flatten()
|
25 |
+
confidences = {labels[i]: float(prediction[i]) for i in range(23)}
|
26 |
+
return confidences
|
27 |
+
|
28 |
+
|
29 |
+
gr.Interface(fn=classify_image,
|
30 |
+
inputs=gr.inputs.Image(shape=(256, 256)),
|
31 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
32 |
+
examples=["123.jpg", "distal-subungual-onychomycosis-86.jpg"]).launch()
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|