Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,6 +129,8 @@ def detect_periodontitis(image_np):
|
|
| 129 |
|
| 130 |
# Summaries — CLEAN (no method labels)
|
| 131 |
summaries = []
|
|
|
|
|
|
|
| 132 |
for tooth in results["distance_analyses"]:
|
| 133 |
tid = tooth["tooth_id"]
|
| 134 |
analysis = tooth["analysis"]
|
|
@@ -137,11 +139,19 @@ def detect_periodontitis(image_np):
|
|
| 137 |
px = analysis["mean_distance"]
|
| 138 |
mm = px * mm_per_px
|
| 139 |
summaries.append(f"Tooth {tid}: {mm:.2f} mm")
|
|
|
|
|
|
|
| 140 |
else:
|
| 141 |
summaries.append(f"Tooth {tid}: no valid CEJ–ABC measurement")
|
| 142 |
|
| 143 |
summary_text = "\n".join(summaries)
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
# Remove temp
|
| 146 |
try:
|
| 147 |
os.remove(temp_path)
|
|
@@ -149,8 +159,7 @@ def detect_periodontitis(image_np):
|
|
| 149 |
pass
|
| 150 |
|
| 151 |
return combined_rgb, summary_text
|
| 152 |
-
|
| 153 |
-
|
| 154 |
# ==========================
|
| 155 |
# Gradio Interface
|
| 156 |
# ==========================
|
|
|
|
| 129 |
|
| 130 |
# Summaries — CLEAN (no method labels)
|
| 131 |
summaries = []
|
| 132 |
+
has_periodontitis = False # flag
|
| 133 |
+
|
| 134 |
for tooth in results["distance_analyses"]:
|
| 135 |
tid = tooth["tooth_id"]
|
| 136 |
analysis = tooth["analysis"]
|
|
|
|
| 139 |
px = analysis["mean_distance"]
|
| 140 |
mm = px * mm_per_px
|
| 141 |
summaries.append(f"Tooth {tid}: {mm:.2f} mm")
|
| 142 |
+
if mm > 2.0:
|
| 143 |
+
has_periodontitis = True
|
| 144 |
else:
|
| 145 |
summaries.append(f"Tooth {tid}: no valid CEJ–ABC measurement")
|
| 146 |
|
| 147 |
summary_text = "\n".join(summaries)
|
| 148 |
|
| 149 |
+
# Add interpretation
|
| 150 |
+
if has_periodontitis:
|
| 151 |
+
summary_text += "\n\n⚠️ Interpretation: Some teeth show CEJ–ABC distances > 2 mm, indicating periodontitis."
|
| 152 |
+
else:
|
| 153 |
+
summary_text += "\n\n✅ Interpretation: CEJ–ABC distances are all ≤ 2 mm, no periodontitis detected."
|
| 154 |
+
|
| 155 |
# Remove temp
|
| 156 |
try:
|
| 157 |
os.remove(temp_path)
|
|
|
|
| 159 |
pass
|
| 160 |
|
| 161 |
return combined_rgb, summary_text
|
| 162 |
+
|
|
|
|
| 163 |
# ==========================
|
| 164 |
# Gradio Interface
|
| 165 |
# ==========================
|