Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use yolov5l6u pre-train model checkpoint by Ultralytics hub #11428

Closed
1 task done
xiaohangguo opened this issue Apr 24, 2023 · 1 comment
Closed
1 task done
Labels
question Further information is requested

Comments

@xiaohangguo
Copy link

xiaohangguo commented Apr 24, 2023

Search before asking

Question

That's it. I uploaded my own dataset on the Ultralytics hub, chose pre train=True, and made minor adjustments to Yolov5l6u. Now I have a weight. pt weight file, but I have cloned the source code of Yolov5 and cannot detect it properly.

First wrong:

self.orientation = int(self.cap.get(cv2.CAP_PROP_ORIENTATION_META))
i modify .
self.orientation = int(self.cap.get(48)) # rotation degrees

and second run:

Traceback (most recent call last):
  File "detect.py", line 261, in <module>
    main(opt)
  File "detect.py", line 256, in main
    run(**vars(opt))
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "detect.py", line 98, in run
    model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data, fp16=half)
  File "/media/hang/软件/Obejct/yolov5/models/common.py", line 344, in __init__
    model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse)
  File "/media/hang/软件/Obejct/yolov5/models/experimental.py", line 80, in attempt_load
    ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float()  # FP32 model
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 673, in to
    return self._apply(convert)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 146, in _apply
    self = super()._apply(fn)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 387, in _apply
    module._apply(fn)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 409, in _apply
    param_applied = fn(param)
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/nn/modules/module.py", line 671, in convert
    return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
RuntimeError: CUDA error: unknown error

third run: i using the scl:

python detect.py --source fire.mkv --data data.yaml

data.yaml is my datasets yaml :

train: ./train/images
val: ./valid/images
test: ./test/images

nc: 5
names: ['Fire', 'Smoke', 'Sand-Storm', 'land-slide5', 'landslideM']

##and get wrong:

Traceback (most recent call last):
  File "detect.py", line 261, in <module>
    main(opt)
  File "detect.py", line 256, in main
    run(**vars(opt))
  File "/home/hang/anaconda3/envs/yolo/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "detect.py", line 160, in run
    s += f"{n} {names[int(c)]}{'s' * (n > 1)}, "  # add to string
KeyError: 2474

Additional

In addition, I know that when pre train=True, pre training will be based on the fine-tuned weights of the COCO dataset. I don't know if it already contains some category information, so when reasoning, I need to add my own dataset label and COCO dataset label to data.yaml.

  1. I don't know if my guess is correct, but I guess it's because of data.ymal, which makes it impossible to reason
  2. It may be that the current source code of YOLOv5 does not support running this YOLOv5l6u checkpoint
@xiaohangguo xiaohangguo added the question Further information is requested label Apr 24, 2023
@glenn-jocher
Copy link
Member

@xiaohangguo based on the error messages you provided, it seems that there are a few issues with your setup.

First, regarding the orientation Meta error, it seems like you have modified the code to use a different enumeration for the self.orientation property. You mentioned that you changed it to self.orientation = int(self.cap.get(48)) but it is unclear what 48 corresponds to. It might be worth looking into the cv2.CAP_PROP_ORIENTATION_META enumeration to make sure that you are using the correct value.

Second, the CUDA error suggests that there might be an issue with the installation of CUDA on your system. I would recommend verifying your CUDA installation by running the nvidia-smi command to ensure that your GPU is being properly detected and that the correct version of CUDA is installed.

Finally, the KeyError that you encountered might be caused by a mismatch between your data.yaml file and your training data. It looks like the error is coming from the names[int(c)] expression, which suggests that the model is trying to map an index that is not defined in your names list. You may want to double-check that your data is correctly labeled and that your data.yaml file matches your data format. You can also try running the detection script with the --verbose flag to get additional debug information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants