scchess commited on
Commit
47aa72a
·
1 Parent(s): 7c99a6d

Added class_name

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -18,8 +18,10 @@ def detect(image):
18
  x1, y1, x2, y2 = box.xyxy[0].tolist() # Get box coordinates
19
  conf = float(box.conf[0]) # Get confidence
20
  cls = int(box.cls[0]) # Get class
 
21
  detections.append({
22
  'class': cls,
 
23
  'confidence': conf,
24
  'box': [x1, y1, x2, y2]
25
  })
@@ -35,6 +37,6 @@ gr.Interface(
35
  gr.JSON(label="Detection Results")
36
  ],
37
  title="YOLOv9 (Ultralytics) Object Detection",
38
- description="Upload an image to run object detection using your custom YOLOv9 model. The results will show both the annotated image and the detection details.",
39
  ).launch()
40
 
 
18
  x1, y1, x2, y2 = box.xyxy[0].tolist() # Get box coordinates
19
  conf = float(box.conf[0]) # Get confidence
20
  cls = int(box.cls[0]) # Get class
21
+ class_name = model.names[cls] # Get class name
22
  detections.append({
23
  'class': cls,
24
+ 'class_name': class_name,
25
  'confidence': conf,
26
  'box': [x1, y1, x2, y2]
27
  })
 
37
  gr.JSON(label="Detection Results")
38
  ],
39
  title="YOLOv9 (Ultralytics) Object Detection",
40
+ description="Upload an image to run object detection using your custom YOLOv9 model. The results will show both the annotated image and the detection details including class names.",
41
  ).launch()
42