ssd512_voc0712.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. _base_ = 'ssd300_voc0712.py'
  2. input_size = 512
  3. model = dict(
  4. neck=dict(
  5. out_channels=(512, 1024, 512, 256, 256, 256, 256),
  6. level_strides=(2, 2, 2, 2, 1),
  7. level_paddings=(1, 1, 1, 1, 1),
  8. last_kernel_size=4),
  9. bbox_head=dict(
  10. in_channels=(512, 1024, 512, 256, 256, 256, 256),
  11. anchor_generator=dict(
  12. input_size=input_size,
  13. strides=[8, 16, 32, 64, 128, 256, 512],
  14. basesize_ratio_range=(0.15, 0.9),
  15. ratios=([2], [2, 3], [2, 3], [2, 3], [2, 3], [2], [2]))))
  16. # dataset settings
  17. dataset_type = 'VOCDataset'
  18. data_root = 'data/VOCdevkit/'
  19. train_pipeline = [
  20. dict(type='LoadImageFromFile'),
  21. dict(type='LoadAnnotations', with_bbox=True),
  22. dict(
  23. type='Expand',
  24. mean={{_base_.model.data_preprocessor.mean}},
  25. to_rgb={{_base_.model.data_preprocessor.bgr_to_rgb}},
  26. ratio_range=(1, 4)),
  27. dict(
  28. type='MinIoURandomCrop',
  29. min_ious=(0.1, 0.3, 0.5, 0.7, 0.9),
  30. min_crop_size=0.3),
  31. dict(type='Resize', scale=(input_size, input_size), keep_ratio=False),
  32. dict(type='RandomFlip', prob=0.5),
  33. dict(
  34. type='PhotoMetricDistortion',
  35. brightness_delta=32,
  36. contrast_range=(0.5, 1.5),
  37. saturation_range=(0.5, 1.5),
  38. hue_delta=18),
  39. dict(type='PackDetInputs')
  40. ]
  41. test_pipeline = [
  42. dict(type='LoadImageFromFile'),
  43. dict(type='Resize', scale=(input_size, input_size), keep_ratio=False),
  44. # avoid bboxes being resized
  45. dict(type='LoadAnnotations', with_bbox=True),
  46. dict(
  47. type='PackDetInputs',
  48. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  49. 'scale_factor'))
  50. ]
  51. train_dataloader = dict(
  52. batch_size=8,
  53. num_workers=3,
  54. dataset=dict( # RepeatDataset
  55. # the dataset is repeated 10 times, and the training schedule is 2x,
  56. # so the actual epoch = 12 * 10 = 120.
  57. times=10,
  58. dataset=dict( # ConcatDataset
  59. # VOCDataset will add different `dataset_type` in dataset.metainfo,
  60. # which will get error if using ConcatDataset. Adding
  61. # `ignore_keys` can avoid this error.
  62. ignore_keys=['dataset_type'],
  63. datasets=[
  64. dict(
  65. type=dataset_type,
  66. data_root=data_root,
  67. ann_file='VOC2007/ImageSets/Main/trainval.txt',
  68. data_prefix=dict(sub_data_root='VOC2007/'),
  69. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  70. pipeline=train_pipeline),
  71. dict(
  72. type=dataset_type,
  73. data_root=data_root,
  74. ann_file='VOC2012/ImageSets/Main/trainval.txt',
  75. data_prefix=dict(sub_data_root='VOC2012/'),
  76. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  77. pipeline=train_pipeline)
  78. ])))
  79. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  80. test_dataloader = val_dataloader