lokesh341 commited on
Commit
95e331e
·
1 Parent(s): ab34bf4

Delete services/detection_service.py

Browse files
Files changed (1) hide show
  1. services/detection_service.py +0 -37
services/detection_service.py DELETED
@@ -1,37 +0,0 @@
1
- '''
2
- from transformers import pipeline
3
- import cv2
4
-
5
- object_detector = pipeline("object-detection", model="facebook/detr-resnet-50")
6
-
7
- def detect_objects(image_path):
8
- image = cv2.imread(image_path)
9
- results = object_detector(image)
10
- return [r for r in results if r['score'] > 0.7]
11
-
12
- '''
13
-
14
- # services/detection_service.py
15
-
16
- from transformers import pipeline
17
- from PIL import Image
18
-
19
- # ✅ Load Hugging Face DETR pipeline properly
20
- object_detector = pipeline("object-detection", model="facebook/detr-resnet-50")
21
-
22
- def detect_objects(image_path):
23
- """
24
- Detect objects using Hugging Face DETR pipeline.
25
- - Accepts a file path to a local image.
26
- - Converts image to PIL format.
27
- - Feeds into Hugging Face detector.
28
- - Returns list of high-confidence detections.
29
- """
30
- # ✅ Correct way: Open image properly
31
- image = Image.open(image_path).convert("RGB")
32
-
33
- # ✅ Run inference
34
- results = object_detector(image)
35
-
36
- # ✅ Return only high-confidence detections
37
- return [r for r in results if r['score'] > 0.7]