properly select size
Browse files
app.py
CHANGED
|
@@ -35,8 +35,6 @@ import torch
|
|
| 35 |
from PIL import Image
|
| 36 |
import requests
|
| 37 |
|
| 38 |
-
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 39 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 40 |
|
| 41 |
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 42 |
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
|
|
@@ -84,7 +82,7 @@ def streaming_object_detection(recording_id: str, img):
|
|
| 84 |
# convert outputs (bounding boxes and class logits) to COCO API
|
| 85 |
# let's only keep detections with score > 0.9
|
| 86 |
|
| 87 |
-
target_sizes = torch.tensor([img.
|
| 88 |
results = processor.post_process_object_detection(
|
| 89 |
outputs, target_sizes=target_sizes, threshold=0.9
|
| 90 |
)[0]
|
|
|
|
| 35 |
from PIL import Image
|
| 36 |
import requests
|
| 37 |
|
|
|
|
|
|
|
| 38 |
|
| 39 |
processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
|
| 40 |
model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
|
|
|
|
| 82 |
# convert outputs (bounding boxes and class logits) to COCO API
|
| 83 |
# let's only keep detections with score > 0.9
|
| 84 |
|
| 85 |
+
target_sizes = torch.tensor([img.size[::-1]])
|
| 86 |
results = processor.post_process_object_detection(
|
| 87 |
outputs, target_sizes=target_sizes, threshold=0.9
|
| 88 |
)[0]
|