Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,12 +18,9 @@ outputs = model(**inputs)
|
|
| 18 |
target_sizes = torch.tensor([image.size[::-1]])
|
| 19 |
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
| 20 |
|
| 21 |
-
persons = 0
|
| 22 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 23 |
box = [round(i, 2) for i in box.tolist()]
|
| 24 |
print(
|
| 25 |
-
|
| 26 |
-
|
| 27 |
)
|
| 28 |
-
$persons++
|
| 29 |
-
|
|
|
|
| 18 |
target_sizes = torch.tensor([image.size[::-1]])
|
| 19 |
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
| 20 |
|
|
|
|
| 21 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 22 |
box = [round(i, 2) for i in box.tolist()]
|
| 23 |
print(
|
| 24 |
+
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 25 |
+
f"{round(score.item(), 3)} at location {box}"
|
| 26 |
)
|
|
|
|
|
|