You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

AD_mlops_test17.py 5.4 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. _base_ = [
  2. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  3. ]
  4. pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_small_patch4_window7_224.pth'
  5. model = dict(
  6. type='ATSS',
  7. backbone=dict(
  8. depths=[2, 2, 18, 2],
  9. type='SwinTransformer',
  10. embed_dims=96,
  11. num_heads=[3, 6, 12, 24],
  12. window_size=7,
  13. mlp_ratio=4,
  14. qkv_bias=True,
  15. qk_scale=None,
  16. drop_rate=0.,
  17. attn_drop_rate=0.,
  18. drop_path_rate=0.2,
  19. patch_norm=True,
  20. out_indices=(0, 1, 2, 3),
  21. with_cp=False,
  22. convert_weights=True,
  23. init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
  24. neck=dict(
  25. type='FPN',
  26. in_channels=[96, 192, 384, 768],
  27. out_channels=256,
  28. num_outs=5),
  29. bbox_head=dict(
  30. type='ATSSHead',
  31. num_classes=11,
  32. in_channels=256,
  33. stacked_convs=4,
  34. feat_channels=256,
  35. anchor_generator=dict(
  36. type='AnchorGenerator',
  37. ratios=[1.0],
  38. octave_base_scale=8,
  39. scales_per_octave=1,
  40. strides=[8, 16, 32, 64, 128]),
  41. bbox_coder=dict(
  42. type='DeltaXYWHBBoxCoder',
  43. target_means=[.0, .0, .0, .0],
  44. target_stds=[0.1, 0.1, 0.2, 0.2]),
  45. loss_cls=dict(
  46. type='FocalLoss',
  47. use_sigmoid=True,
  48. gamma=2.0,
  49. alpha=0.25,
  50. loss_weight=1.0),
  51. loss_bbox=dict(type='GIoULoss', loss_weight=2.0),
  52. loss_centerness=dict(
  53. type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0)),
  54. # training and testing settings
  55. train_cfg=dict(
  56. assigner=dict(type='ATSSAssigner', topk=9),
  57. allowed_border=-1,
  58. pos_weight=-1,
  59. debug=False),
  60. test_cfg=dict(
  61. nms_pre=1000,
  62. min_bbox_size=0,
  63. score_thr=0.05,
  64. nms=dict(type='nms', iou_threshold=0.6),
  65. max_per_img=100))
  66. dataset_type = 'CocoDataset'
  67. classes = ('yiwei','loujian','celi','libei','fantie','lianxi','duojian','shunjian','shaoxi','jiahan','yiwu')
  68. img_norm_cfg = dict(
  69. mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
  70. train_pipeline = [
  71. dict(type='LoadImageFromFile'),
  72. dict(type='LoadAnnotations', with_bbox=True),
  73. dict(
  74. type='Resize',
  75. img_scale=[(400, 400), (500, 500)],
  76. multiscale_mode='value',
  77. keep_ratio=True),
  78. dict(type='RandomFlip', flip_ratio=[0.2,0.2,0.2], direction=['horizontal', 'vertical', 'diagonal']),
  79. dict(type='BrightnessTransform', level=5, prob=0.5),
  80. dict(type='ContrastTransform', level=5, prob=0.5),
  81. dict(type='RandomShift', shift_ratio=0.5),
  82. dict(type='MinIoURandomCrop', min_ious=(0.5, 0.7, 0.9), min_crop_size=0.8),
  83. dict(type='Normalize', **img_norm_cfg),
  84. dict(type='Pad', size_divisor=32),
  85. dict(type='DefaultFormatBundle'),
  86. dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
  87. ]
  88. test_pipeline = [
  89. dict(type='LoadImageFromFile'),
  90. dict(
  91. type='MultiScaleFlipAug',
  92. img_scale=[(400, 400)],
  93. flip=False,
  94. transforms=[
  95. dict(type='Resize', keep_ratio=True),
  96. dict(type='RandomFlip'),
  97. dict(type='Normalize', **img_norm_cfg),
  98. dict(type='Pad', size_divisor=32),
  99. dict(type='ImageToTensor', keys=['img']),
  100. dict(type='Collect', keys=['img']),
  101. ])
  102. ]
  103. data = dict(
  104. samples_per_gpu=6,
  105. workers_per_gpu=6,
  106. train=dict(
  107. type='AD_ClassBalancedDataset',
  108. dataset=dict(
  109. type=dataset_type,
  110. img_prefix='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2106_10_coco/train/images/',
  111. classes=classes,
  112. ann_file='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2106_10_coco/train/annotations/train.json',
  113. pipeline=train_pipeline,
  114. ),
  115. oversample_thr = 1.0),
  116. val=dict(
  117. type=dataset_type,
  118. img_prefix='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2112_coco/test/images/',
  119. classes=classes,
  120. ann_file='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2112_coco/test/annotations/test.json',
  121. pipeline=test_pipeline),
  122. test=dict(
  123. type=dataset_type,
  124. img_prefix='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2112_coco/test/images/',
  125. classes=classes,
  126. ann_file='/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_2112_coco/test/annotations/test.json',
  127. pipeline=test_pipeline))
  128. # optimizer
  129. optimizer = dict(
  130. _delete_=True,
  131. type='AdamW',
  132. lr=0.0001,
  133. betas=(0.9, 0.999),
  134. weight_decay=0.05,
  135. paramwise_cfg=dict(
  136. custom_keys={
  137. 'absolute_pos_embed': dict(decay_mult=0.),
  138. 'relative_position_bias_table': dict(decay_mult=0.),
  139. 'norm': dict(decay_mult=0.)
  140. }))
  141. optimizer_config = dict(grad_clip=None)
  142. # learning policy
  143. lr_config = dict(
  144. _delete_=True,
  145. policy='step',
  146. warmup='linear',
  147. warmup_iters=1000,
  148. warmup_ratio=0.001,
  149. step=[8, 11])
  150. runner = dict(type='EpochBasedRunner', max_epochs=20)
  151. evaluation = dict(interval=1, metric='bbox')
  152. checkpoint_config = dict(interval=1)

No Description

Contributors (3)