├── LICENSE ├── README.md ├── demo ├── .gitkeep ├── STL.png └── Teaser.png ├── detection ├── .DS_Store ├── README.md ├── configs │ ├── _base_ │ │ ├── datasets │ │ │ ├── cityscapes_detection.py │ │ │ ├── cityscapes_instance.py │ │ │ ├── coco_detection.py │ │ │ ├── coco_instance.py │ │ │ ├── coco_instance_semantic.py │ │ │ ├── deepfashion.py │ │ │ ├── lvis_v0.5_instance.py │ │ │ ├── lvis_v1_instance.py │ │ │ ├── voc0712.py │ │ │ └── wider_face.py │ │ ├── default_runtime.py │ │ ├── models │ │ │ ├── cascade_mask_rcnn_pvtv2_b2_fpn.py │ │ │ ├── cascade_mask_rcnn_r50_fpn.py │ │ │ ├── cascade_rcnn_r50_fpn.py │ │ │ ├── fast_rcnn_r50_fpn.py │ │ │ ├── faster_rcnn_r50_caffe_c4.py │ │ │ ├── faster_rcnn_r50_caffe_dc5.py │ │ │ ├── faster_rcnn_r50_fpn.py │ │ │ ├── mask_rcnn_r50_caffe_c4.py │ │ │ ├── mask_rcnn_r50_fpn.py │ │ │ ├── retinanet_r50_fpn.py │ │ │ ├── rpn_r50_caffe_c4.py │ │ │ ├── rpn_r50_fpn.py │ │ │ └── ssd300.py │ │ └── schedules │ │ │ ├── schedule_1x.py │ │ │ ├── schedule_20e.py │ │ │ └── schedule_2x.py │ ├── cascade_mask_fan_base_fpn_3x_mstrain_fp16.py │ ├── cascade_mask_fan_base_fpn_3x_mstrain_fp16_22k.py │ ├── cascade_mask_fan_large_fpn_3x_mstrain_fp16.py │ ├── cascade_mask_fan_large_fpn_3x_mstrain_fp16_22k.py │ ├── cascade_mask_fan_small_fpn_3x_mstrain_fp16.py │ └── cascade_mask_fan_tiny_fpn_3x_mstrain_fp16.py ├── dist_train.sh ├── install.sh ├── mmcv_custom │ └── runner │ │ ├── checkpoint.py │ │ ├── epoch_based_runner.py │ │ └── optimizer.py ├── mmdet_custom │ └── apis │ │ └── train.py ├── mn_train.sh ├── models │ ├── __init__.py │ ├── convnext_utils.py │ └── fan.py ├── test.py ├── tools │ ├── coco_c_test_all.sh │ ├── dist_test_coco_c.sh │ └── gen_coco_c.py └── train.py ├── main.py ├── models ├── __init__.py ├── convnext_utils.py ├── fan.py └── swin_utils.py ├── requirements.txt ├── scripts ├── NGC │ ├── start_multi_node.sh │ └── start_single_node.sh ├── fan_stl_student │ ├── fan_small_stl.sh │ ├── fan_tiny_stl.sh │ ├── mn_fan_base_stl.sh │ └── mn_fan_large_stl.sh ├── fan_token_labeler │ ├── fan_small_tl.sh │ ├── fan_tiny_tl.sh │ ├── mn_fan_base_tl.sh │ └── mn_fan_large_tl.sh ├── imagenet_a_val.sh ├── imagenet_c_val.sh └── imagenet_r_val.sh ├── segmentation ├── .DS_Store ├── README.md ├── local_configs │ ├── _base_ │ │ ├── datasets │ │ │ ├── ade20k.py │ │ │ ├── ade20k_repeat.py │ │ │ ├── cityscapes.py │ │ │ ├── cityscapes_1024x1024.py │ │ │ ├── cityscapes_1024x1024_repeat.py │ │ │ ├── cityscapes_768x768_repeat.py │ │ │ ├── cityscapes_repeat.py │ │ │ └── cocostuff_repeat.py │ │ ├── default_runtime.py │ │ ├── models │ │ │ ├── ann_r50-d8.py │ │ │ ├── apcnet_r50-d8.py │ │ │ ├── ccnet_r50-d8.py │ │ │ ├── cgnet.py │ │ │ ├── danet_r50-d8.py │ │ │ ├── deeplabv3_r50-d8.py │ │ │ ├── deeplabv3_unet_s5-d16.py │ │ │ ├── deeplabv3plus_r50-d8.py │ │ │ ├── dmnet_r50-d8.py │ │ │ ├── dnl_r50-d8.py │ │ │ ├── emanet_r50-d8.py │ │ │ ├── encnet_r50-d8.py │ │ │ ├── fast_scnn.py │ │ │ ├── fcn_hr18.py │ │ │ ├── fcn_r50-d8.py │ │ │ ├── fcn_unet_s5-d16.py │ │ │ ├── fpn_r50.py │ │ │ ├── gcnet_r50-d8.py │ │ │ ├── lraspp_m-v3-d8.py │ │ │ ├── nonlocal_r50-d8.py │ │ │ ├── ocrnet_hr18.py │ │ │ ├── ocrnet_r50-d8.py │ │ │ ├── pointrend_r50.py │ │ │ ├── psanet_r50-d8.py │ │ │ ├── pspnet_r50-d8.py │ │ │ ├── pspnet_unet_s5-d16.py │ │ │ ├── segformer.py │ │ │ ├── setr_pup.py │ │ │ └── upernet_r50.py │ │ └── schedules │ │ │ ├── schedule_160k.py │ │ │ ├── schedule_160k_8gpu_adamw.py │ │ │ ├── schedule_20k.py │ │ │ ├── schedule_320k_8gpu_adamw.py │ │ │ ├── schedule_40k.py │ │ │ ├── schedule_40k_8gpu_adamw.py │ │ │ ├── schedule_40k_8gpu_sgd.py │ │ │ ├── schedule_80k.py │ │ │ ├── schedule_80k_8gpu_adamw.py │ │ │ └── schedule_80k_8gpu_sgd.py │ └── fan │ │ └── fan_hybrid │ │ ├── fan_hybrid_base.1024x1024.city.160k.py │ │ ├── fan_hybrid_large.1024x1024.city.160k.py │ │ ├── fan_hybrid_small.1024x1024.city.160k.py │ │ └── fan_hybrid_tiny.1024x1024.city.160k.py ├── mmseg │ ├── .DS_Store │ ├── __init__.py │ ├── apis │ │ ├── __init__.py │ │ ├── inference.py │ │ ├── test.py │ │ └── train.py │ ├── core │ │ ├── __init__.py │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── class_names.cpython-36.pyc │ │ │ │ ├── class_names.cpython-37.pyc │ │ │ │ ├── class_names.cpython-38.pyc │ │ │ │ ├── eval_hooks.cpython-36.pyc │ │ │ │ ├── eval_hooks.cpython-37.pyc │ │ │ │ ├── eval_hooks.cpython-38.pyc │ │ │ │ ├── metrics.cpython-36.pyc │ │ │ │ ├── metrics.cpython-37.pyc │ │ │ │ └── metrics.cpython-38.pyc │ │ │ ├── class_names.py │ │ │ ├── eval_hooks.py │ │ │ └── metrics.py │ │ ├── seg │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── builder.cpython-36.pyc │ │ │ │ ├── builder.cpython-37.pyc │ │ │ │ └── builder.cpython-38.pyc │ │ │ ├── builder.py │ │ │ └── sampler │ │ │ │ ├── __init__.py │ │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── base_pixel_sampler.cpython-36.pyc │ │ │ │ ├── base_pixel_sampler.cpython-37.pyc │ │ │ │ ├── base_pixel_sampler.cpython-38.pyc │ │ │ │ ├── ohem_pixel_sampler.cpython-36.pyc │ │ │ │ ├── ohem_pixel_sampler.cpython-37.pyc │ │ │ │ └── ohem_pixel_sampler.cpython-38.pyc │ │ │ │ ├── base_pixel_sampler.py │ │ │ │ └── ohem_pixel_sampler.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── misc.cpython-36.pyc │ │ │ ├── misc.cpython-37.pyc │ │ │ └── misc.cpython-38.pyc │ │ │ └── misc.py │ ├── datasets │ │ ├── __init__.py │ │ ├── ade.py │ │ ├── builder.py │ │ ├── chase_db1.py │ │ ├── cityscapes.py │ │ ├── cocostuff.py │ │ ├── custom.py │ │ ├── dataset_wrappers.py │ │ ├── drive.py │ │ ├── hrf.py │ │ ├── mapillary.py │ │ ├── pascal_context.py │ │ ├── pipelines │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── compose.cpython-36.pyc │ │ │ │ ├── compose.cpython-37.pyc │ │ │ │ ├── compose.cpython-38.pyc │ │ │ │ ├── formating.cpython-36.pyc │ │ │ │ ├── formating.cpython-37.pyc │ │ │ │ ├── formating.cpython-38.pyc │ │ │ │ ├── loading.cpython-36.pyc │ │ │ │ ├── loading.cpython-37.pyc │ │ │ │ ├── loading.cpython-38.pyc │ │ │ │ ├── test_time_aug.cpython-36.pyc │ │ │ │ ├── test_time_aug.cpython-37.pyc │ │ │ │ ├── test_time_aug.cpython-38.pyc │ │ │ │ ├── transforms.cpython-36.pyc │ │ │ │ ├── transforms.cpython-37.pyc │ │ │ │ └── transforms.cpython-38.pyc │ │ │ ├── compose.py │ │ │ ├── formating.py │ │ │ ├── loading.py │ │ │ ├── test_time_aug.py │ │ │ └── transforms.py │ │ ├── stare.py │ │ └── voc.py │ ├── models │ │ ├── __init__.py │ │ ├── backbones │ │ │ ├── __init__.py │ │ │ ├── convnext_utils.py │ │ │ ├── fan.py │ │ │ └── swin_utils.py │ │ ├── builder.py │ │ ├── decode_heads │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── ann_head.cpython-36.pyc │ │ │ │ ├── ann_head.cpython-37.pyc │ │ │ │ ├── ann_head.cpython-38.pyc │ │ │ │ ├── apc_head.cpython-36.pyc │ │ │ │ ├── apc_head.cpython-37.pyc │ │ │ │ ├── apc_head.cpython-38.pyc │ │ │ │ ├── aspp_head.cpython-36.pyc │ │ │ │ ├── aspp_head.cpython-37.pyc │ │ │ │ ├── aspp_head.cpython-38.pyc │ │ │ │ ├── cascade_decode_head.cpython-36.pyc │ │ │ │ ├── cascade_decode_head.cpython-37.pyc │ │ │ │ ├── cascade_decode_head.cpython-38.pyc │ │ │ │ ├── cc_head.cpython-36.pyc │ │ │ │ ├── cc_head.cpython-37.pyc │ │ │ │ ├── cc_head.cpython-38.pyc │ │ │ │ ├── da_head.cpython-36.pyc │ │ │ │ ├── da_head.cpython-37.pyc │ │ │ │ ├── da_head.cpython-38.pyc │ │ │ │ ├── decode_head.cpython-36.pyc │ │ │ │ ├── decode_head.cpython-37.pyc │ │ │ │ ├── decode_head.cpython-38.pyc │ │ │ │ ├── dm_head.cpython-36.pyc │ │ │ │ ├── dm_head.cpython-37.pyc │ │ │ │ ├── dm_head.cpython-38.pyc │ │ │ │ ├── dnl_head.cpython-36.pyc │ │ │ │ ├── dnl_head.cpython-37.pyc │ │ │ │ ├── dnl_head.cpython-38.pyc │ │ │ │ ├── ema_head.cpython-36.pyc │ │ │ │ ├── ema_head.cpython-37.pyc │ │ │ │ ├── ema_head.cpython-38.pyc │ │ │ │ ├── enc_head.cpython-36.pyc │ │ │ │ ├── enc_head.cpython-37.pyc │ │ │ │ ├── enc_head.cpython-38.pyc │ │ │ │ ├── fcn_head.cpython-36.pyc │ │ │ │ ├── fcn_head.cpython-37.pyc │ │ │ │ ├── fcn_head.cpython-38.pyc │ │ │ │ ├── fpn_head.cpython-36.pyc │ │ │ │ ├── fpn_head.cpython-37.pyc │ │ │ │ ├── fpn_head.cpython-38.pyc │ │ │ │ ├── gc_head.cpython-36.pyc │ │ │ │ ├── gc_head.cpython-37.pyc │ │ │ │ ├── gc_head.cpython-38.pyc │ │ │ │ ├── lraspp_head.cpython-36.pyc │ │ │ │ ├── lraspp_head.cpython-37.pyc │ │ │ │ ├── lraspp_head.cpython-38.pyc │ │ │ │ ├── nl_head.cpython-36.pyc │ │ │ │ ├── nl_head.cpython-37.pyc │ │ │ │ ├── nl_head.cpython-38.pyc │ │ │ │ ├── ocr_head.cpython-36.pyc │ │ │ │ ├── ocr_head.cpython-37.pyc │ │ │ │ ├── ocr_head.cpython-38.pyc │ │ │ │ ├── point_head.cpython-36.pyc │ │ │ │ ├── point_head.cpython-37.pyc │ │ │ │ ├── point_head.cpython-38.pyc │ │ │ │ ├── psa_head.cpython-36.pyc │ │ │ │ ├── psa_head.cpython-37.pyc │ │ │ │ ├── psa_head.cpython-38.pyc │ │ │ │ ├── psp_head.cpython-36.pyc │ │ │ │ ├── psp_head.cpython-37.pyc │ │ │ │ ├── psp_head.cpython-38.pyc │ │ │ │ ├── segformer_head.cpython-36.pyc │ │ │ │ ├── segformer_head.cpython-37.pyc │ │ │ │ ├── segformer_head.cpython-38.pyc │ │ │ │ ├── sep_aspp_head.cpython-36.pyc │ │ │ │ ├── sep_aspp_head.cpython-37.pyc │ │ │ │ ├── sep_aspp_head.cpython-38.pyc │ │ │ │ ├── sep_fcn_head.cpython-36.pyc │ │ │ │ ├── sep_fcn_head.cpython-37.pyc │ │ │ │ ├── sep_fcn_head.cpython-38.pyc │ │ │ │ ├── setr_up_head.cpython-36.pyc │ │ │ │ ├── setr_up_head.cpython-37.pyc │ │ │ │ ├── setr_up_head.cpython-38.pyc │ │ │ │ ├── uper_head.cpython-36.pyc │ │ │ │ ├── uper_head.cpython-37.pyc │ │ │ │ └── uper_head.cpython-38.pyc │ │ │ ├── ann_head.py │ │ │ ├── apc_head.py │ │ │ ├── aspp_head.py │ │ │ ├── cascade_decode_head.py │ │ │ ├── cc_head.py │ │ │ ├── da_head.py │ │ │ ├── decode_head.py │ │ │ ├── dm_head.py │ │ │ ├── dnl_head.py │ │ │ ├── ema_head.py │ │ │ ├── enc_head.py │ │ │ ├── fcn_head.py │ │ │ ├── fpn_head.py │ │ │ ├── gc_head.py │ │ │ ├── lraspp_head.py │ │ │ ├── nl_head.py │ │ │ ├── ocr_head.py │ │ │ ├── point_head.py │ │ │ ├── psa_head.py │ │ │ ├── psp_head.py │ │ │ ├── segformer_head.py │ │ │ ├── segformer_head.py.bak │ │ │ ├── sep_aspp_head.py │ │ │ ├── sep_fcn_head.py │ │ │ ├── setr_up_head.py │ │ │ └── uper_head.py │ │ ├── losses │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── accuracy.cpython-36.pyc │ │ │ │ ├── accuracy.cpython-37.pyc │ │ │ │ ├── accuracy.cpython-38.pyc │ │ │ │ ├── cross_entropy_loss.cpython-36.pyc │ │ │ │ ├── cross_entropy_loss.cpython-37.pyc │ │ │ │ ├── cross_entropy_loss.cpython-38.pyc │ │ │ │ ├── lovasz_loss.cpython-36.pyc │ │ │ │ ├── lovasz_loss.cpython-37.pyc │ │ │ │ ├── lovasz_loss.cpython-38.pyc │ │ │ │ ├── utils.cpython-36.pyc │ │ │ │ ├── utils.cpython-37.pyc │ │ │ │ └── utils.cpython-38.pyc │ │ │ ├── accuracy.py │ │ │ ├── cross_entropy_loss.py │ │ │ ├── lovasz_loss.py │ │ │ └── utils.py │ │ ├── necks │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── fpn.cpython-36.pyc │ │ │ │ ├── fpn.cpython-37.pyc │ │ │ │ └── fpn.cpython-38.pyc │ │ │ └── fpn.py │ │ ├── segmentors │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-36.pyc │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── base.cpython-36.pyc │ │ │ │ ├── base.cpython-37.pyc │ │ │ │ ├── base.cpython-38.pyc │ │ │ │ ├── cascade_encoder_decoder.cpython-36.pyc │ │ │ │ ├── cascade_encoder_decoder.cpython-37.pyc │ │ │ │ ├── cascade_encoder_decoder.cpython-38.pyc │ │ │ │ ├── encoder_decoder.cpython-36.pyc │ │ │ │ ├── encoder_decoder.cpython-37.pyc │ │ │ │ └── encoder_decoder.cpython-38.pyc │ │ │ ├── base.py │ │ │ ├── cascade_encoder_decoder.py │ │ │ └── encoder_decoder.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── inverted_residual.cpython-36.pyc │ │ │ ├── inverted_residual.cpython-37.pyc │ │ │ ├── inverted_residual.cpython-38.pyc │ │ │ ├── make_divisible.cpython-36.pyc │ │ │ ├── make_divisible.cpython-37.pyc │ │ │ ├── make_divisible.cpython-38.pyc │ │ │ ├── res_layer.cpython-36.pyc │ │ │ ├── res_layer.cpython-37.pyc │ │ │ ├── res_layer.cpython-38.pyc │ │ │ ├── se_layer.cpython-36.pyc │ │ │ ├── se_layer.cpython-37.pyc │ │ │ ├── se_layer.cpython-38.pyc │ │ │ ├── self_attention_block.cpython-36.pyc │ │ │ ├── self_attention_block.cpython-37.pyc │ │ │ ├── self_attention_block.cpython-38.pyc │ │ │ ├── up_conv_block.cpython-36.pyc │ │ │ ├── up_conv_block.cpython-37.pyc │ │ │ └── up_conv_block.cpython-38.pyc │ │ │ ├── drop.py │ │ │ ├── inverted_residual.py │ │ │ ├── make_divisible.py │ │ │ ├── norm.py │ │ │ ├── res_layer.py │ │ │ ├── se_layer.py │ │ │ ├── self_attention_block.py │ │ │ └── up_conv_block.py │ ├── ops │ │ ├── __init__.py │ │ ├── encoding.py │ │ └── wrappers.py │ ├── utils │ │ ├── __init__.py │ │ ├── collect_env.py │ │ └── logger.py │ └── version.py ├── requirements.txt ├── requirements │ ├── docs.txt │ ├── optional.txt │ ├── readthedocs.txt │ ├── runtime.txt │ └── tests.txt ├── scripts │ ├── eval_city_c.sh │ ├── fan_base_hybrid_city.sh │ ├── fan_large_hybrid_city.sh │ ├── fan_small_hybrid_city.sh │ └── fan_tiny_hybrid_city.sh ├── setup.py └── tools │ ├── dist_test.sh │ ├── dist_test_city_c.sh │ ├── dist_train.sh │ ├── gen_city_c.py │ ├── test.py │ ├── test_city_c.py │ └── train.py ├── train_token_labeler.py ├── utils ├── __init__.py ├── evaluation │ ├── __init__.py │ ├── convnext_utils.py │ ├── fan.py │ └── swin_utils.py ├── imagenet_a.py ├── imagenet_r.py ├── loss │ ├── __init__.py │ └── cross_entropy.py ├── mce_utils.py ├── scaler.py ├── teacher_data │ ├── __init__.py │ ├── clean_teacher_transforms_factory.py │ ├── dataset.py │ ├── dataset_factory.py │ ├── loader.py │ ├── mixup_clean_teacher.py │ ├── random_augment_clean_teacher.py │ ├── random_erasing_clean_teacher.py │ └── transforms.py ├── token_label_generation.py └── utils.py └── validate_ood.py /demo/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/demo/.gitkeep -------------------------------------------------------------------------------- /demo/STL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/demo/STL.png -------------------------------------------------------------------------------- /demo/Teaser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/demo/Teaser.png -------------------------------------------------------------------------------- /detection/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/detection/.DS_Store -------------------------------------------------------------------------------- /detection/README.md: -------------------------------------------------------------------------------- 1 | # Detection codebase for FAN models 2 | 3 | Our detection code is developed on top of [MMDetection v2.11.0](https://github.com/open-mmlab/mmdetection/tree/v2.11.0). 4 | 5 | 6 | ## Dependencies 7 | 8 | Install according to the guidelines in [MMDetection v2.11.0](https://github.com/open-mmlab/mmdetection/tree/v2.11.0). 9 | 10 | or 11 | 12 | ``` 13 | pip install mmdet==2.13.0 --user 14 | ``` 15 | 16 | Below is the environment configuration for our codebase: 17 | 18 | CUDA Version: 11.1 19 | 20 | Torchvision: 0.8.1 21 | 22 | Pytorch: 1.7.1 23 | 24 | mmcv-full: 1.3.0 25 | 26 | timm: 0.5.4 27 | 28 | 29 | ## Data preparation 30 | 31 | Prepare COCO according to the guidelines in [MMDetection v2.11.0](https://github.com/open-mmlab/mmdetection/tree/v2.13.0). 32 | 33 | 34 | ## Training 35 | To train FAN-T-Hybrid + Cascade MRCNN on COCO train2017 on 4 nodes with 32 gpus, run following commands on each node separately: 36 | 37 | ``` 38 | bash mn_train.sh configs/cascade_mask_fan_tiny_fpn_3x_mstrain_fp16.py 4 $local_rank "master node address" 39 | ``` 40 | 41 | To train FAN-T-Hybrid on a single node: 42 | ``` 43 | bash dist_train.sh configs/cascade_mask_fan_tiny_fpn_3x_mstrain_fp16.py 8 44 | ``` 45 | 46 | ## COCO-C Dataset Generation 47 | To generate COCO-C dataset: 48 | ``` 49 | python3 tools/gen_coco_c.py 50 | ``` 51 | 52 | 53 | ## Test robustness on COCO-C 54 | 55 | To test robustness on a single corruption type: 56 | ``` 57 | bash dist_test_coco_c.sh $CONFIG $CKP 8 gaussian_noise 1 --work-dir $WORKDIR 58 | ``` 59 | 60 | We also provide a script to test robustness over all corruption categories: 61 | ``` 62 | bash tools/coco_c_test_all.sh 63 | ``` 64 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/coco_detection.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CocoDataset' 3 | data_root = '../../COCO/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | train_pipeline = [ 7 | dict(type='LoadImageFromFile'), 8 | dict(type='LoadAnnotations', with_bbox=True), 9 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 10 | dict(type='RandomFlip', flip_ratio=0.5), 11 | dict(type='Normalize', **img_norm_cfg), 12 | dict(type='Pad', size_divisor=32), 13 | dict(type='DefaultFormatBundle'), 14 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), 15 | ] 16 | test_pipeline = [ 17 | dict(type='LoadImageFromFile'), 18 | dict( 19 | type='MultiScaleFlipAug', 20 | img_scale=(1333, 800), 21 | flip=False, 22 | transforms=[ 23 | dict(type='Resize', keep_ratio=True), 24 | dict(type='RandomFlip'), 25 | dict(type='Normalize', **img_norm_cfg), 26 | dict(type='Pad', size_divisor=32), 27 | dict(type='ImageToTensor', keys=['img']), 28 | dict(type='Collect', keys=['img']), 29 | ]) 30 | ] 31 | data = dict( 32 | samples_per_gpu=2, 33 | workers_per_gpu=2, 34 | train=dict( 35 | type=dataset_type, 36 | ann_file=data_root + 'annotations/instances_train2017.json', 37 | img_prefix=data_root + 'train2017/', 38 | pipeline=train_pipeline), 39 | val=dict( 40 | type=dataset_type, 41 | ann_file=data_root + 'annotations/instances_val2017.json', 42 | img_prefix=data_root + 'val2017/', 43 | pipeline=test_pipeline), 44 | test=dict( 45 | type=dataset_type, 46 | ann_file=data_root + 'annotations/instances_val2017.json', 47 | img_prefix=data_root + 'val2017/', 48 | pipeline=test_pipeline)) 49 | evaluation = dict(interval=1, metric='bbox') 50 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/coco_instance.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CocoDataset' 3 | data_root = '../../COCO/' 4 | # data_root = 'data/coco/' 5 | img_norm_cfg = dict( 6 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 7 | train_pipeline = [ 8 | dict(type='LoadImageFromFile'), 9 | dict(type='LoadAnnotations', with_bbox=True, with_mask=True), 10 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 11 | dict(type='RandomFlip', flip_ratio=0.5), 12 | dict(type='Normalize', **img_norm_cfg), 13 | dict(type='Pad', size_divisor=32), 14 | dict(type='DefaultFormatBundle'), 15 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), 16 | ] 17 | test_pipeline = [ 18 | dict(type='LoadImageFromFile'), 19 | dict( 20 | type='MultiScaleFlipAug', 21 | img_scale=(1333, 800), 22 | flip=False, 23 | transforms=[ 24 | dict(type='Resize', keep_ratio=True), 25 | dict(type='RandomFlip'), 26 | dict(type='Normalize', **img_norm_cfg), 27 | dict(type='Pad', size_divisor=32), 28 | dict(type='ImageToTensor', keys=['img']), 29 | dict(type='Collect', keys=['img']), 30 | ]) 31 | ] 32 | data = dict( 33 | samples_per_gpu=2, 34 | workers_per_gpu=2, 35 | train=dict( 36 | type=dataset_type, 37 | ann_file=data_root + 'annotations/instances_train2017.json', 38 | img_prefix=data_root + 'train2017/', 39 | pipeline=train_pipeline), 40 | val=dict( 41 | type=dataset_type, 42 | ann_file=data_root + 'annotations/instances_val2017.json', 43 | img_prefix=data_root + 'val2017/', 44 | pipeline=test_pipeline), 45 | test=dict( 46 | type=dataset_type, 47 | ann_file=data_root + 'annotations/instances_val2017.json', 48 | img_prefix=data_root + 'val2017/', 49 | pipeline=test_pipeline)) 50 | evaluation = dict(metric=['bbox', 'segm']) 51 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/coco_instance_semantic.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CocoDataset' 3 | data_root = 'data/coco/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | train_pipeline = [ 7 | dict(type='LoadImageFromFile'), 8 | dict( 9 | type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), 10 | dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), 11 | dict(type='RandomFlip', flip_ratio=0.5), 12 | dict(type='Normalize', **img_norm_cfg), 13 | dict(type='Pad', size_divisor=32), 14 | dict(type='SegRescale', scale_factor=1 / 8), 15 | dict(type='DefaultFormatBundle'), 16 | dict( 17 | type='Collect', 18 | keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks', 'gt_semantic_seg']), 19 | ] 20 | test_pipeline = [ 21 | dict(type='LoadImageFromFile'), 22 | dict( 23 | type='MultiScaleFlipAug', 24 | img_scale=(1333, 800), 25 | flip=False, 26 | transforms=[ 27 | dict(type='Resize', keep_ratio=True), 28 | dict(type='RandomFlip', flip_ratio=0.5), 29 | dict(type='Normalize', **img_norm_cfg), 30 | dict(type='Pad', size_divisor=32), 31 | dict(type='ImageToTensor', keys=['img']), 32 | dict(type='Collect', keys=['img']), 33 | ]) 34 | ] 35 | data = dict( 36 | samples_per_gpu=2, 37 | workers_per_gpu=2, 38 | train=dict( 39 | type=dataset_type, 40 | ann_file=data_root + 'annotations/instances_train2017.json', 41 | img_prefix=data_root + 'train2017/', 42 | seg_prefix=data_root + 'stuffthingmaps/train2017/', 43 | pipeline=train_pipeline), 44 | val=dict( 45 | type=dataset_type, 46 | ann_file=data_root + 'annotations/instances_val2017.json', 47 | img_prefix=data_root + 'val2017/', 48 | pipeline=test_pipeline), 49 | test=dict( 50 | type=dataset_type, 51 | ann_file=data_root + 'annotations/instances_val2017.json', 52 | img_prefix=data_root + 'val2017/', 53 | pipeline=test_pipeline)) 54 | evaluation = dict(metric=['bbox', 'segm']) 55 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/deepfashion.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'DeepFashionDataset' 3 | data_root = 'data/DeepFashion/In-shop/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | train_pipeline = [ 7 | dict(type='LoadImageFromFile'), 8 | dict(type='LoadAnnotations', with_bbox=True, with_mask=True), 9 | dict(type='Resize', img_scale=(750, 1101), keep_ratio=True), 10 | dict(type='RandomFlip', flip_ratio=0.5), 11 | dict(type='Normalize', **img_norm_cfg), 12 | dict(type='Pad', size_divisor=32), 13 | dict(type='DefaultFormatBundle'), 14 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']), 15 | ] 16 | test_pipeline = [ 17 | dict(type='LoadImageFromFile'), 18 | dict( 19 | type='MultiScaleFlipAug', 20 | img_scale=(750, 1101), 21 | flip=False, 22 | transforms=[ 23 | dict(type='Resize', keep_ratio=True), 24 | dict(type='RandomFlip'), 25 | dict(type='Normalize', **img_norm_cfg), 26 | dict(type='Pad', size_divisor=32), 27 | dict(type='ImageToTensor', keys=['img']), 28 | dict(type='Collect', keys=['img']), 29 | ]) 30 | ] 31 | data = dict( 32 | imgs_per_gpu=2, 33 | workers_per_gpu=1, 34 | train=dict( 35 | type=dataset_type, 36 | ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json', 37 | img_prefix=data_root + 'Img/', 38 | pipeline=train_pipeline, 39 | data_root=data_root), 40 | val=dict( 41 | type=dataset_type, 42 | ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json', 43 | img_prefix=data_root + 'Img/', 44 | pipeline=test_pipeline, 45 | data_root=data_root), 46 | test=dict( 47 | type=dataset_type, 48 | ann_file=data_root + 49 | 'annotations/DeepFashion_segmentation_gallery.json', 50 | img_prefix=data_root + 'Img/', 51 | pipeline=test_pipeline, 52 | data_root=data_root)) 53 | evaluation = dict(interval=5, metric=['bbox', 'segm']) 54 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/lvis_v0.5_instance.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | _base_ = 'coco_instance.py' 3 | dataset_type = 'LVISV05Dataset' 4 | data_root = 'data/lvis_v0.5/' 5 | data = dict( 6 | samples_per_gpu=2, 7 | workers_per_gpu=2, 8 | train=dict( 9 | _delete_=True, 10 | type='ClassBalancedDataset', 11 | oversample_thr=1e-3, 12 | dataset=dict( 13 | type=dataset_type, 14 | ann_file=data_root + 'annotations/lvis_v0.5_train.json', 15 | img_prefix=data_root + 'train2017/')), 16 | val=dict( 17 | type=dataset_type, 18 | ann_file=data_root + 'annotations/lvis_v0.5_val.json', 19 | img_prefix=data_root + 'val2017/'), 20 | test=dict( 21 | type=dataset_type, 22 | ann_file=data_root + 'annotations/lvis_v0.5_val.json', 23 | img_prefix=data_root + 'val2017/')) 24 | evaluation = dict(metric=['bbox', 'segm']) 25 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/lvis_v1_instance.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | _base_ = 'coco_instance.py' 3 | dataset_type = 'LVISV1Dataset' 4 | data_root = 'data/lvis_v1/' 5 | data = dict( 6 | samples_per_gpu=2, 7 | workers_per_gpu=2, 8 | train=dict( 9 | _delete_=True, 10 | type='ClassBalancedDataset', 11 | oversample_thr=1e-3, 12 | dataset=dict( 13 | type=dataset_type, 14 | ann_file=data_root + 'annotations/lvis_v1_train.json', 15 | img_prefix=data_root)), 16 | val=dict( 17 | type=dataset_type, 18 | ann_file=data_root + 'annotations/lvis_v1_val.json', 19 | img_prefix=data_root), 20 | test=dict( 21 | type=dataset_type, 22 | ann_file=data_root + 'annotations/lvis_v1_val.json', 23 | img_prefix=data_root)) 24 | evaluation = dict(metric=['bbox', 'segm']) 25 | -------------------------------------------------------------------------------- /detection/configs/_base_/datasets/voc0712.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'VOCDataset' 3 | data_root = 'data/VOCdevkit/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | train_pipeline = [ 7 | dict(type='LoadImageFromFile'), 8 | dict(type='LoadAnnotations', with_bbox=True), 9 | dict(type='Resize', img_scale=(1000, 600), keep_ratio=True), 10 | dict(type='RandomFlip', flip_ratio=0.5), 11 | dict(type='Normalize', **img_norm_cfg), 12 | dict(type='Pad', size_divisor=32), 13 | dict(type='DefaultFormatBundle'), 14 | dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), 15 | ] 16 | test_pipeline = [ 17 | dict(type='LoadImageFromFile'), 18 | dict( 19 | type='MultiScaleFlipAug', 20 | img_scale=(1000, 600), 21 | flip=False, 22 | transforms=[ 23 | dict(type='Resize', keep_ratio=True), 24 | dict(type='RandomFlip'), 25 | dict(type='Normalize', **img_norm_cfg), 26 | dict(type='Pad', size_divisor=32), 27 | dict(type='ImageToTensor', keys=['img']), 28 | dict(type='Collect', keys=['img']), 29 | ]) 30 | ] 31 | data = dict( 32 | samples_per_gpu=2, 33 | workers_per_gpu=2, 34 | train=dict( 35 | type='RepeatDataset', 36 | times=3, 37 | dataset=dict( 38 | type=dataset_type, 39 | ann_file=[ 40 | data_root + 'VOC2007/ImageSets/Main/trainval.txt', 41 | data_root + 'VOC2012/ImageSets/Main/trainval.txt' 42 | ], 43 | img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'], 44 | pipeline=train_pipeline)), 45 | val=dict( 46 | type=dataset_type, 47 | ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', 48 | img_prefix=data_root + 'VOC2007/', 49 | pipeline=test_pipeline), 50 | test=dict( 51 | type=dataset_type, 52 | ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt', 53 | img_prefix=data_root + 'VOC2007/', 54 | pipeline=test_pipeline)) 55 | evaluation = dict(interval=1, metric='mAP') 56 | -------------------------------------------------------------------------------- /detection/configs/_base_/default_runtime.py: -------------------------------------------------------------------------------- 1 | checkpoint_config = dict(interval=1) 2 | # yapf:disable 3 | log_config = dict( 4 | interval=50, 5 | hooks=[ 6 | dict(type='TextLoggerHook'), 7 | # dict(type='TensorboardLoggerHook') 8 | ]) 9 | # yapf:enable 10 | custom_hooks = [dict(type='NumClassCheckHook')] 11 | 12 | dist_params = dict(backend='nccl') 13 | log_level = 'INFO' 14 | load_from = None 15 | resume_from = None 16 | workflow = [('train', 1)] 17 | -------------------------------------------------------------------------------- /detection/configs/_base_/models/retinanet_r50_fpn.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | model = dict( 3 | type='RetinaNet', 4 | pretrained='torchvision://resnet50', 5 | backbone=dict( 6 | type='ResNet', 7 | depth=50, 8 | num_stages=4, 9 | out_indices=(0, 1, 2, 3), 10 | frozen_stages=1, 11 | norm_cfg=dict(type='BN', requires_grad=True), 12 | norm_eval=True, 13 | style='pytorch'), 14 | neck=dict( 15 | type='FPN', 16 | in_channels=[256, 512, 1024, 2048], 17 | out_channels=256, 18 | start_level=1, 19 | add_extra_convs='on_input', 20 | num_outs=5), 21 | bbox_head=dict( 22 | type='RetinaHead', 23 | num_classes=80, 24 | in_channels=256, 25 | stacked_convs=4, 26 | feat_channels=256, 27 | anchor_generator=dict( 28 | type='AnchorGenerator', 29 | octave_base_scale=4, 30 | scales_per_octave=3, 31 | ratios=[0.5, 1.0, 2.0], 32 | strides=[8, 16, 32, 64, 128]), 33 | bbox_coder=dict( 34 | type='DeltaXYWHBBoxCoder', 35 | target_means=[.0, .0, .0, .0], 36 | target_stds=[1.0, 1.0, 1.0, 1.0]), 37 | loss_cls=dict( 38 | type='FocalLoss', 39 | use_sigmoid=True, 40 | gamma=2.0, 41 | alpha=0.25, 42 | loss_weight=1.0), 43 | loss_bbox=dict(type='L1Loss', loss_weight=1.0)), 44 | # model training and testing settings 45 | train_cfg=dict( 46 | assigner=dict( 47 | type='MaxIoUAssigner', 48 | pos_iou_thr=0.5, 49 | neg_iou_thr=0.4, 50 | min_pos_iou=0, 51 | ignore_iof_thr=-1), 52 | allowed_border=-1, 53 | pos_weight=-1, 54 | debug=False), 55 | test_cfg=dict( 56 | nms_pre=1000, 57 | min_bbox_size=0, 58 | score_thr=0.05, 59 | nms=dict(type='nms', iou_threshold=0.5), 60 | max_per_img=100)) 61 | -------------------------------------------------------------------------------- /detection/configs/_base_/models/rpn_r50_caffe_c4.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | model = dict( 3 | type='RPN', 4 | pretrained='open-mmlab://detectron2/resnet50_caffe', 5 | backbone=dict( 6 | type='ResNet', 7 | depth=50, 8 | num_stages=3, 9 | strides=(1, 2, 2), 10 | dilations=(1, 1, 1), 11 | out_indices=(2, ), 12 | frozen_stages=1, 13 | norm_cfg=dict(type='BN', requires_grad=False), 14 | norm_eval=True, 15 | style='caffe'), 16 | neck=None, 17 | rpn_head=dict( 18 | type='RPNHead', 19 | in_channels=1024, 20 | feat_channels=1024, 21 | anchor_generator=dict( 22 | type='AnchorGenerator', 23 | scales=[2, 4, 8, 16, 32], 24 | ratios=[0.5, 1.0, 2.0], 25 | strides=[16]), 26 | bbox_coder=dict( 27 | type='DeltaXYWHBBoxCoder', 28 | target_means=[.0, .0, .0, .0], 29 | target_stds=[1.0, 1.0, 1.0, 1.0]), 30 | loss_cls=dict( 31 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0), 32 | loss_bbox=dict(type='L1Loss', loss_weight=1.0)), 33 | # model training and testing settings 34 | train_cfg=dict( 35 | rpn=dict( 36 | assigner=dict( 37 | type='MaxIoUAssigner', 38 | pos_iou_thr=0.7, 39 | neg_iou_thr=0.3, 40 | min_pos_iou=0.3, 41 | ignore_iof_thr=-1), 42 | sampler=dict( 43 | type='RandomSampler', 44 | num=256, 45 | pos_fraction=0.5, 46 | neg_pos_ub=-1, 47 | add_gt_as_proposals=False), 48 | allowed_border=0, 49 | pos_weight=-1, 50 | debug=False)), 51 | test_cfg=dict( 52 | rpn=dict( 53 | nms_pre=12000, 54 | max_per_img=2000, 55 | nms=dict(type='nms', iou_threshold=0.7), 56 | min_bbox_size=0))) 57 | -------------------------------------------------------------------------------- /detection/configs/_base_/models/rpn_r50_fpn.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | model = dict( 3 | type='RPN', 4 | pretrained='torchvision://resnet50', 5 | backbone=dict( 6 | type='ResNet', 7 | depth=50, 8 | num_stages=4, 9 | out_indices=(0, 1, 2, 3), 10 | frozen_stages=1, 11 | norm_cfg=dict(type='BN', requires_grad=True), 12 | norm_eval=True, 13 | style='pytorch'), 14 | neck=dict( 15 | type='FPN', 16 | in_channels=[256, 512, 1024, 2048], 17 | out_channels=256, 18 | num_outs=5), 19 | rpn_head=dict( 20 | type='RPNHead', 21 | in_channels=256, 22 | feat_channels=256, 23 | anchor_generator=dict( 24 | type='AnchorGenerator', 25 | scales=[8], 26 | ratios=[0.5, 1.0, 2.0], 27 | strides=[4, 8, 16, 32, 64]), 28 | bbox_coder=dict( 29 | type='DeltaXYWHBBoxCoder', 30 | target_means=[.0, .0, .0, .0], 31 | target_stds=[1.0, 1.0, 1.0, 1.0]), 32 | loss_cls=dict( 33 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0), 34 | loss_bbox=dict(type='L1Loss', loss_weight=1.0)), 35 | # model training and testing settings 36 | train_cfg=dict( 37 | rpn=dict( 38 | assigner=dict( 39 | type='MaxIoUAssigner', 40 | pos_iou_thr=0.7, 41 | neg_iou_thr=0.3, 42 | min_pos_iou=0.3, 43 | ignore_iof_thr=-1), 44 | sampler=dict( 45 | type='RandomSampler', 46 | num=256, 47 | pos_fraction=0.5, 48 | neg_pos_ub=-1, 49 | add_gt_as_proposals=False), 50 | allowed_border=0, 51 | pos_weight=-1, 52 | debug=False)), 53 | test_cfg=dict( 54 | rpn=dict( 55 | nms_pre=2000, 56 | max_per_img=1000, 57 | nms=dict(type='nms', iou_threshold=0.7), 58 | min_bbox_size=0))) 59 | -------------------------------------------------------------------------------- /detection/configs/_base_/models/ssd300.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | input_size = 300 3 | model = dict( 4 | type='SingleStageDetector', 5 | pretrained='open-mmlab://vgg16_caffe', 6 | backbone=dict( 7 | type='SSDVGG', 8 | input_size=input_size, 9 | depth=16, 10 | with_last_pool=False, 11 | ceil_mode=True, 12 | out_indices=(3, 4), 13 | out_feature_indices=(22, 34), 14 | l2_norm_scale=20), 15 | neck=None, 16 | bbox_head=dict( 17 | type='SSDHead', 18 | in_channels=(512, 1024, 512, 256, 256, 256), 19 | num_classes=80, 20 | anchor_generator=dict( 21 | type='SSDAnchorGenerator', 22 | scale_major=False, 23 | input_size=input_size, 24 | basesize_ratio_range=(0.15, 0.9), 25 | strides=[8, 16, 32, 64, 100, 300], 26 | ratios=[[2], [2, 3], [2, 3], [2, 3], [2], [2]]), 27 | bbox_coder=dict( 28 | type='DeltaXYWHBBoxCoder', 29 | target_means=[.0, .0, .0, .0], 30 | target_stds=[0.1, 0.1, 0.2, 0.2])), 31 | # model training and testing settings 32 | train_cfg=dict( 33 | assigner=dict( 34 | type='MaxIoUAssigner', 35 | pos_iou_thr=0.5, 36 | neg_iou_thr=0.5, 37 | min_pos_iou=0., 38 | ignore_iof_thr=-1, 39 | gt_max_assign_all=False), 40 | smoothl1_beta=1., 41 | allowed_border=-1, 42 | pos_weight=-1, 43 | neg_pos_ratio=3, 44 | debug=False), 45 | test_cfg=dict( 46 | nms_pre=1000, 47 | nms=dict(type='nms', iou_threshold=0.45), 48 | min_bbox_size=0, 49 | score_thr=0.02, 50 | max_per_img=200)) 51 | cudnn_benchmark = True 52 | -------------------------------------------------------------------------------- /detection/configs/_base_/schedules/schedule_1x.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) 3 | optimizer_config = dict(grad_clip=None) 4 | # learning policy 5 | lr_config = dict( 6 | policy='step', 7 | warmup='linear', 8 | warmup_iters=500, 9 | warmup_ratio=0.001, 10 | step=[8, 11]) 11 | runner = dict(type='EpochBasedRunner', max_epochs=12) 12 | -------------------------------------------------------------------------------- /detection/configs/_base_/schedules/schedule_20e.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) 3 | optimizer_config = dict(grad_clip=None) 4 | # learning policy 5 | lr_config = dict( 6 | policy='step', 7 | warmup='linear', 8 | warmup_iters=500, 9 | warmup_ratio=0.001, 10 | step=[16, 19]) 11 | runner = dict(type='EpochBasedRunner', max_epochs=20) 12 | -------------------------------------------------------------------------------- /detection/configs/_base_/schedules/schedule_2x.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) 3 | optimizer_config = dict(grad_clip=None) 4 | # learning policy 5 | lr_config = dict( 6 | policy='step', 7 | warmup='linear', 8 | warmup_iters=500, 9 | warmup_ratio=0.001, 10 | step=[16, 22]) 11 | runner = dict(type='EpochBasedRunner', max_epochs=24) 12 | -------------------------------------------------------------------------------- /detection/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | 9 | CONFIG=$1 10 | GPUS=$2 11 | PORT=${PORT:-29500} 12 | 13 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 14 | python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=66667 \ 15 | $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} 16 | -------------------------------------------------------------------------------- /detection/install.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | pip install mmdet==2.13.0 --user 8 | pip install -U timm --user 9 | -------------------------------------------------------------------------------- /detection/mmcv_custom/runner/optimizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Open-MMLab. All rights reserved. 2 | from mmcv.runner import OptimizerHook, HOOKS 3 | try: 4 | import apex 5 | except: 6 | print('apex is not installed') 7 | 8 | 9 | @HOOKS.register_module() 10 | class DistOptimizerHook(OptimizerHook): 11 | """Optimizer hook for distributed training.""" 12 | 13 | def __init__(self, update_interval=1, grad_clip=None, coalesce=True, bucket_size_mb=-1, use_fp16=False): 14 | self.grad_clip = grad_clip 15 | self.coalesce = coalesce 16 | self.bucket_size_mb = bucket_size_mb 17 | self.update_interval = update_interval 18 | self.use_fp16 = use_fp16 19 | 20 | def before_run(self, runner): 21 | runner.optimizer.zero_grad() 22 | 23 | def after_train_iter(self, runner): 24 | runner.outputs['loss'] /= self.update_interval 25 | if self.use_fp16: 26 | with apex.amp.scale_loss(runner.outputs['loss'], runner.optimizer) as scaled_loss: 27 | scaled_loss.backward() 28 | else: 29 | runner.outputs['loss'].backward() 30 | if self.every_n_iters(runner, self.update_interval): 31 | if self.grad_clip is not None: 32 | self.clip_grads(runner.model.parameters()) 33 | runner.optimizer.step() 34 | runner.optimizer.zero_grad() -------------------------------------------------------------------------------- /detection/mn_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | 9 | set -e 10 | set -x 11 | 12 | CONFIG=$1 13 | NODE_NUM=$2 14 | NODE_RANK=$3 15 | MASTER_ADDR=$4 16 | 17 | 18 | PORT=${PORT:-29500} 19 | 20 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 21 | python3 -m torch.distributed.launch --nproc_per_node=8 --master_port=$PORT \ 22 | --nnodes=$NODE_NUM --node_rank=$NODE_RANK --master_addr=$MASTER_ADDR \ 23 | $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:5} 24 | -------------------------------------------------------------------------------- /detection/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | from .fan import * 8 | -------------------------------------------------------------------------------- /detection/tools/dist_test_coco_c.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | set -e 9 | set -x 10 | 11 | CONFIG=$1 12 | CHECKPOINT=$2 13 | GPUS=$3 14 | CORRUPT=$4 15 | SEVERITY=$5 16 | PORT=${PORT:-29501} 17 | 18 | 19 | # corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise', 'speckle_noise', 20 | # 'defocus_blur', 'glass_blur', 'motion_blur', 'gaussian_blur', 21 | # 'snow', 'frost', 'fog', 'spatter', 22 | # 'brightness', 'contrast', 'saturate', 'jpeg_compression'] 23 | 24 | 25 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 26 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 27 | $(dirname "$0")/test_cocoC.py $CONFIG $CHECKPOINT \ 28 | --corrupt $CORRUPT --severity $SEVERITY \ 29 | --launcher pytorch --eval bbox segm ${@:6} 30 | -------------------------------------------------------------------------------- /detection/tools/gen_coco_c.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | import matplotlib.pyplot as plt 8 | import matplotlib.image as mpimg 9 | import numpy as np 10 | from imagecorruptions import corrupt 11 | from PIL import Image 12 | import seaborn as sns 13 | import random 14 | import cv2 15 | import os 16 | import mmcv 17 | from IPython import embed 18 | import argparse 19 | 20 | 21 | random.seed(8) # for reproducibility 22 | np.random.seed(8) 23 | 24 | corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', 25 | 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', 26 | 'brightness', 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression', 27 | 'speckle_noise', 'gaussian_blur', 'spatter', 'saturate', 'glass_blur'] 28 | 29 | 30 | def perturb(i, p, s): 31 | img = corrupt(i, corruption_name=p, severity=s) 32 | return img 33 | 34 | 35 | def convert_img_path(ori_path, suffix): 36 | new_path = ori_path.replace('clean', suffix) 37 | return new_path 38 | 39 | def main(): 40 | img_dir = './data/coco-c/clean' 41 | severity = [1, 2, 3, 4, 5] 42 | num_imgs = 5000 43 | for p in corruptions: 44 | print("\n ### gen corruption:{} ###".format(p)) 45 | prog_bar = mmcv.ProgressBar(num_imgs) 46 | for img_path in mmcv.scandir(img_dir, suffix='jpg', recursive=True): 47 | img_path = os.path.join(img_dir, img_path) 48 | img = mmcv.imread(img_path) 49 | prog_bar.update() 50 | for s in severity: 51 | perturbed_img = perturb(img, p, s) 52 | img_suffix = p+"_"+str(s) 53 | perturbed_img_path = convert_img_path(img_path, img_suffix) 54 | mmcv.imwrite(perturbed_img, perturbed_img_path, auto_mkdir=True) 55 | 56 | if __name__ == '__main__': 57 | main() 58 | -------------------------------------------------------------------------------- /models/__init__.py: -------------------------------------------------------------------------------- 1 | from .fan import * 2 | 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib==3.5.1 2 | matplotlib-inline==0.1.3 3 | mccabe==0.6.1 4 | mmcv-full==1.3.0 5 | mmdet==2.11.0 6 | mmpycocotools==12.0.3 7 | numpy==1.21.5 8 | onnx==1.11.0 9 | opencv-contrib-python-headless==4.2.0.32 10 | opencv-python==4.2.0.32 11 | opencv-python-headless==4.2.0.32 12 | Pillow==9.1.1 13 | scikit-image==0.19.2 14 | scikit-learn==1.0.2 15 | scipy==1.7.3 16 | six==1.16.0 17 | terminaltables==3.1.10 18 | threadpoolctl==3.1.0 19 | tifffile==2021.11.2 20 | timm==0.5.4 21 | torch==1.10.1 22 | torchaudio==0.10.1 23 | torchcontrib==0.0.2 24 | torchvision==0.11.2 25 | tqdm==4.64.0 26 | -------------------------------------------------------------------------------- /scripts/NGC/start_multi_node.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/STL/blob/master/LICENSE 6 | 7 | ngc batch run --instance dgx1v.32g.8.norm --result /results --name 'multi-node-model.fanV2_small_12_p4_hybrid_offline_self_training' --image "nvcr.io/nvidian/swaiinf/mypytorch:22.05-py3-fanv2" --org nvidian --team swaiinf --ace nv-us-west-2 --datasetid 103922:/dataset/imagenet_raw --datasetid 103923:/dataset/imagenet_raw_val --commandline "apt update; apt install tmux -y; cd ../FAN_V2/imagenet_tar/; mpirun --allow-run-as-root -x NCCL_IB_HCA=mlx5_4,mlx5_6,mlx5_8,mlx5_10 -np \${NGC_ARRAY_SIZE} -npernode 1 bash -c \"bash preprocess_dataset_to_raid.sh \"; sleep 167h" --workspace ul1-WvoGTd2002uZIwJ9oQ:/FAN_V2 --replicas 4 --total-runtime 167h --array-type MPI -p 8080 -p 8081 -p 8082 -p 8083 -p 8084 -p 8085 8 | -------------------------------------------------------------------------------- /scripts/NGC/start_single_node.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/STL/blob/master/LICENSE 6 | 7 | ngc batch run --instance dgx1v.32g.8.norm --result /results --name 'ml-model.fanV2_small_12_p4_hybrid_offline_self_training' --image "nvcr.io/nvidian/swaiinf/mypytorch:22.05-py3-fanv2" --org nvidian --team swaiinf --ace nv-us-west-2 --datasetid 103922:/dataset/imagenet_raw --datasetid 103923:/dataset/imagenet_raw_val --commandline "apt update; apt install tmux -y; cd ../FAN_V2/imagenet_tar/; bash -c \"bash preprocess_dataset_to_raid.sh \"; sleep 167h" --workspace ul1-WvoGTd2002uZIwJ9oQ:/FAN_V2 -p 8080 -p 8081 -p 8082 -p 8083 -p 8084 -p 8085 8 | -------------------------------------------------------------------------------- /scripts/fan_stl_student/fan_small_stl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | python3 -m torch.distributed.launch --nproc_per_node=8 main.py ../../raid/imagenet_raw/ --model fan_small_12_p4_hybrid_token -b 128 --sched cosine --epochs 350 --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 5 --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel --reprob 0.3 --lr 20e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 --drop-path .25 --img-size 224 --mixup 0.8 --cutmix 1.0 --smoothing 0.1 --output ../trained_models/fan_small_12_p4_hybrid_stl/ --amp --model-ema --token-label --cls-weight 1.0 --dense-weight 1.0 --offline-model ../trained_models/fan_small_12_p4_hybrid_token_labeler/train/20220817-162417-fan_small_12_p4_hybrid_token-224/model_best.pth.tar 10 | -------------------------------------------------------------------------------- /scripts/fan_stl_student/fan_tiny_stl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | python3 -m torch.distributed.launch --nproc_per_node=8 main.py ../../raid/imagenet_raw/ --model fan_tiny_8_p4_hybrid_token -b 128 --sched cosine --epochs 350 --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 5 --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel --reprob 0.3 --lr 20e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 --drop-path .05 --img-size 224 --mixup 0.8 --cutmix 1.0 --smoothing 0.1 --output ../trained_models/fan_tiny_8_p4_hybrid_stl/ --amp --model-ema --token-label --cls-weight 1.0 --dense-weight 1.0 --offline-model ../trained_models/fan_tiny_8_p4_hybrid_token_labeler/train/20230123-175642-fan_tiny_8_p4_hybrid_token-224/model_best.pth.tar 10 | -------------------------------------------------------------------------------- /scripts/fan_stl_student/mn_fan_base_stl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | set -e 10 | set -x 11 | export NCCL_LL_THRESHOLD=0 12 | 13 | 14 | rank_num=$1 15 | rank_index=$2 16 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 -m torch.distributed.launch --nproc_per_node=8 --nnodes=$rank_num \ 17 | --node_rank=$rank_index --master_addr="10.148.236.57" --master_port=3349 \ 18 | main.py ../../raid/imagenet_raw/ --model fan_base_16_p4_hybrid_token -b 64 --sched cosine --epochs 350 \ 19 | --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 10 \ 20 | --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel \ 21 | --reprob 0.3 --lr 40e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 \ 22 | --drop-path .35 --img-size 224 --mixup 0.8 --cutmix 1.0 \ 23 | --smoothing 0.1 \ 24 | --output ../trained_models/fan_base_16_p4_hybrid_stl/ \ 25 | --amp --model-ema \ 26 | --token-label --cls-weight 1.0 --dense-weight 1.0 \ 27 | --offline-model ../trained_models/fan_base_16_p4_hybrid_token_labeler/train/20220902-165215-fan_base_16_p4_hybrid_token-224/model_best.pth.tar \ 28 | -------------------------------------------------------------------------------- /scripts/fan_stl_student/mn_fan_large_stl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | set -e 10 | set -x 11 | export NCCL_LL_THRESHOLD=0 12 | 13 | 14 | rank_num=$1 15 | rank_index=$2 16 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 -m torch.distributed.launch --nproc_per_node=8 --nnodes=$rank_num \ 17 | --node_rank=$rank_index --master_addr="10.148.236.150" --master_port=3349 \ 18 | main.py ../../raid/imagenet_raw/ --model fan_large_16_p4_hybrid_token -b 64 --sched cosine --epochs 350 \ 19 | --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 10 \ 20 | --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel \ 21 | --reprob 0.3 --lr 40e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 \ 22 | --drop-path .45 --img-size 224 --mixup 0.8 --cutmix 1.0 \ 23 | --smoothing 0.1 \ 24 | --output ../trained_models/fan_large_16_p4_hybrid_stl/ \ 25 | --amp --model-ema \ 26 | --token-label --cls-weight 1.0 --dense-weight 1.0 \ 27 | --offline-model ../trained_models/fan_large_16_p4_hybrid_token_labeler/train/20221013-231810-fan_large_16_p4_hybrid_token-224/model_best.pth.tar \ 28 | -------------------------------------------------------------------------------- /scripts/fan_token_labeler/fan_small_tl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | python3 -m torch.distributed.launch --nproc_per_node=8 train_token_labeler.py ../../raid/imagenet_raw/ --model fan_small_12_p4_hybrid_token -b 128 --sched cosine --epochs 350 --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 5 --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel --reprob 0.3 --lr 20e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 --drop-path .25 --img-size 224 --mixup 0.8 --cutmix 1.0 --smoothing 0.1 --output ../trained_models/fan_small_12_p4_hybrid_token_labeler/ --amp --model-ema --token-label --cls-with-single-token-label 10 | -------------------------------------------------------------------------------- /scripts/fan_token_labeler/fan_tiny_tl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | python3 -m torch.distributed.launch --nproc_per_node=8 train_token_labeler.py ../../raid/imagenet_raw/ --model fan_tiny_8_p4_hybrid_token -b 128 --sched cosine --epochs 350 --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 5 --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel --reprob 0.3 --lr 20e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 --drop-path .05 --img-size 224 --mixup 0.8 --cutmix 1.0 --smoothing 0.1 --output ../trained_models/fan_tiny_8_p4_hybrid_token_labeler/ --amp --model-ema --token-label --cls-with-single-token-label 10 | -------------------------------------------------------------------------------- /scripts/fan_token_labeler/mn_fan_base_tl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | set -e 10 | set -x 11 | export NCCL_LL_THRESHOLD=0 12 | 13 | 14 | rank_num=$1 15 | rank_index=$2 16 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 -m torch.distributed.launch --nproc_per_node=8 --nnodes=$rank_num \ 17 | --node_rank=$rank_index --master_addr="10.148.237.38" --master_port=3349 \ 18 | train_token_labeler.py ../../raid/imagenet_raw/ --model fan_base_16_p4_hybrid_token -b 64 --sched cosine --epochs 350 \ 19 | --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 10 \ 20 | --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel \ 21 | --reprob 0.3 --lr 40e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 \ 22 | --drop-path .35 --img-size 224 --mixup 0.8 --cutmix 1.0 \ 23 | --smoothing 0.1 \ 24 | --output ../trained_models/fan_base_16_p4_hybrid_token_labeler/ \ 25 | --amp --model-ema \ 26 | --token-label --cls-with-single-token-label \ 27 | -------------------------------------------------------------------------------- /scripts/fan_token_labeler/mn_fan_large_tl.sh: -------------------------------------------------------------------------------- 1 | #!/user/bin/env bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | cd ../../ 9 | set -e 10 | set -x 11 | export NCCL_LL_THRESHOLD=0 12 | 13 | 14 | rank_num=$1 15 | rank_index=$2 16 | CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python3 -m torch.distributed.launch --nproc_per_node=8 --nnodes=$rank_num \ 17 | --node_rank=$rank_index --master_addr="10.148.236.108" --master_port=3349 \ 18 | train_token_labeler.py ../../raid/imagenet_raw/ --model fan_large_16_p4_hybrid_token -b 64 --sched cosine --epochs 350 \ 19 | --opt adamw -j 16 --warmup-lr 1e-6 --warmup-epochs 10 \ 20 | --model-ema-decay 0.99992 --aa rand-m9-mstd0.5-inc1 --remode pixel \ 21 | --reprob 0.3 --lr 40e-4 --min-lr 1e-6 --weight-decay .05 --drop 0.0 \ 22 | --drop-path .45 --img-size 224 --mixup 0.8 --cutmix 1.0 \ 23 | --smoothing 0.1 \ 24 | --output ../trained_models/fan_large_16_p4_hybrid_token_labeler/ \ 25 | --amp --model-ema \ 26 | --token-label --cls-with-single-token-label \ 27 | -------------------------------------------------------------------------------- /scripts/imagenet_a_val.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 9 | # 10 | # This work is made available under the Nvidia Source Code License-NC. 11 | # To view a copy of this license, visit 12 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 13 | 14 | model_name=$1 15 | ckpt=$2 16 | CUDA_VISIBLE_DEVICES=0 python3 ./validate_ood.py \ 17 | ../imagenet_a/ \ 18 | --model $model_name \ 19 | --img-size 224 \ 20 | -b 128 \ 21 | -j 32 \ 22 | --no-test-pool \ 23 | --imagenet_a \ 24 | --results-file ../debug/ \ 25 | --checkpoint $ckpt \ 26 | --imagenet_a 27 | -------------------------------------------------------------------------------- /scripts/imagenet_c_val.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 9 | # 10 | # This work is made available under the Nvidia Source Code License-NC. 11 | # To view a copy of this license, visit 12 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 13 | 14 | model_name=$1 15 | ckpt=$2 16 | CUDA_VISIBLE_DEVICES=0 python3 ./validate_ood.py \ 17 | ../imagenet_c/ \ 18 | --model $model_name \ 19 | --img-size 224 \ 20 | -b 128 \ 21 | -j 16 \ 22 | --amp \ 23 | --results-file ../output/ \ 24 | --checkpoint $ckpt \ 25 | --imagenet_c 26 | -------------------------------------------------------------------------------- /scripts/imagenet_r_val.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/STL/blob/master/LICENSE 7 | 8 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 9 | # 10 | # This work is made available under the Nvidia Source Code License-NC. 11 | # To view a copy of this license, visit 12 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 13 | 14 | model_name=$1 15 | ckpt=$2 16 | CUDA_VISIBLE_DEVICES=0 python3 ./validate_ood.py \ 17 | ../datasets/imagenet_r/imagenet-r/ \ 18 | --model $model_name \ 19 | --img-size 224 \ 20 | -b 256 \ 21 | -j 32 \ 22 | --imagenet_r \ 23 | --results-file ../debug/ \ 24 | --checkpoint $ckpt \ 25 | --use-ema \ 26 | --imagenet_r 27 | -------------------------------------------------------------------------------- /segmentation/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/.DS_Store -------------------------------------------------------------------------------- /segmentation/README.md: -------------------------------------------------------------------------------- 1 | # Segmentation codebase for FAN models 2 | 3 | Our segmentationcode is developed on top of [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0). 4 | 5 | 6 | ## Dependencies 7 | 8 | Install according to the guidelines in [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0). 9 | 10 | Below is the environment configuration for our codebase: 11 | 12 | CUDA Version: 11.1 13 | 14 | Pytorch: 1.7.1 15 | 16 | Torchvision: 0.8.1 17 | 18 | timm: 0.5.4 19 | 20 | The rest of the dependencies can be installed via: 21 | pip3 install -r requirements.txt 22 | 23 | 24 | ## Dataset preparation 25 | 26 | Prepare Cityscapes according to the guidelines in [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0). 27 | 28 | To generate Cityscapes-C dataset, first install the natural image corruption lib via: 29 | 30 | pip3 install imagecorruptions 31 | 32 | Then, run the following command: 33 | 34 | ``` 35 | python3 tools/gen_city_c.py 36 | ``` 37 | 38 | To evaluation the robustness on Cityscape-C: 39 | ``` 40 | ./tools/dist_test_city_c.sh /PATH/TO/CONFIG/FILE /PATH/TO/CHECKPOINT/FILE 1 --eval mIoU --results-file ../output/ 41 | ``` 42 | 43 | 44 | ## Training 45 | 46 | An example of running fan_hybrid_tiny model with SegFormer Head: 47 | ``` 48 | bash scripts/fan_tiny_hybrid_city.sh 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/datasets/ade20k.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'ADE20KDataset' 3 | data_root = 'data/ade/ADEChallengeData2016' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | crop_size = (576, 576) 7 | train_pipeline = [ 8 | dict(type='LoadImageFromFile'), 9 | dict(type='LoadAnnotations', reduce_zero_label=True), 10 | dict(type='Resize', img_scale=(2048, 576), ratio_range=(0.5, 2.0)), 11 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 12 | dict(type='RandomFlip', prob=0.5), 13 | dict(type='PhotoMetricDistortion'), 14 | dict(type='Normalize', **img_norm_cfg), 15 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 16 | dict(type='DefaultFormatBundle'), 17 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 18 | ] 19 | test_pipeline = [ 20 | dict(type='LoadImageFromFile'), 21 | dict( 22 | type='MultiScaleFlipAug', 23 | img_scale=(2048, 576), 24 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 25 | flip=False, 26 | transforms=[ 27 | dict(type='Resize', keep_ratio=True), 28 | dict(type='RandomFlip'), 29 | dict(type='Normalize', **img_norm_cfg), 30 | dict(type='ImageToTensor', keys=['img']), 31 | dict(type='Collect', keys=['img']), 32 | ]) 33 | ] 34 | data = dict( 35 | samples_per_gpu=4, 36 | workers_per_gpu=4, 37 | train=dict( 38 | type=dataset_type, 39 | data_root=data_root, 40 | img_dir='images/training', 41 | ann_dir='annotations/training', 42 | pipeline=train_pipeline), 43 | val=dict( 44 | type=dataset_type, 45 | data_root=data_root, 46 | img_dir='images/validation', 47 | ann_dir='annotations/validation', 48 | pipeline=test_pipeline), 49 | test=dict( 50 | type=dataset_type, 51 | data_root=data_root, 52 | img_dir='images/validation', 53 | ann_dir='annotations/validation', 54 | pipeline=test_pipeline)) 55 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/datasets/cityscapes.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CityscapesDataset' 3 | data_root = 'data/cityscapes/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | crop_size = (512, 1024) 7 | train_pipeline = [ 8 | dict(type='LoadImageFromFile'), 9 | dict(type='LoadAnnotations'), 10 | dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), 11 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 12 | dict(type='RandomFlip', prob=0.5), 13 | dict(type='PhotoMetricDistortion'), 14 | dict(type='Normalize', **img_norm_cfg), 15 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 16 | dict(type='DefaultFormatBundle'), 17 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 18 | ] 19 | test_pipeline = [ 20 | dict(type='LoadImageFromFile'), 21 | dict( 22 | type='MultiScaleFlipAug', 23 | img_scale=(2048, 1024), 24 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 25 | flip=False, 26 | transforms=[ 27 | dict(type='Resize', keep_ratio=True), 28 | dict(type='RandomFlip'), 29 | dict(type='Normalize', **img_norm_cfg), 30 | dict(type='ImageToTensor', keys=['img']), 31 | dict(type='Collect', keys=['img']), 32 | ]) 33 | ] 34 | data = dict( 35 | samples_per_gpu=2, 36 | workers_per_gpu=2, 37 | train=dict( 38 | type=dataset_type, 39 | data_root=data_root, 40 | img_dir='leftImg8bit/train', 41 | ann_dir='gtFine/train', 42 | pipeline=train_pipeline), 43 | val=dict( 44 | type=dataset_type, 45 | data_root=data_root, 46 | img_dir='leftImg8bit/val', 47 | ann_dir='gtFine/val', 48 | pipeline=test_pipeline), 49 | test=dict( 50 | type=dataset_type, 51 | data_root=data_root, 52 | img_dir='leftImg8bit/val', 53 | ann_dir='gtFine/val', 54 | pipeline=test_pipeline)) 55 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/datasets/cityscapes_1024x1024.py: -------------------------------------------------------------------------------- 1 | _base_ = './cityscapes.py' 2 | img_norm_cfg = dict( 3 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 4 | crop_size = (1024, 1024) 5 | train_pipeline = [ 6 | dict(type='LoadImageFromFile'), 7 | dict(type='LoadAnnotations'), 8 | dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), 9 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 10 | dict(type='RandomFlip', prob=0.5), 11 | dict(type='PhotoMetricDistortion'), 12 | dict(type='Normalize', **img_norm_cfg), 13 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 14 | dict(type='DefaultFormatBundle'), 15 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 16 | ] 17 | test_pipeline = [ 18 | dict(type='LoadImageFromFile'), 19 | dict( 20 | type='MultiScaleFlipAug', 21 | img_scale=(2048, 1024), 22 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 23 | flip=False, 24 | transforms=[ 25 | dict(type='Resize', keep_ratio=True), 26 | dict(type='RandomFlip'), 27 | dict(type='Normalize', **img_norm_cfg), 28 | dict(type='ImageToTensor', keys=['img']), 29 | dict(type='Collect', keys=['img']), 30 | ]) 31 | ] 32 | data = dict( 33 | train=dict(pipeline=train_pipeline), 34 | val=dict(pipeline=test_pipeline), 35 | test=dict(pipeline=test_pipeline)) 36 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/datasets/cityscapes_768x768_repeat.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CityscapesDataset' 3 | data_root = 'data/cityscapes/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | crop_size = (768, 768) 7 | train_pipeline = [ 8 | dict(type='LoadImageFromFile'), 9 | dict(type='LoadAnnotations'), 10 | dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), 11 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 12 | dict(type='RandomFlip', prob=0.5), 13 | dict(type='PhotoMetricDistortion'), 14 | dict(type='Normalize', **img_norm_cfg), 15 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 16 | dict(type='DefaultFormatBundle'), 17 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 18 | ] 19 | test_pipeline = [ 20 | dict(type='LoadImageFromFile'), 21 | dict( 22 | type='MultiScaleFlipAug', 23 | img_scale=(2048, 1024), 24 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 25 | flip=False, 26 | transforms=[ 27 | dict(type='Resize', keep_ratio=True), 28 | dict(type='RandomFlip'), 29 | dict(type='Normalize', **img_norm_cfg), 30 | dict(type='ImageToTensor', keys=['img']), 31 | dict(type='Collect', keys=['img']), 32 | ]) 33 | ] 34 | data = dict( 35 | samples_per_gpu=2, 36 | workers_per_gpu=2, 37 | train=dict( 38 | type='RepeatDataset', 39 | times=500, 40 | dataset=dict( 41 | type=dataset_type, 42 | data_root=data_root, 43 | img_dir='leftImg8bit/train', 44 | ann_dir='gtFine/train', 45 | pipeline=train_pipeline)), 46 | val=dict( 47 | type=dataset_type, 48 | data_root=data_root, 49 | img_dir='leftImg8bit/val', 50 | ann_dir='gtFine/val', 51 | pipeline=test_pipeline), 52 | test=dict( 53 | type=dataset_type, 54 | data_root=data_root, 55 | img_dir='leftImg8bit/val', 56 | ann_dir='gtFine/val', 57 | pipeline=test_pipeline)) 58 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/datasets/cityscapes_repeat.py: -------------------------------------------------------------------------------- 1 | # dataset settings 2 | dataset_type = 'CityscapesDataset' 3 | data_root = '../cityscapes/leftImg8bit_trainvaltest/' 4 | img_norm_cfg = dict( 5 | mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) 6 | crop_size = (512, 1024) 7 | train_pipeline = [ 8 | dict(type='LoadImageFromFile'), 9 | dict(type='LoadAnnotations'), 10 | dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), 11 | dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), 12 | dict(type='RandomFlip', prob=0.5), 13 | dict(type='PhotoMetricDistortion'), 14 | dict(type='Normalize', **img_norm_cfg), 15 | dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), 16 | dict(type='DefaultFormatBundle'), 17 | dict(type='Collect', keys=['img', 'gt_semantic_seg']), 18 | ] 19 | test_pipeline = [ 20 | dict(type='LoadImageFromFile'), 21 | dict( 22 | type='MultiScaleFlipAug', 23 | img_scale=(2048, 1024), 24 | # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], 25 | flip=False, 26 | transforms=[ 27 | dict(type='Resize', keep_ratio=True), 28 | dict(type='RandomFlip'), 29 | dict(type='Normalize', **img_norm_cfg), 30 | dict(type='ImageToTensor', keys=['img']), 31 | dict(type='Collect', keys=['img']), 32 | ]) 33 | ] 34 | data = dict( 35 | samples_per_gpu=2, 36 | workers_per_gpu=2, 37 | train=dict( 38 | type='RepeatDataset', 39 | times=300, 40 | dataset=dict( 41 | type=dataset_type, 42 | data_root=data_root, 43 | img_dir='leftImg8bit/train', 44 | ann_dir='gtFine/train', 45 | pipeline=train_pipeline)), 46 | val=dict( 47 | type=dataset_type, 48 | data_root=data_root, 49 | img_dir='leftImg8bit/val', 50 | ann_dir='gtFine/val', 51 | pipeline=test_pipeline), 52 | test=dict( 53 | type=dataset_type, 54 | data_root=data_root, 55 | img_dir='leftImg8bit/val', 56 | ann_dir='gtFine/val', 57 | pipeline=test_pipeline)) 58 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/default_runtime.py: -------------------------------------------------------------------------------- 1 | # yapf:disable 2 | log_config = dict( 3 | interval=50, 4 | hooks=[ 5 | dict(type='TextLoggerHook', by_epoch=False), 6 | # dict(type='TensorboardLoggerHook') 7 | ]) 8 | # yapf:enable 9 | dist_params = dict(backend='nccl') 10 | log_level = 'INFO' 11 | load_from = None 12 | resume_from = None 13 | workflow = [('train', 1)] 14 | cudnn_benchmark = True 15 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/ann_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='ANNHead', 19 | in_channels=[1024, 2048], 20 | in_index=[2, 3], 21 | channels=512, 22 | project_channels=256, 23 | query_scales=(1, ), 24 | key_pool_scales=(1, 3, 6, 8), 25 | dropout_ratio=0.1, 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 31 | auxiliary_head=dict( 32 | type='FCNHead', 33 | in_channels=1024, 34 | in_index=2, 35 | channels=256, 36 | num_convs=1, 37 | concat_input=False, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 44 | # model training and testing settings 45 | train_cfg=dict(), 46 | test_cfg=dict(mode='whole')) 47 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/apcnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='APCHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pool_scales=(1, 2, 3, 6), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=dict(type='SyncBN', requires_grad=True), 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/ccnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='CCHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | recurrence=2, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/cgnet.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', eps=1e-03, requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='CGNet', 7 | norm_cfg=norm_cfg, 8 | in_channels=3, 9 | num_channels=(32, 64, 128), 10 | num_blocks=(3, 21), 11 | dilations=(2, 4), 12 | reductions=(8, 16)), 13 | decode_head=dict( 14 | type='FCNHead', 15 | in_channels=256, 16 | in_index=2, 17 | channels=256, 18 | num_convs=0, 19 | concat_input=False, 20 | dropout_ratio=0, 21 | num_classes=19, 22 | norm_cfg=norm_cfg, 23 | loss_decode=dict( 24 | type='CrossEntropyLoss', 25 | use_sigmoid=False, 26 | loss_weight=1.0, 27 | class_weight=[ 28 | 2.5959933, 6.7415504, 3.5354059, 9.8663225, 9.690899, 9.369352, 29 | 10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905, 30 | 10.347791, 6.3927646, 10.226669, 10.241062, 10.280587, 31 | 10.396974, 10.055647 32 | ])), 33 | # model training and testing settings 34 | train_cfg=dict(sampler=None), 35 | test_cfg=dict(mode='whole')) 36 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/danet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DAHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pam_channels=64, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/deeplabv3_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='ASPPHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | dilations=(1, 12, 24, 36), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/deeplabv3_unet_s5-d16.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained=None, 6 | backbone=dict( 7 | type='UNet', 8 | in_channels=3, 9 | base_channels=64, 10 | num_stages=5, 11 | strides=(1, 1, 1, 1, 1), 12 | enc_num_convs=(2, 2, 2, 2, 2), 13 | dec_num_convs=(2, 2, 2, 2), 14 | downsamples=(True, True, True, True), 15 | enc_dilations=(1, 1, 1, 1, 1), 16 | dec_dilations=(1, 1, 1, 1), 17 | with_cp=False, 18 | conv_cfg=None, 19 | norm_cfg=norm_cfg, 20 | act_cfg=dict(type='ReLU'), 21 | upsample_cfg=dict(type='InterpConv'), 22 | norm_eval=False), 23 | decode_head=dict( 24 | type='ASPPHead', 25 | in_channels=64, 26 | in_index=4, 27 | channels=16, 28 | dilations=(1, 12, 24, 36), 29 | dropout_ratio=0.1, 30 | num_classes=2, 31 | norm_cfg=norm_cfg, 32 | align_corners=False, 33 | loss_decode=dict( 34 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 35 | auxiliary_head=dict( 36 | type='FCNHead', 37 | in_channels=128, 38 | in_index=3, 39 | channels=64, 40 | num_convs=1, 41 | concat_input=False, 42 | dropout_ratio=0.1, 43 | num_classes=2, 44 | norm_cfg=norm_cfg, 45 | align_corners=False, 46 | loss_decode=dict( 47 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 48 | # model training and testing settings 49 | train_cfg=dict(), 50 | test_cfg=dict(mode='slide', crop_size=256, stride=170)) 51 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/deeplabv3plus_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DepthwiseSeparableASPPHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | dilations=(1, 12, 24, 36), 23 | c1_in_channels=256, 24 | c1_channels=48, 25 | dropout_ratio=0.1, 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 31 | auxiliary_head=dict( 32 | type='FCNHead', 33 | in_channels=1024, 34 | in_index=2, 35 | channels=256, 36 | num_convs=1, 37 | concat_input=False, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 44 | # model training and testing settings 45 | train_cfg=dict(), 46 | test_cfg=dict(mode='whole')) 47 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/dmnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DMHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | filter_sizes=(1, 3, 5, 7), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=dict(type='SyncBN', requires_grad=True), 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/dnl_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='DNLHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | dropout_ratio=0.1, 23 | reduction=2, 24 | use_scale=True, 25 | mode='embedded_gaussian', 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 31 | auxiliary_head=dict( 32 | type='FCNHead', 33 | in_channels=1024, 34 | in_index=2, 35 | channels=256, 36 | num_convs=1, 37 | concat_input=False, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 44 | # model training and testing settings 45 | train_cfg=dict(), 46 | test_cfg=dict(mode='whole')) 47 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/emanet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='EMAHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=256, 22 | ema_channels=512, 23 | num_bases=64, 24 | num_stages=3, 25 | momentum=0.1, 26 | dropout_ratio=0.1, 27 | num_classes=19, 28 | norm_cfg=norm_cfg, 29 | align_corners=False, 30 | loss_decode=dict( 31 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 32 | auxiliary_head=dict( 33 | type='FCNHead', 34 | in_channels=1024, 35 | in_index=2, 36 | channels=256, 37 | num_convs=1, 38 | concat_input=False, 39 | dropout_ratio=0.1, 40 | num_classes=19, 41 | norm_cfg=norm_cfg, 42 | align_corners=False, 43 | loss_decode=dict( 44 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 45 | # model training and testing settings 46 | train_cfg=dict(), 47 | test_cfg=dict(mode='whole')) 48 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/encnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='EncHead', 19 | in_channels=[512, 1024, 2048], 20 | in_index=(1, 2, 3), 21 | channels=512, 22 | num_codes=32, 23 | use_se_loss=True, 24 | add_lateral=False, 25 | dropout_ratio=0.1, 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), 31 | loss_se_decode=dict( 32 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), 33 | auxiliary_head=dict( 34 | type='FCNHead', 35 | in_channels=1024, 36 | in_index=2, 37 | channels=256, 38 | num_convs=1, 39 | concat_input=False, 40 | dropout_ratio=0.1, 41 | num_classes=19, 42 | norm_cfg=norm_cfg, 43 | align_corners=False, 44 | loss_decode=dict( 45 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 46 | # model training and testing settings 47 | train_cfg=dict(), 48 | test_cfg=dict(mode='whole')) 49 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/fast_scnn.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True, momentum=0.01) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='FastSCNN', 7 | downsample_dw_channels=(32, 48), 8 | global_in_channels=64, 9 | global_block_channels=(64, 96, 128), 10 | global_block_strides=(2, 2, 1), 11 | global_out_channels=128, 12 | higher_in_channels=64, 13 | lower_in_channels=128, 14 | fusion_out_channels=128, 15 | out_indices=(0, 1, 2), 16 | norm_cfg=norm_cfg, 17 | align_corners=False), 18 | decode_head=dict( 19 | type='DepthwiseSeparableFCNHead', 20 | in_channels=128, 21 | channels=128, 22 | concat_input=False, 23 | num_classes=19, 24 | in_index=-1, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.4)), 29 | auxiliary_head=[ 30 | dict( 31 | type='FCNHead', 32 | in_channels=128, 33 | channels=32, 34 | num_convs=1, 35 | num_classes=19, 36 | in_index=-2, 37 | norm_cfg=norm_cfg, 38 | concat_input=False, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.4)), 42 | dict( 43 | type='FCNHead', 44 | in_channels=64, 45 | channels=32, 46 | num_convs=1, 47 | num_classes=19, 48 | in_index=-3, 49 | norm_cfg=norm_cfg, 50 | concat_input=False, 51 | align_corners=False, 52 | loss_decode=dict( 53 | type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.4)), 54 | ], 55 | # model training and testing settings 56 | train_cfg=dict(), 57 | test_cfg=dict(mode='whole')) 58 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/fcn_hr18.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://msra/hrnetv2_w18', 6 | backbone=dict( 7 | type='HRNet', 8 | norm_cfg=norm_cfg, 9 | norm_eval=False, 10 | extra=dict( 11 | stage1=dict( 12 | num_modules=1, 13 | num_branches=1, 14 | block='BOTTLENECK', 15 | num_blocks=(4, ), 16 | num_channels=(64, )), 17 | stage2=dict( 18 | num_modules=1, 19 | num_branches=2, 20 | block='BASIC', 21 | num_blocks=(4, 4), 22 | num_channels=(18, 36)), 23 | stage3=dict( 24 | num_modules=4, 25 | num_branches=3, 26 | block='BASIC', 27 | num_blocks=(4, 4, 4), 28 | num_channels=(18, 36, 72)), 29 | stage4=dict( 30 | num_modules=3, 31 | num_branches=4, 32 | block='BASIC', 33 | num_blocks=(4, 4, 4, 4), 34 | num_channels=(18, 36, 72, 144)))), 35 | decode_head=dict( 36 | type='FCNHead', 37 | in_channels=[18, 36, 72, 144], 38 | in_index=(0, 1, 2, 3), 39 | channels=sum([18, 36, 72, 144]), 40 | input_transform='resize_concat', 41 | kernel_size=1, 42 | num_convs=1, 43 | concat_input=False, 44 | dropout_ratio=-1, 45 | num_classes=19, 46 | norm_cfg=norm_cfg, 47 | align_corners=False, 48 | loss_decode=dict( 49 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 50 | # model training and testing settings 51 | train_cfg=dict(), 52 | test_cfg=dict(mode='whole')) 53 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/fcn_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='FCNHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | num_convs=2, 23 | concat_input=True, 24 | dropout_ratio=0.1, 25 | num_classes=19, 26 | norm_cfg=norm_cfg, 27 | align_corners=False, 28 | loss_decode=dict( 29 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 30 | auxiliary_head=dict( 31 | type='FCNHead', 32 | in_channels=1024, 33 | in_index=2, 34 | channels=256, 35 | num_convs=1, 36 | concat_input=False, 37 | dropout_ratio=0.1, 38 | num_classes=19, 39 | norm_cfg=norm_cfg, 40 | align_corners=False, 41 | loss_decode=dict( 42 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 43 | # model training and testing settings 44 | train_cfg=dict(), 45 | test_cfg=dict(mode='whole')) 46 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/fcn_unet_s5-d16.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained=None, 6 | backbone=dict( 7 | type='UNet', 8 | in_channels=3, 9 | base_channels=64, 10 | num_stages=5, 11 | strides=(1, 1, 1, 1, 1), 12 | enc_num_convs=(2, 2, 2, 2, 2), 13 | dec_num_convs=(2, 2, 2, 2), 14 | downsamples=(True, True, True, True), 15 | enc_dilations=(1, 1, 1, 1, 1), 16 | dec_dilations=(1, 1, 1, 1), 17 | with_cp=False, 18 | conv_cfg=None, 19 | norm_cfg=norm_cfg, 20 | act_cfg=dict(type='ReLU'), 21 | upsample_cfg=dict(type='InterpConv'), 22 | norm_eval=False), 23 | decode_head=dict( 24 | type='FCNHead', 25 | in_channels=64, 26 | in_index=4, 27 | channels=64, 28 | num_convs=1, 29 | concat_input=False, 30 | dropout_ratio=0.1, 31 | num_classes=2, 32 | norm_cfg=norm_cfg, 33 | align_corners=False, 34 | loss_decode=dict( 35 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 36 | auxiliary_head=dict( 37 | type='FCNHead', 38 | in_channels=128, 39 | in_index=3, 40 | channels=64, 41 | num_convs=1, 42 | concat_input=False, 43 | dropout_ratio=0.1, 44 | num_classes=2, 45 | norm_cfg=norm_cfg, 46 | align_corners=False, 47 | loss_decode=dict( 48 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 49 | # model training and testing settings 50 | train_cfg=dict(), 51 | test_cfg=dict(mode='slide', crop_size=256, stride=170)) 52 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/fpn_r50.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 1, 1), 12 | strides=(1, 2, 2, 2), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | neck=dict( 18 | type='FPN', 19 | in_channels=[256, 512, 1024, 2048], 20 | out_channels=256, 21 | num_outs=4), 22 | decode_head=dict( 23 | type='FPNHead', 24 | in_channels=[256, 256, 256, 256], 25 | in_index=[0, 1, 2, 3], 26 | feature_strides=[4, 8, 16, 32], 27 | channels=128, 28 | dropout_ratio=0.1, 29 | num_classes=19, 30 | norm_cfg=norm_cfg, 31 | align_corners=False, 32 | loss_decode=dict( 33 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 34 | # model training and testing settings 35 | train_cfg=dict(), 36 | test_cfg=dict(mode='whole')) 37 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/gcnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='GCHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | ratio=1 / 4., 23 | pooling_type='att', 24 | fusion_types=('channel_add', ), 25 | dropout_ratio=0.1, 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 31 | auxiliary_head=dict( 32 | type='FCNHead', 33 | in_channels=1024, 34 | in_index=2, 35 | channels=256, 36 | num_convs=1, 37 | concat_input=False, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 44 | # model training and testing settings 45 | train_cfg=dict(), 46 | test_cfg=dict(mode='whole')) 47 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/lraspp_m-v3-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', eps=0.001, requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | backbone=dict( 6 | type='MobileNetV3', 7 | arch='large', 8 | out_indices=(1, 3, 16), 9 | norm_cfg=norm_cfg), 10 | decode_head=dict( 11 | type='LRASPPHead', 12 | in_channels=(16, 24, 960), 13 | in_index=(0, 1, 2), 14 | channels=128, 15 | input_transform='multiple_select', 16 | dropout_ratio=0.1, 17 | num_classes=19, 18 | norm_cfg=norm_cfg, 19 | act_cfg=dict(type='ReLU'), 20 | align_corners=False, 21 | loss_decode=dict( 22 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 23 | # model training and testing settings 24 | train_cfg=dict(), 25 | test_cfg=dict(mode='whole')) 26 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/nonlocal_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='NLHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | dropout_ratio=0.1, 23 | reduction=2, 24 | use_scale=True, 25 | mode='embedded_gaussian', 26 | num_classes=19, 27 | norm_cfg=norm_cfg, 28 | align_corners=False, 29 | loss_decode=dict( 30 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 31 | auxiliary_head=dict( 32 | type='FCNHead', 33 | in_channels=1024, 34 | in_index=2, 35 | channels=256, 36 | num_convs=1, 37 | concat_input=False, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 44 | # model training and testing settings 45 | train_cfg=dict(), 46 | test_cfg=dict(mode='whole')) 47 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/ocrnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='CascadeEncoderDecoder', 5 | num_stages=2, 6 | pretrained='open-mmlab://resnet50_v1c', 7 | backbone=dict( 8 | type='ResNetV1c', 9 | depth=50, 10 | num_stages=4, 11 | out_indices=(0, 1, 2, 3), 12 | dilations=(1, 1, 2, 4), 13 | strides=(1, 2, 1, 1), 14 | norm_cfg=norm_cfg, 15 | norm_eval=False, 16 | style='pytorch', 17 | contract_dilation=True), 18 | decode_head=[ 19 | dict( 20 | type='FCNHead', 21 | in_channels=1024, 22 | in_index=2, 23 | channels=256, 24 | num_convs=1, 25 | concat_input=False, 26 | dropout_ratio=0.1, 27 | num_classes=19, 28 | norm_cfg=norm_cfg, 29 | align_corners=False, 30 | loss_decode=dict( 31 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 32 | dict( 33 | type='OCRHead', 34 | in_channels=2048, 35 | in_index=3, 36 | channels=512, 37 | ocr_channels=256, 38 | dropout_ratio=0.1, 39 | num_classes=19, 40 | norm_cfg=norm_cfg, 41 | align_corners=False, 42 | loss_decode=dict( 43 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)) 44 | ], 45 | # model training and testing settings 46 | train_cfg=dict(), 47 | test_cfg=dict(mode='whole')) 48 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/pointrend_r50.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='CascadeEncoderDecoder', 5 | num_stages=2, 6 | pretrained='open-mmlab://resnet50_v1c', 7 | backbone=dict( 8 | type='ResNetV1c', 9 | depth=50, 10 | num_stages=4, 11 | out_indices=(0, 1, 2, 3), 12 | dilations=(1, 1, 1, 1), 13 | strides=(1, 2, 2, 2), 14 | norm_cfg=norm_cfg, 15 | norm_eval=False, 16 | style='pytorch', 17 | contract_dilation=True), 18 | neck=dict( 19 | type='FPN', 20 | in_channels=[256, 512, 1024, 2048], 21 | out_channels=256, 22 | num_outs=4), 23 | decode_head=[ 24 | dict( 25 | type='FPNHead', 26 | in_channels=[256, 256, 256, 256], 27 | in_index=[0, 1, 2, 3], 28 | feature_strides=[4, 8, 16, 32], 29 | channels=128, 30 | dropout_ratio=-1, 31 | num_classes=19, 32 | norm_cfg=norm_cfg, 33 | align_corners=False, 34 | loss_decode=dict( 35 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 36 | dict( 37 | type='PointHead', 38 | in_channels=[256], 39 | in_index=[0], 40 | channels=256, 41 | num_fcs=3, 42 | coarse_pred_each_layer=True, 43 | dropout_ratio=-1, 44 | num_classes=19, 45 | align_corners=False, 46 | loss_decode=dict( 47 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)) 48 | ], 49 | # model training and testing settings 50 | train_cfg=dict( 51 | num_points=2048, oversample_ratio=3, importance_sample_ratio=0.75), 52 | test_cfg=dict( 53 | mode='whole', 54 | subdivision_steps=2, 55 | subdivision_num_points=8196, 56 | scale_factor=2)) 57 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/psanet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='PSAHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | mask_size=(97, 97), 23 | psa_type='bi-direction', 24 | compact=False, 25 | shrink_factor=2, 26 | normalization_factor=1.0, 27 | psa_softmax=True, 28 | dropout_ratio=0.1, 29 | num_classes=19, 30 | norm_cfg=norm_cfg, 31 | align_corners=False, 32 | loss_decode=dict( 33 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 34 | auxiliary_head=dict( 35 | type='FCNHead', 36 | in_channels=1024, 37 | in_index=2, 38 | channels=256, 39 | num_convs=1, 40 | concat_input=False, 41 | dropout_ratio=0.1, 42 | num_classes=19, 43 | norm_cfg=norm_cfg, 44 | align_corners=False, 45 | loss_decode=dict( 46 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 47 | # model training and testing settings 48 | train_cfg=dict(), 49 | test_cfg=dict(mode='whole')) 50 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/pspnet_r50-d8.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 2, 4), 12 | strides=(1, 2, 1, 1), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='PSPHead', 19 | in_channels=2048, 20 | in_index=3, 21 | channels=512, 22 | pool_scales=(1, 2, 3, 6), 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/pspnet_unet_s5-d16.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained=None, 6 | backbone=dict( 7 | type='UNet', 8 | in_channels=3, 9 | base_channels=64, 10 | num_stages=5, 11 | strides=(1, 1, 1, 1, 1), 12 | enc_num_convs=(2, 2, 2, 2, 2), 13 | dec_num_convs=(2, 2, 2, 2), 14 | downsamples=(True, True, True, True), 15 | enc_dilations=(1, 1, 1, 1, 1), 16 | dec_dilations=(1, 1, 1, 1), 17 | with_cp=False, 18 | conv_cfg=None, 19 | norm_cfg=norm_cfg, 20 | act_cfg=dict(type='ReLU'), 21 | upsample_cfg=dict(type='InterpConv'), 22 | norm_eval=False), 23 | decode_head=dict( 24 | type='PSPHead', 25 | in_channels=64, 26 | in_index=4, 27 | channels=16, 28 | pool_scales=(1, 2, 3, 6), 29 | dropout_ratio=0.1, 30 | num_classes=2, 31 | norm_cfg=norm_cfg, 32 | align_corners=False, 33 | loss_decode=dict( 34 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 35 | auxiliary_head=dict( 36 | type='FCNHead', 37 | in_channels=128, 38 | in_index=3, 39 | channels=64, 40 | num_convs=1, 41 | concat_input=False, 42 | dropout_ratio=0.1, 43 | num_classes=2, 44 | norm_cfg=norm_cfg, 45 | align_corners=False, 46 | loss_decode=dict( 47 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 48 | # model training and testing settings 49 | train_cfg=dict(), 50 | test_cfg=dict(mode='slide', crop_size=256, stride=170)) 51 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/segformer.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | find_unused_parameters = True 4 | model = dict( 5 | type='EncoderDecoder', 6 | pretrained=None, 7 | backbone=dict( 8 | type='mit_b2', 9 | # type='IMTRv21_5', 10 | style='pytorch'), 11 | decode_head=dict( 12 | type='SegFormerHead', 13 | in_channels=[64, 128, 320, 512], 14 | in_index=[0, 1, 2, 3], 15 | feature_strides=[4, 8, 16, 32], 16 | channels=128, 17 | dropout_ratio=0.1, 18 | num_classes=19, 19 | norm_cfg=norm_cfg, 20 | align_corners=False, 21 | decoder_params=dict(), 22 | loss_decode=dict(type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 23 | # model training and testing settings 24 | train_cfg=dict(), 25 | test_cfg=dict(mode='whole')) 26 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/models/upernet_r50.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | norm_cfg = dict(type='SyncBN', requires_grad=True) 3 | model = dict( 4 | type='EncoderDecoder', 5 | pretrained='open-mmlab://resnet50_v1c', 6 | backbone=dict( 7 | type='ResNetV1c', 8 | depth=50, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | dilations=(1, 1, 1, 1), 12 | strides=(1, 2, 2, 2), 13 | norm_cfg=norm_cfg, 14 | norm_eval=False, 15 | style='pytorch', 16 | contract_dilation=True), 17 | decode_head=dict( 18 | type='UPerHead', 19 | in_channels=[256, 512, 1024, 2048], 20 | in_index=[0, 1, 2, 3], 21 | pool_scales=(1, 2, 3, 6), 22 | channels=512, 23 | dropout_ratio=0.1, 24 | num_classes=19, 25 | norm_cfg=norm_cfg, 26 | align_corners=False, 27 | loss_decode=dict( 28 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), 29 | auxiliary_head=dict( 30 | type='FCNHead', 31 | in_channels=1024, 32 | in_index=2, 33 | channels=256, 34 | num_convs=1, 35 | concat_input=False, 36 | dropout_ratio=0.1, 37 | num_classes=19, 38 | norm_cfg=norm_cfg, 39 | align_corners=False, 40 | loss_decode=dict( 41 | type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), 42 | # model training and testing settings 43 | train_cfg=dict(), 44 | test_cfg=dict(mode='whole')) 45 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_160k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=160000) 8 | checkpoint_config = dict(by_epoch=False, interval=16000) 9 | evaluation = dict(interval=16000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_160k_8gpu_adamw.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='AdamW', lr=0.02/100, weight_decay=0.0001) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=0.0, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=160000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_20k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=20000) 8 | checkpoint_config = dict(by_epoch=False, interval=2000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_320k_8gpu_adamw.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='AdamW', lr=0.02/100, weight_decay=0.0001) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=0.0, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=320000) 8 | checkpoint_config = dict(by_epoch=False, interval=8000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_40k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=40000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=4000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_40k_8gpu_adamw.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='AdamW', lr=0.02/100, weight_decay=0.0001) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=0.0, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=40000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_40k_8gpu_sgd.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=40000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=4000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_80k.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=80000) 8 | checkpoint_config = dict(by_epoch=False, interval=8000) 9 | evaluation = dict(interval=8000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_80k_8gpu_adamw.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='AdamW', lr=0.02/100, weight_decay=0.0001) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=0.0, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=80000) 8 | checkpoint_config = dict(by_epoch=False, interval=4000) 9 | evaluation = dict(interval=2000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/local_configs/_base_/schedules/schedule_80k_8gpu_sgd.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0005) 3 | optimizer_config = dict() 4 | # learning policy 5 | lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) 6 | # runtime settings 7 | runner = dict(type='IterBasedRunner', max_iters=80000) 8 | checkpoint_config = dict(by_epoch=False, interval=8000) 9 | evaluation = dict(interval=8000, metric='mIoU') 10 | -------------------------------------------------------------------------------- /segmentation/mmseg/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/.DS_Store -------------------------------------------------------------------------------- /segmentation/mmseg/__init__.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | from .version import __version__, version_info 4 | 5 | MMCV_MIN = '1.1.4' 6 | MMCV_MAX = '1.3.0' 7 | 8 | 9 | def digit_version(version_str): 10 | digit_version = [] 11 | for x in version_str.split('.'): 12 | if x.isdigit(): 13 | digit_version.append(int(x)) 14 | elif x.find('rc') != -1: 15 | patch_version = x.split('rc') 16 | digit_version.append(int(patch_version[0]) - 1) 17 | digit_version.append(int(patch_version[1])) 18 | return digit_version 19 | 20 | 21 | mmcv_min_version = digit_version(MMCV_MIN) 22 | mmcv_max_version = digit_version(MMCV_MAX) 23 | mmcv_version = digit_version(mmcv.__version__) 24 | 25 | 26 | assert (mmcv_min_version <= mmcv_version <= mmcv_max_version), \ 27 | f'MMCV=={mmcv.__version__} is used but incompatible. ' \ 28 | f'Please install mmcv>={mmcv_min_version}, <={mmcv_max_version}.' 29 | 30 | __all__ = ['__version__', 'version_info'] 31 | -------------------------------------------------------------------------------- /segmentation/mmseg/apis/__init__.py: -------------------------------------------------------------------------------- 1 | from .inference import inference_segmentor, init_segmentor, show_result_pyplot 2 | from .test import multi_gpu_test, single_gpu_test 3 | from .train import get_root_logger, set_random_seed, train_segmentor 4 | 5 | __all__ = [ 6 | 'get_root_logger', 'set_random_seed', 'train_segmentor', 'init_segmentor', 7 | 'inference_segmentor', 'multi_gpu_test', 'single_gpu_test', 8 | 'show_result_pyplot' 9 | ] 10 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/__init__.py: -------------------------------------------------------------------------------- 1 | from .evaluation import * # noqa: F401, F403 2 | from .seg import * # noqa: F401, F403 3 | from .utils import * # noqa: F401, F403 4 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .class_names import get_classes, get_palette 2 | from .eval_hooks import DistEvalHook, EvalHook 3 | from .metrics import eval_metrics, mean_dice, mean_iou 4 | 5 | __all__ = [ 6 | 'EvalHook', 'DistEvalHook', 'mean_dice', 'mean_iou', 'eval_metrics', 7 | 'get_classes', 'get_palette' 8 | ] 9 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/class_names.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/eval_hooks.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/evaluation/__pycache__/metrics.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__init__.py: -------------------------------------------------------------------------------- 1 | from .builder import build_pixel_sampler 2 | from .sampler import BasePixelSampler, OHEMPixelSampler 3 | 4 | __all__ = ['build_pixel_sampler', 'BasePixelSampler', 'OHEMPixelSampler'] 5 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/builder.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/builder.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/builder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/builder.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/__pycache__/builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/__pycache__/builder.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/builder.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import Registry, build_from_cfg 2 | 3 | PIXEL_SAMPLERS = Registry('pixel sampler') 4 | 5 | 6 | def build_pixel_sampler(cfg, **default_args): 7 | """Build pixel sampler for segmentation map.""" 8 | return build_from_cfg(cfg, PIXEL_SAMPLERS, default_args) 9 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_pixel_sampler import BasePixelSampler 2 | from .ohem_pixel_sampler import OHEMPixelSampler 3 | 4 | __all__ = ['BasePixelSampler', 'OHEMPixelSampler'] 5 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/base_pixel_sampler.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/seg/sampler/__pycache__/ohem_pixel_sampler.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/seg/sampler/base_pixel_sampler.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | 4 | class BasePixelSampler(metaclass=ABCMeta): 5 | """Base class of pixel sampler.""" 6 | 7 | def __init__(self, **kwargs): 8 | pass 9 | 10 | @abstractmethod 11 | def sample(self, seg_logit, seg_label): 12 | """Placeholder for sample function.""" 13 | pass 14 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .misc import add_prefix 2 | 3 | __all__ = ['add_prefix'] 4 | -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/misc.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/misc.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/misc.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/misc.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/__pycache__/misc.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/core/utils/__pycache__/misc.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/core/utils/misc.py: -------------------------------------------------------------------------------- 1 | def add_prefix(inputs, prefix): 2 | """Add prefix for dict. 3 | 4 | Args: 5 | inputs (dict): The input dict with str keys. 6 | prefix (str): The prefix to add. 7 | 8 | Returns: 9 | 10 | dict: The dict with keys updated with ``prefix``. 11 | """ 12 | 13 | outputs = dict() 14 | for name, value in inputs.items(): 15 | outputs[f'{prefix}.{name}'] = value 16 | 17 | return outputs 18 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .ade import ADE20KDataset 2 | from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset 3 | from .chase_db1 import ChaseDB1Dataset 4 | from .cityscapes import CityscapesDataset 5 | from .custom import CustomDataset 6 | from .dataset_wrappers import ConcatDataset, RepeatDataset 7 | from .drive import DRIVEDataset 8 | from .hrf import HRFDataset 9 | from .pascal_context import PascalContextDataset 10 | from .stare import STAREDataset 11 | from .voc import PascalVOCDataset 12 | from .mapillary import MapillaryDataset 13 | from .cocostuff import CocoStuff 14 | 15 | __all__ = [ 16 | 'CustomDataset', 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 17 | 'DATASETS', 'build_dataset', 'PIPELINES', 'CityscapesDataset', 18 | 'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset', 19 | 'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset', 'STAREDataset', 'MapillaryDataset', 'CocoStuff' 20 | ] 21 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/chase_db1.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class ChaseDB1Dataset(CustomDataset): 9 | """Chase_db1 dataset. 10 | 11 | In segmentation map annotation for Chase_db1, 0 stands for background, 12 | which is included in 2 categories. ``reduce_zero_label`` is fixed to False. 13 | The ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '_1stHO.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(ChaseDB1Dataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='_1stHO.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/dataset_wrappers.py: -------------------------------------------------------------------------------- 1 | from torch.utils.data.dataset import ConcatDataset as _ConcatDataset 2 | 3 | from .builder import DATASETS 4 | 5 | 6 | @DATASETS.register_module() 7 | class ConcatDataset(_ConcatDataset): 8 | """A wrapper of concatenated dataset. 9 | 10 | Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but 11 | concat the group flag for image aspect ratio. 12 | 13 | Args: 14 | datasets (list[:obj:`Dataset`]): A list of datasets. 15 | """ 16 | 17 | def __init__(self, datasets): 18 | super(ConcatDataset, self).__init__(datasets) 19 | self.CLASSES = datasets[0].CLASSES 20 | self.PALETTE = datasets[0].PALETTE 21 | 22 | 23 | @DATASETS.register_module() 24 | class RepeatDataset(object): 25 | """A wrapper of repeated dataset. 26 | 27 | The length of repeated dataset will be `times` larger than the original 28 | dataset. This is useful when the data loading time is long but the dataset 29 | is small. Using RepeatDataset can reduce the data loading time between 30 | epochs. 31 | 32 | Args: 33 | dataset (:obj:`Dataset`): The dataset to be repeated. 34 | times (int): Repeat times. 35 | """ 36 | 37 | def __init__(self, dataset, times): 38 | self.dataset = dataset 39 | self.times = times 40 | self.CLASSES = dataset.CLASSES 41 | self.PALETTE = dataset.PALETTE 42 | self._ori_len = len(self.dataset) 43 | 44 | def __getitem__(self, idx): 45 | """Get item from original dataset.""" 46 | return self.dataset[idx % self._ori_len] 47 | 48 | def __len__(self): 49 | """The length is multiplied by ``times``""" 50 | return self.times * self._ori_len 51 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/drive.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class DRIVEDataset(CustomDataset): 9 | """DRIVE dataset. 10 | 11 | In segmentation map annotation for DRIVE, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '_manual1.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(DRIVEDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='_manual1.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/hrf.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class HRFDataset(CustomDataset): 9 | """HRF dataset. 10 | 11 | In segmentation map annotation for HRF, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(HRFDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | from .compose import Compose 2 | from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, 3 | Transpose, to_tensor) 4 | from .loading import LoadAnnotations, LoadImageFromFile 5 | from .test_time_aug import MultiScaleFlipAug 6 | from .transforms import (CLAHE, AdjustGamma, Normalize, Pad, 7 | PhotoMetricDistortion, RandomCrop, RandomFlip, 8 | RandomRotate, Rerange, Resize, RGB2Gray, SegRescale) 9 | 10 | __all__ = [ 11 | 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', 12 | 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', 13 | 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', 'RandomCrop', 14 | 'Normalize', 'SegRescale', 'PhotoMetricDistortion', 'RandomRotate', 15 | 'AdjustGamma', 'CLAHE', 'Rerange', 'RGB2Gray' 16 | ] 17 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/compose.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/formating.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/loading.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/test_time_aug.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/datasets/pipelines/__pycache__/transforms.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/pipelines/compose.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | from mmcv.utils import build_from_cfg 4 | 5 | from ..builder import PIPELINES 6 | 7 | 8 | @PIPELINES.register_module() 9 | class Compose(object): 10 | """Compose multiple transforms sequentially. 11 | 12 | Args: 13 | transforms (Sequence[dict | callable]): Sequence of transform object or 14 | config dict to be composed. 15 | """ 16 | 17 | def __init__(self, transforms): 18 | assert isinstance(transforms, collections.abc.Sequence) 19 | self.transforms = [] 20 | for transform in transforms: 21 | if isinstance(transform, dict): 22 | transform = build_from_cfg(transform, PIPELINES) 23 | self.transforms.append(transform) 24 | elif callable(transform): 25 | self.transforms.append(transform) 26 | else: 27 | raise TypeError('transform must be callable or a dict') 28 | 29 | def __call__(self, data): 30 | """Call function to apply transforms sequentially. 31 | 32 | Args: 33 | data (dict): A result dict contains the data to transform. 34 | 35 | Returns: 36 | dict: Transformed data. 37 | """ 38 | 39 | for t in self.transforms: 40 | data = t(data) 41 | if data is None: 42 | return None 43 | return data 44 | 45 | def __repr__(self): 46 | format_string = self.__class__.__name__ + '(' 47 | for t in self.transforms: 48 | format_string += '\n' 49 | format_string += f' {t}' 50 | format_string += '\n)' 51 | return format_string 52 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/stare.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class STAREDataset(CustomDataset): 9 | """STARE dataset. 10 | 11 | In segmentation map annotation for STARE, 0 stands for background, which is 12 | included in 2 categories. ``reduce_zero_label`` is fixed to False. The 13 | ``img_suffix`` is fixed to '.png' and ``seg_map_suffix`` is fixed to 14 | '.ah.png'. 15 | """ 16 | 17 | CLASSES = ('background', 'vessel') 18 | 19 | PALETTE = [[120, 120, 120], [6, 230, 230]] 20 | 21 | def __init__(self, **kwargs): 22 | super(STAREDataset, self).__init__( 23 | img_suffix='.png', 24 | seg_map_suffix='.ah.png', 25 | reduce_zero_label=False, 26 | **kwargs) 27 | assert osp.exists(self.img_dir) 28 | -------------------------------------------------------------------------------- /segmentation/mmseg/datasets/voc.py: -------------------------------------------------------------------------------- 1 | import os.path as osp 2 | 3 | from .builder import DATASETS 4 | from .custom import CustomDataset 5 | 6 | 7 | @DATASETS.register_module() 8 | class PascalVOCDataset(CustomDataset): 9 | """Pascal VOC dataset. 10 | 11 | Args: 12 | split (str): Split txt file for Pascal VOC. 13 | """ 14 | 15 | CLASSES = ('background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 16 | 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 17 | 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 18 | 'train', 'tvmonitor') 19 | 20 | PALETTE = [[0, 0, 0], [128, 0, 0], [0, 128, 0], [128, 128, 0], [0, 0, 128], 21 | [128, 0, 128], [0, 128, 128], [128, 128, 128], [64, 0, 0], 22 | [192, 0, 0], [64, 128, 0], [192, 128, 0], [64, 0, 128], 23 | [192, 0, 128], [64, 128, 128], [192, 128, 128], [0, 64, 0], 24 | [128, 64, 0], [0, 192, 0], [128, 192, 0], [0, 64, 128]] 25 | 26 | def __init__(self, split, **kwargs): 27 | super(PascalVOCDataset, self).__init__( 28 | img_suffix='.jpg', seg_map_suffix='.png', split=split, **kwargs) 29 | assert osp.exists(self.img_dir) and self.split is not None 30 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .backbones import * # noqa: F401,F403 2 | from .builder import (BACKBONES, HEADS, LOSSES, SEGMENTORS, build_backbone, 3 | build_head, build_loss, build_segmentor) 4 | from .decode_heads import * # noqa: F401,F403 5 | from .losses import * # noqa: F401,F403 6 | from .necks import * # noqa: F401,F403 7 | from .segmentors import * # noqa: F401,F403 8 | 9 | __all__ = [ 10 | 'BACKBONES', 'HEADS', 'LOSSES', 'SEGMENTORS', 'build_backbone', 11 | 'build_head', 'build_loss', 'build_segmentor' 12 | ] 13 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | from .fan import * 8 | from .swin_utils import * 9 | 10 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/builder.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | from mmcv.utils import Registry, build_from_cfg 4 | from torch import nn 5 | 6 | BACKBONES = Registry('backbone') 7 | NECKS = Registry('neck') 8 | HEADS = Registry('head') 9 | LOSSES = Registry('loss') 10 | SEGMENTORS = Registry('segmentor') 11 | 12 | 13 | def build(cfg, registry, default_args=None): 14 | """Build a module. 15 | 16 | Args: 17 | cfg (dict, list[dict]): The config of modules, is is either a dict 18 | or a list of configs. 19 | registry (:obj:`Registry`): A registry the module belongs to. 20 | default_args (dict, optional): Default arguments to build the module. 21 | Defaults to None. 22 | 23 | Returns: 24 | nn.Module: A built nn module. 25 | """ 26 | 27 | if isinstance(cfg, list): 28 | modules = [ 29 | build_from_cfg(cfg_, registry, default_args) for cfg_ in cfg 30 | ] 31 | return nn.Sequential(*modules) 32 | else: 33 | return build_from_cfg(cfg, registry, default_args) 34 | 35 | 36 | def build_backbone(cfg): 37 | """Build backbone.""" 38 | return build(cfg, BACKBONES) 39 | 40 | 41 | def build_neck(cfg): 42 | """Build neck.""" 43 | return build(cfg, NECKS) 44 | 45 | 46 | def build_head(cfg): 47 | """Build head.""" 48 | return build(cfg, HEADS) 49 | 50 | 51 | def build_loss(cfg): 52 | """Build loss.""" 53 | return build(cfg, LOSSES) 54 | 55 | 56 | def build_segmentor(cfg, train_cfg=None, test_cfg=None): 57 | """Build segmentor.""" 58 | if train_cfg is not None or test_cfg is not None: 59 | warnings.warn( 60 | 'train_cfg and test_cfg is deprecated, ' 61 | 'please specify them in model', UserWarning) 62 | assert cfg.get('train_cfg') is None or train_cfg is None, \ 63 | 'train_cfg specified in both outer field and model field ' 64 | assert cfg.get('test_cfg') is None or test_cfg is None, \ 65 | 'test_cfg specified in both outer field and model field ' 66 | return build(cfg, SEGMENTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) 67 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .ann_head import ANNHead 2 | from .apc_head import APCHead 3 | from .aspp_head import ASPPHead 4 | from .cc_head import CCHead 5 | from .da_head import DAHead 6 | from .dm_head import DMHead 7 | from .dnl_head import DNLHead 8 | from .ema_head import EMAHead 9 | from .enc_head import EncHead 10 | from .fcn_head import FCNHead 11 | from .fpn_head import FPNHead 12 | from .gc_head import GCHead 13 | from .lraspp_head import LRASPPHead 14 | from .nl_head import NLHead 15 | from .ocr_head import OCRHead 16 | from .point_head import PointHead 17 | from .psa_head import PSAHead 18 | from .psp_head import PSPHead 19 | from .sep_aspp_head import DepthwiseSeparableASPPHead 20 | from .sep_fcn_head import DepthwiseSeparableFCNHead 21 | from .uper_head import UPerHead 22 | 23 | 24 | from .segformer_head import SegFormerHead 25 | from .setr_up_head import SETRUPHead 26 | 27 | 28 | __all__ = [ 29 | 'FCNHead', 'PSPHead', 'ASPPHead', 'PSAHead', 'NLHead', 'GCHead', 'CCHead', 30 | 'UPerHead', 'DepthwiseSeparableASPPHead', 'ANNHead', 'DAHead', 'OCRHead', 31 | 'EncHead', 'DepthwiseSeparableFCNHead', 'FPNHead', 'EMAHead', 'DNLHead', 32 | 'PointHead', 'APCHead', 'DMHead', 'LRASPPHead', 33 | 'SegFormerHead', 34 | ] 35 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ann_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/apc_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/aspp_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cascade_decode_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/cc_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/da_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/decode_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dm_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/dnl_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ema_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/enc_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fcn_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/fpn_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/gc_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/lraspp_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/nl_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/ocr_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/point_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psa_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/psp_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/segformer_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_aspp_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/sep_fcn_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/setr_up_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/decode_heads/__pycache__/uper_head.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/cc_head.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from ..builder import HEADS 4 | from .fcn_head import FCNHead 5 | 6 | try: 7 | from mmcv.ops import CrissCrossAttention 8 | except ModuleNotFoundError: 9 | CrissCrossAttention = None 10 | 11 | 12 | @HEADS.register_module() 13 | class CCHead(FCNHead): 14 | """CCNet: Criss-Cross Attention for Semantic Segmentation. 15 | 16 | This head is the implementation of `CCNet 17 | `_. 18 | 19 | Args: 20 | recurrence (int): Number of recurrence of Criss Cross Attention 21 | module. Default: 2. 22 | """ 23 | 24 | def __init__(self, recurrence=2, **kwargs): 25 | if CrissCrossAttention is None: 26 | raise RuntimeError('Please install mmcv-full for ' 27 | 'CrissCrossAttention ops') 28 | super(CCHead, self).__init__(num_convs=2, **kwargs) 29 | self.recurrence = recurrence 30 | self.cca = CrissCrossAttention(self.channels) 31 | 32 | def forward(self, inputs): 33 | """Forward function.""" 34 | x = self._transform_inputs(inputs) 35 | output = self.convs[0](x) 36 | for _ in range(self.recurrence): 37 | output = self.cca(output) 38 | output = self.convs[1](output) 39 | if self.concat_input: 40 | output = self.conv_cat(torch.cat([x, output], dim=1)) 41 | output = self.cls_seg(output) 42 | return output 43 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/gc_head.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from mmcv.cnn import ContextBlock 3 | 4 | from ..builder import HEADS 5 | from .fcn_head import FCNHead 6 | 7 | 8 | @HEADS.register_module() 9 | class GCHead(FCNHead): 10 | """GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond. 11 | 12 | This head is the implementation of `GCNet 13 | `_. 14 | 15 | Args: 16 | ratio (float): Multiplier of channels ratio. Default: 1/4. 17 | pooling_type (str): The pooling type of context aggregation. 18 | Options are 'att', 'avg'. Default: 'avg'. 19 | fusion_types (tuple[str]): The fusion type for feature fusion. 20 | Options are 'channel_add', 'channel_mul'. Defautl: ('channel_add',) 21 | """ 22 | 23 | def __init__(self, 24 | ratio=1 / 4., 25 | pooling_type='att', 26 | fusion_types=('channel_add', ), 27 | **kwargs): 28 | super(GCHead, self).__init__(num_convs=2, **kwargs) 29 | self.ratio = ratio 30 | self.pooling_type = pooling_type 31 | self.fusion_types = fusion_types 32 | self.gc_block = ContextBlock( 33 | in_channels=self.channels, 34 | ratio=self.ratio, 35 | pooling_type=self.pooling_type, 36 | fusion_types=self.fusion_types) 37 | 38 | def forward(self, inputs): 39 | """Forward function.""" 40 | x = self._transform_inputs(inputs) 41 | output = self.convs[0](x) 42 | output = self.gc_block(output) 43 | output = self.convs[1](output) 44 | if self.concat_input: 45 | output = self.conv_cat(torch.cat([x, output], dim=1)) 46 | output = self.cls_seg(output) 47 | return output 48 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/decode_heads/nl_head.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from mmcv.cnn import NonLocal2d 3 | 4 | from ..builder import HEADS 5 | from .fcn_head import FCNHead 6 | 7 | 8 | @HEADS.register_module() 9 | class NLHead(FCNHead): 10 | """Non-local Neural Networks. 11 | 12 | This head is the implementation of `NLNet 13 | `_. 14 | 15 | Args: 16 | reduction (int): Reduction factor of projection transform. Default: 2. 17 | use_scale (bool): Whether to scale pairwise_weight by 18 | sqrt(1/inter_channels). Default: True. 19 | mode (str): The nonlocal mode. Options are 'embedded_gaussian', 20 | 'dot_product'. Default: 'embedded_gaussian.'. 21 | """ 22 | 23 | def __init__(self, 24 | reduction=2, 25 | use_scale=True, 26 | mode='embedded_gaussian', 27 | **kwargs): 28 | super(NLHead, self).__init__(num_convs=2, **kwargs) 29 | self.reduction = reduction 30 | self.use_scale = use_scale 31 | self.mode = mode 32 | self.nl_block = NonLocal2d( 33 | in_channels=self.channels, 34 | reduction=self.reduction, 35 | use_scale=self.use_scale, 36 | conv_cfg=self.conv_cfg, 37 | norm_cfg=self.norm_cfg, 38 | mode=self.mode) 39 | 40 | def forward(self, inputs): 41 | """Forward function.""" 42 | x = self._transform_inputs(inputs) 43 | output = self.convs[0](x) 44 | output = self.nl_block(output) 45 | output = self.convs[1](output) 46 | if self.concat_input: 47 | output = self.conv_cat(torch.cat([x, output], dim=1)) 48 | output = self.cls_seg(output) 49 | return output 50 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | from .accuracy import Accuracy, accuracy 2 | from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, 3 | cross_entropy, mask_cross_entropy) 4 | from .lovasz_loss import LovaszLoss 5 | from .utils import reduce_loss, weight_reduce_loss, weighted_loss 6 | 7 | __all__ = [ 8 | 'accuracy', 'Accuracy', 'cross_entropy', 'binary_cross_entropy', 9 | 'mask_cross_entropy', 'CrossEntropyLoss', 'reduce_loss', 10 | 'weight_reduce_loss', 'weighted_loss', 'LovaszLoss' 11 | ] 12 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/accuracy.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/cross_entropy_loss.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/lovasz_loss.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/utils.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/losses/__pycache__/utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/losses/__pycache__/utils.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | from .fpn import FPN 2 | 3 | __all__ = ['FPN'] 4 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/fpn.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/fpn.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/fpn.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/fpn.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/necks/__pycache__/fpn.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/necks/__pycache__/fpn.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__init__.py: -------------------------------------------------------------------------------- 1 | from .cascade_encoder_decoder import CascadeEncoderDecoder 2 | from .encoder_decoder import EncoderDecoder 3 | 4 | __all__ = ['EncoderDecoder', 'CascadeEncoderDecoder'] 5 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/base.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/base.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/base.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/base.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/base.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/base.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/cascade_encoder_decoder.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/segmentors/__pycache__/encoder_decoder.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .inverted_residual import InvertedResidual, InvertedResidualV3 2 | from .make_divisible import make_divisible 3 | from .res_layer import ResLayer 4 | from .self_attention_block import SelfAttentionBlock 5 | from .up_conv_block import UpConvBlock 6 | 7 | __all__ = [ 8 | 'ResLayer', 'SelfAttentionBlock', 'make_divisible', 'InvertedResidual', 9 | 'UpConvBlock', 'InvertedResidualV3' 10 | ] 11 | -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/inverted_residual.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/make_divisible.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/res_layer.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/se_layer.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/self_attention_block.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-36.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-37.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NVlabs/STL/376d0abd21b388ba859a5d25cc56abd7825354b9/segmentation/mmseg/models/utils/__pycache__/up_conv_block.cpython-38.pyc -------------------------------------------------------------------------------- /segmentation/mmseg/models/utils/make_divisible.py: -------------------------------------------------------------------------------- 1 | def make_divisible(value, divisor, min_value=None, min_ratio=0.9): 2 | """Make divisible function. 3 | 4 | This function rounds the channel number to the nearest value that can be 5 | divisible by the divisor. It is taken from the original tf repo. It ensures 6 | that all layers have a channel number that is divisible by divisor. It can 7 | be seen here: https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py # noqa 8 | 9 | Args: 10 | value (int): The original channel number. 11 | divisor (int): The divisor to fully divide the channel number. 12 | min_value (int): The minimum value of the output channel. 13 | Default: None, means that the minimum value equal to the divisor. 14 | min_ratio (float): The minimum ratio of the rounded channel number to 15 | the original channel number. Default: 0.9. 16 | 17 | Returns: 18 | int: The modified output channel number. 19 | """ 20 | 21 | if min_value is None: 22 | min_value = divisor 23 | new_value = max(min_value, int(value + divisor / 2) // divisor * divisor) 24 | # Make sure that round down does not go down by more than (1-min_ratio). 25 | if new_value < min_ratio * value: 26 | new_value += divisor 27 | return new_value 28 | -------------------------------------------------------------------------------- /segmentation/mmseg/ops/__init__.py: -------------------------------------------------------------------------------- 1 | from .encoding import Encoding 2 | from .wrappers import Upsample, resize 3 | 4 | __all__ = ['Upsample', 'resize', 'Encoding'] 5 | -------------------------------------------------------------------------------- /segmentation/mmseg/ops/wrappers.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | import torch 4 | import torch.nn as nn 5 | import torch.nn.functional as F 6 | 7 | 8 | def resize(input, 9 | size=None, 10 | scale_factor=None, 11 | mode='nearest', 12 | align_corners=None, 13 | warning=True): 14 | if warning: 15 | if size is not None and align_corners: 16 | input_h, input_w = tuple(int(x) for x in input.shape[2:]) 17 | output_h, output_w = tuple(int(x) for x in size) 18 | if output_h > input_h or output_w > output_h: 19 | if ((output_h > 1 and output_w > 1 and input_h > 1 20 | and input_w > 1) and (output_h - 1) % (input_h - 1) 21 | and (output_w - 1) % (input_w - 1)): 22 | warnings.warn( 23 | f'When align_corners={align_corners}, ' 24 | 'the output would more aligned if ' 25 | f'input size {(input_h, input_w)} is `x+1` and ' 26 | f'out size {(output_h, output_w)} is `nx+1`') 27 | if isinstance(size, torch.Size): 28 | size = tuple(int(x) for x in size) 29 | return F.interpolate(input, size, scale_factor, mode, align_corners) 30 | 31 | 32 | class Upsample(nn.Module): 33 | 34 | def __init__(self, 35 | size=None, 36 | scale_factor=None, 37 | mode='nearest', 38 | align_corners=None): 39 | super(Upsample, self).__init__() 40 | self.size = size 41 | if isinstance(scale_factor, tuple): 42 | self.scale_factor = tuple(float(factor) for factor in scale_factor) 43 | else: 44 | self.scale_factor = float(scale_factor) if scale_factor else None 45 | self.mode = mode 46 | self.align_corners = align_corners 47 | 48 | def forward(self, x): 49 | if not self.size: 50 | size = [int(t * self.scale_factor) for t in x.shape[-2:]] 51 | else: 52 | size = self.size 53 | return resize(x, size, None, self.mode, self.align_corners) 54 | -------------------------------------------------------------------------------- /segmentation/mmseg/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .collect_env import collect_env 2 | from .logger import get_root_logger, print_log 3 | 4 | __all__ = ['get_root_logger', 'collect_env', 'print_log'] 5 | -------------------------------------------------------------------------------- /segmentation/mmseg/utils/collect_env.py: -------------------------------------------------------------------------------- 1 | from mmcv.utils import collect_env as collect_base_env 2 | from mmcv.utils import get_git_hash 3 | 4 | import mmseg 5 | 6 | 7 | def collect_env(): 8 | """Collect the information of the running environments.""" 9 | env_info = collect_base_env() 10 | env_info['MMSegmentation'] = f'{mmseg.__version__}+{get_git_hash()[:7]}' 11 | 12 | return env_info 13 | 14 | 15 | if __name__ == '__main__': 16 | for name, val in collect_env().items(): 17 | print('{}: {}'.format(name, val)) 18 | -------------------------------------------------------------------------------- /segmentation/mmseg/utils/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from mmcv.utils import get_logger 4 | 5 | 6 | def get_root_logger(log_file=None, log_level=logging.INFO): 7 | """Get the root logger. 8 | 9 | The logger will be initialized if it has not been initialized. By default a 10 | StreamHandler will be added. If `log_file` is specified, a FileHandler will 11 | also be added. The name of the root logger is the top-level package name, 12 | e.g., "mmseg". 13 | 14 | Args: 15 | log_file (str | None): The log filename. If specified, a FileHandler 16 | will be added to the root logger. 17 | log_level (int): The root logger level. Note that only the process of 18 | rank 0 is affected, while other processes will set the level to 19 | "Error" and be silent most of the time. 20 | 21 | Returns: 22 | logging.Logger: The root logger. 23 | """ 24 | 25 | logger = get_logger(name='mmseg', log_file=log_file, log_level=log_level) 26 | 27 | return logger 28 | 29 | def print_log(msg, logger=None, level=logging.INFO): 30 | """Print a log message. 31 | Args: 32 | msg (str): The message to be logged. 33 | logger (logging.Logger | str | None): The logger to be used. Some 34 | special loggers are: 35 | - "root": the root logger obtained with `get_root_logger()`. 36 | - "silent": no message will be printed. 37 | - None: The `print()` method will be used to print log messages. 38 | level (int): Logging level. Only available when `logger` is a Logger 39 | object or "root". 40 | """ 41 | if logger is None: 42 | print(msg) 43 | elif logger == 'root': 44 | _logger = get_root_logger() 45 | _logger.log(level, msg) 46 | elif isinstance(logger, logging.Logger): 47 | logger.log(level, msg) 48 | elif logger != 'silent': 49 | raise TypeError( 50 | 'logger should be either a logging.Logger object, "root", ' 51 | '"silent" or None, but got {}'.format(logger)) -------------------------------------------------------------------------------- /segmentation/mmseg/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Open-MMLab. All rights reserved. 2 | 3 | __version__ = '0.11.0' 4 | 5 | 6 | def parse_version_info(version_str): 7 | version_info = [] 8 | for x in version_str.split('.'): 9 | if x.isdigit(): 10 | version_info.append(int(x)) 11 | elif x.find('rc') != -1: 12 | patch_version = x.split('rc') 13 | version_info.append(int(patch_version[0])) 14 | version_info.append(f'rc{patch_version[1]}') 15 | return tuple(version_info) 16 | 17 | 18 | version_info = parse_version_info(__version__) 19 | -------------------------------------------------------------------------------- /segmentation/requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements/optional.txt 2 | -r requirements/runtime.txt 3 | -r requirements/tests.txt 4 | -------------------------------------------------------------------------------- /segmentation/requirements/docs.txt: -------------------------------------------------------------------------------- 1 | recommonmark 2 | sphinx 3 | sphinx_markdown_tables 4 | sphinx_rtd_theme 5 | -------------------------------------------------------------------------------- /segmentation/requirements/optional.txt: -------------------------------------------------------------------------------- 1 | cityscapesscripts 2 | -------------------------------------------------------------------------------- /segmentation/requirements/readthedocs.txt: -------------------------------------------------------------------------------- 1 | mmcv 2 | torch 3 | torchvision 4 | -------------------------------------------------------------------------------- /segmentation/requirements/runtime.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | numpy 3 | terminaltables 4 | -------------------------------------------------------------------------------- /segmentation/requirements/tests.txt: -------------------------------------------------------------------------------- 1 | codecov 2 | flake8 3 | interrogate 4 | isort==4.3.21 5 | pytest 6 | xdoctest>=0.10.0 7 | yapf 8 | -------------------------------------------------------------------------------- /segmentation/scripts/eval_city_c.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | ./tools/dist_test_c.sh /PATH/TO/CONFIG/FILE /PATH/TO/CHECKPOINT/FILE 1 --eval mIoU --results-file ../output/ 8 | -------------------------------------------------------------------------------- /segmentation/scripts/fan_base_hybrid_city.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | ./tools/dist_train.sh local_configs/fan/fan_hybrid/fan_hybrid_base.1024x1024.city.160k 8 --work-dir ../fan_hybrid_base/ 8 | 9 | -------------------------------------------------------------------------------- /segmentation/scripts/fan_large_hybrid_city.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | ./tools/dist_train.sh local_configs/fan/fan_hybrid/fan_hybrid_large.1024x1024.city.160k 8 --work-dir ../fan_hybrid_large/ 8 | -------------------------------------------------------------------------------- /segmentation/scripts/fan_small_hybrid_city.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | ./tools/dist_train.sh local_configs/fan/fan_hybrid/fan_hybrid_small.1024x1024.city.160k 8 --work-dir ../fan_hybrid_small/ 8 | -------------------------------------------------------------------------------- /segmentation/scripts/fan_tiny_hybrid_city.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | ./tools/dist_train.sh local_configs/fan/fan_hybrid/fan_hybrid_tiny.1024x1024.city.160k 1 --work-dir ../fan_hybrid_tiny/ 8 | -------------------------------------------------------------------------------- /segmentation/tools/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | CONFIG=$1 9 | CHECKPOINT=$2 10 | GPUS=$3 11 | PORT=${PORT:-29500} 12 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 13 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 14 | $(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} 15 | -------------------------------------------------------------------------------- /segmentation/tools/dist_test_city_c.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | CONFIG=$1 9 | CHECKPOINT=$2 10 | GPUS=$3 11 | PORT=${PORT:-29500} 12 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 13 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 14 | $(dirname "$0")/test_city_c.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} 15 | -------------------------------------------------------------------------------- /segmentation/tools/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 3 | # 4 | # This work is made available under the Nvidia Source Code License-NC. 5 | # To view a copy of this license, visit 6 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 7 | 8 | CONFIG=$1 9 | GPUS=$2 10 | PORT=${PORT:-29500} 11 | 12 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 13 | python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 14 | $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} 15 | -------------------------------------------------------------------------------- /segmentation/tools/gen_city_c.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021-2022, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/FAN/blob/main/LICENSE 6 | 7 | # Copyright (c) Open-MMLab. All rights reserved. 8 | 9 | import numpy as np 10 | from imagecorruptions import corrupt 11 | import random 12 | import os 13 | import mmcv 14 | 15 | 16 | random.seed(8) # for reproducibility 17 | np.random.seed(8) 18 | 19 | 20 | corruptions = ['gaussian_noise', 'shot_noise', 'impulse_noise', 'defocus_blur', 21 | 'glass_blur', 'motion_blur', 'zoom_blur', 'snow', 'frost', 'fog', 22 | 'brightness', 'contrast', 'elastic_transform', 'pixelate', 'jpeg_compression', 23 | 'speckle_noise', 'gaussian_blur', 'spatter', 'saturate'] 24 | 25 | def perturb(i, p, s): 26 | img = corrupt(i, corruption_name=p, severity=s) 27 | return img 28 | 29 | 30 | def convert_img_path(ori_path, suffix): 31 | new_path = ori_path.replace('clean', suffix) 32 | assert new_path != ori_path 33 | return new_path 34 | 35 | def main(): 36 | img_dir = '../ade20k_c/clean/' 37 | severity = [1, 2, 3, 4, 5] 38 | num_imgs = 5000 39 | for p in corruptions: 40 | print("\n ### gen corruption:{} ###".format(p)) 41 | prog_bar = mmcv.ProgressBar(num_imgs) 42 | for img_path in mmcv.scandir(img_dir, suffix='jpg', recursive=True): 43 | img_path = os.path.join(img_dir, img_path) 44 | img = mmcv.imread(img_path) 45 | prog_bar.update() 46 | for s in severity: 47 | perturbed_img = perturb(img, p, s) 48 | img_suffix = p+"/"+str(s) 49 | perturbed_img_path = convert_img_path(img_path, img_suffix) 50 | mmcv.imwrite(perturbed_img, perturbed_img_path, auto_mkdir=True) 51 | 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .utils import load_for_transfer_learning, load_for_probing 2 | from .scaler import ApexScaler_SAM 3 | from .mce_utils import * 4 | from .token_label_generation import * 5 | -------------------------------------------------------------------------------- /utils/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .fan import * 2 | 3 | -------------------------------------------------------------------------------- /utils/loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .cross_entropy import * 2 | -------------------------------------------------------------------------------- /utils/scaler.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from timm.utils import ApexScaler, NativeScaler 3 | try: 4 | from apex import amp 5 | has_apex = True 6 | except ImportError: 7 | amp = None 8 | has_apex = False 9 | 10 | class ApexScaler_SAM(ApexScaler): 11 | 12 | def __call__(self, loss, optimizer, clip_grad=None, clip_mode='norm', parameters=None, create_graph=False, step=0, rho=0.05): 13 | with amp.scale_loss(loss, optimizer) as scaled_loss: 14 | scaled_loss.backward(create_graph=create_graph) 15 | if step==0 or step==2: 16 | if clip_grad is not None: 17 | dispatch_clip_grad(amp.master_params(optimizer), clip_grad, mode=clip_mode) 18 | optimizer.step() 19 | elif step==1: 20 | torch.nn.utils.clip_grad_norm_(amp.master_params(optimizer), rho, norm_type=2.0) 21 | optimizer.step() 22 | -------------------------------------------------------------------------------- /utils/teacher_data/__init__.py: -------------------------------------------------------------------------------- 1 | from .dataset import ImageDataset, IterableImageDataset, AugMixDataset 2 | from .dataset_factory import create_dataset_clean_teacher 3 | from .clean_teacher_transforms_factory import create_transform_clean_teacher 4 | from .loader import create_loader_clean_teacher 5 | from .random_erasing_clean_teacher import * 6 | from .mixup_clean_teacher import MixupCleanTeacher, FastCollateMixupCleanTeacher 7 | -------------------------------------------------------------------------------- /utils/token_label_generation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023, NVIDIA Corporation & Affiliates. All rights reserved. 2 | # 3 | # This work is made available under the Nvidia Source Code License-NC. 4 | # To view a copy of this license, visit 5 | # https://github.com/NVlabs/STL/blob/master/LICENSE 6 | 7 | 8 | import torch 9 | # Token label generation 10 | def token_label_generation(model, input, args, amp_autocast=None): 11 | model.eval() 12 | with torch.no_grad(): 13 | if args.channels_last: 14 | input = input.contiguous(memory_format=torch.channels_last) 15 | 16 | with amp_autocast(): 17 | output = model(input) 18 | aux_target = output[1] 19 | 20 | if args.softmax_token_label: 21 | aux_target_softmax = torch.nn.functional.softmax(aux_target, dim=-1) 22 | return aux_target_softmax 23 | elif args.single_token_label: 24 | aux_target = torch.mean(aux_target, dim=-2) 25 | 26 | if not args.no_gumbel: 27 | aux_target_one_hot = torch.nn.functional.gumbel_softmax(aux_target, tau=1, hard=True, dim=-1) 28 | else: 29 | 30 | aux_target_one_hot = torch.argmax(aux_target.softmax(-1),dim=-1) 31 | aux_target_one_hot = torch.nn.functional.one_hot(aux_target_one_hot, 1000) 32 | # add label smoothing 33 | aux_target_one_hot = token_label_smoothing(aux_target_one_hot, args.smoothing) 34 | 35 | 36 | return aux_target_one_hot 37 | 38 | 39 | # Token label smoothing 40 | def token_label_smoothing(y_hot, α=0.1, K=1000): 41 | # y_ls = (1 - α) * y_hot + α / K , K = # of class 42 | y_ls = (1-α)*y_hot + α/K 43 | 44 | return y_ls 45 | 46 | 47 | 48 | --------------------------------------------------------------------------------