Spaces:
Sleeping
Sleeping
Update periodontitis_detection.py
Browse files- periodontitis_detection.py +14 -4
periodontitis_detection.py
CHANGED
|
@@ -216,11 +216,7 @@ class SimpleDentalSegmentationNoEnhance:
|
|
| 216 |
Perform full analysis on a dental image:
|
| 217 |
segmentation, detection, distance measurement, and visualization.
|
| 218 |
"""
|
| 219 |
-
img_bgr = cv2.imread(image_path)
|
| 220 |
-
if img_bgr is None:
|
| 221 |
-
raise FileNotFoundError(f"Could not read image: {image_path}")
|
| 222 |
|
| 223 |
-
h_orig, w_orig = img_bgr.shape[:2]
|
| 224 |
cej_unet, abc_unet, _ = self.run_unet(img_bgr)
|
| 225 |
cej_mask = self.resize_mask_to_original(cej_unet, (h_orig, w_orig))
|
| 226 |
abc_mask = self.resize_mask_to_original(abc_unet, (h_orig, w_orig))
|
|
@@ -235,6 +231,20 @@ class SimpleDentalSegmentationNoEnhance:
|
|
| 235 |
alpha = 0.4
|
| 236 |
combined = cv2.addWeighted(overlay, alpha, img_bgr, 1 - alpha, 0)
|
| 237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
all_results = []
|
| 239 |
|
| 240 |
for det in detections:
|
|
|
|
| 216 |
Perform full analysis on a dental image:
|
| 217 |
segmentation, detection, distance measurement, and visualization.
|
| 218 |
"""
|
|
|
|
|
|
|
|
|
|
| 219 |
|
|
|
|
| 220 |
cej_unet, abc_unet, _ = self.run_unet(img_bgr)
|
| 221 |
cej_mask = self.resize_mask_to_original(cej_unet, (h_orig, w_orig))
|
| 222 |
abc_mask = self.resize_mask_to_original(abc_unet, (h_orig, w_orig))
|
|
|
|
| 231 |
alpha = 0.4
|
| 232 |
combined = cv2.addWeighted(overlay, alpha, img_bgr, 1 - alpha, 0)
|
| 233 |
|
| 234 |
+
for det in detections:
|
| 235 |
+
x1, y1, x2, y2 = det["bbox"].astype(int)
|
| 236 |
+
cv2.rectangle(combined, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
| 237 |
+
cv2.putText(
|
| 238 |
+
combined,
|
| 239 |
+
f"Tooth {det['tooth_id']}",
|
| 240 |
+
(x1, y1 - 5),
|
| 241 |
+
cv2.FONT_HERSHEY_SIMPLEX,
|
| 242 |
+
0.5,
|
| 243 |
+
(0, 255, 0),
|
| 244 |
+
1,
|
| 245 |
+
cv2.LINE_AA
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
all_results = []
|
| 249 |
|
| 250 |
for det in detections:
|