yolov5学习


源码地址
https://github.com/ultralytics/yolov5
其中有个教程(notebook)
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb#scrollTo=wbvMlHd_QwMG

配置环境

ubuntu18.04 (notebook上看用的linux所以就先用这个试水)

1.python3.7+

在这里插入图片描述 !!!ubuntu系统一定不要随意改python和python3的指向!!!
参考Ubuntu更新python3.5到最新版本——3.7.4

2. 安装依赖

在这里插入图片描述

坑1

执行

pip3 install -U -r yolov5/requirements.txt

报错(点链接解决)
subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.

坑2

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文件自己装一遍。
…无报错,这里就一个一个来就对了。

坑3

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 "<stdin>", 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。

3.inference

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)

在这里插入图片描述在这里插入图片描述后面再更新。。。。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值