Sanjayraju30 commited on
Commit
af188c8
·
verified ·
1 Parent(s): a617247

Create services/detection_service.py

Browse files
Files changed (1) hide show
  1. services/detection_service.py +9 -0
services/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 and r['label'] == 'pole']