Spaces:
Build error
Build error
Commit
·
d260a1c
1
Parent(s):
c72d473
update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,7 @@ model = None
|
|
17 |
model = load_model("MelaNet.h5", compile=False)
|
18 |
model.summary()
|
19 |
|
|
|
20 |
examples = ["benign.png", "malignant.png"]
|
21 |
labels = ["Benign", "Malignant"]
|
22 |
|
@@ -35,6 +36,7 @@ def preprocess_image(img_array):
|
|
35 |
return img_array
|
36 |
|
37 |
|
|
|
38 |
def inference(img):
|
39 |
img = preprocess_image(img)
|
40 |
img = np.expand_dims(img, 0)
|
@@ -44,13 +46,14 @@ def inference(img):
|
|
44 |
labels_probs = {labels[i]: float(preds[i]) for i, _ in enumerate(labels)}
|
45 |
return labels_probs
|
46 |
|
47 |
-
|
|
|
48 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2004.06824' target='_blank'>Melanoma Detection using Adversarial Training and Deep Transfer Learning</a> | <a href='https://github.com/hasibzunair/adversarial-lesions' target='_blank'>Github</a></p>"
|
49 |
|
50 |
gr.Interface(
|
51 |
fn=inference,
|
52 |
-
title=
|
53 |
-
description =
|
54 |
article=article,
|
55 |
inputs="image",
|
56 |
outputs="label",
|
|
|
17 |
model = load_model("MelaNet.h5", compile=False)
|
18 |
model.summary()
|
19 |
|
20 |
+
# Path to examples and class label list
|
21 |
examples = ["benign.png", "malignant.png"]
|
22 |
labels = ["Benign", "Malignant"]
|
23 |
|
|
|
36 |
return img_array
|
37 |
|
38 |
|
39 |
+
# Main inference function
|
40 |
def inference(img):
|
41 |
img = preprocess_image(img)
|
42 |
img = np.expand_dims(img, 0)
|
|
|
46 |
labels_probs = {labels[i]: float(preds[i]) for i, _ in enumerate(labels)}
|
47 |
return labels_probs
|
48 |
|
49 |
+
title = "Melanoma Detection Demo"
|
50 |
+
description = "This model predicts if the given image has benign or malignant symptoms. To use it, simply upload a skin lesion image, or click one of the examples to load them. Read more at the links below"
|
51 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2004.06824' target='_blank'>Melanoma Detection using Adversarial Training and Deep Transfer Learning</a> | <a href='https://github.com/hasibzunair/adversarial-lesions' target='_blank'>Github</a></p>"
|
52 |
|
53 |
gr.Interface(
|
54 |
fn=inference,
|
55 |
+
title=title,
|
56 |
+
description = description,
|
57 |
article=article,
|
58 |
inputs="image",
|
59 |
outputs="label",
|