viep-fault-detection / detection_service.py
Sanjayraju30's picture
Create detection_service.py
18c4da4 verified
raw
history blame
283 Bytes
from transformers import pipeline
import cv2
object_detector = pipeline("object-detection", model="facebook/detr-resnet-50")
def detect_objects(image_path):
image = cv2.imread(image_path)
results = object_detector(image)
return [r for r in results if r['score'] > 0.7]