Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,9 +20,13 @@ target_sizes = torch.tensor([image.size[::-1]])
|
|
| 20 |
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
| 21 |
|
| 22 |
# Afficher les résultats
|
|
|
|
| 23 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 24 |
box = [round(i, 2) for i in box.tolist()]
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.9)[0]
|
| 21 |
|
| 22 |
# Afficher les résultats
|
| 23 |
+
persons = 0
|
| 24 |
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
|
| 25 |
box = [round(i, 2) for i in box.tolist()]
|
| 26 |
+
if model.config.id2label[label.item()] == 'person':
|
| 27 |
+
print(
|
| 28 |
+
f"Detected {model.config.id2label[label.item()]} with confidence "
|
| 29 |
+
f"{round(score.item(), 3)} at location {box}"
|
| 30 |
+
)
|
| 31 |
+
persons++
|
| 32 |
+
|