WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.33k stars 4.2k forks source link

Error in the function "utils.google_utils.attempt_download" #487

Open PoissonChasseur opened 2 years ago

PoissonChasseur commented 2 years ago

I just downloaded the latest code from the main branche and when I try to simply run the code with the usage of the webcam with:

python detect.py --source 0

I got the following error message:

(yolov5) C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main>python detect.py --source 0
Namespace(weights='yolov7.pt', source='0', img_size=640, conf_thres=0.25, iou_thres=0.45, device='', view_img=False, save_txt=False, save_conf=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, no_trace=False)
YOLOR  2022-8-11 torch 1.11.0 CUDA:0 (NVIDIA GeForce RTX 3080 Laptop GPU, 16383.5MB)

fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
  File "C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main\utils\google_utils.py", line 26, in attempt_download
    assets = [x['name'] for x in response['assets']]  # release assets
KeyError: 'assets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main\detect.py", line 195, in <module>
    detect()
  File "C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main\detect.py", line 34, in detect
    model = attempt_load(weights, map_location=device)  # load FP32 model
  File "C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main\models\experimental.py", line 241, in attempt_load
    attempt_download(w)
  File "C:\Users\vincentrm\D\Obj_detection_Yolo\yolov7-main\utils\google_utils.py", line 31, in attempt_download
    tag = subprocess.check_output('git tag', shell=True).decode().split()[-1]
  File "C:\Users\vincentrm\Miniconda3\envs\yolov5\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\vincentrm\Miniconda3\envs\yolov5\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'git tag' returned non-zero exit status 128.

When I manually try the link the code is trying to use: https://api.github.com/repos/WongKinYiu/yolov7/releases/latest

I can see why there is this error message since I am seing this:

{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/repos#get-the-latest-release"
}

Does anyone know how to solve this ?

PoissonChasseur commented 2 years ago

I made a temporary correction by simply changing line 30 of the "utils.google_utils.py" file by defining:

tag = 'v0.1'

instead of

tag = subprocess.check_output('git tag', shell=True).decode().split()[-1]

Since the pre-trained model files are currently placed in: https://github.com/WongKinYiu/yolov7/releases/tag/v0.1

However, a better solution (which would also be able to handle future tags) would be much better.

PoissonChasseur commented 2 years ago

Also, at line 28 of the "utils.google_utils.py" file with the following code:

            assets = ['yolov7.pt', 'yolov7-tiny.pt', 'yolov7x.pt', 'yolov7-d6.pt', 'yolov7-e6.pt', 
                      'yolov7-e6e.pt', 'yolov7-w6.pt']

It's missing all cases with "_training" (which seem to be the ones to use for "transfer learning", based on the README), so it looks like this line should be changed to something like this:

            assets = ['yolov7.pt', 'yolov7-tiny.pt', 'yolov7x.pt', 'yolov7-d6.pt', 'yolov7-e6.pt', 
                      'yolov7-e6e.pt', 'yolov7-w6.pt', 'yolov7x_training.pt',
                      'yolov7-e6_training.pt', 'yolov7-e6e_training.pt', 'yolov7-d6_training.pt',
                      'yolov7-w6_training.pt', 'yolov7_training.pt'] 
addisonklinke commented 2 years ago

Why is there no yolov7-tiny_training.pt? Is there a problem with using the non-transfer-learning yolov7-tiny.pt instead?