mask2former_r50_8xb2-lsj-50e_coco.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. _base_ = ['./mask2former_r50_8xb2-lsj-50e_coco-panoptic.py']
  2. num_things_classes = 80
  3. num_stuff_classes = 0
  4. num_classes = num_things_classes + num_stuff_classes
  5. image_size = (1024, 1024)
  6. batch_augments = [
  7. dict(
  8. type='BatchFixedSizePad',
  9. size=image_size,
  10. img_pad_value=0,
  11. pad_mask=True,
  12. mask_pad_value=0,
  13. pad_seg=False)
  14. ]
  15. data_preprocessor = dict(
  16. type='DetDataPreprocessor',
  17. mean=[123.675, 116.28, 103.53],
  18. std=[58.395, 57.12, 57.375],
  19. bgr_to_rgb=True,
  20. pad_size_divisor=32,
  21. pad_mask=True,
  22. mask_pad_value=0,
  23. pad_seg=False,
  24. batch_augments=batch_augments)
  25. model = dict(
  26. data_preprocessor=data_preprocessor,
  27. panoptic_head=dict(
  28. num_things_classes=num_things_classes,
  29. num_stuff_classes=num_stuff_classes,
  30. loss_cls=dict(class_weight=[1.0] * num_classes + [0.1])),
  31. panoptic_fusion_head=dict(
  32. num_things_classes=num_things_classes,
  33. num_stuff_classes=num_stuff_classes),
  34. test_cfg=dict(panoptic_on=False))
  35. # dataset settings
  36. train_pipeline = [
  37. dict(
  38. type='LoadImageFromFile',
  39. to_float32=True,
  40. backend_args={{_base_.backend_args}}),
  41. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  42. dict(type='RandomFlip', prob=0.5),
  43. # large scale jittering
  44. dict(
  45. type='RandomResize',
  46. scale=image_size,
  47. ratio_range=(0.1, 2.0),
  48. resize_type='Resize',
  49. keep_ratio=True),
  50. dict(
  51. type='RandomCrop',
  52. crop_size=image_size,
  53. crop_type='absolute',
  54. recompute_bbox=True,
  55. allow_negative_crop=True),
  56. dict(type='FilterAnnotations', min_gt_bbox_wh=(1e-5, 1e-5), by_mask=True),
  57. dict(type='PackDetInputs')
  58. ]
  59. test_pipeline = [
  60. dict(
  61. type='LoadImageFromFile',
  62. to_float32=True,
  63. backend_args={{_base_.backend_args}}),
  64. dict(type='Resize', scale=(1333, 800), keep_ratio=True),
  65. # If you don't have a gt annotation, delete the pipeline
  66. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  67. dict(
  68. type='PackDetInputs',
  69. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  70. 'scale_factor'))
  71. ]
  72. dataset_type = 'CocoDataset'
  73. data_root = 'data/coco/'
  74. train_dataloader = dict(
  75. dataset=dict(
  76. type=dataset_type,
  77. ann_file='annotations/instances_train2017.json',
  78. data_prefix=dict(img='train2017/'),
  79. pipeline=train_pipeline))
  80. val_dataloader = dict(
  81. dataset=dict(
  82. type=dataset_type,
  83. ann_file='annotations/instances_val2017.json',
  84. data_prefix=dict(img='val2017/'),
  85. pipeline=test_pipeline))
  86. test_dataloader = val_dataloader
  87. val_evaluator = dict(
  88. _delete_=True,
  89. type='CocoMetric',
  90. ann_file=data_root + 'annotations/instances_val2017.json',
  91. metric=['bbox', 'segm'],
  92. format_only=False,
  93. backend_args={{_base_.backend_args}})
  94. test_evaluator = val_evaluator