当前位置:   article > 正文

RT-DETR rtdetr-r18 - ultralytics - YOLOv8版本训练自己的数据集

rtdetr-r18

0 源码与相关参考

源码请从b站up主【魔傀面具】获取:https://space.bilibili.com/286900343?spm_id_from=333.337.0.0

以下代码为私有

github

https://github.com/Whiffe/ultralytics-RT-DETR
  • 1

码云

https://github.com/Whiffe/ultralytics-RT-DETR
  • 1

参考:b站魔傀面具
https://space.bilibili.com/286900343?spm_id_from=333.337.0.0

1 安装

注意,开始之前,需要配置好YOLOv8的环境

conda create -n rtdetr python=3.8
  • 1
conda activate rtdetr
  • 1
git clone https://github.com/Whiffe/ultralytics-RT-DETR
# git clone https://github.com/Whiffe/ultralytics-RT-DETR

cd ultralytics-RT-DETR

pip install ultralytics

python setup.py develop

pip install timm thop efficientnet_pytorch einops grad-cam dill -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install -U openmim

mim install mmengine

mim install "mmcv>=2.0.0"

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

pip install psutil

2 数据集准备

moon.yaml

path: D:\mySearch\RT-detr\ultralytics-RT-DETR\dataset
train: ./yolo_behavior_Dataset_all2/images/train
val: ./yolo_behavior_Dataset_all2/images/val

# number of classes
nc: 5

# class names
names: [ 'weigh','height measure','drop ball','size measure','record']

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

3 训练 rtdetr-r18

python train.py
  • 1

在这里插入图片描述

import warnings
warnings.filterwarnings('ignore')
from ultralytics import RTDETR

if __name__ == '__main__':
    model = RTDETR('ultralytics/cfg/models/rt-detr/rtdetr-r18.yaml')
    # model.load('') # loading pretrain weights
    model.train(data='dataset/moon.yaml',
                cache=False,
                imgsz=640,
                epochs=100,
                batch=4,
                workers=4,
                device='0',
                # resume='', # last.pt path
                project='runs/train',
                name='exp',
                )
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

在这里插入图片描述

4 pytorch 版本升级

pytorch离线安装网站:

https://download.pytorch.org/whl/torch_stable.html

pytorch需要1.9.0及以上版本

cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl
https://download.pytorch.org/whl/cu111/torch-1.9.0%2Bcu111-cp38-cp38-linux_x86_64.whl

在这里插入图片描述
卸载

pip uninstall torch
  • 1

安装

pip install torch-1.9.0+cu111-cp38-cp38-linux_x86_64.whl
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/941161
推荐阅读
相关标签
  

闽ICP备14008679号