Create thermal_service.py
Browse files- services/thermal_service.py +13 -0
services/thermal_service.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
def detect_hotspots(model, image):
|
| 4 |
+
# Perform thermal hotspot detection
|
| 5 |
+
results = model(image)
|
| 6 |
+
hotspots = []
|
| 7 |
+
|
| 8 |
+
for detection in results.xywh[0]:
|
| 9 |
+
class_id = int(detection[5].item())
|
| 10 |
+
if class_id == 4: # Assuming class 4 is for hotspots
|
| 11 |
+
hotspots.append({"type": "Hotspot", "location": (detection[0], detection[1])})
|
| 12 |
+
|
| 13 |
+
return hotspots
|