ziaddBou commited on
Commit
dea3fb9
1 Parent(s): b84c74d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -39,21 +39,8 @@ def predict(image):
39
 
40
  # Make prediction
41
  prediction = model.predict(img_array)
42
- # Calculate prediction probability
43
- prediction_probability = float(prediction[0][0])
44
-
45
- # Check if prediction is 'Normal' or 'Pneumonia'
46
- if prediction_probability <= 0.5:
47
- # If 'Normal', add 70% to its probability but cap it at 1.0 (100%)
48
- adjusted_probability = min(prediction_probability + 0.5, 1.0)
49
- pred_class = 'Normal'
50
- else:
51
- # If 'Pneumonia', use the original probability
52
- adjusted_probability = prediction_probability
53
- pred_class = 'Pneumonia'
54
-
55
- # Return the prediction class and the (adjusted) probability
56
- return {pred_class: adjusted_probability}
57
 
58
  iface = gr.Interface(fn=predict,
59
  inputs=gr.components.Image(image_mode='RGB', label="Upload X-ray Image"),
 
39
 
40
  # Make prediction
41
  prediction = model.predict(img_array)
42
+ pred_class = 'Pneumonia' if prediction[0][0] > 0.5 else 'Normal' # Update based on your model output
43
+ return {pred_class: float(prediction[0][0])}
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  iface = gr.Interface(fn=predict,
46
  inputs=gr.components.Image(image_mode='RGB', label="Upload X-ray Image"),