Spaces:
Runtime error
Runtime error
File size: 883 Bytes
d41b506 c2dcaee fc3c42a 0882703 c2dcaee fc3c42a 682cff4 0882703 14b47fb c2dcaee 682cff4 c2dcaee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# services/thermal_service.py
import cv2
from transformers import pipeline
# Load HuggingFace DETR model
thermal_detector = pipeline("object-detection", model="facebook/detr-resnet-50")
def detect_thermal_anomalies(image_path):
results = thermal_detector(image_path) # ✅ directly pass path, not NumPy image!
thermal_boxes = []
for result in results:
if result['score'] > 0.7:
box = result['box']
thermal_boxes.append(box)
return thermal_boxes
def overlay_thermal_boxes(image_path, boxes):
image = cv2.imread(image_path)
for box in boxes:
xmin, ymin, xmax, ymax = box['xmin'], box['ymin'], box['xmax'], box['ymax']
cv2.rectangle(image, (xmin, ymin), (xmax, ymax), (0, 0, 255), 2)
cv2.putText(image, 'Hotspot', (xmin, ymin - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
return image
|