赞
踩
就是这个文件夹,别怕
下载链接,我下了yolov8s.py,放在该路径E:\nfshare\yolov8\ultralytics\weights
ps:model文件类型可以是yaml,也可以是pt
E:\nfshare\yolov8\ultralytics\cfg\models\v8\yolov8.yaml,就改类别数
nc: 9 # number of classes
E:\nfshare\yolov8\ultralytics\cfg\datasets\hr.yaml,这些和yolov5一样
E:\nfshare\yolov8\ultralytics\cfg\default.yaml ,就动了以下几个参数
- model: weights/yolov8s.pt # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
- data: cfg/datasets/hr.yaml # (str, optional) path to data file, i.e. coco128.yaml
- epochs: 1 # (int) number of epochs to train for
- amp: False
- batch: 8
运行代码 yolo cfg=cfg/default.yaml
在路径下新建python脚本文件\yolov8\ultralytics\demo.py,就像运行yolov5的模型一样,运行该脚本文件。
下面这些参数要怎么设置我还没懂。
- #import sys
- #sys.path.append("/home/yyt/nfshare/yolov8/")
- from ultralytics import YOLO
-
- # Create a new YOLO model from scratch
- #model = YOLO('/home/yyt/nfshare/yolov8/ultralytics/cfg/models/v8/yolov8.yaml')
-
- # Load a pretrained YOLO model (recommended for training)
- model = YOLO('/home/yyt/nfshare/yolov8/ultralytics/weights/yolov8s.pt')
-
- # Train the model using the 'coco128.yaml' dataset for 3 epochs
- results = model.train(data='/home/yyt/nfshare/yolov8/ultralytics/cfg/datasets/hr.yaml',amp=False,epochs=2,batch=8,val=True)
-
- # Evaluate the model's performance on the validation set
- #results = model.val(data='/home/yyt/nfshare/yolov8/ultralytics/cfg/datasets/hr.yaml',amp=False,epochs=2,batch=8)
-
- success = model.export(format='onnx')
直接输入yolo cfg=/文件的路径/default.yaml
yolo task=detect mode=train model=/yolov8/ultralytics/cfg/runs/detect/train6//weights/last.pt(模型位置,模型可以是.yaml形式或者.pt) data=/yolov8/ultralytics/cfg/datasets/hr.yaml(数据集.yaml文件位置) epochs=150 save=True resume=True (后面的都是参数,具体写什么看default.yaml里面你需要改什么)
修改default.yaml,运行代码和train一样
修改mode: val,model:/runs/detect/train6/weights/last.pt ,split: test
这个方法能显示test每张图片检测的结果
yolo predict model= '/home/yyt/nfshare/yolov8/ultralytics/cfg/runs/detect/train6/weights/last.pt'(模型路径) source= '/home/yyt/nfshare/zijianshujuji/image/test'(图片文件路径)
显卡问题,batch值太大
解决:在default.yaml中,改小batch值 ,amp改为False
为了解决问题1 result全显示为0,我删去了validator中的如下代码,恢复看看能不能跑通val
self.args.half = self.device.type != 'cpu' # force FP16 val during training
失败
amp改为ture,好的这个不能改,改了又都是nan
不是我瞎改的问题
- #'model': deepcopy(de_parallel(self.model)).half(),
- 'model': deepcopy(de_parallel(self.model)).float(),
- #'ema': deepcopy(self.ema.ema).half(),
- 'ema': deepcopy(self.ema.ema).float(),
无效果
- #batch['img'] = (batch['img'].half() if self.args.half else batch['img'].float()) / 255
- batch['img'] = (batch['img'].float()) / 255
不行
batch_size=4
不行
- (yolov5) root@xxdell:/home/yyt/nfshare/yolov8/ultralytics# yolo cfg=/home/yyt/nfshare/yolov8/ultralytics/cfg/default.yaml
- Traceback (most recent call last):
- File "/home/nephilim/environment/anaconda3/envs/yolov5/bin/yolo", line 5, in <module>
- from ultralytics.cfg import entrypoint
- ModuleNotFoundError: No module named 'ultralytics'
解决方法:在/home/xx/environment/anaconda3/envs/yolov5/bin/yolo文件中添加路径
sys.path.append("/home/yyt/nfshare/yolov8/")
再次运行,解决
原本的训练结果保存在/home/yyt/nfshare/yolov8/runs 里面,即我的共享文件夹和yolov8存在的项目文件了,现在被更改了也不知道是怎么回事,前两次训练结果就没有出现。现在的文件夹路径在虚拟机的环境路径里/home/xx/environment/anaconda3/envs/yolov5/bin/runs/detect
感觉使用的不是yolov8,而是yolov5
- (base) yyt@dell:/home/xx/environment/anaconda3/envs/yolov5/bin/runs/detect$ stat train
- File: train
- Size: 4096 Blocks: 8 IO Block: 4096 directory
- Device: 824h/2084d Inode: 16883842 Links: 3
- Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
- Access: 2023-08-21 15:02:27.587039861 +0800
- Modify: 2023-08-21 14:59:15.937472731 +0800
- Change: 2023-08-21 14:59:15.937472731 +0800
这几次运行的都是配置default.yaml,运行python文件,正常显示。
命令行直接输入代码如下,模型改为之前跑的last.pt,epochs是总的训练次数
yolo task=detect mode=train model=/home/yyt/nfshare/yolov8/ultralytics/cfg/runs/detect/train6//weights/last.pt data=/home/yyt/nfshare/yolov8/ultralytics/cfg/datasets/hr.yaml epochs=150 save=True resume=True
训练完模型后,继续跑val测试,出现以下错误。
- Validating runs/detect/train/weights/best.pt...
- Ultralytics YOLOv8.0.173 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/710582推荐阅读
相关标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。