Skip to content

Commit fa49718

Browse files
committed
refine autoaugment
1 parent eda53b9 commit fa49718

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

Augmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __call__(self, sample):
7676
image = image.astype(np.float32)/255.0
7777

7878
sample = {'img': image, 'annot': annots}
79-
# easy_visualization(sample)
79+
easy_visualization(sample)
8080
return sample
8181

8282

config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
dataset_type = 1 => voc dataset
33
dataset_type = 2 => kitti dataset
44
"""
5-
dataset_type = 2
5+
dataset_type = 1
66
epochs = 100
77
CUDA_DEVICES = '6'
88

99
kitti_batch_size = 24
10-
voc_batch_size = 8
10+
voc_batch_size = 2
1111

1212
# voc_root_dir = '/home/CN/zhenglin.zhou/Documents/VOC/VOCdevkit/'
1313
# kitti_root_dir = '/home/CN/zhenglin.zhou/Documents/Kitti/training/'
1414

15-
voc_root_dir = 'D:\VOC\VOCdevkit'
15+
voc_root_dir = 'D:/VOC/VOCdevkit'
1616
kitti_root_dir = 'D:/KITTI/training'
1717

1818
""" Mixup """
1919
use_mixup = 0
2020
alpha = 1
2121

2222
""" Autoaugment """
23-
use_autoaugment = 1
23+
use_autoaugment = 0

retinanet/losses.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def forward(self, classifications, regressions, anchors, annotations):
171171
regression_losses.append(torch.tensor(0).float().cuda())
172172
else:
173173
regression_losses.append(torch.tensor(0).float())
174-
175174
# return torch.stack(classification_losses).mean(dim=0, keepdim=True), torch.stack(regression_losses).mean(dim=0, keepdim=True)
176175
return torch.stack(classification_losses), torch.stack(regression_losses)
177176

test_augmentation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
if __name__ == '__main__':
88
voc_train = VocDataset(voc_root_dir, 'train',
99
transform=transforms.Compose([autoaugmenter('test')]))
10-
for i in range(voc_train.__len__()):
11-
print(i)
12-
sample = voc_train[i]
13-
# sample = voc_train[11]
14-
# sample = voc_train[9]
10+
# for i in range(voc_train.__len__()):
11+
# print(i)
12+
# sample = voc_train[i]
13+
sample = voc_train[11]
1514
# SplitKittiDataset(kitti_root_dir, 0.5) # 分割KITTI数据集,50%训练集,50%测试集
1615
#
1716
# kitti_train = KittiDataset(kitti_root_dir, 'train', transform=transforms.Compose([autoaugmenter('test')]))

train.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
author: zhenglin.zhou
1717
date: 20200724
1818
"""
19-
CUDA_DEVICES = config.CUDA_DEVICES
20-
os.environ["CUDA_VISIBLE_DEVICES"] = CUDA_DEVICES
19+
# CUDA_DEVICES = config.CUDA_DEVICES
20+
# os.environ["CUDA_VISIBLE_DEVICES"] = CUDA_DEVICES
2121

2222
print('CUDA available: {}'.format(torch.cuda.is_available()))
2323

@@ -26,12 +26,12 @@ def main():
2626
epochs = config.epochs
2727
if config.use_autoaugment:
2828
transform = transforms.Compose([Normalizer(),
29-
autoaugmenter(),
29+
autoaugmenter('v1'),
3030
Resizer(),
3131
])
3232
else:
3333
transform = transforms.Compose([Normalizer(),
34-
retinanet_augmentater('v1'),
34+
retinanet_augmentater(),
3535
Resizer(),
3636
])
3737

@@ -56,9 +56,6 @@ def main():
5656
sampler = AspectRatioBasedSampler(dataset_train, batch_size=batch_size, drop_last=False)
5757
dataloader_train = DataLoader(dataset_train, num_workers=3,
5858
collate_fn=collater, batch_sampler=sampler)
59-
sampler_val = AspectRatioBasedSampler(dataset_val, batch_size=batch_size, drop_last=False)
60-
dataloader_val = DataLoader(dataset_train, num_workers=3,
61-
collate_fn=collater, batch_sampler=sampler)
6259

6360
retinanet = model.resnet18(num_classes=dataset_train.num_classes(), pretrained=True)
6461

0 commit comments

Comments
 (0)