当前位置:网站首页>YOLOv7 uses cloud GPU to train its own dataset
YOLOv7 uses cloud GPU to train its own dataset
2022-08-02 14:27:00 【night cub】
最近注意到yolov7出来了,Just started watchingyolov5呢,只能说大佬就是大佬.Just ran through not long agoyolov5的代码,看见yolov7出来了,Just thought to try it out.看了很多csdn上的教程,收获很多,But everyone started running on their own computers,Without a graphics card, I can only use the cloudGPU了.Just started to explore the cloudGPU真的心累,一点基础没有,硬是把csdn和bThe station turned over,Some basic operations will be done.使用的云GPUHengyuan Cloud,I saw a lot of houses at first,Finally, it is given because the student is registered50代金券,I chose it without hesitation,After all, prostitution is too fragrant,And the documentation is pretty detailed,But the community is not so good,Going around for a while didn't solve a lot of my problems at the time,All are standard answers...不小心扯远了,哈哈哈,第二次在csdn上写东西(Strictly speaking, this is the first time I have written such a long article),大家多多包涵.后面如果有时间的话,I will write another cloudGPU怎么用,Hope it helps if you don't have a graphics card and want to use the cloudGPU的同学.接下来就进入正题吧
The cloud is usedGPU+pycharm专业版(Community edition cannot be remotely linked,If you are a student, you can use the education mailbox to apply for the professional version,They replied to me the same day when I applied)
首先,先贴上YOLOv7的代码链接(官方):
https://github.com/WongKinYiu/yolov7
不过访问github经常不稳定,深有体会.所以,Also posted a link to the web drive(Although a certain degree of speed is slow),The weights file is.zip格式,Change it after downloading.ptsuffix is fine.The code download time is approx7.17.
Weighted link links:https://pan.baidu.com/s/18FyZKy1u4QOUnAH0nGkjrg
提取码:oxle
代码链接:https://pan.baidu.com/s/13wwiix8q75fHDZzEULc9yw
提取码:rto5
pycharminterpreter configuration:
train.py的参数设置
其中weights cfg data hyp是需要设置的,batch-sizeIf it is too large, an error may be reported that the graphics card has insufficient memory,workers可以参考https://blog.csdn.net/flamebox/article/details/123011129
weights
The weights file can be downloaded from the link above,上传到服务器上.我只使用了yolo7.pt,If you are interested, you can try other weight files,But it might be usefultrain_aux.py.
cfg和hyp
yolov7The model file is used in the codeyaml文件,不过需要修改ncis the number of categories in its own dataset.Hyperparameters are also default files.
data
数据集文件,复制data文件下的coco.yaml一份命名为mydata.yaml.其中train_list.txtis its own datasetimages/train的绝对路径,val_list.txt是images/val的绝对路径.Here I wrote relative paths,Note that this relative path is relative to train.py文件的,不是相对于mydata.yaml文件.Of course, absolute paths will not go wrong,I saw a blogger say that the relative path is wrong,我就试了一下,结果使用../train_list.txt出错,The program cannot find the file.
Automatically acquire datasetstrain和val的imagesThe absolute path to the image in the folder,参考https://blog.csdn.net/qq_58355216/article/details/125677147
下面是生成train_list.txt的代码,如果要生成val_list.txt,将path和with open('./train_list.txt', 'w') as f:中的train换val
# From Mr. Dinosaur https://blog.csdn.net/qq_58355216/article/details/125677147
import os
def listdir(path, list_name):
for file in os.listdir(path):
file_path = os.path.join(path, file)
if os.path.isdir(file_path):
listdir(file_path, list_name)
else:
list_name.append(file_path)
list_name = []
path = '/hy-tmp/yolov7-main/mydata/images/train' # The absolute path to the folder where the training set images are located
listdir(path, list_name)
print(list_name)
with open('./train_list.txt', 'w') as f: # 在当前目录下生成train_list.txt文件
write = ''
for i in list_name:
write = write + str(i) + '\n'
f.write(write)
不过mydata.yamlCan also be set to andYOLOv5中data参数的值一样,You can also start training.(So what is the difference between these two methods?Anyone who knows can tell me in the comments)
训练
Basically the parameters need to be set alreadyok了,可以开始训练了.Remember to sync the modified project with the cloud,就可以运行train.py文件了.
Because it's just a test to see if it can run,所以epoch设置为30.训练结果保存在runs/train/exp.
报错
1、Use Hengyuan CloudGPU训练的时候,会出现(I don't know if it's an environmental issue)
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
在终端输入下面代码
apt-get install libglib2.0-dev
2、batch size设置过大出现RuntimeError: CUDA out of memory.
3、报错,参考https://blog.csdn.net/qq_36944952/article/details/124683408
AttributeError:module ‘distutils’ has no attribute 'version
使用如下代码
pip uninstall setuptools
pip install setuptools==59.5.0 //需要比你之前的低
测试
Parameter settings for the test file
Weights are used for training30次的best.pt文件,Prediction pictures folderinference/images,注意路径写对.--view-img参数默认false,设置为trueThe prediction results window can be displayed(But use the cloud to rundetect.py文件,The display will report an error,I have searched a lot of tutorials to no avail(The tutorial says to use itmobaxterm),If anyone knows a solution, please let me know in the comments).project和nameis the result save pathruns/detect/exp.
结果
报错
1、Forgot to uploaddetect.py到服务器,Caused it to fail all the time.报下面的错
subprocess.CalledProcessError: Command ‘git tag’ returned non-zero exit status 128
There may also be a problem with the parameter settings,Can double check
ps The above is just a simple trainingyolov7,Please let me know if the article is wrong or if you have better insights
边栏推荐
猜你喜欢
[ROS] (06) ROS Communication - Topic Communication
MobileNet ShuffleNet & yolov5 replace backbone
[ROS] Introduction to common tools in ROS (to be continued)
存储系统Cache(知识点+例题)
【ROS】工控机的软件包不编译
c语言三子棋详解!!! (电脑智能下棋)(附上完整代码)
Unit 5 Hold Status
C语言——断言assert的使用
What's wrong with running yolov5 (1) p, r, map are all 0
YOLOv7使用云GPU训练自己的数据集
随机推荐
[ROS](02)创建&编译ROS软件包Package
drf source code analysis and global catch exception
window10下半自动标注
安装使用——百家CMS微商城说明文档(2)
MobileNet ShuffleNet & yolov5替换backbone
Verilog学习 系列
Unit 6 meet ORM
chapter7
Chapter6 visualization (don't want to see the version)
STM32 (F407) - stack
[ROS](06)ROS通信 —— 话题(Topic)通信
MarkDown syntax summary
C语言——断言assert的使用
Flask framework in-depth
Unit 15 Paging, Filtering
drf serializer - Serializer
执行栈和执行上下文
yolov5 improvement (1) Add attention focus mechanism
原码、反码、补码和移码
[ROS](03)CMakeLists.txt详解