You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before I closed #273, I wanted to make a PR to add some documentation of how to go from Ultralytics weights --> yolort weights --> LibTorch C++ inference (how to run deployment/libtorch/main.cpp with Ultralytics weights). I was going to reference in the documentation to use the CLI tool as you mentioned for the weights conversion, but I'm not sure how to use that script properly?
# python3>>> from yolort.models import YOLO, YOLOv5>>> checkpoint_path = 'yolov5-rt-stack/conversion_testing/yolov5_darknet_pan_s_r60_custom.pt' >>> model = YOLOv5.load_from_yolov5(checkpoint_path = checkpoint_path, version = 'r6.0')Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo_module.py", line 308, in load_from_yolov5 model = YOLO.load_from_yolov5(checkpoint_path, **kwargs) File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo.py", line 204, in load_from_yolov5 model_info = load_from_ultralytics(checkpoint_path, version=version) File "/home/mpopovich/git/yolov5-rt-stack/yolort/utils/update_module_state.py", line 60, in load_from_ultralytics checkpoint_yolov5 = load_yolov5_model(checkpoint_path) File "/home/mpopovich/git/yolov5-rt-stack/yolort/v5/helper.py", line 67, in load_yolov5_model model_ckpt = ckpt["model"] # load modelKeyError: 'model'>>> model = YOLO.load_from_yolov5(checkpoint_path = checkpoint_path, version = 'r6.0')Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo.py", line 204, in load_from_yolov5 model_info = load_from_ultralytics(checkpoint_path, version=version) File "/home/mpopovich/git/yolov5-rt-stack/yolort/utils/update_module_state.py", line 60, in load_from_ultralytics checkpoint_yolov5 = load_yolov5_model(checkpoint_path) File "/home/mpopovich/git/yolov5-rt-stack/yolort/v5/helper.py", line 67, in load_yolov5_model model_ckpt = ckpt["model"] # load modelKeyError: 'model'
You also mentioned I might be able to convert the model weights if "I load the translated checkpoints in yolort.models.yolov5s()". I'm not seeing any argument that would allow me to load a checkpoint using yolort.models.yolov5s():
>>> from yolort.models import yolov5s>>> model = yolov5s(checkpoint_path = checkpoint_path)Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/__init__.py", line 57, in yolov5s model = YOLOv5(arch="yolov5_darknet_pan_s_r60", **kwargs) File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo_module.py", line 59, in __init__ model = yolo.__dict__[arch]( File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo.py", line 523, in yolov5_darknet_pan_s_r60 return build_model( File "/home/mpopovich/git/yolov5-rt-stack/yolort/models/yolo.py", line 262, in build_model model = YOLO(backbone, num_classes, **kwargs)TypeError: __init__() got an unexpected keyword argument 'checkpoint_path'
Let me know what I'm doing wrong - thank you!
Versions
Click to display Versions
# python3 -m torch.utils.collect_envCollecting environment information...PyTorch version: 1.9.0a0+gitd69c22dIs debug build: FalseCUDA used to build PyTorch: 11.2ROCM used to build PyTorch: N/AOS: Ubuntu 20.04.2 LTS (x86_64)GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0Clang version: Could not collectCMake version: version 3.21.1Libc version: glibc-2.31Python version: 3.8 (64-bit runtime)Python platform: Linux-5.4.0-92-generic-x86_64-with-glibc2.29Is CUDA available: TrueCUDA runtime version: 11.2.152GPU models and configuration: GPU 0: GeForce GTX 1080GPU 1: GeForce GTX 1080GPU 2: GeForce GTX 1080Nvidia driver version: 460.91.03cuDNN version: Probably one of the following:/usr/lib/x86_64-linux-gnu/libcudnn.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.1.0/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.1.0HIP runtime version: N/AMIOpen runtime version: N/AVersions of relevant libraries:[pip3] numpy==1.21.4[pip3] pytorch-lightning==1.5.8[pip3] torch==1.9.0a0+gitd69c22d[pip3] torchmetrics==0.6.2[pip3] torchvision==0.10.0a0+300a8a4[conda] Could not collect
The text was updated successfully, but these errors were encountered:
I'm a little hesitant here whether we adopt this brand new interface or make a backward compatible interface like torchvision.
Because we do not yet support training, I currently judge that most people use the classmethods YOLO.load_from_yolov5() or YOLOv5.load_from_yolov5() to load custom checkpoints, and we will remain this classmethod. So I'm inclined to go the route of completely adopting the new interface from torchvision.
zhiqwang
changed the title
How to use the CLI tool (yolov5_to_yolort.py) to translate checkpoints from Ultralytics yolov5 to yolort
Add Multi-Weight Support API
Mar 15, 2022
🐛 Describe the bug
Before I closed #273, I wanted to make a PR to add some documentation of how to go from Ultralytics weights --> yolort weights --> LibTorch C++ inference (how to run
deployment/libtorch/main.cpp
with Ultralytics weights). I was going to reference in the documentation to use the CLI tool as you mentioned for the weights conversion, but I'm not sure how to use that script properly?It seems to run just fine:
But I'm not sure how to use the output model? If you can elaborate on how, I'd be happy to make a PR with added documentation.
I tried to use it directly in
deployment/libtorch/main.cpp
but that gave the same error as #142:I tried to load it in python, but with no luck:
You also mentioned I might be able to convert the model weights if "I load the translated checkpoints in
yolort.models.yolov5s()
". I'm not seeing any argument that would allow me to load a checkpoint usingyolort.models.yolov5s()
:Let me know what I'm doing wrong - thank you!
Versions
Click to display Versions
The text was updated successfully, but these errors were encountered: