linhcuem commited on
Commit
e31efcc
1 Parent(s): 8b488a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -31,10 +31,10 @@ image_path = [['test_images/2a998cfb0901db5f8210.jpg','cham_diem_yolov8', 640, 0
31
  # model = YOLO('linhcuem/chamdiemgianhang_yolov8_300epochs')
32
  # model = YOLO('linhcuem/chamdiemgianhang_yolov8_ver21')
33
  # model = YOLO('linhcuem/cham_diem_yolov8_ver20')
34
- model_ids = ['linhcuem/checker_TB_yolov8_ver1', 'linhcuem/cham_diem_yolov8', 'linhcuem/chamdiemgianhang_yolov8_300epochs', 'linhcuem/cham_diem_yolov8_ver20', 'linhcuem/chamdiemgianhang_yolov8_ver21']
35
- # model = YOLO('linhcuem/checker_TB_yolov8_ver1')
36
- current_model_id = model_ids[-1]
37
- model = YOLO(current_model_id)
38
  # model = YOLO(model_path)
39
 
40
  ###################################################
@@ -46,18 +46,14 @@ def yolov8_img_inference(
46
  iou_threshold = 0.45,
47
  ):
48
  # model = YOLO(model_path)
49
- global current_model_id
50
- global model
51
- if model_path != current_model_id:
52
- model = YOLO(model_path)
53
- current_model_id = model_path
54
  model.conf = conf_threshold
55
  model.iou = iou_threshold
56
  # model.overrides['conf'] = conf_threshold
57
  # model.overrides['iou'] = iou_threshold
58
  # model.overrides['agnostic_nms'] = False
59
  # model.overrides['max_det'] = 1000
60
- # image = read_image
61
  results = model.predict(image, imgsz=image_size, conf=conf_threshold, iou=iou_threshold)
62
  render = render_result(model=model, image=image, result=results[0])
63
  # get the model names list
@@ -142,7 +138,8 @@ interface_image = gr.Interface(
142
  fn=yolov8_img_inference,
143
  inputs=[
144
  gr.Image(type='pil'),
145
- gr.Dropdown(model_ids, value=model_ids[-1]),
 
146
  gr.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
147
  gr.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
148
  gr.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
 
31
  # model = YOLO('linhcuem/chamdiemgianhang_yolov8_300epochs')
32
  # model = YOLO('linhcuem/chamdiemgianhang_yolov8_ver21')
33
  # model = YOLO('linhcuem/cham_diem_yolov8_ver20')
34
+ # model_ids = ['linhcuem/checker_TB_yolov8_ver1', 'linhcuem/cham_diem_yolov8', 'linhcuem/chamdiemgianhang_yolov8_300epochs', 'linhcuem/cham_diem_yolov8_ver20', 'linhcuem/chamdiemgianhang_yolov8_ver21']
35
+ # # model = YOLO('linhcuem/checker_TB_yolov8_ver1')
36
+ # current_model_id = model_ids[-1]
37
+ # model = YOLO(current_model_id)
38
  # model = YOLO(model_path)
39
 
40
  ###################################################
 
46
  iou_threshold = 0.45,
47
  ):
48
  # model = YOLO(model_path)
49
+ model = YOLO(model_path)
 
 
 
 
50
  model.conf = conf_threshold
51
  model.iou = iou_threshold
52
  # model.overrides['conf'] = conf_threshold
53
  # model.overrides['iou'] = iou_threshold
54
  # model.overrides['agnostic_nms'] = False
55
  # model.overrides['max_det'] = 1000
56
+ image = read_image
57
  results = model.predict(image, imgsz=image_size, conf=conf_threshold, iou=iou_threshold)
58
  render = render_result(model=model, image=image, result=results[0])
59
  # get the model names list
 
138
  fn=yolov8_img_inference,
139
  inputs=[
140
  gr.Image(type='pil'),
141
+ gr.Dropdown(["linhcuem/checker_TB_yolov8_ver1", "linhcuem/chamdiemgianhang_yolov8_ver21"],
142
+ default="linhcuem/checker_TB_yolov8_ver1", label="Model"),
143
  gr.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
144
  gr.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
145
  gr.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),