NoahH7 commited on
Commit
758e865
·
verified ·
1 Parent(s): 49ff8c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- print(
26
- f"Detected {model.config.id2label[label.item()]} with confidence "
27
- f"{round(score.item(), 3)} at location {box}"
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
+