Alanhau commited on
Commit
da7fbc7
1 Parent(s): 8026979

[Update] Fix issue: fail to load model

Browse files
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -6,29 +6,6 @@ from yolov7.utils.google_utils import attempt_download_from_hub, attempt_downloa
6
  from yolov7.utils.torch_utils import TracedModel
7
  YOLO_MODEL_FILE_NAME="kadirnar/yolov7-v0.1"
8
 
9
- def load_local_model(model_file, autoshape=True, device='cpu', trace=False, size=640, half=False, hf_model=False):
10
- """
11
- Creates a specified YOLOv7 model
12
- Arguments:
13
- model_path (str): path of the model
14
- device (str): select device that model will be loaded (cpu, cuda)
15
- trace (bool): if True, model will be traced
16
- size (int): size of the input image
17
- half (bool): if True, model will be in half precision
18
- hf_model (bool): if True, model will be loaded from huggingface hub
19
- Returns:
20
- pytorch model
21
- (Adapted from yolov7.hubconf.create)
22
- """
23
-
24
- model = attempt_load(model_file, map_location=device)
25
- if trace:
26
- model = TracedModel(model, device, size)
27
- if autoshape:
28
- model = autoShape(model)
29
- if half:
30
- model.half()
31
- return model
32
 
33
  # YOLO_MODEL_FILE_NAME="kadirnar/yolov7-tiny-v0.1"
34
  def yolov7_inference(
@@ -37,7 +14,7 @@ def yolov7_inference(
37
  conf_threshold: gr.inputs.Slider = 0.25,
38
  iou_threshold: gr.inputs.Slider = 0.45,
39
  ):
40
- model = yolov7.load_model(YOLO_MODEL_FILE_NAME, device="cpu", hf_model=False, trace=False)
41
  model.conf = conf_threshold
42
  model.iou = iou_threshold
43
  results = model([image], size=image_size)
 
6
  from yolov7.utils.torch_utils import TracedModel
7
  YOLO_MODEL_FILE_NAME="kadirnar/yolov7-v0.1"
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # YOLO_MODEL_FILE_NAME="kadirnar/yolov7-tiny-v0.1"
11
  def yolov7_inference(
 
14
  conf_threshold: gr.inputs.Slider = 0.25,
15
  iou_threshold: gr.inputs.Slider = 0.45,
16
  ):
17
+ model = yolov7.load(YOLO_MODEL_FILE_NAME, device="cpu", hf_model=True, trace=False)
18
  model.conf = conf_threshold
19
  model.iou = iou_threshold
20
  results = model([image], size=image_size)