AdrielAmoguis commited on
Commit
4694dbb
·
1 Parent(s): 4c87af3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -23,20 +23,23 @@ def snap(image, model, conf, iou):
23
  elif model == "S-Raw":
24
  results = s_raw_model(image, conf=conf, iou=iou)
25
 
 
 
26
  # Convert the results list into an output image
27
- for result in results:
28
- classes = result.boxes.cls.cpu().numpy()
29
- probs = result.boxes.conf.cpu().numpy()
30
- boxes = result.boxes.xyxy.cpu().numpy()
31
 
32
- print("-------------------")
33
- print(classes)
34
- print("-------------------")
35
- print(probs)
36
- print("-------------------")
37
- print(boxes)
38
 
39
- x1, y1, x2, y2 = boxes
 
40
  x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
41
  cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
42
  cv2.putText(image, f"{classes} {probs:.2f}", (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
@@ -45,7 +48,7 @@ def snap(image, model, conf, iou):
45
  resulting_image = Image.fromarray(image)
46
 
47
  # Get the labels
48
- labels = results.pandas().xyxy[0]["name"].values
49
 
50
  # Sort the labels by their x-value first and then by their y-value
51
  # print(labels)
 
23
  elif model == "S-Raw":
24
  results = s_raw_model(image, conf=conf, iou=iou)
25
 
26
+
27
+
28
  # Convert the results list into an output image
29
+ result = results[0]
30
+ classes = result.boxes.cls.cpu().numpy()
31
+ probs = result.boxes.conf.cpu().numpy()
32
+ boxes = result.boxes.xyxy.cpu().numpy()
33
 
34
+ print("-------------------")
35
+ print(classes)
36
+ print("-------------------")
37
+ print(probs)
38
+ print("-------------------")
39
+ print(boxes)
40
 
41
+ for i in range(len(boxes)):
42
+ x1, y1, x2, y2 = boxes[i]
43
  x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
44
  cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
45
  cv2.putText(image, f"{classes} {probs:.2f}", (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
 
48
  resulting_image = Image.fromarray(image)
49
 
50
  # Get the labels
51
+ # labels = results.pandas().xyxy[0]["name"].values
52
 
53
  # Sort the labels by their x-value first and then by their y-value
54
  # print(labels)