yolor icon indicating copy to clipboard operation
yolor copied to clipboard

在Colab上 跑 顯示需要 torch 1.10 但無法裝

Open elliotthwang opened this issue 3 years ago • 4 comments

ERROR: Cannot install torch==1.10.0 and torchvision==0.8.1 because these package versions have conflicting dependencies.

elliotthwang avatar Dec 29 '21 12:12 elliotthwang

## 檢查 torch and torchvision 的版本
import torch
import torchvision
print('torch = ', torch.__version__)
print('torchvision = ', torchvision.__version__)

## 原版 requirements.txt 舊了點,需更新一些參數的版本
## torch==1.7.0 需更新為前面程式的檢查的版本 1.10.0
## torchvision==0.8.1 需更新為前面程式的檢查的版本 0.11.1
!sed -i '12s/torch==1.7.0/torch==1.10.0/' requirements.txt
!sed -i '13s/torchvision==0.8.1/torchvision==0.11.1/' requirements.txt
!cat requirements.txt | grep -i 'torch'

robmlee avatar Feb 16 '22 00:02 robmlee

不過目前在推論 detect.py 時:

!python detect.py --source inference/images/horses.jpg --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --conf 0.25 --img-size 1280 --device 0 --output /content/drive/MyDrive/YOLOR-Output

會出現如下錯誤:

Namespace(agnostic_nms=False, augment=False, cfg='cfg/yolor_p6.cfg', classes=None, conf_thres=0.25, device='0', img_size=1280, iou_thres=0.5, names='data/coco.names', output='/content/drive/MyDrive/YOLOR-Output', save_txt=False, source='inference/images/horses.jpg', update=False, view_img=False, weights=['yolor_p6.pt'])
/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "detect.py", line 186, in <module>
    detect()
  File "detect.py", line 44, in detect
    model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 608, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 777, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

robmlee avatar Feb 16 '22 01:02 robmlee

自行摸索找出了解法如下: The work around solution: https://github.com/WongKinYiu/yolor/issues/183#issuecomment-1041253857

本問題可以 close 了! This issue can be closed.

robmlee avatar Feb 18 '22 00:02 robmlee

ERROR: Cannot install torch==1.10.0 and torchvision==0.8.1 because these package versions have conflicting dependencies.

本問題可以 close 了! This issue can be closed.

robmlee avatar Feb 18 '22 00:02 robmlee