Spaces:
Runtime error
Runtime error
Create detection_service.py
Browse files- detection_service.py +9 -0
detection_service.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import cv2
|
3 |
+
|
4 |
+
object_detector = pipeline("object-detection", model="facebook/detr-resnet-50")
|
5 |
+
|
6 |
+
def detect_objects(image_path):
|
7 |
+
image = cv2.imread(image_path)
|
8 |
+
results = object_detector(image)
|
9 |
+
return [r for r in results if r['score'] > 0.7]
|