faruqaziz commited on
Commit
62799af
·
verified ·
1 Parent(s): 27d7cd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -10,7 +10,7 @@ def download_models(model_id):
10
  return f"./{model_id}"
11
 
12
  box_annotator = sv.BoxAnnotator()
13
- category_dict = { }
14
 
15
 
16
  @spaces.GPU(duration=200)
@@ -21,7 +21,8 @@ def yolov10_inference(image, model_id, image_size, conf_threshold, iou_threshold
21
  detections = sv.Detections.from_ultralytics(results)
22
 
23
  labels = [
24
- 'arborio', 'ipsala', 'jasmine', 'karacadag', 'basmati'
 
25
  ]
26
  annotated_image = box_annotator.annotate(image, detections=detections, labels=labels)
27
 
 
10
  return f"./{model_id}"
11
 
12
  box_annotator = sv.BoxAnnotator()
13
+ category_dict = {0: 'arborio', 1: 'ipsala', 2: 'jasmine', 3: 'karacadag', 4: 'basmati'}
14
 
15
 
16
  @spaces.GPU(duration=200)
 
21
  detections = sv.Detections.from_ultralytics(results)
22
 
23
  labels = [
24
+ f"{category_dict[class_id]} {confidence:.2f}"
25
+ for class_id, confidence in zip(detections.class_id, detections.confidence)
26
  ]
27
  annotated_image = box_annotator.annotate(image, detections=detections, labels=labels)
28