Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,18 +38,19 @@ def predict(image_path):
|
|
| 38 |
predicted_class = 'Pneumonia' if predicted_probabilities > 0.5 else 'Normal'
|
| 39 |
confidence_score = predicted_probabilities if predicted_class == 'Pneumonia' else 1 - predicted_probabilities
|
| 40 |
confidence_score *= 100
|
| 41 |
-
confidence_score = str(confidence_score) + "%"
|
| 42 |
|
| 43 |
-
return
|
| 44 |
|
| 45 |
image_component = gr.Image(type="filepath", label="Chest X-ray Image")
|
| 46 |
label_component = gr.Label(label="Classification result", num_top_classes=1)
|
|
|
|
|
|
|
| 47 |
description = ""
|
| 48 |
title = "Pneumonia Classifier"
|
| 49 |
|
| 50 |
demo = gr.Interface(fn=predict,
|
| 51 |
inputs=image_component,
|
| 52 |
-
outputs=label_component,
|
| 53 |
description=description,
|
| 54 |
title=title,
|
| 55 |
examples=["demo_example_imgs/NORMAL-0001-0001.jpeg",
|
|
|
|
| 38 |
predicted_class = 'Pneumonia' if predicted_probabilities > 0.5 else 'Normal'
|
| 39 |
confidence_score = predicted_probabilities if predicted_class == 'Pneumonia' else 1 - predicted_probabilities
|
| 40 |
confidence_score *= 100
|
|
|
|
| 41 |
|
| 42 |
+
return predicted_class, confidence_score
|
| 43 |
|
| 44 |
image_component = gr.Image(type="filepath", label="Chest X-ray Image")
|
| 45 |
label_component = gr.Label(label="Classification result", num_top_classes=1)
|
| 46 |
+
confidence_component = gr.Label(label="Confidence Score (%)")
|
| 47 |
+
|
| 48 |
description = ""
|
| 49 |
title = "Pneumonia Classifier"
|
| 50 |
|
| 51 |
demo = gr.Interface(fn=predict,
|
| 52 |
inputs=image_component,
|
| 53 |
+
outputs=[label_component, confidence_component],
|
| 54 |
description=description,
|
| 55 |
title=title,
|
| 56 |
examples=["demo_example_imgs/NORMAL-0001-0001.jpeg",
|