ubuntu18.04 (notebook上看用的linux所以就先用这个试水)
!!!ubuntu系统一定不要随意改python和python3的指向!!!
参考Ubuntu更新python3.5到最新版本——3.7.4。
执行
pip3 install -U -r yolov5/requirements.txt
报错(点链接解决)
subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-4qd_3u92/pycocotools/
https://www.cnblogs.com/xiao987334176/p/12600835.html
重新执行
pip3 install -U -r yolov5/requirements.txt
问题应该是缺cython,就装了一个,又报错,我决定按txt文件自己装一遍。
…无报错,这里就一个一个来就对了。
ming@ming-P95-HP:~/git$ cd yolov5/
ming@ming-P95-HP:~/git/yolov5$ python3
Python 3.7.4 (default, Jun 12 2020, 21:31:03)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
from IPython.display import Image # for displaying images
from utils.google_utils import gdrive_download # for downloading models/datasets>>> Traceback (most recent call last):
File "" , line 1, in <module>
ModuleNotFoundError: No module named 'IPython'
>>> print('torch %s %s' % (torch.__version__, torch.cuda.get_device_properties(0) if torch.cuda.is_available() else 'CPU'))
>>> print('torch %s %s' % (torch.__version__, torch.cuda.get_device_properties(0) if torch.cuda.is_available() else 'CPU'))
torch 1.5.0 _CudaDeviceProperties(name='GeForce GTX 1060', major=6, minor=1, total_memory=6078MB, multi_processor_count=10)
>>>
ipython没有,整一个。
pip3 install IPython
再运行ok。
ming@ming-P95-HP:~/git/yolov5$ python detect.py --weights yolov5s.pt --img 640 --conf 0.4 --source ./inference/images/
Traceback (most recent call last):
File "detect.py", line 3, in <module>
from utils.datasets import *
File "/home/ming/git/yolov5/utils/datasets.py", line 17, in <module>
from utils.utils import xyxy2xywh, xywh2xyxy
File "/home/ming/git/yolov5/utils/utils.py", line 18, in <module>
import torchvision
ModuleNotFoundError: No module named 'torchvision'
pip install torchvision
pip install scipy # 后面发现也缺这个
然后搞定。
ming@ming-P95-HP:~/git/yolov5$ python detect.py --weights yolov5s.pt --img 640 --conf 0.4 --source ./inference/images/
Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.4, device='', fourcc='mp4v', half=False, img_size=640, iou_thres=0.5, output='inference/output', save_txt=False, source='./inference/images/', view_img=False, weights='yolov5s.pt')
Using CUDA device0 _CudaDeviceProperties(name='GeForce GTX 1060', total_memory=6078MB)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 408 0 408 0 0 231 0 --:--:-- 0:00:01 --:--:-- 231
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0
100 27.1M 0 27.1M 0 0 1408k 0 --:--:-- 0:00:19 --:--:-- 2044k
Downloading https://drive.google.com/uc?export=download&id=1R5T6rIyy3lLwgFXNms8whc-387H0tMQO as yolov5s.pt... Done (47.3s)
/home/ming/.local/lib/python3.7/site-packages/torch/serialization.py:657: SourceChangeWarning: source code of class 'models.yolo.Model' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/ming/.local/lib/python3.7/site-packages/torch/serialization.py:657: SourceChangeWarning: source code of class 'models.yolo.Detect' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
image 1/2 inference/images/bus.jpg: 640x512 3 persons, 1 buss, Done. (0.011s)
image 2/2 inference/images/zidane.jpg: 384x640 2 persons, 1 ties, Done. (0.011s)
Results saved to /home/ming/git/yolov5/inference/output
Done. (0.186s)