Hey all, I have trained my own YOLOv6 model via this manual (https://github.com/meituan/YOLOv6/blob/main/docs/Train_custom_data.md) and I am currently trying to convert it from a .pt file to .blob file via the https://tools.luxonis.com/ website. When I upload the .pt file, the site automatically recognized that this is a YOLOV6 (latest) model. But when I click 'Submit' I get the following error, see attached picture.

I also tried the other options for YOLOv6 R2+R3 and YOLOV6 R1, but none work.

I used yolov6n.py config file to train my weight and only changed these 2 parameters:

use_dfl = True
reg_max = 16

I get the feeling that my weight might be corrupted somehow in the proces of training. Could this be possible because I only trained with the CPU.

jakaskerl

I tried the colab notebook u linked in your post but the notebook gave and error when executing this code:

! python tools/train.py --img-size 640 --batch 32 --epochs 2 --data data/voc.yaml --conf configs/yolov6n_finetune.py --device 0

The error I got is:

Train: Checking formats of images with 2 process(es):
0 image(s) corrupted: 100% 16551/16551 [00:04<00:00, 3492.70it/s]
Train: Checking formats of labels with 2 process(es):
16551 label(s) found, 0 label(s) missing, 0 label(s) empty, 0 invalid label files: 100% 16551/16551 [00:05<00:00, 3060.44it/s]
Train: Final numbers of valid images: 16551/ labels: 16551.
11.2s for dataset initialization.
Val: Checking formats of images with 2 process(es):
0 image(s) corrupted: 100% 4952/4952 [00:02<00:00, 2001.52it/s]
Val: Checking formats of labels with 2 process(es):
4952 label(s) found, 0 label(s) missing, 0 label(s) empty, 0 invalid label files: 100% 4952/4952 [00:03<00:00, 1368.68it/s]
Convert to COCO format
100% 4952/4952 [00:00<00:00, 33957.31it/s]
Convert to COCO format finished. Resutls saved in VOCdevkit/voc_07_12/annotations/instances_val.json
Val: Final numbers of valid images: 4952/ labels: 4952.
8.3s for dataset initialization.
Loading state_dict from weights/yolov6n.pt for fine-tuning...
Traceback (most recent call last):
File "/content/YOLOv6/tools/train.py", line 128, in <module>
main(args)
File "/content/YOLOv6/tools/train.py", line 113, in main
trainer = Trainer(args, cfg, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/content/YOLOv6/yolov6/core/engine.py", line 56, in init
model = self.get_model(args, cfg, self.num_classes, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/content/YOLOv6/yolov6/core/engine.py", line 385, in get_model
model = load_state_dict(weights, model, map_location=device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/content/YOLOv6/yolov6/utils/checkpoint.py", line 13, in load_state_dict
ckpt = torch.load(weights, map_location=map_location)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/torch/serialization.py", line 1470, in load
raise pickle.UnpicklingError(get_wo_message(str(e))) from None
pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL yolov6.models.yolo.Model was not an allowed global by default. Please use `torch.serialization.add_safe_globals([Model])` or the `torch.serialization.safe_globals([Model])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

I am using the free version of colab with the T4 GPU.

Hi,

I think I found my own error 🙂.

I played around in Google Colab and made this: https://filebin.net/7jqxlof2o16g8izi

I think my fault was to NOT use a finetune config file for training.

The .pt file from this notebook can be succesfully converted to the RVC2 format.

Thanks @jakaskerl for ur help!

Did I miss somewhere in the documentation that I should use a finetune config for training a YOLOv6 model or might this be an idea to add to the documentation somewhere?