kedimestan commited on
Commit
d164cde
·
verified ·
1 Parent(s): d501ffc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -74,15 +74,23 @@ def predict(image: Image.Image):
74
  input_tensor = transform(image).unsqueeze(0).to(device)
75
  with torch.no_grad():
76
  output = model(input_tensor).squeeze(0).cpu().numpy()
77
- prediction = "Positive" if output[0] > 0.5 else "Negative"
78
- return {"Prediction": prediction, "Probability": round(float(output[0]), 2)}
 
 
 
 
 
 
79
 
80
  # Gradio arayüzü
81
- def gradio_interface(image):
82
- return predict(image)
83
 
84
- # Gradio arayüzü oluşturma
85
- inputs = gr.Image(type="pil", label="Upload Image")
86
- outputs = gr.JSON(label="Prediction Result")
87
-
88
- gr.Interface(fn=gradio_interface, inputs=inputs, outputs=outputs, title="Retinoblastoma Detection", theme="default").launch(debug=True)
 
 
 
74
  input_tensor = transform(image).unsqueeze(0).to(device)
75
  with torch.no_grad():
76
  output = model(input_tensor).squeeze(0).cpu().numpy()
77
+ probability = round(float(output[0]), 2)
78
+ if probability < 0.5:
79
+ prediction = "Hasta"
80
+ color = "red"
81
+ else:
82
+ prediction = "Normal"
83
+ color = "green"
84
+ return f"<div style='text-align: center; font-size: 24px; color: {color};'><strong>{prediction}</strong><br>Olasılık: {probability}</div>"
85
 
86
  # Gradio arayüzü
87
+ inputs = gr.Image(type="pil", label="Görsel Yükle")
88
+ outputs = gr.HTML(label="Tahmin Sonucu")
89
 
90
+ gr.Interface(
91
+ fn=predict,
92
+ inputs=inputs,
93
+ outputs=outputs,
94
+ title="Retinoblastoma Tespiti",
95
+ theme="default"
96
+ ).launch(debug=True)