【备份】mmdetection 3.0.0 DINO训练自己的数据集config文件

环境:py3.8 + pytorch 1.8.1 + cuda 11.1

服务器Ubuntu版本:Ubuntu 22.04.1 LTS

环境配置过程:

conda create -n mmdet_py38 python=3.8    # 创建环境
conda activate mmdet_py38    # 激活环境
pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html    # 安装pytorch
# 使用 MIM 安装 MMEngine 和 MMCV
pip install -U openmim
mim install mmengine
mim install "mmcv==2.0.0"
pip install -v -e . #进入到项目文件夹下执行此命令

config文件:

_base_ = '../dino/dino-4scale_r50_8xb2-24e_coco.py'
model = dict(bbox_head=dict(num_classes=5))

dataset_type = 'CocoDataset'
data_root = '/data/zy/dataset/project/Cooper001_withlabel/coco/'
classes = ('Inlet', 'Slightshort', 'Generalshort', 'Severeshort', 'Outlet')

# Modify dataset related settings
metainfo = {
    'classes': ('Inlet', 'Slightshort', 'Generalshort', 'Severeshort', 'Outlet' ),

}
#backend_args = None

train_dataloader = dict(
    batch_size=2,
    num_workers=2,
    dataset=dict(
        data_root=data_root,
        metainfo=dict(classes=classes),
        ann_file='annotations/instances_train2017.json',
        data_prefix=dict(img='train2017/'),
        ))
val_dataloader = dict(
    dataset=dict(
        data_root=data_root,
        metainfo=dict(classes=classes),
        ann_file='annotations/instances_val2017.json',
        data_prefix=dict(img='val2017/'),
        ))

val_evaluator = dict(ann_file=data_root + 'annotations/instances_val2017.json')

# inference on test dataset and
# format the output results for submission.
test_dataloader = dict(
    batch_size=1,
    num_workers=2,
    persistent_workers=True,
    drop_last=False,
    sampler=dict(type='DefaultSampler', shuffle=False),
    dataset=dict(
        type=dataset_type,
        data_root=data_root,
        ann_file=data_root + 'annotations/instances_test2017.json',
        data_prefix=dict(img='test2017/'),
        test_mode=True,
        ))
test_evaluator = dict(
    type='CocoMetric',
    metric='bbox',
    format_only=True,
    ann_file=data_root + 'annotations/instances_test2017.json',
    outfile_prefix='./work_dirs/coco_detection/test')

#test_dataloader = val_dataloader
#test_evaluator = val_evaluator
        
evaluation = dict(interval=1, metric='bbox', classwise=True)  
load_from = '/data/zy/code/mmdetection-3.x/checkpoints/dino-4scale_r50_8xb2-12e_coco_20221202_182705-55b2bba2.pth'

训练指令:

CUDA_VISIBLE_DEVICES=1 python tools/train.py ./configs/demo/dino-4scale_r50_8xb2-24e_coco.py --work-dir ./work_dir/dino

 

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
mmdetection是一个开源的物体检测工具库,其中包含了RTMDet(Real-Time Multiscale Detection)模型。RTMDet在目标检测、实例分割和旋转框检测等领域表现出色,并且其精度超越了最新推出的YOLOv8。商汤在2023年6月4日开源了mmdetectionv3.0.0版本,并对RTMDet进行了高度评价,称其不仅在从微小到超大的模型尺寸上实现了最佳参数-精度平衡,还取得了最新的技术突破。 如果你想配置和训练RTMDet,可以按照以下步骤进行操作: 1. 安装mmcv和mmdetection:使用pip命令安装mmcv和mmdetection库。具体命令如下: ``` pip install -U openmim mim install mmengine mim install "mmcv>=2.0.0" git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection pip install -v -e . ``` 2. 验证安装:下载RTMDet的配置文件和权重文件。具体命令如下: ``` mim download mmdet --config rtmdet_tiny_8xb32-300e_coco --dest . ``` 3. 进行训练:根据你的数据集修改配置文件中的num_classes,将其改为你数据集的类别数量(不包括背景类)。然后使用train.py脚本进行训练,具体命令如下: ``` python tools/train.py \ ${CONFIG_FILE} \ [optional arguments] ``` 4. 进行测试:使用测试集中带有真值的图像进行测试,验证模型的性能。 请注意,以上步骤仅为训练RTMDet的基本流程,具体的配置和参数设置可能因实际情况而有所不同。你可以参考mmdetection官方文档和GitHub仓库获取更详细的信息和示例代码。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [当今最强最快的目标检测器(超越 YOLO v8)RTMDet的环境配置及自定义训练](https://blog.csdn.net/qq_42308217/article/details/130628650)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [mmdetection3.1.0 训练自己的数据集](https://blog.csdn.net/shuaijieer/article/details/131754881)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值