linhcuem commited on
Commit
2ad137f
1 Parent(s): 1ddd5fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -28,16 +28,13 @@ def yolov8_img_inference(
28
  ):
29
  model = YOLO(model_path)
30
  model.conf = conf_threshold
31
- model.iou= iou_threshold
32
- # model.overrides['agnostic_nms'] = False # NMS class-agnostic
33
- # model.overrides['max_det'] = 1000
34
- # image = read_image(image)
35
- results = model.predict(image, imgz=image_size, return_outputs=True)
36
  object_prediction_list = []
37
  for _, image_results in enumerate(results):
38
  if len(image_results)!=0:
39
- image_prediction_in_xyxy_format = image_results['det']
40
- for pred in image_prediction_in_xyxy_format:
41
  x1, y1, x2, y2 = (
42
  int(pred[0]),
43
  int(pred[1]),
@@ -55,9 +52,11 @@ def yolov8_img_inference(
55
  category_name=category_name,
56
  )
57
  object_prediction_list.append(object_prediction)
 
58
  image = read_image(image)
59
  output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
60
  return output_image['image']
 
61
 
62
  inputs_image = [
63
  gr.inputs.Image(type="filepath", label="Input Image"),
 
28
  ):
29
  model = YOLO(model_path)
30
  model.conf = conf_threshold
31
+ model.iou = iou_threshold
32
+ results = model.predict(image, imgsz=image_size, return_outputs=True)
 
 
 
33
  object_prediction_list = []
34
  for _, image_results in enumerate(results):
35
  if len(image_results)!=0:
36
+ image_predictions_in_xyxy_format = image_results['det']
37
+ for pred in image_predictions_in_xyxy_format:
38
  x1, y1, x2, y2 = (
39
  int(pred[0]),
40
  int(pred[1]),
 
52
  category_name=category_name,
53
  )
54
  object_prediction_list.append(object_prediction)
55
+
56
  image = read_image(image)
57
  output_image = visualize_object_predictions(image=image, object_prediction_list=object_prediction_list)
58
  return output_image['image']
59
+
60
 
61
  inputs_image = [
62
  gr.inputs.Image(type="filepath", label="Input Image"),