数据集准备
道路交通信号灯颜色目标检测数据集
Small Traffic Light Dataset (S2TLD):Small Traffic Light Dataset (S2TLD)_数据集-飞桨AI Studio星河社区 (baidu.com)
轨道交通场景语义分割数据集
官方下载地址(需注册申请):WildDash 2 Benchmark
Railsem19_数据集-飞桨AI Studio星河社区 (baidu.com)
基于IAT的道路交通信号灯颜色目标检测方法
加工数据集
1、为模拟黑暗/强光场景,首先对数据集进行加工,具体而言,利用PS批量将图像分别的曝光度增加-5、-3、0、+3、+5。和实际情况不同的是,黑暗场景中信号灯的颜色理应更加醒目,因此本加工方法仅供参考。
2、将S2TLD中文件结构调整成IAT_mmdetection的结构
S2TLD
|
|——Annotations
| |——LABLE
|——JPEGImages
| |——IMGS
|——main
| |——train.txt
| |——val.txt
| |——test.txt
修改配置(IAT_high/IAT_mmdetection)
修改数据集配置(configs/_base_/datasets)
1、为更加方便,选择直接在单gpu训练的yolo中进行修改(configs/yolo/exdark_yolo.py)。
(1)数据集路径修改
data_root = '/home/yhb/Illumination-Adaptive-Transformer/data/S2TLD/'
(2)gpu修改
samples_per_gpu=2,
workers_per_gpu=1,
(3)train/val/test图像和标注文件路径修改
data = dict(
samples_per_gpu=2,
workers_per_gpu=1,
train=dict(
type=dataset_type,
ann_file=data_root + 'main/train.txt',
img_prefix=data_root + 'JPEGImages/IMGS',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
ann_file = data_root + 'main/val.txt',
img_prefix=data_root + 'JPEGImages/IMGS',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
ann_file = data_root + 'main/val.txt',
img_prefix=data_root + 'JPEGImages/IMGS',
pipeline=test_pipeline))
2、mmdet/datasets,S2TLD数据集内共包含5个类,因此将CLASSES进行更改。
CLASSES = ('red', 'yellow', 'green', 'off', 'wait_on')
修改模型配置
1、yolov3_IAT_lol.py,修改类的数量,对应数据集中的类
num_classes=5,
训练
python tools/train.py configs/yolo/yolov3_IAT_lol.py --gpu-ids 0
测试
python tools/test.py configs/yolo/yolov3_IAT_lol.py /home/yhb/Illumination-Adaptive-Transformer/IAT_high/IAT_mmdetection/work_dirs/yolov3_IAT_lol/best2_epoch.pth --eval mAP --show --show-dir=output2
基于IAT的轨道交通场景语义分割方法
修改配置(IAT_high/IAT_mmseg)
修改数据集配置(configs/_base_、mmseg/datasets)
1、为修改起来更加方便,选择直接在默认的/datasets/ACDC_night.py文件中进行修改,Railsem19数据集内共包含21个类。
(1)数据集路径修改
data_root = '/home/yhb/Illumination-Adaptive-Transformer/data/railseg19'
(2)原图像尺寸修改,图像尺寸查看:打开图像—属性
img_scale=(1536, 1024)
(3)gpu修改
samples_per_gpu=2,
workers_per_gpu=1,
(4)train/val/test图像路径修改
train=dict(
type=dataset_type,
data_root=data_root,
img_dir='image/train',
ann_dir='label/train',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir='image/val',
ann_dir='label/val',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir='image/val',
ann_dir='label/val',
pipeline=test_pipeline))
2、修改ACDC_night.py
修改类别名称和对应颜色
CLASSES = ['buffer-stop', 'crossing', 'guard-rail', 'train-car', 'platform', 'rail', 'switch-indicator', 'switch-left', 'switch-right', 'switch-unknown', 'switch-static', 'track-sign-front', 'track-signal-front', 'track-signal-back', 'person-group', 'car', 'fence', 'person', 'pole', 'rail-occluder', 'truck']
PALETTE = [[70,70,70], [128,64,128], [0,255,0], [100,80,0], [232,35,244], [255,255,0], [127,255,0], [255,255,0], [127,127,0], [191,191,0], [0,255,127], [0,220,220], [30,170,250], [0,85,125], [60,20,220], [142,0,0], [153,153,190], [60,20,220], [153,153,153], [255,255,255], [70,0,0]]
修改模型配置
1、修改models/deeplabv3plus_r50-d8_wtih_IAT_LOL.py
(1)SyncBN代表分布式训练,单卡训练将其改成BN
norm_cfg = dict(type='BN', requires_grad=True)
(2)修改预训练模型
checkpoint='/home/yhb/Illumination-Adaptive-Transformer/IAT_high/IAT_mmseg/work_dir/IAT_LOL/iter_20000.pth')
(3)修改类的数量,对应数据集中的类,共两处
num_classes=21,
(4)根据需要选择不同的训练伦次
_base_ = [
'../_base_/models/deeplabv3plus_r50-d8.py',
'../_base_/datasets/ACDC_night_with_DeepLPF.py', '../_base_/default_runtime.py',
'../_base_/schedules/schedule_20k.py'
]
训练
python tools/train.py /home/yhb/Illumination-Adaptive-Transformer/IAT_high/IAT_mmseg/configs/deeplabv3plus/deeplabv3plus_r50-d8_1024x1024_80k_ACDC_night_with_IAT_LOL.py
测试
python tools/test.py configs/deeplabv3plus/deeplabv3plus_r50-d8_1024x1024_80k_ACDC_night_with_IAT.py work_dirs/deeplabv3plus_r50-d8_1024x1024_80k_ACDC_night_with_IAT_LOL/iter_20000.pth --eval mIoU --gpu-id=0 --show-dir=/home/yhb/Illumination-Adaptive-Transformer/IAT_high/IAT_mmseg/output2