Zengyf-CVer commited on
Commit
a75f393
1 Parent(s): a529cd4

v04 update

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -133,16 +133,22 @@ def yaml_csv(file_path, file_tag):
133
 
134
 
135
  # model loading
136
- def model_loading(model_name, device, opt=["refresh_yolov5"]):
137
-
138
- # load model
139
- model = torch.hub.load(
140
- model_path,
141
- model_name,
142
- force_reload=[True if "refresh_yolov5" in opt else False][0],
143
- device=device,
144
- _verbose=False
145
- )
 
 
 
 
 
 
146
 
147
  return model
148
 
@@ -218,9 +224,15 @@ def yolo_det_img(img, device, model_name, infer_size, conf, iou, max_num, model_
218
  if model_name_tmp != model_name:
219
  # Model judgment to avoid repeated loading
220
  model_name_tmp = model_name
 
221
  model = model_loading(model_name_tmp, device, opt)
222
  elif device_tmp != device:
 
223
  device_tmp = device
 
 
 
 
224
  model = model_loading(model_name_tmp, device, opt)
225
 
226
  # -------------Model tuning -------------
@@ -363,11 +375,17 @@ def yolo_det_video(video, device, model_name, infer_size, conf, iou, max_num, mo
363
  if model_name_tmp != model_name:
364
  # Model judgment to avoid repeated loading
365
  model_name_tmp = model_name
 
366
  model = model_loading(model_name_tmp, device, opt)
367
  elif device_tmp != device:
 
368
  device_tmp = device
 
369
  model = model_loading(model_name_tmp, device, opt)
370
-
 
 
 
371
  # -------------Model tuning -------------
372
  model.conf = conf # NMS confidence threshold
373
  model.iou = iou # NMS IOU threshold
 
133
 
134
 
135
  # model loading
136
+ def model_loading(model_name, device, opt=[]):
137
+
138
+ # 加载本地模型
139
+ try:
140
+ # load model
141
+ model = torch.hub.load(
142
+ model_path,
143
+ model_name,
144
+ force_reload=[True if "refresh_yolov5" in opt else False][0],
145
+ device=device,
146
+ _verbose=False
147
+ )
148
+ except Exception as e:
149
+ print(e)
150
+ else:
151
+ print(f"🚀 welcome to {GYD_VERSION},{model_name} loaded successfully!")
152
 
153
  return model
154
 
 
224
  if model_name_tmp != model_name:
225
  # Model judgment to avoid repeated loading
226
  model_name_tmp = model_name
227
+ print(f"Loading model {model_name_tmp}......")
228
  model = model_loading(model_name_tmp, device, opt)
229
  elif device_tmp != device:
230
+ # Device judgment to avoid repeated loading
231
  device_tmp = device
232
+ print(f"Loading model {model_name_tmp}......")
233
+ model = model_loading(model_name_tmp, device, opt)
234
+ else:
235
+ print(f"Loading model {model_name_tmp}......")
236
  model = model_loading(model_name_tmp, device, opt)
237
 
238
  # -------------Model tuning -------------
 
375
  if model_name_tmp != model_name:
376
  # Model judgment to avoid repeated loading
377
  model_name_tmp = model_name
378
+ print(f"Loading model {model_name_tmp}......")
379
  model = model_loading(model_name_tmp, device, opt)
380
  elif device_tmp != device:
381
+ # Device judgment to avoid repeated loading
382
  device_tmp = device
383
+ print(f"Loading model {model_name_tmp}......")
384
  model = model_loading(model_name_tmp, device, opt)
385
+ else:
386
+ print(f"Loading model {model_name_tmp}......")
387
+ model = model_loading(model_name_tmp, device, opt)
388
+
389
  # -------------Model tuning -------------
390
  model.conf = conf # NMS confidence threshold
391
  model.iou = iou # NMS IOU threshold