BhumikaMak commited on
Commit
c629158
·
1 Parent(s): ad21b0c
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -16,8 +16,12 @@ from ultralytics import YOLO
16
  COLORS = np.random.uniform(0, 255, size=(80, 3))
17
 
18
  # Function to parse YOLO detections
19
- def parse_detections(results):
20
- detections = results.pandas().xyxy[0].to_dict()
 
 
 
 
21
  boxes, colors, names = [], [], []
22
  for i in range(len(detections["xmin"])):
23
  confidence = detections["confidence"][i]
@@ -81,7 +85,7 @@ def process_image(image, yolo_versions=["yolov5"]):
81
  target_layers = [model.model.model[-1]]
82
  # Run YOLO detection
83
  results = model([rgb_img])
84
- boxes, colors, names = parse_detections(results)
85
  detections_img = draw_detections(boxes, colors, names, rgb_img.copy())
86
 
87
  # Grad-CAM visualization
 
16
  COLORS = np.random.uniform(0, 255, size=(80, 3))
17
 
18
  # Function to parse YOLO detections
19
+ def parse_detections(results, yolo_version):
20
+ if yolo_version == "yolov5":
21
+ detections = results.pandas().xyxy[0].to_dict()
22
+ else:
23
+ detections = results[0].pandas().xyxy[0].to_dict()
24
+
25
  boxes, colors, names = [], [], []
26
  for i in range(len(detections["xmin"])):
27
  confidence = detections["confidence"][i]
 
85
  target_layers = [model.model.model[-1]]
86
  # Run YOLO detection
87
  results = model([rgb_img])
88
+ boxes, colors, names = parse_detections(results, yolo_version)
89
  detections_img = draw_detections(boxes, colors, names, rgb_img.copy())
90
 
91
  # Grad-CAM visualization