linhcuem commited on
Commit
705b2ec
·
verified ·
1 Parent(s): 7b3040c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -29,12 +29,12 @@ image_path = [['test_images/2a998cfb0901db5f8210.jpg','cham_diem_yolov8', 640, 0
29
  # Load YOLO model
30
  # model = YOLO('linhcuem/cham_diem_yolov8')
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,6 +46,11 @@ def yolov8_img_inference(
46
  iou_threshold: gr.inputs.Slider = 0.45,
47
  ):
48
  # model = YOLO(model_path)
 
 
 
 
 
49
  model.conf = conf_threshold
50
  model.iou = iou_threshold
51
  # model.overrides['conf'] = conf_threshold
@@ -137,9 +142,9 @@ interface_image = gr.Interface(
137
  fn=yolov8_img_inference,
138
  inputs=[
139
  gr.inputs.Image(type='pil'),
140
- gr.inputs.Dropdown(["linhcuem/chamdiemgianhang_yolov8_ver21"],
141
- default="linhcuem/chamdiemgianhang_yolov8_ver21", label="Model"),
142
-
143
  gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
144
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
145
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),
 
29
  # Load YOLO model
30
  # model = YOLO('linhcuem/cham_diem_yolov8')
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: gr.inputs.Slider = 0.45,
47
  ):
48
  # model = YOLO(model_path)
49
+ global current_model_id
50
+ global model
51
+ if model_id != current_model_id:
52
+ model = YOLO(model_id)
53
+ current_model_id = model_id
54
  model.conf = conf_threshold
55
  model.iou = iou_threshold
56
  # model.overrides['conf'] = conf_threshold
 
142
  fn=yolov8_img_inference,
143
  inputs=[
144
  gr.inputs.Image(type='pil'),
145
+ # gr.inputs.Dropdown(["linhcuem/chamdiemgianhang_yolov8_ver21"],
146
+ # default="linhcuem/chamdiemgianhang_yolov8_ver21", label="Model"),
147
+ gr.inputs.Dropdown(model_ids, value=model_ids[-1]),
148
  gr.inputs.Slider(minimum=320, maximum=1280, default=640, step=32, label="Image Size"),
149
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.25, step=0.05, label="Confidence Threshold"),
150
  gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.45, step=0.05, label="IOU Threshold"),