Spaces:
Runtime error
Runtime error
Commit ·
03082bc
1
Parent(s): 96e80a0
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,11 +24,16 @@ def predict(image):
|
|
| 24 |
|
| 25 |
return {'label': label, 'confidence': float(confidence)} # Convert confidence to float
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
examples = [["benign.jpg"], ["malignant.jpg"]]
|
| 28 |
|
| 29 |
# Define input and output components
|
| 30 |
image_input = gr.inputs.Image(shape=(150, 150))
|
| 31 |
-
label_output = gr.outputs.Label()
|
| 32 |
|
| 33 |
# Define a Gradio interface for user interaction
|
| 34 |
iface = gr.Interface(
|
|
|
|
| 24 |
|
| 25 |
return {'label': label, 'confidence': float(confidence)} # Convert confidence to float
|
| 26 |
|
| 27 |
+
# Custom post-processing function to sort by confidence
|
| 28 |
+
def custom_postprocess(output):
|
| 29 |
+
sorted_output = sorted(output.items(), key=lambda x: x[1], reverse=True)
|
| 30 |
+
return f"{sorted_output[0][0]} ({sorted_output[0][1] * 100:.2f}%)"
|
| 31 |
+
|
| 32 |
examples = [["benign.jpg"], ["malignant.jpg"]]
|
| 33 |
|
| 34 |
# Define input and output components
|
| 35 |
image_input = gr.inputs.Image(shape=(150, 150))
|
| 36 |
+
label_output = gr.outputs.Label(postprocess=custom_postprocess)
|
| 37 |
|
| 38 |
# Define a Gradio interface for user interaction
|
| 39 |
iface = gr.Interface(
|