lyuwenyu / RT-DETR

[CVPR 2024] Official RT-DETR (RTDETR paddle pytorch), Real-Time DEtection TRansformer, DETRs Beat YOLOs on Real-time Object Detection. 🔥 🔥 🔥
Apache License 2.0
2.31k stars 258 forks source link

rtdetrv2 tuning error #430

Closed ksv87 closed 1 month ago

ksv87 commented 1 month ago

Dont work tuning from checkpoint from README.txt

ModuleNotFoundError: No module named 'cvperception'

Load PResNet18 state_dict
tuning checkpoint from D:\research\RT-DETR\rtdetrv2_pytorch\rtdetrv2_r18vd_120e_coco_rerun_48.1.pth
D:\research\RT-DETR\rtdetrv2_pytorch\tools\..\src\solver\_solver.py:157: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  state = torch.load(path, map_location='cpu')
Traceback (most recent call last):
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\train.py", line 67, in <module>
    main(args)
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\train.py", line 37, in main
    solver.fit()
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\..\src\solver\det_solver.py", line 20, in fit
    self.train()
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\..\src\solver\_solver.py", line 70, in train
    self._setup()
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\..\src\solver\_solver.py", line 42, in _setup
    self.load_tuning_state(self.cfg.tuning)
  File "D:\research\RT-DETR\rtdetrv2_pytorch\tools\..\src\solver\_solver.py", line 157, in load_tuning_state
    state = torch.load(path, map_location='cpu')
  File "C:\Users\ksv\.conda\envs\rt-detr\lib\site-packages\torch\serialization.py", line 1097, in load
    return _load(
  File "C:\Users\ksv\.conda\envs\rt-detr\lib\site-packages\torch\serialization.py", line 1525, in _load
    result = unpickler.load()
  File "C:\Users\ksv\.conda\envs\rt-detr\lib\site-packages\torch\serialization.py", line 1515, in find_class
    return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'cvperception'

To Reproduce python tools\train.py -c configs\rtdetrv2\rtdetrv2_r18vd_120e_coco.yml --use-amp -t "D:\research\RT-DETR\rtdetrv2_pytorch\rtdetrv2_r18vd_120e_coco_rerun_48.1.pth"

lyuwenyu commented 1 month ago

你在报错的load_tuning_state位置里torch.load加上参数weights_only=True试一下

Jerry-Chang975 commented 1 month ago

I encountered the same problem. Adding the parameter weights_only=True still doesn't solve the issue.

D:\Projects\ObjectDetectionStudy\RT-DETR\venv\lib\site-packages\torch_utils.py:776: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.get(instance, owner)() Traceback (most recent call last): File "D:\Projects\ObjectDetectionStudy\RT-DETR\rtdetrv2_pytorch\tools\export_onnx.py", line 99, in main(args) File "D:\Projects\ObjectDetectionStudy\RT-DETR\rtdetrv2_pytorch\tools\export_onnx.py", line 24, in main checkpoint = torch.load(args.resume, map_location='cpu', weights_only=True) File "D:\Projects\ObjectDetectionStudy\RT-DETR\venv\lib\site-packages\torch\serialization.py", line 808, in load raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None _pickle.UnpicklingError: Weights only load failed. 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 get the file from a trusted source. WeightsUnpickler error: Unsupported class collections.Counter

lyuwenyu commented 1 month ago

I updated weight link. You can remove downloaded weight firstly and try it agian.

@Jerry-Chang975 @ksv87

ksv87 commented 1 month ago

I updated weight link. You can remove downloaded weight firstly and try it agian. @lyuwenyu thanks! it's helped!