rishabh5752 commited on
Commit
99234ff
·
1 Parent(s): 164e569

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -22,19 +22,17 @@ def predict(image):
22
  label = 'Malignant'
23
  confidence = prediction[0][0] # Confidence for malignant
24
 
25
- return {'label': label, 'confidence': float(confidence)} # Convert confidence to float
26
 
27
- # Custom post-processing function to format the label and confidence
28
- def custom_postprocess(output):
29
- label = output['label']
30
- confidence = output['confidence'] * 100
31
- return f"{label} ({confidence:.2f}%)"
32
 
33
  examples = [["benign.jpg"], ["malignant.jpg"]]
34
 
35
- # Define input and output components
36
  image_input = gr.inputs.Image(shape=(150, 150))
37
- label_output = gr.outputs.Label()
38
 
39
  # Define a Gradio interface for user interaction
40
  iface = gr.Interface(
 
22
  label = 'Malignant'
23
  confidence = prediction[0][0] # Confidence for malignant
24
 
25
+ return label, confidence
26
 
27
+ # Custom component to display label with confidence
28
+ def label_with_confidence(label, confidence):
29
+ return f"{label} ({confidence * 100:.2f}%)"
 
 
30
 
31
  examples = [["benign.jpg"], ["malignant.jpg"]]
32
 
33
+ # Define input and custom output components
34
  image_input = gr.inputs.Image(shape=(150, 150))
35
+ label_output = gr.outputs.Component(label_with_confidence, inputs=["label", "confidence"])
36
 
37
  # Define a Gradio interface for user interaction
38
  iface = gr.Interface(