Update app.py
Browse files
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 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
# Gradio arayüzü
|
81 |
-
|
82 |
-
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
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)
|