Spaces:
Sleeping
Sleeping
Commit
·
385e56e
1
Parent(s):
8337710
test
Browse files
app.py
CHANGED
@@ -4,18 +4,19 @@ import cv2
|
|
4 |
import tempfile
|
5 |
from ultralytics import YOLOv10
|
6 |
|
7 |
-
|
|
|
8 |
|
9 |
@spaces.GPU
|
10 |
def yolov10_inference(image, conf_threshold):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
|
21 |
def app():
|
|
|
4 |
import tempfile
|
5 |
from ultralytics import YOLOv10
|
6 |
|
7 |
+
image_processor = RTDetrImageProcessor.from_pretrained("PekingU/rtdetr_r50vd")
|
8 |
+
model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd")
|
9 |
|
10 |
@spaces.GPU
|
11 |
def yolov10_inference(image, conf_threshold):
|
12 |
+
|
13 |
+
inputs = image_processor(images=image, return_tensors="pt")
|
14 |
+
|
15 |
+
with torch.no_grad():
|
16 |
+
outputs = model(**inputs)
|
17 |
+
|
18 |
+
results = image_processor.post_process_object_detection(outputs, target_sizes=torch.tensor([image.size[::-1]]), threshold=0.3)
|
19 |
+
|
20 |
|
21 |
|
22 |
def app():
|