From 36454996c2cd7920b6400ab2e8c59f029503a398 Mon Sep 17 00:00:00 2001 From: wangwl Date: Wed, 24 Dec 2025 02:11:19 +0000 Subject: [PATCH 1/4] add SwinS3 --- .../SwinS3/Cream/AutoFormer/README.md | 124 + .../SwinS3/Cream/AutoFormer/evolution.py | 564 + .../experiments/subnet/AutoFormer-B.yaml | 59 + .../experiments/subnet/AutoFormer-S.yaml | 54 + .../experiments/subnet/AutoFormer-T.yaml | 51 + .../experiments/supernet/supernet-B.yaml | 21 + .../experiments/supernet/supernet-S.yaml | 22 + .../experiments/supernet/supernet-T.yaml | 20 + .../SwinS3/Cream/AutoFormer/lib/config.py | 39 + .../SwinS3/Cream/AutoFormer/lib/datasets.py | 220 + .../Cream/AutoFormer/lib/imagenet_withhold.py | 78 + .../SwinS3/Cream/AutoFormer/lib/samplers.py | 57 + .../Cream/AutoFormer/lib/subImageNet.py | 48 + .../SwinS3/Cream/AutoFormer/lib/utils.py | 235 + .../AutoFormer/model/module/Linear_super.py | 81 + .../Cream/AutoFormer/model/module/__init__.py | 0 .../model/module/embedding_super.py | 49 + .../model/module/layernorm_super.py | 45 + .../model/module/multihead_super.py | 160 + .../AutoFormer/model/module/qkv_super.py | 83 + .../AutoFormer/model/supernet_transformer.py | 312 + .../SwinS3/Cream/AutoFormer/model/utils.py | 106 + .../SwinS3/Cream/AutoFormer/requirements.txt | 9 + .../Cream/AutoFormer/supernet_engine.py | 160 + .../SwinS3/Cream/AutoFormer/supernet_train.py | 397 + .../SwinS3/Cream/AutoFormerV2/README.md | 82 + .../Cream/AutoFormerV2/configs/S3-B.yaml | 5 + .../Cream/AutoFormerV2/configs/S3-S.yaml | 5 + .../Cream/AutoFormerV2/configs/S3-T.yaml | 5 + .../SwinS3/Cream/AutoFormerV2/engine.py | 46 + .../SwinS3/Cream/AutoFormerV2/evaluation.py | 292 + .../SwinS3/Cream/AutoFormerV2/lib/config.py | 39 + .../SwinS3/Cream/AutoFormerV2/lib/datasets.py | 220 + .../SwinS3/Cream/AutoFormerV2/lib/samplers.py | 57 + .../SwinS3/Cream/AutoFormerV2/lib/utils.py | 235 + .../SwinS3/Cream/AutoFormerV2/model/SSS.py | 577 + .../Cream/AutoFormerV2/requirements.txt | 10 + .../SwinS3/Cream/CDARTS/CDARTS/_init_paths.py | 19 + .../CDARTS/CDARTS/cells/cifar_genotype.json | 1 + .../CDARTS/CDARTS/cells/dartsv1_genotype.json | 1 + .../CDARTS/CDARTS/cells/dartsv2_genotype.json | 1 + .../CDARTS/cells/imagenet_genotype.json | 1 + .../CDARTS/cells/pcdarts_cifar_genotype.json | 1 + .../cells/pcdarts_imagenet_genotype.json | 1 + .../CDARTS/CDARTS/cells/pdarts_genotype.json | 1 + .../SwinS3/Cream/CDARTS/CDARTS/retrain.py | 206 + .../SwinS3/Cream/CDARTS/CDARTS/search.py | 403 + .../SwinS3/Cream/CDARTS/CDARTS/test.py | 96 + .../Cream/CDARTS/CDARTS_detection/README.md | 58 + .../configs/CyDAS_retinanet_1x.py | 129 + .../CDARTS/CDARTS_detection/mmcv/__init__.py | 13 + .../mmcv/arraymisc/__init__.py | 3 + .../mmcv/arraymisc/quantization.py | 56 + .../CDARTS_detection/mmcv/cnn/__init__.py | 11 + .../CDARTS_detection/mmcv/cnn/alexnet.py | 61 + .../CDARTS_detection/mmcv/cnn/resnet.py | 314 + .../CDARTS/CDARTS_detection/mmcv/cnn/vgg.py | 174 + .../CDARTS_detection/mmcv/cnn/weight_init.py | 57 + .../CDARTS_detection/mmcv/fileio/__init__.py | 8 + .../mmcv/fileio/handlers/__init__.py | 6 + .../mmcv/fileio/handlers/base.py | 26 + .../mmcv/fileio/handlers/json_handler.py | 15 + .../mmcv/fileio/handlers/pickle_handler.py | 25 + .../mmcv/fileio/handlers/yaml_handler.py | 23 + .../CDARTS/CDARTS_detection/mmcv/fileio/io.py | 112 + .../CDARTS_detection/mmcv/fileio/parse.py | 50 + .../CDARTS_detection/mmcv/image/__init__.py | 12 + .../CDARTS/CDARTS_detection/mmcv/image/io.py | 79 + .../mmcv/image/transforms/__init__.py | 12 + .../mmcv/image/transforms/colorspace.py | 77 + .../mmcv/image/transforms/geometry.py | 203 + .../mmcv/image/transforms/normalize.py | 17 + .../mmcv/image/transforms/resize.py | 107 + .../CDARTS_detection/mmcv/opencv_info.py | 12 + .../mmcv/parallel/__init__.py | 10 + .../mmcv/parallel/_functions.py | 74 + .../CDARTS_detection/mmcv/parallel/collate.py | 84 + .../mmcv/parallel/data_container.py | 84 + .../mmcv/parallel/data_parallel.py | 9 + .../mmcv/parallel/distributed.py | 50 + .../mmcv/parallel/scatter_gather.py | 54 + .../CDARTS_detection/mmcv/runner/__init__.py | 23 + .../mmcv/runner/checkpoint.py | 217 + .../mmcv/runner/dist_utils.py | 76 + .../mmcv/runner/hooks/__init__.py | 16 + .../mmcv/runner/hooks/checkpoint.py | 25 + .../mmcv/runner/hooks/closure.py | 9 + .../mmcv/runner/hooks/hook.py | 58 + .../mmcv/runner/hooks/iter_timer.py | 16 + .../mmcv/runner/hooks/logger/__init__.py | 8 + .../mmcv/runner/hooks/logger/base.py | 70 + .../mmcv/runner/hooks/logger/pavi.py | 176 + .../mmcv/runner/hooks/logger/tensorboard.py | 55 + .../mmcv/runner/hooks/logger/text.py | 123 + .../mmcv/runner/hooks/lr_updater.py | 183 + .../mmcv/runner/hooks/memory.py | 23 + .../mmcv/runner/hooks/optimizer.py | 35 + .../mmcv/runner/hooks/sampler_seed.py | 7 + .../mmcv/runner/log_buffer.py | 40 + .../mmcv/runner/parallel_test.py | 74 + .../CDARTS_detection/mmcv/runner/priority.py | 53 + .../CDARTS_detection/mmcv/runner/runner.py | 426 + .../CDARTS_detection/mmcv/runner/utils.py | 78 + .../CDARTS_detection/mmcv/utils/__init__.py | 17 + .../CDARTS_detection/mmcv/utils/config.py | 159 + .../CDARTS_detection/mmcv/utils/misc.py | 218 + .../CDARTS_detection/mmcv/utils/path.py | 79 + .../mmcv/utils/progressbar.py | 174 + .../CDARTS_detection/mmcv/utils/timer.py | 117 + .../CDARTS/CDARTS_detection/mmcv/version.py | 1 + .../CDARTS_detection/mmcv/video/__init__.py | 10 + .../CDARTS/CDARTS_detection/mmcv/video/io.py | 332 + .../CDARTS_detection/mmcv/video/optflow.py | 171 + .../mmcv/video/optflow_warp/__init__.py | 0 .../mmcv/video/optflow_warp/flow_warp.cpp | 75 + .../mmcv/video/optflow_warp/flow_warp.hpp | 29 + .../video/optflow_warp/flow_warp_module.cpp | 7928 ++++++++++++ .../video/optflow_warp/flow_warp_module.pyx | 27 + .../CDARTS_detection/mmcv/video/processing.py | 159 + .../mmcv/visualization/__init__.py | 8 + .../mmcv/visualization/color.py | 50 + .../mmcv/visualization/image.py | 146 + .../mmcv/visualization/optflow.py | 113 + .../CDARTS/CDARTS_detection/mmdet/__init__.py | 3 + .../CDARTS_detection/mmdet/apis/__init__.py | 9 + .../CDARTS/CDARTS_detection/mmdet/apis/env.py | 69 + .../CDARTS_detection/mmdet/apis/inference.py | 171 + .../CDARTS_detection/mmdet/apis/train.py | 256 + .../CDARTS_detection/mmdet/core/__init__.py | 7 + .../mmdet/core/anchor/__init__.py | 8 + .../mmdet/core/anchor/anchor_generator.py | 84 + .../mmdet/core/anchor/anchor_target.py | 186 + .../mmdet/core/anchor/guided_anchor_target.py | 285 + .../mmdet/core/bbox/__init__.py | 20 + .../mmdet/core/bbox/assign_sampling.py | 33 + .../mmdet/core/bbox/assigners/__init__.py | 8 + .../bbox/assigners/approx_max_iou_assigner.py | 116 + .../core/bbox/assigners/assign_result.py | 19 + .../core/bbox/assigners/base_assigner.py | 8 + .../core/bbox/assigners/max_iou_assigner.py | 152 + .../mmdet/core/bbox/bbox_target.py | 73 + .../mmdet/core/bbox/geometry.py | 63 + .../mmdet/core/bbox/samplers/__init__.py | 14 + .../mmdet/core/bbox/samplers/base_sampler.py | 78 + .../core/bbox/samplers/combined_sampler.py | 16 + .../samplers/instance_balanced_pos_sampler.py | 41 + .../bbox/samplers/iou_balanced_neg_sampler.py | 133 + .../mmdet/core/bbox/samplers/ohem_sampler.py | 73 + .../core/bbox/samplers/pseudo_sampler.py | 26 + .../core/bbox/samplers/random_sampler.py | 53 + .../core/bbox/samplers/sampling_result.py | 24 + .../mmdet/core/bbox/transforms.py | 180 + .../mmdet/core/evaluation/__init__.py | 14 + .../mmdet/core/evaluation/bbox_overlaps.py | 49 + .../mmdet/core/evaluation/class_names.py | 108 + .../mmdet/core/evaluation/coco_utils.py | 177 + .../mmdet/core/evaluation/eval_hooks.py | 74 + .../mmdet/core/evaluation/mean_ap.py | 455 + .../mmdet/core/evaluation/recall.py | 193 + .../mmdet/core/fp16/__init__.py | 4 + .../mmdet/core/fp16/decorators.py | 160 + .../CDARTS_detection/mmdet/core/fp16/hooks.py | 126 + .../CDARTS_detection/mmdet/core/fp16/utils.py | 23 + .../mmdet/core/mask/__init__.py | 4 + .../mmdet/core/mask/mask_target.py | 36 + .../CDARTS_detection/mmdet/core/mask/utils.py | 30 + .../mmdet/core/post_processing/__init__.py | 8 + .../mmdet/core/post_processing/bbox_nms.py | 64 + .../mmdet/core/post_processing/merge_augs.py | 96 + .../mmdet/core/utils/__init__.py | 7 + .../mmdet/core/utils/dist_utils.py | 89 + .../CDARTS_detection/mmdet/core/utils/misc.py | 37 + .../mmdet/datasets/__init__.py | 17 + .../mmdet/datasets/builder.py | 41 + .../mmdet/datasets/cityscapes.py | 9 + .../CDARTS_detection/mmdet/datasets/coco.py | 372 + .../CDARTS_detection/mmdet/datasets/custom.py | 211 + .../mmdet/datasets/dataset_wrappers.py | 55 + .../mmdet/datasets/loader/__init__.py | 4 + .../mmdet/datasets/loader/build_loader.py | 101 + .../mmdet/datasets/loader/sampler.py | 201 + .../mmdet/datasets/pipelines/__init__.py | 16 + .../mmdet/datasets/pipelines/compose.py | 35 + .../mmdet/datasets/pipelines/formating.py | 186 + .../mmdet/datasets/pipelines/loading.py | 155 + .../mmdet/datasets/pipelines/test_aug.py | 37 + .../mmdet/datasets/pipelines/transforms.py | 853 ++ .../mmdet/datasets/registry.py | 4 + .../mmdet/datasets/transforms.py | 147 + .../CDARTS_detection/mmdet/datasets/utils.py | 68 + .../CDARTS_detection/mmdet/datasets/voc.py | 66 + .../mmdet/datasets/wider_face.py | 42 + .../mmdet/datasets/xml_style.py | 86 + .../CDARTS_detection/mmdet/ops/__init__.py | 19 + .../mmdet/ops/dcn/__init__.py | 13 + .../mmdet/ops/dcn/functions/__init__.py | 0 .../mmdet/ops/dcn/functions/deform_conv.py | 181 + .../mmdet/ops/dcn/functions/deform_pool.py | 69 + .../mmdet/ops/dcn/modules/__init__.py | 0 .../mmdet/ops/dcn/modules/deform_conv.py | 157 + .../mmdet/ops/dcn/modules/deform_pool.py | 172 + .../CDARTS_detection/mmdet/ops/dcn/setup.py | 15 + .../mmdet/ops/dcn/src/deform_conv_cuda.cpp | 695 ++ .../ops/dcn/src/deform_conv_cuda_kernel.cu | 866 ++ .../mmdet/ops/dcn/src/deform_pool_cuda.cpp | 87 + .../ops/dcn/src/deform_pool_cuda_kernel.cu | 364 + .../mmdet/ops/gcb/__init__.py | 5 + .../mmdet/ops/gcb/context_block.py | 104 + .../mmdet/ops/masked_conv/__init__.py | 4 + .../ops/masked_conv/functions/__init__.py | 0 .../ops/masked_conv/functions/masked_conv.py | 56 + .../mmdet/ops/masked_conv/modules/__init__.py | 0 .../ops/masked_conv/modules/masked_conv.py | 30 + .../mmdet/ops/masked_conv/setup.py | 12 + .../masked_conv/src/masked_conv2d_cuda.cpp | 74 + .../masked_conv/src/masked_conv2d_kernel.cu | 113 + .../mmdet/ops/nms/__init__.py | 3 + .../mmdet/ops/nms/nms_wrapper.py | 78 + .../CDARTS_detection/mmdet/ops/nms/setup.py | 84 + .../mmdet/ops/nms/src/nms_cpu.cpp | 71 + .../mmdet/ops/nms/src/nms_cuda.cpp | 17 + .../mmdet/ops/nms/src/nms_kernel.cu | 131 + .../mmdet/ops/nms/src/soft_nms_cpu.cpp | 10246 ++++++++++++++++ .../mmdet/ops/nms/src/soft_nms_cpu.pyx | 127 + .../mmdet/ops/roi_align/__init__.py | 3 + .../mmdet/ops/roi_align/functions/__init__.py | 0 .../ops/roi_align/functions/roi_align.py | 61 + .../mmdet/ops/roi_align/gradcheck.py | 30 + .../mmdet/ops/roi_align/modules/__init__.py | 0 .../mmdet/ops/roi_align/modules/roi_align.py | 16 + .../mmdet/ops/roi_align/roi_align.py | 87 + .../mmdet/ops/roi_align/setup.py | 12 + .../ops/roi_align/src/roi_align_cuda.cpp | 85 + .../ops/roi_align/src/roi_align_kernel.cu | 282 + .../mmdet/ops/roi_pool/__init__.py | 4 + .../mmdet/ops/roi_pool/functions/__init__.py | 0 .../mmdet/ops/roi_pool/functions/roi_pool.py | 55 + .../mmdet/ops/roi_pool/gradcheck.py | 15 + .../mmdet/ops/roi_pool/modules/__init__.py | 0 .../mmdet/ops/roi_pool/modules/roi_pool.py | 14 + .../mmdet/ops/roi_pool/setup.py | 12 + .../mmdet/ops/roi_pool/src/roi_pool_cuda.cpp | 86 + .../mmdet/ops/roi_pool/src/roi_pool_kernel.cu | 156 + .../mmdet/ops/sigmoid_focal_loss/__init__.py | 3 + .../sigmoid_focal_loss/functions/__init__.py | 0 .../functions/sigmoid_focal_loss.py | 34 + .../sigmoid_focal_loss/modules/__init__.py | 0 .../modules/sigmoid_focal_loss.py | 24 + .../mmdet/ops/sigmoid_focal_loss/setup.py | 12 + .../src/sigmoid_focal_loss.cpp | 43 + .../src/sigmoid_focal_loss_cuda.cu | 169 + .../CDARTS_detection/mmdet/utils/__init__.py | 10 + .../mmdet/utils/collect_env.py | 63 + .../mmdet/utils/contextmanagers.py | 126 + .../mmdet/utils/flops_counter.py | 433 + .../CDARTS_detection/mmdet/utils/logger.py | 66 + .../CDARTS_detection/mmdet/utils/profiling.py | 41 + .../CDARTS_detection/mmdet/utils/registry.py | 76 + .../mmdet/utils/util_mixins.py | 105 + .../CDARTS/CDARTS_detection/mmdet/version.py | 5 + .../Cream/CDARTS/CDARTS_detection/setup.py | 112 + .../Cream/CDARTS/CDARTS_detection/test.py | 205 + .../CDARTS_detection/tools/analyze_logs.py | 178 + .../CDARTS_detection/tools/coco_eval.py | 28 + .../tools/convert_datasets/pascal_voc.py | 140 + .../tools/detectron2pytorch.py | 88 + .../CDARTS_detection/tools/get_flops.py | 52 + .../CDARTS_detection/tools/publish_model.py | 34 + .../CDARTS/CDARTS_detection/tools/test.py | 313 + .../tools/upgrade_model_version.py | 42 + .../CDARTS/CDARTS_detection/tools/voc_eval.py | 62 + .../Cream/CDARTS/CDARTS_detection/train.py | 112 + .../Cream/CDARTS/CDARTS_segmentation/LICENSE | 21 + .../CDARTS/CDARTS_segmentation/README.md | 48 + .../configs/ade/cydas.yaml | 37 + .../configs/cityscapes/cydas.yaml | 24 + .../dataloaders/__init__.py | 285 + .../dataloaders/custom_transforms.py | 326 + .../dataloaders/dataloader_utils.py | 104 + .../dataloaders/datasets/__init__.py | 0 .../dataloaders/datasets/cityscapes.py | 153 + .../dataloaders/datasets/coco.py | 160 + .../dataloaders/datasets/combine_dbs.py | 100 + .../dataloaders/datasets/kd.py | 139 + .../dataloaders/datasets/pascal.py | 144 + .../dataloaders/datasets/sbd.py | 128 + .../dataloaders/segdatasets/__init__.py | 4 + .../dataloaders/segdatasets/base_dataset.py | 182 + .../dataloaders/segdatasets/cityscapes.py | 150 + .../segdatasets/cityscapes_panoptic.py | 130 + .../dataloaders/segdatasets/coco_panoptic.py | 299 + .../dataloaders/segdatasets/utils.py | 18 + .../dataloaders/transforms/__init__.py | 3 + .../dataloaders/transforms/build.py | 57 + .../transforms/pre_augmentation_transforms.py | 92 + .../transforms/target_transforms.py | 200 + .../dataloaders/transforms/transforms.py | 172 + .../segmentation/__init__.py | 0 .../segmentation/config/__init__.py | 4 + .../segmentation/config/default.py | 306 + .../segmentation/config/hrnet_config.py | 130 + .../segmentation/data/__init__.py | 2 + .../segmentation/data/build.py | 159 + .../segmentation/data/datasets/__init__.py | 4 + .../data/datasets/base_dataset.py | 182 + .../segmentation/data/datasets/cityscapes.py | 150 + .../data/datasets/cityscapes_panoptic.py | 130 + .../data/datasets/coco_panoptic.py | 299 + .../segmentation/data/datasets/utils.py | 18 + .../segmentation/data/samplers/__init__.py | 1 + .../data/samplers/distributed_sampler.py | 90 + .../segmentation/data/transforms/__init__.py | 3 + .../segmentation/data/transforms/build.py | 57 + .../transforms/pre_augmentation_transforms.py | 92 + .../data/transforms/target_transforms.py | 200 + .../data/transforms/transforms.py | 172 + .../segmentation/evaluation/__init__.py | 5 + .../segmentation/evaluation/coco_instance.py | 107 + .../segmentation/evaluation/coco_panoptic.py | 137 + .../segmentation/evaluation/instance.py | 97 + .../segmentation/evaluation/panoptic.py | 127 + .../segmentation/evaluation/semantic.py | 106 + .../segmentation/model/__init__.py | 1 + .../segmentation/model/backbone/__init__.py | 5 + .../segmentation/model/backbone/hrnet.py | 526 + .../segmentation/model/backbone/mnasnet.py | 280 + .../segmentation/model/backbone/mobilenet.py | 214 + .../segmentation/model/backbone/resnet.py | 351 + .../segmentation/model/backbone/xception.py | 237 + .../segmentation/model/build.py | 133 + .../segmentation/model/decoder/__init__.py | 4 + .../segmentation/model/decoder/aspp.py | 76 + .../segmentation/model/decoder/conv_module.py | 73 + .../segmentation/model/decoder/deeplabv3.py | 37 + .../model/decoder/deeplabv3plus.py | 59 + .../model/decoder/panoptic_deeplab.py | 162 + .../segmentation/model/loss/__init__.py | 7 + .../segmentation/model/loss/criterion.py | 112 + .../segmentation/model/meta_arch/__init__.py | 3 + .../segmentation/model/meta_arch/base.py | 64 + .../segmentation/model/meta_arch/deeplabv3.py | 58 + .../model/meta_arch/deeplabv3plus.py | 63 + .../model/meta_arch/panoptic_deeplab.py | 135 + .../model/post_processing/__init__.py | 3 + .../post_processing/evaluation_format.py | 60 + .../instance_post_processing.py | 237 + .../semantic_post_processing.py | 25 + .../segmentation/solver/__init__.py | 3 + .../segmentation/solver/build.py | 185 + .../segmentation/solver/lr_scheduler.py | 162 + .../segmentation/solver/utils.py | 29 + .../segmentation/utils/__init__.py | 6 + .../segmentation/utils/comm.py | 257 + .../segmentation/utils/debug.py | 196 + .../segmentation/utils/env.py | 35 + .../segmentation/utils/flow_vis.py | 134 + .../segmentation/utils/logger.py | 219 + .../segmentation/utils/save_annotation.py | 360 + .../segmentation/utils/test_utils.py | 137 + .../segmentation/utils/utils.py | 52 + .../CDARTS_segmentation/tools/__init__.py | 0 .../tools/datasets/BaseDataset.py | 161 + .../tools/datasets/__init__.py | 6 + .../tools/datasets/bdd/__init__.py | 3 + .../tools/datasets/bdd/bdd.py | 41 + .../tools/datasets/camvid/__init__.py | 3 + .../tools/datasets/camvid/camvid.py | 17 + .../tools/datasets/cityscapes/__init__.py | 3 + .../tools/datasets/cityscapes/cityscapes.py | 42 + .../datasets/cityscapes/cityscapes_test.txt | 1525 +++ .../cityscapes/cityscapes_train_fine.txt | 2975 +++++ .../cityscapes/cityscapes_val_fine.txt | 500 + .../tools/datasets/coco/__init__.py | 3 + .../tools/datasets/coco/coco.py | 160 + .../tools/engine/__init__.py | 0 .../tools/engine/evaluator.py | 339 + .../tools/engine/logger.py | 90 + .../tools/engine/tester.py | 312 + .../tools/seg_opr/__init__.py | 0 .../tools/seg_opr/loss_opr.py | 199 + .../tools/seg_opr/metric.py | 87 + .../tools/utils/__init__.py | 0 .../tools/utils/cal_model.py | 216 + .../tools/utils/darts_utils.py | 352 + .../tools/utils/dist_utils.py | 81 + .../tools/utils/genotypes.py | 75 + .../tools/utils/img_utils.py | 185 + .../tools/utils/init_func.py | 67 + .../tools/utils/lr_scheduler.py | 56 + .../tools/utils/metrics.py | 46 + .../tools/utils/pyt_utils.py | 291 + .../tools/utils/visualize.py | 89 + .../tools/vis/panoptic_coco_categories.json | 1 + .../tools/vis/vis_cityscapes.py | 106 + .../CDARTS_segmentation/tools/vis/vis_coco.py | 103 + .../CDARTS_segmentation/train/_init_paths.py | 19 + .../CDARTS_segmentation/train/att_sa.py | 231 + .../CDARTS_segmentation/train/builder.py | 872 ++ .../CDARTS_segmentation/train/cal_model.py | 68 + .../CDARTS_segmentation/train/config_test.py | 77 + .../CDARTS_segmentation/train/config_train.py | 115 + .../train/configs/ADE20K/512.yaml | 42 + .../train/configs/ADE20K/base.yaml | 42 + .../Base-PanopticDeepLab-OS16.yaml | 65 + .../Cityscapes-PanopticSegmentation/base.yaml | 65 + ...s16_mg124_poly_90k_bs32_crop_512_1024.yaml | 20 + ...24_poly_90k_bs32_crop_512_1024_dsconv.yaml | 24 + .../CDARTS/CDARTS_segmentation/train/cydas.py | 435 + .../CDARTS_segmentation/train/dataloader.py | 93 + .../CDARTS/CDARTS_segmentation/train/eval.py | 68 + .../CDARTS_segmentation/train/genotypes.py | 13 + .../train/latency_lookup_table.npy | Bin 0 -> 50122 bytes .../CDARTS_segmentation/train/launch.py | 274 + .../CDARTS_segmentation/train/layers.py | 116 + .../CDARTS/CDARTS_segmentation/train/loss.py | 81 + .../CDARTS_segmentation/train/operations.py | 948 ++ .../CDARTS_segmentation/train/seg_metrics.py | 98 + .../CDARTS_segmentation/train/seg_oprs.py | 558 + .../train/slimmable_ops.py | 72 + .../CDARTS/CDARTS_segmentation/train/test.py | 84 + .../CDARTS_segmentation/train/test_seg.py | 191 + .../train/train_ade20k_cydas.py | 569 + .../CDARTS_segmentation/train/train_cydas.py | 516 + .../CDARTS_segmentation/train/vis_arch.py | 44 + .../SwinS3/Cream/CDARTS/LICENSE | 23 + .../SwinS3/Cream/CDARTS/README.md | 67 + .../SwinS3/Cream/CDARTS/SETUP.md | 137 + .../Cream/CDARTS/benchmark201/README.md | 10 + .../CDARTS/benchmark201/configs/config.py | 228 + .../benchmark201/core/augment_function.py | 130 + .../benchmark201/core/pretrain_function.py | 342 + .../benchmark201/core/search_function.py | 241 + .../CDARTS/benchmark201/datasets/cifar.py | 103 + .../benchmark201/datasets/data_utils.py | 393 + .../CDARTS/benchmark201/datasets/imagenet.py | 102 + .../Cream/CDARTS/benchmark201/search.py | 250 + .../search/cifar10-search/tb/readme.md | 0 .../search/imagenet-search/tb/readme.md | 0 .../CDARTS/benchmark201/utils/genotypes.py | 352 + .../CDARTS/benchmark201/utils/get_info.py | 41 + .../Cream/CDARTS/benchmark201/utils/utils.py | 134 + .../CDARTS/benchmark201/utils/visualize.py | 74 + .../SwinS3/Cream/CDARTS/demo/NATS_bench.png | Bin 0 -> 316887 bytes .../SwinS3/Cream/CDARTS/demo/ade.png | Bin 0 -> 101208 bytes .../SwinS3/Cream/CDARTS/demo/cell.png | Bin 0 -> 192864 bytes .../SwinS3/Cream/CDARTS/demo/cell_cifar.png | Bin 0 -> 378109 bytes .../Cream/CDARTS/demo/cell_imagenet.png | Bin 0 -> 277590 bytes .../SwinS3/Cream/CDARTS/demo/chain.png | Bin 0 -> 235975 bytes .../SwinS3/Cream/CDARTS/demo/chain_arch.png | Bin 0 -> 242528 bytes .../SwinS3/Cream/CDARTS/demo/city.png | Bin 0 -> 158042 bytes .../SwinS3/Cream/CDARTS/demo/coco.png | Bin 0 -> 245944 bytes .../SwinS3/Cream/CDARTS/demo/framework1.png | Bin 0 -> 140404 bytes .../SwinS3/Cream/CDARTS/demo/framework2.png | Bin 0 -> 112057 bytes .../retrain/cifar10-retrain/tb/readme.md | 0 .../retrain/imagenet-retrain/tb/readme.md | 0 .../search/cifar10-search/tb/readme.md | 0 .../search/imagenet-search/tb/readme.md | 0 .../SwinS3/Cream/CDARTS/lib/config.py | 229 + .../Cream/CDARTS/lib/core/augment_function.py | 130 + .../CDARTS/lib/core/pretrain_function.py | 342 + .../Cream/CDARTS/lib/core/search_function.py | 254 + .../SwinS3/Cream/CDARTS/lib/datasets/cifar.py | 102 + .../Cream/CDARTS/lib/datasets/data_utils.py | 393 + .../Cream/CDARTS/lib/datasets/imagenet.py | 102 + .../Cream/CDARTS/lib/utils/count_flops.py | 46 + .../Cream/CDARTS/lib/utils/genotypes.py | 159 + .../SwinS3/Cream/CDARTS/lib/utils/utils.py | 117 + .../Cream/CDARTS/lib/utils/visualize.py | 74 + .../SwinS3/Cream/CDARTS/requirements | 5 + .../SwinS3/Cream/CODE_OF_CONDUCT.md | 9 + .../SwinS3/Cream/Cream/README.md | 148 + .../SwinS3/Cream/Cream/data/subclass_list.txt | 100 + .../Cream/Cream/data/subimages_list.txt | 100 + .../SwinS3/Cream/Cream/demo/intro.jpg | Bin 0 -> 329132 bytes .../SwinS3/Cream/Cream/demo/results_100.jpg | Bin 0 -> 124175 bytes .../SwinS3/Cream/Cream/demo/results_600.jpg | Bin 0 -> 122136 bytes .../experiments/configs/retrain/114.yaml | 51 + .../Cream/experiments/configs/retrain/14.yaml | 51 + .../Cream/experiments/configs/retrain/23.yaml | 51 + .../experiments/configs/retrain/287.yaml | 51 + .../Cream/experiments/configs/retrain/43.yaml | 51 + .../experiments/configs/retrain/481.yaml | 51 + .../experiments/configs/retrain/604.yaml | 51 + .../Cream/experiments/configs/retrain/72.yaml | 51 + .../experiments/configs/retrain/retrain.yaml | 51 + .../Cream/experiments/configs/test/test.yaml | 37 + .../experiments/configs/train/train.yaml | 53 + .../experiments/workspace/retrain/README.md | 1 + .../experiments/workspace/test/README.md | 1 + .../experiments/workspace/train/README.md | 1 + .../SwinS3/Cream/Cream/lib/config.py | 120 + .../SwinS3/Cream/Cream/lib/core/retrain.py | 136 + .../SwinS3/Cream/Cream/lib/core/test.py | 87 + .../SwinS3/Cream/Cream/lib/core/train.py | 212 + .../Cream/Cream/lib/utils/builder_util.py | 273 + .../Cream/Cream/lib/utils/flops_table.py | 84 + .../Cream/Cream/lib/utils/op_by_layer_dict.py | 42 + .../lib/utils/search_structure_supernet.py | 48 + .../SwinS3/Cream/Cream/lib/utils/util.py | 176 + .../SwinS3/Cream/Cream/requirements | 12 + .../SwinS3/Cream/Cream/tools/_init_paths.py | 26 + .../Cream/Cream/tools/generate_subImageNet.py | 48 + .../SwinS3/Cream/Cream/tools/main.py | 56 + .../SwinS3/Cream/Cream/tools/retrain.py | 318 + .../SwinS3/Cream/Cream/tools/test.py | 158 + .../SwinS3/Cream/Cream/tools/train.py | 239 + .../SwinS3/Cream/EfficientViT/LICENSE | 37 + .../SwinS3/Cream/EfficientViT/README.md | 76 + .../EfficientViT/classification/README.md | 255 + .../classification/data/__init__.py | 0 .../classification/data/datasets.py | 140 + .../classification/data/samplers.py | 64 + .../classification/data/threeaugment.py | 121 + .../EfficientViT/classification/engine.py | 106 + .../EfficientViT/classification/losses.py | 64 + .../Cream/EfficientViT/classification/main.py | 451 + .../classification/model/__init__.py | 0 .../classification/model/build.py | 183 + .../classification/model/efficientvit.py | 356 + .../classification/requirements.txt | 11 + .../EfficientViT/classification/speed_test.py | 95 + .../EfficientViT/classification/utils.py | 285 + .../Cream/EfficientViT/downstream/README.md | 128 + .../_base_/datasets/cityscapes_detection.py | 55 + .../_base_/datasets/cityscapes_instance.py | 55 + .../configs/_base_/datasets/coco_detection.py | 48 + .../configs/_base_/datasets/coco_instance.py | 48 + .../_base_/datasets/coco_instance_semantic.py | 53 + .../configs/_base_/datasets/deepfashion.py | 53 + .../_base_/datasets/lvis_v0.5_instance.py | 23 + .../_base_/datasets/lvis_v1_instance.py | 23 + .../configs/_base_/datasets/voc0712.py | 55 + .../configs/_base_/datasets/wider_face.py | 63 + .../configs/_base_/default_runtime.py | 16 + .../configs/_base_/schedules/schedule_1x.py | 11 + .../configs/_base_/schedules/schedule_20e.py | 11 + .../configs/_base_/schedules/schedule_2x.py | 11 + .../mask_rcnn_efficientvit_m4_fpn_1x_coco.py | 40 + .../retinanet_efficientvit_m4_fpn_1x_coco.py | 40 + .../EfficientViT/downstream/dist_test.sh | 10 + .../EfficientViT/downstream/dist_train.sh | 9 + .../EfficientViT/downstream/efficientvit.py | 544 + .../downstream/efficientvit_fpn.py | 288 + .../downstream/mmcv_custom/__init__.py | 5 + .../downstream/mmcv_custom/checkpoint.py | 500 + .../downstream/mmcv_custom/runner/__init__.py | 8 + .../mmcv_custom/runner/checkpoint.py | 85 + .../mmcv_custom/runner/epoch_based_runner.py | 104 + .../mmcv_custom/runner/optimizer.py | 33 + .../downstream/mmdet_custom/apis/train.py | 184 + .../Cream/EfficientViT/downstream/test.py | 242 + .../Cream/EfficientViT/downstream/train.py | 245 + .../Classification/SwinS3/Cream/LICENSE | 23 + .../SwinS3/Cream/MiniViT/Mini-DeiT/LICENSE | 199 + .../SwinS3/Cream/MiniViT/Mini-DeiT/README.md | 123 + .../Cream/MiniViT/Mini-DeiT/datasets.py | 110 + .../SwinS3/Cream/MiniViT/Mini-DeiT/engine.py | 94 + .../SwinS3/Cream/MiniViT/Mini-DeiT/irpe.py | 937 ++ .../SwinS3/Cream/MiniViT/Mini-DeiT/losses.py | 63 + .../SwinS3/Cream/MiniViT/Mini-DeiT/main.py | 440 + .../MiniViT/Mini-DeiT/mini_deit_models.py | 59 + .../Mini-DeiT/mini_vision_transformer.py | 318 + .../SwinS3/Cream/MiniViT/Mini-DeiT/models.py | 177 + .../Cream/MiniViT/Mini-DeiT/requirements.txt | 4 + .../Cream/MiniViT/Mini-DeiT/rpe_ops/README.md | 35 + .../MiniViT/Mini-DeiT/rpe_ops/rpe_index.cpp | 142 + .../MiniViT/Mini-DeiT/rpe_ops/rpe_index.py | 100 + .../Mini-DeiT/rpe_ops/rpe_index_cuda.cu | 140 + .../Cream/MiniViT/Mini-DeiT/rpe_ops/setup.py | 25 + .../Cream/MiniViT/Mini-DeiT/samplers.py | 57 + .../SwinS3/Cream/MiniViT/Mini-DeiT/utils.py | 236 + .../SwinS3/Cream/MiniViT/Mini-Swin/LICENSE | 21 + .../SwinS3/Cream/MiniViT/Mini-Swin/README.md | 119 + .../SwinS3/Cream/MiniViT/Mini-Swin/config.py | 320 + .../swin_base_patch4_window12_384.yaml | 13 + .../configs/swin_base_patch4_window7_224.yaml | 9 + ..._patch4_window7_224_minivit_sharenum2.yaml | 11 + ...dow7_224to384_minivit_sharenum2_adamw.yaml | 19 + .../swin_large_patch4_window12_384.yaml | 13 + .../swin_large_patch4_window7_224.yaml | 9 + .../swin_small_patch4_window7_224.yaml | 9 + ..._patch4_window7_224_minivit_sharenum2.yaml | 11 + .../configs/swin_tiny_patch4_window7_224.yaml | 9 + ..._patch4_window7_224_minivit_sharenum6.yaml | 11 + .../Cream/MiniViT/Mini-Swin/data/__init__.py | 1 + .../Cream/MiniViT/Mini-Swin/data/build.py | 130 + .../Mini-Swin/data/cached_image_folder.py | 244 + .../Cream/MiniViT/Mini-Swin/data/samplers.py | 22 + .../Cream/MiniViT/Mini-Swin/data/zipreader.py | 96 + .../SwinS3/Cream/MiniViT/Mini-Swin/logger.py | 34 + .../Cream/MiniViT/Mini-Swin/lr_scheduler.py | 95 + .../SwinS3/Cream/MiniViT/Mini-Swin/main.py | 590 + .../Cream/MiniViT/Mini-Swin/my_meter.py | 32 + .../Cream/MiniViT/Mini-Swin/optimizer.py | 50 + .../Cream/MiniViT/Mini-Swin/requirements.txt | 5 + .../SwinS3/Cream/MiniViT/Mini-Swin/utils.py | 237 + .../SwinS3/Cream/MiniViT/README.md | 58 + .../Classification/SwinS3/Cream/README.md | 193 + .../Classification/SwinS3/Cream/SECURITY.md | 41 + .../SwinS3/Cream/TinyCLIP/LICENSE | 33 + .../SwinS3/Cream/TinyCLIP/MANIFEST.in | 3 + .../SwinS3/Cream/TinyCLIP/Makefile | 9 + .../SwinS3/Cream/TinyCLIP/README.md | 77 + .../SwinS3/Cream/TinyCLIP/docs/EVALUATION.md | 134 + .../SwinS3/Cream/TinyCLIP/docs/PREPARATION.md | 35 + .../SwinS3/Cream/TinyCLIP/docs/PRETRAINING.md | 28 + .../SwinS3/Cream/TinyCLIP/figure/TinyCLIP.jpg | Bin 0 -> 356005 bytes .../SwinS3/Cream/TinyCLIP/figure/fig1.jpg | Bin 0 -> 124003 bytes .../SwinS3/Cream/TinyCLIP/inference.py | 38 + .../Cream/TinyCLIP/requirements-test.txt | 2 + .../Cream/TinyCLIP/requirements-training.txt | 11 + .../SwinS3/Cream/TinyCLIP/requirements.txt | 7 + .../script/auto_weight_inherit_100to75.sh | 35 + .../script/auto_weight_inherit_50to25.sh | 37 + .../script/auto_weight_inherit_75to50.sh | 37 + .../script/manual_weight_inherit_100to75.sh | 28 + .../script/manual_weight_inherit_75to50.sh | 28 + .../SwinS3/Cream/TinyCLIP/setup.py | 57 + .../Cream/TinyCLIP/src/data/gather_cc.py | 93 + .../Cream/TinyCLIP/src/open_clip/__init__.py | 11 + .../open_clip/bpe_simple_vocab_16e6.txt.gz | Bin 0 -> 1356917 bytes .../TinyCLIP/src/open_clip/clip_soft_loss.py | 88 + .../Cream/TinyCLIP/src/open_clip/constants.py | 2 + .../Cream/TinyCLIP/src/open_clip/factory.py | 234 + .../src/open_clip/imagenet_zeroshot_data.py | 251 + .../Cream/TinyCLIP/src/open_clip/l0module.py | 368 + .../Cream/TinyCLIP/src/open_clip/loss.py | 165 + .../Cream/TinyCLIP/src/open_clip/model.py | 1408 +++ .../src/open_clip/model_configs/RN50.json | 21 + .../TinyCLIP-ResNet-19M-Text-19M.json | 21 + .../TinyCLIP-ResNet-30M-Text-29M.json | 21 + .../TinyCLIP-ViT-39M-16-Text-19M.json | 16 + .../TinyCLIP-ViT-40M-32-Text-19M.json | 16 + .../TinyCLIP-ViT-61M-32-Text-29M.json | 16 + .../TinyCLIP-ViT-8M-16-Text-3M.json | 16 + .../src/open_clip/model_configs/ViT-B-16.json | 16 + .../src/open_clip/model_configs/ViT-B-32.json | 16 + .../Cream/TinyCLIP/src/open_clip/openai.py | 138 + .../TinyCLIP/src/open_clip/pretrained.py | 378 + .../Cream/TinyCLIP/src/open_clip/resnet.py | 187 + .../TinyCLIP/src/open_clip/timm_model.py | 122 + .../Cream/TinyCLIP/src/open_clip/tokenizer.py | 215 + .../Cream/TinyCLIP/src/open_clip/transform.py | 123 + .../Cream/TinyCLIP/src/open_clip/utils.py | 62 + .../Cream/TinyCLIP/src/open_clip/version.py | 1 + .../TinyCLIP/src/open_clip/weight_inherit.py | 203 + .../Cream/TinyCLIP/src/training/__init__.py | 0 .../Cream/TinyCLIP/src/training/data.py | 590 + .../TinyCLIP/src/training/distributed.py | 120 + .../Cream/TinyCLIP/src/training/logger.py | 27 + .../TinyCLIP/src/training/loss_scaler.py | 49 + .../Cream/TinyCLIP/src/training/main.py | 564 + .../TinyCLIP/src/training/main_for_test.py | 415 + .../Cream/TinyCLIP/src/training/my_meter.py | 72 + .../Cream/TinyCLIP/src/training/optimizer.py | 101 + .../Cream/TinyCLIP/src/training/params.py | 437 + .../Cream/TinyCLIP/src/training/precision.py | 15 + .../Cream/TinyCLIP/src/training/scheduler.py | 83 + .../Cream/TinyCLIP/src/training/train.py | 773 ++ .../SwinS3/Cream/TinyCLIP/src/training/viz.py | 66 + .../Cream/TinyCLIP/src/training/zero_shot.py | 162 + .../SwinS3/Cream/TinyViT/LICENSE | 38 + .../SwinS3/Cream/TinyViT/README.md | 124 + .../SwinS3/Cream/TinyViT/config.py | 252 + .../TinyViT/configs/1k/tiny_vit_11m.yaml | 11 + .../TinyViT/configs/1k/tiny_vit_21m.yaml | 11 + .../Cream/TinyViT/configs/1k/tiny_vit_5m.yaml | 11 + .../22k_distill/tiny_vit_11m_22k_distill.yaml | 24 + .../22k_distill/tiny_vit_21m_22k_distill.yaml | 24 + .../22k_distill/tiny_vit_5m_22k_distill.yaml | 24 + .../configs/22kto1k/tiny_vit_11m_22kto1k.yaml | 24 + .../configs/22kto1k/tiny_vit_21m_22kto1k.yaml | 24 + .../configs/22kto1k/tiny_vit_5m_22kto1k.yaml | 24 + .../tiny_vit_21m_224to384.yaml | 28 + .../tiny_vit_21m_384to512.yaml | 27 + .../teacher/clip_vit_large_patch14_22k.yaml | 13 + .../SwinS3/Cream/TinyViT/data/__init__.py | 2 + .../Cream/TinyViT/data/augmentation/README.md | 15 + .../TinyViT/data/augmentation/__init__.py | 12 + .../TinyViT/data/augmentation/aug_random.py | 69 + .../data/augmentation/aug_tv_transforms.py | 1100 ++ .../TinyViT/data/augmentation/auto_augment.py | 865 ++ .../Cream/TinyViT/data/augmentation/config.py | 78 + .../TinyViT/data/augmentation/constants.py | 7 + .../TinyViT/data/augmentation/dataset.py | 152 + .../data/augmentation/dataset_factory.py | 140 + .../data/augmentation/dataset_wrapper.py | 90 + .../data/augmentation/distributed_sampler.py | 129 + .../Cream/TinyViT/data/augmentation/loader.py | 289 + .../TinyViT/data/augmentation/manager.py | 153 + .../Cream/TinyViT/data/augmentation/mixup.py | 347 + .../data/augmentation/parsers/__init__.py | 1 + .../data/augmentation/parsers/class_map.py | 19 + .../data/augmentation/parsers/constants.py | 1 + .../data/augmentation/parsers/parser.py | 17 + .../augmentation/parsers/parser_factory.py | 29 + .../parsers/parser_image_folder.py | 69 + .../parsers/parser_image_in_tar.py | 222 + .../augmentation/parsers/parser_image_tar.py | 72 + .../data/augmentation/parsers/parser_tfds.py | 297 + .../data/augmentation/random_erasing.py | 121 + .../TinyViT/data/augmentation/real_labels.py | 42 + .../data/augmentation/tf_preprocessing.py | 232 + .../TinyViT/data/augmentation/transforms.py | 185 + .../data/augmentation/transforms_factory.py | 236 + .../SwinS3/Cream/TinyViT/data/build.py | 211 + .../Cream/TinyViT/data/imagenet22k_dataset.py | 79 + .../Cream/TinyViT/data/imagenet_classnames.py | 165 + .../SwinS3/Cream/TinyViT/data/sampler.py | 157 + .../SwinS3/Cream/TinyViT/docs/EVALUATION.md | 79 + .../SwinS3/Cream/TinyViT/docs/PREPARATION.md | 64 + .../Cream/TinyViT/docs/SAVE_TEACHER_LOGITS.md | 33 + .../SwinS3/Cream/TinyViT/docs/TRAINING.md | 55 + .../SwinS3/Cream/TinyViT/imagenet_1kto22k.txt | 1000 ++ .../SwinS3/Cream/TinyViT/inference.py | 34 + .../SwinS3/Cream/TinyViT/logger.py | 44 + .../SwinS3/Cream/TinyViT/lr_scheduler.py | 109 + .../SwinS3/Cream/TinyViT/main.py | 564 + .../SwinS3/Cream/TinyViT/my_meter.py | 74 + .../SwinS3/Cream/TinyViT/optimizer.py | 61 + .../SwinS3/Cream/TinyViT/requirements.txt | 4 + .../SwinS3/Cream/TinyViT/save_logits.py | 335 + .../SwinS3/Cream/TinyViT/tests/test_models.py | 66 + .../SwinS3/Cream/TinyViT/tinyvit_utils.py | 162 + .../SwinS3/Cream/TinyViT/utils.py | 347 + .../SwinS3/Cream/iRPE/DETR-with-iRPE/LICENSE | 201 + .../Cream/iRPE/DETR-with-iRPE/README.md | 177 + .../iRPE/DETR-with-iRPE/datasets/__init__.py | 25 + .../iRPE/DETR-with-iRPE/datasets/coco.py | 217 + .../iRPE/DETR-with-iRPE/datasets/coco_eval.py | 257 + .../DETR-with-iRPE/datasets/coco_panoptic.py | 99 + .../DETR-with-iRPE/datasets/panoptic_eval.py | 44 + .../DETR-with-iRPE/datasets/transforms.py | 276 + .../Cream/iRPE/DETR-with-iRPE/engine.py | 151 + .../SwinS3/Cream/iRPE/DETR-with-iRPE/main.py | 253 + .../iRPE/DETR-with-iRPE/requirements.txt | 9 + .../iRPE/DETR-with-iRPE/rpe_ops/README.md | 35 + .../iRPE/DETR-with-iRPE/rpe_ops/rpe_index.cpp | 142 + .../iRPE/DETR-with-iRPE/rpe_ops/rpe_index.py | 100 + .../DETR-with-iRPE/rpe_ops/rpe_index_cuda.cu | 140 + .../iRPE/DETR-with-iRPE/rpe_ops/setup.py | 25 + .../iRPE/DETR-with-iRPE/run_with_submitit.py | 111 + .../iRPE/DETR-with-iRPE/util/__init__.py | 1 + .../Cream/iRPE/DETR-with-iRPE/util/box_ops.py | 88 + .../Cream/iRPE/DETR-with-iRPE/util/misc.py | 467 + .../iRPE/DETR-with-iRPE/util/plot_utils.py | 107 + .../SwinS3/Cream/iRPE/DeiT-with-iRPE/LICENSE | 201 + .../Cream/iRPE/DeiT-with-iRPE/README.md | 114 + .../Cream/iRPE/DeiT-with-iRPE/datasets.py | 109 + .../Cream/iRPE/DeiT-with-iRPE/engine.py | 96 + .../Cream/iRPE/DeiT-with-iRPE/hubconf.py | 5 + .../SwinS3/Cream/iRPE/DeiT-with-iRPE/irpe.py | 937 ++ .../Cream/iRPE/DeiT-with-iRPE/losses.py | 65 + .../SwinS3/Cream/iRPE/DeiT-with-iRPE/main.py | 439 + .../Cream/iRPE/DeiT-with-iRPE/models.py | 179 + .../iRPE/DeiT-with-iRPE/requirements.txt | 4 + .../Cream/iRPE/DeiT-with-iRPE/rpe_models.py | 202 + .../iRPE/DeiT-with-iRPE/rpe_ops/README.md | 35 + .../iRPE/DeiT-with-iRPE/rpe_ops/rpe_index.cpp | 142 + .../iRPE/DeiT-with-iRPE/rpe_ops/rpe_index.py | 100 + .../DeiT-with-iRPE/rpe_ops/rpe_index_cuda.cu | 140 + .../iRPE/DeiT-with-iRPE/rpe_ops/setup.py | 25 + .../DeiT-with-iRPE/rpe_vision_transformer.py | 201 + .../iRPE/DeiT-with-iRPE/run_with_submitit.py | 126 + .../Cream/iRPE/DeiT-with-iRPE/samplers.py | 59 + .../SwinS3/Cream/iRPE/DeiT-with-iRPE/tox.ini | 3 + .../SwinS3/Cream/iRPE/DeiT-with-iRPE/utils.py | 238 + .../SwinS3/Cream/iRPE/HOW_TO_EQUIP_iRPE.md | 91 + .../SwinS3/Cream/iRPE/README.md | 64 + .../Classification/SwinS3/Cream/iRPE/iRPE.png | Bin 0 -> 101216 bytes .../Classification/SwinS3/coverage.txt | 3 + PyTorch/build-in/Classification/SwinS3/run | 1 + .../build-in/Classification/SwinS3/swin.py | 628 + .../Classification/SwinS3/swin_loss.jpg | Bin 0 -> 36362 bytes .../Classification/SwinS3/swin_loss.txt | 29 + .../Classification/SwinS3/weloTrainStep.py | 692 ++ 776 files changed, 110939 insertions(+) create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/evolution.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-B.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-S.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-T.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-B.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-S.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-T.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/datasets.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/imagenet_withhold.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/subImageNet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/Linear_super.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/embedding_super.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/layernorm_super.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/multihead_super.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/qkv_super.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/supernet_transformer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-B.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-S.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-T.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/evaluation.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/datasets.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/model/SSS.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/_init_paths.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/cifar_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv1_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv2_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/imagenet_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_cifar_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_imagenet_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pdarts_genotype.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/retrain.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/search.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/configs/CyDAS_retinanet_1x.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/quantization.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/resnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/vgg.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/weight_init.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/base.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/json_handler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/pickle_handler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/yaml_handler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/io.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/io.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/normalize.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/resize.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/opencv_info.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/_functions.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/collate.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_container.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_parallel.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/distributed.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/scatter_gather.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/checkpoint.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/dist_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/hook.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/iter_timer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/pavi.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/tensorboard.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/text.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/lr_updater.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/memory.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/optimizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/log_buffer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/parallel_test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/priority.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/misc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/progressbar.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/timer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/version.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/io.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.hpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/color.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/image.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/env.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/inference.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_generator.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_target.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assign_sampling.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/approx_max_iou_assigner.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/assign_result.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/base_assigner.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/bbox_target.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/geometry.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/ohem_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/random_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/sampling_result.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/bbox_overlaps.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/class_names.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/eval_hooks.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/mean_ap.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/recall.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/hooks.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/bbox_nms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/merge_augs.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/dist_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/builder.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/dataset_wrappers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/build_loader.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/compose.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/formating.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/loading.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/test_aug.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/voc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_conv.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_conv.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_pool.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/context_block.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/masked_conv.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/masked_conv.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/nms_wrapper.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cpu.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.pyx create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/roi_align.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/gradcheck.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/roi_align.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/gradcheck.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/roi_pool.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_kernel.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/contextmanagers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/flops_counter.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/util_mixins.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/version.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/analyze_logs.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/coco_eval.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/convert_datasets/pascal_voc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/detectron2pytorch.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/get_flops.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/publish_model.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/upgrade_model_version.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/voc_eval.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/ade/cydas.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/cityscapes/cydas.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/dataloader_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/combine_dbs.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/kd.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/sbd.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/base_dataset.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/coco_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/pre_augmentation_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/target_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/default.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/base_dataset.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/coco_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/distributed_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/pre_augmentation_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/target_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/hrnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mobilenet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/resnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/xception.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/aspp.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3plus.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/panoptic_deeplab.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/base.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/panoptic_deeplab.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/evaluation_format.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/instance_post_processing.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/semantic_post_processing.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/lr_scheduler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/env.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/flow_vis.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/test_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/BaseDataset.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/bdd.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/camvid.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_test.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_train_fine.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_val_fine.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/evaluator.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/tester.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/loss_opr.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/cal_model.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/darts_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/img_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/init_func.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/lr_scheduler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/pyt_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/visualize.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/panoptic_coco_categories.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_cityscapes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/_init_paths.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/att_sa.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/builder.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cal_model.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/base.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/base.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cydas.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/dataloader.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/eval.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/genotypes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/latency_lookup_table.npy create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/launch.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/layers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/loss.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/operations.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/slimmable_ops.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test_seg.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_cydas.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/vis_arch.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/SETUP.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/configs/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/augment_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/pretrain_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/search_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/cifar.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/data_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/imagenet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/cifar10-search/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/imagenet-search/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/genotypes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/get_info.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/visualize.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/NATS_bench.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/ade.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/cell.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/cell_cifar.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/cell_imagenet.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/chain.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/chain_arch.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/city.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/coco.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/framework1.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/framework2.png create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/experiments/retrain/cifar10-retrain/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/experiments/retrain/imagenet-retrain/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/experiments/search/cifar10-search/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/experiments/search/imagenet-search/tb/readme.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/core/augment_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/core/pretrain_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/core/search_function.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/datasets/cifar.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/datasets/data_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/datasets/imagenet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/utils/count_flops.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/utils/genotypes.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/utils/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/lib/utils/visualize.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/requirements create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/CODE_OF_CONDUCT.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/data/subclass_list.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/data/subimages_list.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/demo/intro.jpg create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/demo/results_100.jpg create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/demo/results_600.jpg create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/114.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/14.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/23.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/287.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/43.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/481.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/604.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/72.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/retrain/retrain.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/test/test.yaml create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/configs/train/train.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/workspace/retrain/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/workspace/test/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/experiments/workspace/train/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/config.py create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/core/retrain.py create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/core/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/core/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/utils/builder_util.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/utils/flops_table.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/utils/op_by_layer_dict.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/utils/search_structure_supernet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/lib/utils/util.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/requirements create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/_init_paths.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/generate_subImageNet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/main.py create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/retrain.py create mode 100755 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/Cream/tools/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/data/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/data/datasets.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/data/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/data/threeaugment.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/losses.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/model/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/model/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/model/efficientvit.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/speed_test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/classification/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/cityscapes_detection.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/cityscapes_instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/coco_detection.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/coco_instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/coco_instance_semantic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/deepfashion.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/lvis_v0.5_instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/lvis_v1_instance.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/voc0712.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/datasets/wider_face.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/default_runtime.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/schedules/schedule_1x.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/schedules/schedule_20e.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/_base_/schedules/schedule_2x.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/mask_rcnn_efficientvit_m4_fpn_1x_coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/configs/retinanet_efficientvit_m4_fpn_1x_coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/dist_test.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/dist_train.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/efficientvit.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/efficientvit_fpn.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/checkpoint.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/runner/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/runner/checkpoint.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/runner/epoch_based_runner.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmcv_custom/runner/optimizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/mmdet_custom/apis/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/EfficientViT/downstream/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/datasets.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/irpe.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/losses.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/mini_deit_models.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/mini_vision_transformer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/models.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/rpe_ops/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/rpe_ops/rpe_index.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/rpe_ops/rpe_index.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/rpe_ops/rpe_index_cuda.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/rpe_ops/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-DeiT/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window12_384.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window7_224.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window7_224_minivit_sharenum2.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_base_patch4_window7_224to384_minivit_sharenum2_adamw.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_large_patch4_window12_384.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_large_patch4_window7_224.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_small_patch4_window7_224.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_small_patch4_window7_224_minivit_sharenum2.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_tiny_patch4_window7_224.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/configs/swin_tiny_patch4_window7_224_minivit_sharenum6.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/data/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/data/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/data/cached_image_folder.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/data/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/data/zipreader.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/lr_scheduler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/my_meter.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/optimizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/Mini-Swin/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/MiniViT/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/SECURITY.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/MANIFEST.in create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/Makefile create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/docs/EVALUATION.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/docs/PREPARATION.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/docs/PRETRAINING.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/figure/TinyCLIP.jpg create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/figure/fig1.jpg create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/inference.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/requirements-test.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/requirements-training.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/script/auto_weight_inherit_100to75.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/script/auto_weight_inherit_50to25.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/script/auto_weight_inherit_75to50.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/script/manual_weight_inherit_100to75.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/script/manual_weight_inherit_75to50.sh create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/data/gather_cc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/bpe_simple_vocab_16e6.txt.gz create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/clip_soft_loss.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/constants.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/factory.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/imagenet_zeroshot_data.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/l0module.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/loss.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/RN50.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ResNet-19M-Text-19M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ResNet-30M-Text-29M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ViT-39M-16-Text-19M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ViT-40M-32-Text-19M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ViT-61M-32-Text-29M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/TinyCLIP-ViT-8M-16-Text-3M.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/ViT-B-16.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/model_configs/ViT-B-32.json create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/openai.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/pretrained.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/resnet.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/timm_model.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/tokenizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/transform.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/version.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/open_clip/weight_inherit.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/data.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/distributed.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/loss_scaler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/main_for_test.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/my_meter.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/optimizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/params.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/precision.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/scheduler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/train.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/viz.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyCLIP/src/training/zero_shot.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/1k/tiny_vit_11m.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/1k/tiny_vit_21m.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/1k/tiny_vit_5m.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22k_distill/tiny_vit_11m_22k_distill.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22k_distill/tiny_vit_21m_22k_distill.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22k_distill/tiny_vit_5m_22k_distill.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22kto1k/tiny_vit_11m_22kto1k.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22kto1k/tiny_vit_21m_22kto1k.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/22kto1k/tiny_vit_5m_22kto1k.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/higher_resolution/tiny_vit_21m_224to384.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/higher_resolution/tiny_vit_21m_384to512.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/configs/teacher/clip_vit_large_patch14_22k.yaml create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/aug_random.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/aug_tv_transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/auto_augment.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/config.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/constants.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/dataset.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/dataset_factory.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/dataset_wrapper.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/distributed_sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/loader.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/manager.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/mixup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/class_map.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/constants.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser_factory.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser_image_folder.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser_image_in_tar.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser_image_tar.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/parsers/parser_tfds.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/random_erasing.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/real_labels.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/tf_preprocessing.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/augmentation/transforms_factory.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/build.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/imagenet22k_dataset.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/imagenet_classnames.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/data/sampler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/docs/EVALUATION.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/docs/PREPARATION.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/docs/SAVE_TEACHER_LOGITS.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/docs/TRAINING.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/imagenet_1kto22k.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/inference.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/logger.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/lr_scheduler.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/my_meter.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/optimizer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/save_logits.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/tests/test_models.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/tinyvit_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/TinyViT/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/coco.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/coco_eval.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/coco_panoptic.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/panoptic_eval.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/datasets/transforms.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/rpe_ops/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/rpe_ops/rpe_index.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/rpe_ops/rpe_index.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/rpe_ops/rpe_index_cuda.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/rpe_ops/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/run_with_submitit.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/util/__init__.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/util/box_ops.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/util/misc.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DETR-with-iRPE/util/plot_utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/LICENSE create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/datasets.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/engine.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/hubconf.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/irpe.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/losses.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/main.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/models.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/requirements.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_models.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_ops/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_ops/rpe_index.cpp create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_ops/rpe_index.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_ops/rpe_index_cuda.cu create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_ops/setup.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/rpe_vision_transformer.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/run_with_submitit.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/samplers.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/tox.ini create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/DeiT-with-iRPE/utils.py create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/HOW_TO_EQUIP_iRPE.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/README.md create mode 100644 PyTorch/build-in/Classification/SwinS3/Cream/iRPE/iRPE.png create mode 100644 PyTorch/build-in/Classification/SwinS3/coverage.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/run create mode 100644 PyTorch/build-in/Classification/SwinS3/swin.py create mode 100644 PyTorch/build-in/Classification/SwinS3/swin_loss.jpg create mode 100644 PyTorch/build-in/Classification/SwinS3/swin_loss.txt create mode 100644 PyTorch/build-in/Classification/SwinS3/weloTrainStep.py diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/README.md new file mode 100644 index 000000000..80bd16c76 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/README.md @@ -0,0 +1,124 @@ +# AutoFormer: Searching Transformers for Visual Recognition + +**This is an official implementation of AutoFormer.** + +AutoFormer is new one-shot architecture search framework dedicated to vision transformer search. It entangles the weights of different vision transformer blocks in the same layers during supernet training. +Benefiting from the strategy, the trained supernet allows thousands of subnets to be very well-trained. Specifically, the performance of these subnets with weights inherited from the supernet is comparable to those retrained from scratch. + +
+ AutoFormer overview + AutoFormer detail +
+ + +## Highlights +- Once-for-all + +AutoFormer is a simple yet effective method to train a once-for-all vision transformer supernet. + +- Competive performance + +AutoFormers consistently outperform DeiTs. + +## Environment Setup + +To set up the enviroment you can easily run the following command: +```buildoutcfg +conda create -n Autoformer python=3.6 +conda activate Autoformer +pip install -r requirements.txt +``` + +## Data Preparation +You need to first download the [ImageNet-2012](http://www.image-net.org/) to the folder `./data/imagenet` and move the validation set to the subfolder `./data/imagenet/val`. To move the validation set, you cloud use the following script: + +The directory structure is the standard layout as following. +``` +/path/to/imagenet/ + train/ + class1/ + img1.jpeg + class2/ + img2.jpeg + val/ + class1/ + img3.jpeg + class/2 + img4.jpeg +``` + + +## Model Zoo +For evaluation, we provide the checkpoints of our models in [Google Drive](https://drive.google.com/drive/folders/1HqzY3afqQUMI6pJ5_BgR2RquJU_b_3eg?usp=sharing) and [GitHub](https://github.com/silent-chen/AutoFormer-model-zoo). + +After downloading the models, you can do the evaluation following the description in *Quick Start - Test*). + +Model download links: + +Model | Params. | Top-1 Acc. % | Top-5 Acc. % | Download link +--- |:---:|:---:|:---:|:---: +AutoFormer-T | 5.8M | 75.3 | 92.7 | [Google Drive](https://drive.google.com/file/d/1uRCW3doQHgn2H-LjyalYEZ4CvmnQtr6Q/view?usp=sharing), [GitHub](https://github.com/silent-chen/AutoFormer-model-zoo/releases/download/v1.0/supernet-tiny.pth) +AutoFormer-S | 22.9M | 81.7 | 95.7 | [Google Drive](https://drive.google.com/file/d/1JTBmLR_nW7-ZbTKafWFvSl8J2orJXiNa/view?usp=sharing), [GitHub](https://github.com/silent-chen/AutoFormer-model-zoo/releases/download/v1.0/supernet-small.pth) +AutoFormer-B | 53.7M | 82.4 | 95.7 | [Google Drive](https://drive.google.com/file/d/1KPjUshk0SbqkaTzlirjPHM9pu19N5w0e/view?usp=sharing), [GitHub](https://github.com/silent-chen/AutoFormer-model-zoo/releases/download/v1.0/supernet-base.pth) + + +## Quick Start +We provide *Supernet Train, Search, Test* code of AutoFormer as follows. + +### Supernet Train + +To train the supernet-T/S/B, we provided the corresponding supernet configuration files in `/experiments/supernet/`. For example, to train the supernet-B, you can run the following command. The default output path is `./`, you can specify the path with argument `--output`. + +```buildoutcfg +python -m torch.distributed.launch --nproc_per_node=8 --use_env supernet_train.py --data-path /PATH/TO/IMAGENT --gp \ +--change_qk --relative_position --mode super --dist-eval --cfg ./experiments/supernet/supernet-B.yaml --epochs 500 --warmup-epochs 20 \ +--output /OUTPUT_PATH --batch-size 128 +``` + +### Search +We run our evolution search on part of the ImageNet training dataset and use the validation set of ImageNet as the test set for fair comparison. To generate the subImagenet in `/PATH/TO/IMAGENET`, you could simply run: +```buildoutcfg +python ./lib/subImageNet.py --data-path /PATH/TO/IMAGENT +``` + + +After obtaining the subImageNet and training of the supernet. We could perform the evolution search using below command. Please remember to config the specific constraint in this evolution search using `--min-param-limits` and `--param-limits`: +```buildoutcfg +python -m torch.distributed.launch --nproc_per_node=8 --use_env evolution.py --data-path /PATH/TO/IMAGENT --gp \ +--change_qk --relative_position --dist-eval --cfg ./experiments/supernet/supernet-B.yaml --resume /PATH/TO/CHECKPOINT \ +--min-param-limits YOUR/CONFIG --param-limits YOUR/CONFIG --data-set EVO_IMNET +``` + +### Test +To test our trained models, you need to put the downloaded model in `/PATH/TO/CHECKPOINT`. After that you could use the following command to test the model (Please change your config file and model checkpoint according to different models. Here we use the AutoFormer-B as an example). +```buildoutcfg +python -m torch.distributed.launch --nproc_per_node=8 --use_env supernet_train.py --data-path /PATH/TO/IMAGENT --gp \ +--change_qk --relative_position --mode retrain --dist-eval --cfg ./experiments/subnet/AutoFormer-B.yaml --resume /PATH/TO/CHECKPOINT --eval +``` + +## Performance + +**Left:** Top-1 accuracy on ImageNet. Our method achieves very competitive performance, being superior to the recent DeiT and ViT. **Right:** 1000 random sampled good architectures in the supernet-S. The supernet trained under our strategy allows subnets to be well optimized. + +
+ + +
+ +## Bibtex + +If this repo is helpful for you, please consider to cite it. Thank you! :) +```bibtex +@InProceedings{AutoFormer, + title = {AutoFormer: Searching Transformers for Visual Recognition}, + author = {Chen, Minghao and Peng, Houwen and Fu, Jianlong and Ling, Haibin}, + booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)}, + month = {October}, + year = {2021}, + pages = {12270-12280} +} +``` + +## Acknowledgements + +The codes are inspired by [HAT](https://github.com/mit-han-lab/hardware-aware-transformers), [timm](https://github.com/rwightman/pytorch-image-models), [DeiT](https://github.com/facebookresearch/deit), [SPOS](https://github.com/megvii-model/SinglePathOneShot). diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/evolution.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/evolution.py new file mode 100644 index 000000000..499cebd8f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/evolution.py @@ -0,0 +1,564 @@ +import random + +import numpy as np +import time +import torch +import torch.backends.cudnn as cudnn +from pathlib import Path + +from lib.datasets import build_dataset +from lib import utils +from supernet_engine import evaluate +from model.supernet_transformer import Vision_TransformerSuper +import argparse +import os +import yaml +from lib.config import cfg, update_config_from_file + +def decode_cand_tuple(cand_tuple): + depth = cand_tuple[0] + return depth, list(cand_tuple[1:depth+1]), list(cand_tuple[depth + 1: 2 * depth + 1]), cand_tuple[-1] + +class EvolutionSearcher(object): + + def __init__(self, args, device, model, model_without_ddp, choices, val_loader, test_loader, output_dir): + self.device = device + self.model = model + self.model_without_ddp = model_without_ddp + self.args = args + self.max_epochs = args.max_epochs + self.select_num = args.select_num + self.population_num = args.population_num + self.m_prob = args.m_prob + self.crossover_num = args.crossover_num + self.mutation_num = args.mutation_num + self.parameters_limits = args.param_limits + self.min_parameters_limits = args.min_param_limits + self.val_loader = val_loader + self.test_loader = test_loader + self.output_dir = output_dir + self.s_prob =args.s_prob + self.memory = [] + self.vis_dict = {} + self.keep_top_k = {self.select_num: [], 50: []} + self.epoch = 0 + self.checkpoint_path = args.resume + self.candidates = [] + self.top_accuracies = [] + self.cand_params = [] + self.choices = choices + + def save_checkpoint(self): + + info = {} + info['top_accuracies'] = self.top_accuracies + info['memory'] = self.memory + info['candidates'] = self.candidates + info['vis_dict'] = self.vis_dict + info['keep_top_k'] = self.keep_top_k + info['epoch'] = self.epoch + checkpoint_path = os.path.join(self.output_dir, "checkpoint-{}.pth.tar".format(self.epoch)) + torch.save(info, checkpoint_path) + print('save checkpoint to', checkpoint_path) + + def load_checkpoint(self): + if not os.path.exists(self.checkpoint_path): + return False + info = torch.load(self.checkpoint_path) + self.memory = info['memory'] + self.candidates = info['candidates'] + self.vis_dict = info['vis_dict'] + self.keep_top_k = info['keep_top_k'] + self.epoch = info['epoch'] + + print('load checkpoint from', self.checkpoint_path) + return True + + def is_legal(self, cand): + assert isinstance(cand, tuple) + if cand not in self.vis_dict: + self.vis_dict[cand] = {} + info = self.vis_dict[cand] + if 'visited' in info: + return False + depth, mlp_ratio, num_heads, embed_dim = decode_cand_tuple(cand) + sampled_config = {} + sampled_config['layer_num'] = depth + sampled_config['mlp_ratio'] = mlp_ratio + sampled_config['num_heads'] = num_heads + sampled_config['embed_dim'] = [embed_dim]*depth + n_parameters = self.model_without_ddp.get_sampled_params_numel(sampled_config) + info['params'] = n_parameters / 10.**6 + + if info['params'] > self.parameters_limits: + print('parameters limit exceed') + return False + + if info['params'] < self.min_parameters_limits: + print('under minimum parameters limit') + return False + + print("rank:", utils.get_rank(), cand, info['params']) + eval_stats = evaluate(self.val_loader, self.model, self.device, amp=self.args.amp, mode='retrain', retrain_config=sampled_config) + test_stats = evaluate(self.test_loader, self.model, self.device, amp=self.args.amp, mode='retrain', retrain_config=sampled_config) + + info['acc'] = eval_stats['acc1'] + info['test_acc'] = test_stats['acc1'] + + info['visited'] = True + + return True + + def update_top_k(self, candidates, *, k, key, reverse=True): + assert k in self.keep_top_k + print('select ......') + t = self.keep_top_k[k] + t += candidates + t.sort(key=key, reverse=reverse) + self.keep_top_k[k] = t[:k] + + def stack_random_cand(self, random_func, *, batchsize=10): + while True: + cands = [random_func() for _ in range(batchsize)] + for cand in cands: + if cand not in self.vis_dict: + self.vis_dict[cand] = {} + info = self.vis_dict[cand] + for cand in cands: + yield cand + + def get_random_cand(self): + + cand_tuple = list() + dimensions = ['mlp_ratio', 'num_heads'] + depth = random.choice(self.choices['depth']) + cand_tuple.append(depth) + for dimension in dimensions: + for i in range(depth): + cand_tuple.append(random.choice(self.choices[dimension])) + + cand_tuple.append(random.choice(self.choices['embed_dim'])) + return tuple(cand_tuple) + + def get_random(self, num): + print('random select ........') + cand_iter = self.stack_random_cand(self.get_random_cand) + while len(self.candidates) < num: + cand = next(cand_iter) + if not self.is_legal(cand): + continue + self.candidates.append(cand) + print('random {}/{}'.format(len(self.candidates), num)) + print('random_num = {}'.format(len(self.candidates))) + + def get_mutation(self, k, mutation_num, m_prob, s_prob): + assert k in self.keep_top_k + print('mutation ......') + res = [] + iter = 0 + max_iters = mutation_num * 10 + + def random_func(): + cand = list(random.choice(self.keep_top_k[k])) + depth, mlp_ratio, num_heads, embed_dim = decode_cand_tuple(cand) + random_s = random.random() + + # depth + if random_s < s_prob: + new_depth = random.choice(self.choices['depth']) + + if new_depth > depth: + mlp_ratio = mlp_ratio + [random.choice(self.choices['mlp_ratio']) for _ in range(new_depth - depth)] + num_heads = num_heads + [random.choice(self.choices['num_heads']) for _ in range(new_depth - depth)] + else: + mlp_ratio = mlp_ratio[:new_depth] + num_heads = num_heads[:new_depth] + + depth = new_depth + # mlp_ratio + for i in range(depth): + random_s = random.random() + if random_s < m_prob: + mlp_ratio[i] = random.choice(self.choices['mlp_ratio']) + + # num_heads + + for i in range(depth): + random_s = random.random() + if random_s < m_prob: + num_heads[i] = random.choice(self.choices['num_heads']) + + # embed_dim + random_s = random.random() + if random_s < s_prob: + embed_dim = random.choice(self.choices['embed_dim']) + + result_cand = [depth] + mlp_ratio + num_heads + [embed_dim] + + return tuple(result_cand) + + cand_iter = self.stack_random_cand(random_func) + while len(res) < mutation_num and max_iters > 0: + max_iters -= 1 + cand = next(cand_iter) + if not self.is_legal(cand): + continue + res.append(cand) + print('mutation {}/{}'.format(len(res), mutation_num)) + + print('mutation_num = {}'.format(len(res))) + return res + + def get_crossover(self, k, crossover_num): + assert k in self.keep_top_k + print('crossover ......') + res = [] + iter = 0 + max_iters = 10 * crossover_num + + def random_func(): + + p1 = random.choice(self.keep_top_k[k]) + p2 = random.choice(self.keep_top_k[k]) + max_iters_tmp = 50 + while len(p1) != len(p2) and max_iters_tmp > 0: + max_iters_tmp -= 1 + p1 = random.choice(self.keep_top_k[k]) + p2 = random.choice(self.keep_top_k[k]) + return tuple(random.choice([i, j]) for i, j in zip(p1, p2)) + + cand_iter = self.stack_random_cand(random_func) + while len(res) < crossover_num and max_iters > 0: + max_iters -= 1 + cand = next(cand_iter) + if not self.is_legal(cand): + continue + res.append(cand) + print('crossover {}/{}'.format(len(res), crossover_num)) + + print('crossover_num = {}'.format(len(res))) + return res + + def search(self): + print( + 'population_num = {} select_num = {} mutation_num = {} crossover_num = {} random_num = {} max_epochs = {}'.format( + self.population_num, self.select_num, self.mutation_num, self.crossover_num, + self.population_num - self.mutation_num - self.crossover_num, self.max_epochs)) + + # self.load_checkpoint() + + self.get_random(self.population_num) + + while self.epoch < self.max_epochs: + print('epoch = {}'.format(self.epoch)) + + self.memory.append([]) + for cand in self.candidates: + self.memory[-1].append(cand) + + self.update_top_k( + self.candidates, k=self.select_num, key=lambda x: self.vis_dict[x]['acc']) + self.update_top_k( + self.candidates, k=50, key=lambda x: self.vis_dict[x]['acc']) + + print('epoch = {} : top {} result'.format( + self.epoch, len(self.keep_top_k[50]))) + tmp_accuracy = [] + for i, cand in enumerate(self.keep_top_k[50]): + print('No.{} {} Top-1 val acc = {}, Top-1 test acc = {}, params = {}'.format( + i + 1, cand, self.vis_dict[cand]['acc'], self.vis_dict[cand]['test_acc'], self.vis_dict[cand]['params'])) + tmp_accuracy.append(self.vis_dict[cand]['acc']) + self.top_accuracies.append(tmp_accuracy) + + mutation = self.get_mutation( + self.select_num, self.mutation_num, self.m_prob, self.s_prob) + crossover = self.get_crossover(self.select_num, self.crossover_num) + + self.candidates = mutation + crossover + + self.get_random(self.population_num) + + self.epoch += 1 + + self.save_checkpoint() + +def get_args_parser(): + parser = argparse.ArgumentParser('DeiT training and evaluation script', add_help=False) + parser.add_argument('--batch-size', default=64, type=int) + + # evolution search parameters + parser.add_argument('--max-epochs', type=int, default=20) + parser.add_argument('--select-num', type=int, default=10) + parser.add_argument('--population-num', type=int, default=50) + parser.add_argument('--m_prob', type=float, default=0.2) + parser.add_argument('--s_prob', type=float, default=0.4) + parser.add_argument('--crossover-num', type=int, default=25) + parser.add_argument('--epochs', type=int, default=30) + parser.add_argument('--mutation-num', type=int, default=25) + parser.add_argument('--param-limits', type=float, default=23) + parser.add_argument('--min-param-limits', type=float, default=18) + + # config file + parser.add_argument('--cfg',help='experiment configure file name',required=True,type=str) + + # custom parameters + parser.add_argument('--platform', default='pai', type=str, choices=['itp', 'pai', 'aml'], + help='Name of model to train') + parser.add_argument('--teacher_model', default='', type=str, + help='Name of teacher model to train') + parser.add_argument('--relative_position', action='store_true') + parser.add_argument('--max_relative_position', type=int, default=14, help='max distance in relative position embedding') + parser.add_argument('--scale', action='store_true') + parser.add_argument('--gp', action='store_true') + parser.add_argument('--change_qkv', action='store_true') + + # Model parameters + parser.add_argument('--model', default='', type=str, metavar='MODEL', + help='Name of model to train') + + parser.add_argument('--input-size', default=224, type=int) + parser.add_argument('--patch_size', default=16, type=int) + + parser.add_argument('--drop', type=float, default=0.0, metavar='PCT', + help='Dropout rate (default: 0.)') + parser.add_argument('--drop-path', type=float, default=0.1, metavar='PCT', + help='Drop path rate (default: 0.1)') + parser.add_argument('--drop-block', type=float, default=None, metavar='PCT', + help='Drop block rate (default: None)') + + parser.add_argument('--model-ema', action='store_true') + parser.add_argument('--no-model-ema', action='store_false', dest='model_ema') + # parser.set_defaults(model_ema=True) + parser.add_argument('--model-ema-decay', type=float, default=0.99996, help='') + parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, help='') + + # custom model argument + parser.add_argument('--rpe_type', type=str, default='bias', choices=['bias', 'direct']) + parser.add_argument('--post_norm', action='store_true') + parser.add_argument('--no_abs_pos', action='store_true') + + # Optimizer parameters + parser.add_argument('--opt', default='adamw', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "adamw"') + parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') + parser.add_argument('--opt-betas', default=None, type=float, nargs='+', metavar='BETA', + help='Optimizer Betas (default: None, use opt default)') + parser.add_argument('--clip-grad', type=float, default=None, metavar='NORM', + help='Clip gradient norm (default: None, no clipping)') + parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') + parser.add_argument('--weight-decay', type=float, default=0.05, + help='weight decay (default: 0.05)') + # Learning rate schedule parameters + parser.add_argument('--sched', default='cosine', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "cosine"') + parser.add_argument('--lr', type=float, default=5e-4, metavar='LR', + help='learning rate (default: 5e-4)') + parser.add_argument('--lr-noise', type=float, nargs='+', default=None, metavar='pct, pct', + help='learning rate noise on/off epoch percentages') + parser.add_argument('--lr-noise-pct', type=float, default=0.67, metavar='PERCENT', + help='learning rate noise limit percent (default: 0.67)') + parser.add_argument('--lr-noise-std', type=float, default=1.0, metavar='STDDEV', + help='learning rate noise std-dev (default: 1.0)') + parser.add_argument('--warmup-lr', type=float, default=1e-6, metavar='LR', + help='warmup learning rate (default: 1e-6)') + parser.add_argument('--min-lr', type=float, default=1e-5, metavar='LR', + help='lower lr bound for cyclic schedulers that hit 0 (1e-5)') + parser.add_argument('--lr-power', type=float, default=1.0, + help='power of the polynomial lr scheduler') + + parser.add_argument('--decay-epochs', type=float, default=30, metavar='N', + help='epoch interval to decay LR') + parser.add_argument('--warmup-epochs', type=int, default=5, metavar='N', + help='epochs to warmup LR, if scheduler supports') + parser.add_argument('--cooldown-epochs', type=int, default=10, metavar='N', + help='epochs to cooldown LR at min_lr, after cyclic schedule ends') + parser.add_argument('--patience-epochs', type=int, default=10, metavar='N', + help='patience epochs for Plateau LR scheduler (default: 10') + parser.add_argument('--decay-rate', '--dr', type=float, default=0.1, metavar='RATE', + help='LR decay rate (default: 0.1)') + + # Augmentation parameters + parser.add_argument('--color-jitter', type=float, default=0.4, metavar='PCT', + help='Color jitter factor (default: 0.4)') + parser.add_argument('--aa', type=str, default='rand-m9-mstd0.5-inc1', metavar='NAME', + help='Use AutoAugment policy. "v0" or "original". " + \ + "(default: rand-m9-mstd0.5-inc1)'), + parser.add_argument('--smoothing', type=float, default=0.1, help='Label smoothing (default: 0.1)') + parser.add_argument('--train-interpolation', type=str, default='bicubic', + help='Training interpolation (random, bilinear, bicubic default: "bicubic")') + + parser.add_argument('--repeated-aug', action='store_true') + parser.add_argument('--no-repeated-aug', action='store_false', dest='repeated_aug') + parser.set_defaults(repeated_aug=True) + + # * Random Erase params + parser.add_argument('--reprob', type=float, default=0.25, metavar='PCT', + help='Random erase prob (default: 0.25)') + parser.add_argument('--remode', type=str, default='pixel', + help='Random erase mode (default: "pixel")') + parser.add_argument('--recount', type=int, default=1, + help='Random erase count (default: 1)') + parser.add_argument('--resplit', action='store_true', default=False, + help='Do not random erase first (clean) augmentation split') + + # * Mixup params + parser.add_argument('--mixup', type=float, default=0.8, + help='mixup alpha, mixup enabled if > 0. (default: 0.8)') + parser.add_argument('--cutmix', type=float, default=1.0, + help='cutmix alpha, cutmix enabled if > 0. (default: 1.0)') + parser.add_argument('--cutmix-minmax', type=float, nargs='+', default=None, + help='cutmix min/max ratio, overrides alpha and enables cutmix if set (default: None)') + parser.add_argument('--mixup-prob', type=float, default=1.0, + help='Probability of performing mixup or cutmix when either/both is enabled') + parser.add_argument('--mixup-switch-prob', type=float, default=0.5, + help='Probability of switching to cutmix when both mixup and cutmix enabled') + parser.add_argument('--mixup-mode', type=str, default='batch', + help='How to apply mixup/cutmix params. Per "batch", "pair", or "elem"') + + # Dataset parameters + parser.add_argument('--data-path', default='/datasets01_101/imagenet_full_size/061417/', type=str, + help='dataset path') + parser.add_argument('--data-set', default='IMNET', choices=['CIFAR', 'IMNET', 'INAT', 'INAT19', 'EVO_IMNET'], + type=str, help='Image Net dataset path') + parser.add_argument('--inat-category', default='name', + choices=['kingdom', 'phylum', 'class', 'order', 'supercategory', 'family', 'genus', 'name'], + type=str, help='semantic granularity') + parser.add_argument('--no-prefetcher', action='store_true', default=False, + help='disable fast prefetcher') + parser.add_argument('--output_dir', default='', + help='path where to save, empty for no saving') + parser.add_argument('--device', default='cuda', + help='device to use for training / testing') + parser.add_argument('--seed', default=0, type=int) + parser.add_argument('--resume', default='', help='resume from checkpoint') + parser.add_argument('--start_epoch', default=0, type=int, metavar='N', + help='start epoch') + parser.add_argument('--eval', action='store_true', help='Perform evaluation only') + parser.add_argument('--num_workers', default=10, type=int) + parser.add_argument('--dist-eval', action='store_true', default=False, help='Enabling distributed evaluation') + parser.add_argument('--pin-mem', action='store_true', + help='Pin CPU memory in DataLoader for more efficient (sometimes) transfer to GPU.') + parser.add_argument('--no-pin-mem', action='store_false', dest='pin_mem', + help='') + parser.set_defaults(pin_mem=True) + + # distributed training parameters + parser.add_argument('--world_size', default=1, type=int, + help='number of distributed processes') + parser.add_argument('--dist_url', default='env://', help='url used to set up distributed training') + parser.add_argument('--amp', action='store_true') + parser.add_argument('--no-amp', action='store_false', dest='amp') + parser.set_defaults(amp=True) + + return parser + +def main(args): + + update_config_from_file(args.cfg) + utils.init_distributed_mode(args) + + device = torch.device(args.device) + + print(args) + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + # save config for later experiments + with open(os.path.join(args.output_dir, "config.yaml"), 'w') as f: + f.write(args_text) + # fix the seed for reproducibility + + seed = args.seed + utils.get_rank() + torch.manual_seed(seed) + np.random.seed(seed) + random.seed(args.seed) + cudnn.benchmark = True + + args.prefetcher = not args.no_prefetcher + + dataset_val, args.nb_classes = build_dataset(is_train=False, args=args, folder_name="subImageNet") + dataset_test, _ = build_dataset(is_train=False, args=args, folder_name="val") + + if args.distributed: + num_tasks = utils.get_world_size() + global_rank = utils.get_rank() + if args.dist_eval: + if len(dataset_val) % num_tasks != 0: + print( + 'Warning: Enabling distributed evaluation with an eval dataset not divisible by process number. ' + 'This will slightly alter validation results as extra duplicate entries are added to achieve ' + 'equal num of samples per-process.') + sampler_val = torch.utils.data.DistributedSampler( + dataset_val, num_replicas=num_tasks, rank=global_rank, shuffle=False) + sampler_test = torch.utils.data.DistributedSampler( + dataset_test, num_replicas=num_tasks, rank=global_rank, shuffle=False) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + sampler_test = torch.utils.data.SequentialSampler(dataset_test) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + sampler_test = torch.utils.data.SequentialSampler(dataset_test) + + data_loader_test = torch.utils.data.DataLoader( + dataset_test, batch_size=int(2 * args.batch_size), + sampler=sampler_test, num_workers=args.num_workers, + pin_memory=args.pin_mem, drop_last=False + ) + + data_loader_val = torch.utils.data.DataLoader( + dataset_val, batch_size=int(2 * args.batch_size), + sampler=sampler_val, num_workers=args.num_workers, + pin_memory=args.pin_mem, drop_last=False + ) + + print(f"Creating SuperVisionTransformer") + print(cfg) + model = Vision_TransformerSuper(img_size=args.input_size, + patch_size=args.patch_size, + embed_dim=cfg.SUPERNET.EMBED_DIM, depth=cfg.SUPERNET.DEPTH, + num_heads=cfg.SUPERNET.NUM_HEADS,mlp_ratio=cfg.SUPERNET.MLP_RATIO, + qkv_bias=True, drop_rate=args.drop, + drop_path_rate=args.drop_path, + gp=args.gp, + num_classes=args.nb_classes, + max_relative_position=args.max_relative_position, + relative_position=args.relative_position, + change_qkv=args.change_qkv, abs_pos=not args.no_abs_pos) + + model.to(device) + model_without_ddp = model + if args.distributed: + model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu]) + model_without_ddp = model.module + + + n_parameters = sum(p.numel() for p in model.parameters() if p.requires_grad) + print('number of params:', n_parameters) + if args.resume: + if args.resume.startswith('https'): + checkpoint = torch.hub.load_state_dict_from_url( + args.resume, map_location='cpu', check_hash=True) + else: + checkpoint = torch.load(args.resume, map_location='cpu') + print("resume from checkpoint: {}".format(args.resume)) + model_without_ddp.load_state_dict(checkpoint['model']) + + choices = {'num_heads': cfg.SEARCH_SPACE.NUM_HEADS, 'mlp_ratio': cfg.SEARCH_SPACE.MLP_RATIO, + 'embed_dim': cfg.SEARCH_SPACE.EMBED_DIM , 'depth': cfg.SEARCH_SPACE.DEPTH} + + + t = time.time() + searcher = EvolutionSearcher(args, device, model, model_without_ddp, choices, data_loader_val, data_loader_test, args.output_dir) + + searcher.search() + + print('total searching time = {:.2f} hours'.format( + (time.time() - t) / 3600)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser('AutoFormer evolution search', parents=[get_args_parser()]) + args = parser.parse_args() + if args.output_dir: + Path(args.output_dir).mkdir(parents=True, exist_ok=True) + main(args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-B.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-B.yaml new file mode 100644 index 000000000..88c819b9b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-B.yaml @@ -0,0 +1,59 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 10 + EMBED_DIM: 640 + DEPTH: 16 +SEARCH_SPACE: + MLP_RATIO: + - 3.0 + - 3.5 + - 4.0 + NUM_HEADS: + - 8 + - 9 + - 10 + DEPTH: + - 14 + - 15 + - 16 + EMBED_DIM: + - 528 + - 576 + - 624 +RETRAIN: + MLP_RATIO: + - 3.5 + - 3.5 + - 4.0 + - 3.5 + - 4.0 + - 3.5 + - 3.5 + - 3.0 + - 4.0 + - 4.0 + - 3.0 + - 4.0 + - 3.0 + - 3.5 + NUM_HEADS: + - 9 + - 9 + - 9 + - 9 + - 9 + - 10 + - 9 + - 9 + - 10 + - 9 + - 10 + - 9 + - 9 + - 10 + DEPTH: 14 + EMBED_DIM: 576 + + + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-S.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-S.yaml new file mode 100644 index 000000000..e3cf60a9f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-S.yaml @@ -0,0 +1,54 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 7 + EMBED_DIM: 448 + DEPTH: 14 +SEARCH_SPACE: + MLP_RATIO: + - 3.0 + - 3.5 + - 4.0 + NUM_HEADS: + - 5 + - 6 + - 7 + DEPTH: + - 12 + - 13 + - 14 + EMBED_DIM: + - 320 + - 384 + - 448 +RETRAIN: + MLP_RATIO: + - 3.0 + - 3.5 + - 3.0 + - 3.5 + - 4.0 + - 4.0 + - 4.0 + - 4.0 + - 4.0 + - 4.0 + - 4.0 + - 3.5 + - 4.0 + NUM_HEADS: + - 6 + - 6 + - 5 + - 7 + - 5 + - 5 + - 5 + - 6 + - 6 + - 7 + - 7 + - 6 + - 7 + DEPTH: 13 + EMBED_DIM: 384 + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-T.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-T.yaml new file mode 100644 index 000000000..55dd1d520 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/subnet/AutoFormer-T.yaml @@ -0,0 +1,51 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 4 + EMBED_DIM: 256 + DEPTH: 14 +SEARCH_SPACE: + MLP_RATIO: + - 3.5 + - 4 + NUM_HEADS: + - 3 + - 4 + DEPTH: + - 12 + - 13 + - 14 + EMBED_DIM: + - 192 + - 216 + - 240 +RETRAIN: + MLP_RATIO: + - 3.5 + - 3.5 + - 3.0 + - 3.5 + - 3.0 + - 3.0 + - 4.0 + - 4.0 + - 3.5 + - 4.0 + - 3.5 + - 4.0 + - 3.5 + NUM_HEADS: + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 3 + - 4 + - 3 + - 3 + DEPTH: 13 + EMBED_DIM: 192 \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-B.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-B.yaml new file mode 100644 index 000000000..130917572 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-B.yaml @@ -0,0 +1,21 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 10 + EMBED_DIM: 640 + DEPTH: 16 +SEARCH_SPACE: + MLP_RATIO: + - 3.0 + - 3.5 + - 4.0 + NUM_HEADS: + - 9 + - 10 + DEPTH: + - 14 + - 15 + - 16 + EMBED_DIM: + - 528 + - 576 + - 624 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-S.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-S.yaml new file mode 100644 index 000000000..2df263c47 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-S.yaml @@ -0,0 +1,22 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 7 + EMBED_DIM: 448 + DEPTH: 14 +SEARCH_SPACE: + MLP_RATIO: + - 3.0 + - 3.5 + - 4.0 + NUM_HEADS: + - 5 + - 6 + - 7 + DEPTH: + - 12 + - 13 + - 14 + EMBED_DIM: + - 320 + - 384 + - 448 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-T.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-T.yaml new file mode 100644 index 000000000..48698ba75 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/experiments/supernet/supernet-T.yaml @@ -0,0 +1,20 @@ +SUPERNET: + MLP_RATIO: 4.0 + NUM_HEADS: 4 + EMBED_DIM: 256 + DEPTH: 14 +SEARCH_SPACE: + MLP_RATIO: + - 3.5 + - 4 + NUM_HEADS: + - 3 + - 4 + DEPTH: + - 12 + - 13 + - 14 + EMBED_DIM: + - 192 + - 216 + - 240 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/config.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/config.py new file mode 100644 index 000000000..ad62c16e3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/config.py @@ -0,0 +1,39 @@ +from easydict import EasyDict as edict +import yaml + +cfg = edict() + + +def _edict2dict(dest_dict, src_edict): + if isinstance(dest_dict, dict) and isinstance(src_edict, dict): + for k, v in src_edict.items(): + if not isinstance(v, edict): + dest_dict[k] = v + else: + dest_dict[k] = {} + _edict2dict(dest_dict[k], v) + else: + return + +def gen_config(config_file): + cfg_dict = {} + _edict2dict(cfg_dict, cfg) + with open(config_file, 'w') as f: + yaml.dump(cfg_dict, f, default_flow_style=False) + + +def _update_config(base_cfg, exp_cfg): + if isinstance(base_cfg, edict) and isinstance(exp_cfg, edict): + for k, v in exp_cfg.items(): + base_cfg[k] = v + else: + return + + +def update_config_from_file(filename): + exp_config = None + with open(filename) as f: + exp_config = edict(yaml.safe_load(f)) + _update_config(cfg, exp_config) + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/datasets.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/datasets.py new file mode 100644 index 000000000..654079237 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/datasets.py @@ -0,0 +1,220 @@ +import os +import cv2 +import json +import torch +import scipy +import scipy.io as sio +from skimage import io + +from torchvision import datasets, transforms +from torchvision.datasets.folder import ImageFolder, default_loader + +from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD +from timm.data import create_transform + +class Flowers(ImageFolder): + def __init__(self, root, train=True, transform=None, **kwargs): + self.dataset_root = root + self.loader = default_loader + self.target_transform = None + self.transform = transform + label_path = os.path.join(root, 'imagelabels.mat') + split_path = os.path.join(root, 'setid.mat') + + print('Dataset Flowers is trained with resolution 224!') + + # labels + labels = sio.loadmat(label_path)['labels'][0] + self.img_to_label = dict() + for i in range(len(labels)): + self.img_to_label[i] = labels[i] + + splits = sio.loadmat(split_path) + self.trnid, self.valid, self.tstid = sorted(splits['trnid'][0].tolist()), \ + sorted(splits['valid'][0].tolist()), \ + sorted(splits['tstid'][0].tolist()) + if train: + self.imgs = self.trnid + self.valid + else: + self.imgs = self.tstid + + self.samples = [] + for item in self.imgs: + self.samples.append((os.path.join(root, 'jpg', "image_{:05d}.jpg".format(item)), self.img_to_label[item-1]-1)) + +class Cars196(ImageFolder, datasets.CIFAR10): + base_folder_devkit = 'devkit' + base_folder_trainims = 'cars_train' + base_folder_testims = 'cars_test' + + filename_testanno = 'cars_test_annos.mat' + filename_trainanno = 'cars_train_annos.mat' + + base_folder = 'cars_train' + train_list = [ + ['00001.jpg', '8df595812fee3ca9a215e1ad4b0fb0c4'], + ['00002.jpg', '4b9e5efcc3612378ec63a22f618b5028'] + ] + test_list = [] + num_training_classes = 98 # 196/2 + + def __init__(self, root, train=False, transform=None, target_transform=None, **kwargs): + self.root = root + self.transform = transform + + self.target_transform = target_transform + self.loader = default_loader + print('Dataset Cars196 is trained with resolution 224!') + + self.samples = [] + self.nb_classes = 196 + + if train: + labels = \ + sio.loadmat(os.path.join(self.root, self.base_folder_devkit, self.filename_trainanno))['annotations'][0] + for item in labels: + img_name = item[-1].tolist()[0] + label = int(item[4]) - 1 + self.samples.append((os.path.join(self.root, self.base_folder_trainims, img_name), label)) + else: + labels = \ + sio.loadmat(os.path.join(self.root, 'cars_test_annos_withlabels.mat'))['annotations'][0] + for item in labels: + img_name = item[-1].tolist()[0] + label = int(item[-2]) - 1 + self.samples.append((os.path.join(self.root, self.base_folder_testims, img_name), label)) + +class Pets(ImageFolder): + def __init__(self, root, train=True, transform=None, target_transform=None, **kwargs): + self.dataset_root = root + self.loader = default_loader + self.target_transform = None + self.transform = transform + train_list_path = os.path.join(self.dataset_root, 'annotations', 'trainval.txt') + test_list_path = os.path.join(self.dataset_root, 'annotations', 'test.txt') + + self.samples = [] + if train: + with open(train_list_path, 'r') as f: + for line in f: + img_name = line.split(' ')[0] + label = int(line.split(' ')[1]) + self.samples.append((os.path.join(root, 'images', "{}.jpg".format(img_name)), label-1)) + else: + with open(test_list_path, 'r') as f: + for line in f: + img_name = line.split(' ')[0] + label = int(line.split(' ')[1]) + self.samples.append((os.path.join(root, 'images', "{}.jpg".format(img_name)), label-1)) + +class INatDataset(ImageFolder): + def __init__(self, root, train=True, year=2018, transform=None, target_transform=None, + category='name', loader=default_loader): + self.transform = transform + self.loader = loader + self.target_transform = target_transform + self.year = year + # assert category in ['kingdom','phylum','class','order','supercategory','family','genus','name'] + path_json = os.path.join(root, f'{"train" if train else "val"}{year}.json') + with open(path_json) as json_file: + data = json.load(json_file) + + with open(os.path.join(root, 'categories.json')) as json_file: + data_catg = json.load(json_file) + + path_json_for_targeter = os.path.join(root, f"train{year}.json") + + with open(path_json_for_targeter) as json_file: + data_for_targeter = json.load(json_file) + + targeter = {} + indexer = 0 + for elem in data_for_targeter['annotations']: + king = [] + king.append(data_catg[int(elem['category_id'])][category]) + if king[0] not in targeter.keys(): + targeter[king[0]] = indexer + indexer += 1 + self.nb_classes = len(targeter) + + self.samples = [] + for elem in data['images']: + cut = elem['file_name'].split('/') + target_current = int(cut[2]) + path_current = os.path.join(root, cut[0], cut[2], cut[3]) + + categors = data_catg[target_current] + target_current_true = targeter[categors[category]] + self.samples.append((path_current, target_current_true)) + + # __getitem__ and __len__ inherited from ImageFolder + +def build_dataset(is_train, args, folder_name=None): + transform = build_transform(is_train, args) + + if args.data_set == 'CIFAR10': + dataset = datasets.CIFAR10(args.data_path, train=is_train, transform=transform, download=True) + nb_classes = 10 + elif args.data_set == 'CIFAR100': + dataset = datasets.CIFAR100(args.data_path, train=is_train, transform=transform, download=True) + nb_classes = 100 + elif args.data_set == 'CARS': + dataset = Cars196(args.data_path, train=is_train, transform=transform) + nb_classes = 196 + elif args.data_set == 'PETS': + dataset = Pets(args.data_path, train=is_train, transform=transform) + nb_classes = 37 + elif args.data_set == 'FLOWERS': + dataset = Flowers(args.data_path, train=is_train, transform=transform) + nb_classes = 102 + elif args.data_set == 'IMNET': + root = os.path.join(args.data_path, 'train' if is_train else 'val') + dataset = datasets.ImageFolder(root, transform=transform) + nb_classes = 1000 + elif args.data_set == 'EVO_IMNET': + root = os.path.join(args.data_path, folder_name) + dataset = datasets.ImageFolder(root, transform=transform) + nb_classes = 1000 + elif args.data_set == 'INAT': + dataset = INatDataset(args.data_path, train=is_train, year=2018, + category=args.inat_category, transform=transform) + nb_classes = dataset.nb_classes + elif args.data_set == 'INAT19': + dataset = INatDataset(args.data_path, train=is_train, year=2019, + category=args.inat_category, transform=transform) + nb_classes = dataset.nb_classes + + return dataset, nb_classes + +def build_transform(is_train, args): + resize_im = args.input_size > 32 + if is_train: + # this should always dispatch to transforms_imagenet_train + transform = create_transform( + input_size=args.input_size, + is_training=True, + color_jitter=args.color_jitter, + auto_augment=args.aa, + interpolation=args.train_interpolation, + re_prob=args.reprob, + re_mode=args.remode, + re_count=args.recount, + ) + if not resize_im: + # replace RandomResizedCropAndInterpolation with + # RandomCrop + transform.transforms[0] = transforms.RandomCrop( + args.input_size, padding=4) + return transform + + t = [] + if resize_im: + size = int((256 / 224) * args.input_size) + t.append( + transforms.Resize(size, interpolation=3), # to maintain same ratio w.r.t. 224 images + ) + t.append(transforms.CenterCrop(args.input_size)) + + t.append(transforms.ToTensor()) + t.append(transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD)) + return transforms.Compose(t) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/imagenet_withhold.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/imagenet_withhold.py new file mode 100644 index 000000000..324499062 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/imagenet_withhold.py @@ -0,0 +1,78 @@ + +from PIL import Image +import io + +import torch +from torch.utils.data import Dataset +import torchvision.transforms as transforms + + +class ImageNet_Withhold(Dataset): + def __init__(self, data_root, ann_file='', transform=None, train=True, task ='train'): + super(ImageNet_Withhold, self).__init__() + ann_file = ann_file + '/' + 'val_true.txt' + train_split = (task == 'train' or task == 'val') + self.data_root = data_root + '/'+ ('train' if train_split else 'val') + + self.data = [] + self.nb_classes = 0 + folders = {} + cnt = 0 + self.z = ZipReader() + # if train: + # for member in self.tarfile.getmembers(): + # print(member) + # self.tarfile = tarfile.open(self.data_root) + + f = open(ann_file) + prefix = 'data/sdb/imagenet'+'/'+ ('train' if train_split else 'val') + '/' + for line in f: + tmp = line.strip().split('\t')[0] + class_pic = tmp.split('/') + class_tmp = class_pic[0] + pic = class_pic[1] + + if class_tmp in folders: + # print(self.tarfile.getmember(('train/' if train else 'val/') + tmp[0] + '.JPEG')) + self.data.append((class_tmp + '.zip', prefix + tmp + '.JPEG', folders[class_tmp])) + else: + folders[class_tmp] = cnt + cnt += 1 + self.data.append((class_tmp + '.zip', prefix + tmp + '.JPEG',folders[class_tmp])) + + normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], + std=[0.229, 0.224, 0.225]) + if transform is not None: + self.transforms = transform + else: + if train: + self.transforms = transforms.Compose([ + transforms.RandomSizedCrop(224), + transforms.RandomHorizontalFlip(), + transforms.ToTensor(), + normalize, + ]) + else: + self.transforms = transforms.Compose([ + transforms.Scale(256), + transforms.CenterCrop(224), + transforms.ToTensor(), + normalize, + ]) + + + self.nb_classes = cnt + def __len__(self): + return len(self.data) + + def __getitem__(self, idx): + + # print('extract_file', time.time()-start_time) + iob = self.z.read(self.data_root + '/' + self.data[idx][0], self.data[idx][1]) + iob = io.BytesIO(iob) + img = Image.open(iob).convert('RGB') + target = self.data[idx][2] + if self.transforms is not None: + img = self.transforms(img) + # print('open', time.time()-start_time) + return img, target diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/samplers.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/samplers.py new file mode 100644 index 000000000..870a7cdf3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/samplers.py @@ -0,0 +1,57 @@ +import torch +import torch.distributed as dist +import math + + +class RASampler(torch.utils.data.Sampler): + """Sampler that restricts data loading to a subset of the dataset for distributed, + with repeated augmentation. + It ensures that different each augmented version of a sample will be visible to a + different process (GPU) + Heavily based on torch.utils.data.DistributedSampler + """ + + def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): + if num_replicas is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + num_replicas = dist.get_world_size() + if rank is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + rank = dist.get_rank() + self.dataset = dataset + self.num_replicas = num_replicas + self.rank = rank + self.epoch = 0 + self.num_samples = int(math.ceil(len(self.dataset) * 3.0 / self.num_replicas)) + self.total_size = self.num_samples * self.num_replicas + # self.num_selected_samples = int(math.ceil(len(self.dataset) / self.num_replicas)) + self.num_selected_samples = int(math.floor(len(self.dataset) // 256 * 256 / self.num_replicas)) + self.shuffle = shuffle + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch) + if self.shuffle: + indices = torch.randperm(len(self.dataset), generator=g).tolist() + else: + indices = list(range(len(self.dataset))) + + # add extra samples to make it evenly divisible + indices = [ele for ele in indices for i in range(3)] + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + + assert len(indices) == self.num_samples + return iter(indices[:self.num_selected_samples]) + + def __len__(self): + return self.num_selected_samples + + def set_epoch(self, epoch): + self.epoch = epoch diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/subImageNet.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/subImageNet.py new file mode 100644 index 000000000..cf86a8d3c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/subImageNet.py @@ -0,0 +1,48 @@ +import os +import random +import argparse +random.seed(0) +parser = argparse.ArgumentParser('Generate SubImageNet', add_help=False) +parser.add_argument('--data-path', default='../data/imagenet', type=str, + help='dataset path') +args = parser.parse_args() + +data_path = args.data_path +ImageNet_train_path = os.path.join(data_path, 'train') +subImageNet_name = 'subImageNet' +class_idx_txt_path = os.path.join(data_path, subImageNet_name) + +# train +classes = sorted(os.listdir(ImageNet_train_path)) +if not os.path.exists(os.path.join(data_path, subImageNet_name)): + os.mkdir(os.path.join(data_path, subImageNet_name)) + +subImageNet = dict() +with open(os.path.join(class_idx_txt_path, 'subimages_list.txt'), 'w') as f: + subImageNet_class = classes + for iclass in subImageNet_class: + class_path = os.path.join(ImageNet_train_path, iclass) + if not os.path.exists( + os.path.join( + data_path, + subImageNet_name, + iclass)): + os.mkdir(os.path.join(data_path, subImageNet_name, iclass)) + subImages = random.sample(sorted(os.listdir(class_path)), 100) + # print("{}\n".format(subImages)) + f.write("{}\n".format(subImages)) + subImageNet[iclass] = subImages + for image in subImages: + raw_path = os.path.join(ImageNet_train_path, iclass, image) + new_ipath = os.path.join( + data_path, subImageNet_name, iclass, image) + os.system('cp {} {}'.format(raw_path, new_ipath)) + +sub_classes = sorted(subImageNet.keys()) +with open(os.path.join(class_idx_txt_path, 'info.txt'), 'w') as f: + class_idx = 0 + for key in sub_classes: + images = sorted((subImageNet[key])) + # print(len(images)) + f.write("{}\n".format(key)) + class_idx = class_idx + 1 \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/utils.py new file mode 100644 index 000000000..347b790aa --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/lib/utils.py @@ -0,0 +1,235 @@ +import io +import os +import time +from collections import defaultdict, deque +import datetime + +import torch +import torch.distributed as dist + + +class SmoothedValue(object): + """Track a series of values and provide access to smoothed values over a + window or the global series average. + """ + + def __init__(self, window_size=20, fmt=None): + if fmt is None: + fmt = "{median:.4f} ({global_avg:.4f})" + self.deque = deque(maxlen=window_size) + self.total = 0.0 + self.count = 0 + self.fmt = fmt + + def update(self, value, n=1): + self.deque.append(value) + self.count += n + self.total += value * n + + def synchronize_between_processes(self): + """ + Warning: does not synchronize the deque! + """ + if not is_dist_avail_and_initialized(): + return + t = torch.tensor([self.count, self.total], dtype=torch.float64, device='cuda') + dist.barrier() + dist.all_reduce(t) + t = t.tolist() + self.count = int(t[0]) + self.total = t[1] + + @property + def median(self): + d = torch.tensor(list(self.deque)) + return d.median().item() + + @property + def avg(self): + d = torch.tensor(list(self.deque), dtype=torch.float32) + return d.mean().item() + + @property + def global_avg(self): + return self.total / self.count + + @property + def max(self): + return max(self.deque) + + @property + def value(self): + return self.deque[-1] + + def __str__(self): + return self.fmt.format( + median=self.median, + avg=self.avg, + global_avg=self.global_avg, + max=self.max, + value=self.value) + + +class MetricLogger(object): + def __init__(self, delimiter="\t"): + self.meters = defaultdict(SmoothedValue) + self.delimiter = delimiter + + def update(self, **kwargs): + for k, v in kwargs.items(): + if isinstance(v, torch.Tensor): + v = v.item() + assert isinstance(v, (float, int)) + self.meters[k].update(v) + + def __getattr__(self, attr): + if attr in self.meters: + return self.meters[attr] + if attr in self.__dict__: + return self.__dict__[attr] + raise AttributeError("'{}' object has no attribute '{}'".format( + type(self).__name__, attr)) + + def __str__(self): + loss_str = [] + for name, meter in self.meters.items(): + loss_str.append( + "{}: {}".format(name, str(meter)) + ) + return self.delimiter.join(loss_str) + + def synchronize_between_processes(self): + for meter in self.meters.values(): + meter.synchronize_between_processes() + + def add_meter(self, name, meter): + self.meters[name] = meter + + def log_every(self, iterable, print_freq, header=None): + i = 0 + if not header: + header = '' + start_time = time.time() + end = time.time() + iter_time = SmoothedValue(fmt='{avg:.4f}') + data_time = SmoothedValue(fmt='{avg:.4f}') + space_fmt = ':' + str(len(str(len(iterable)))) + 'd' + log_msg = [ + header, + '[{0' + space_fmt + '}/{1}]', + 'eta: {eta}', + '{meters}', + 'time: {time}', + 'data: {data}' + ] + if torch.cuda.is_available(): + log_msg.append('max mem: {memory:.0f}') + log_msg = self.delimiter.join(log_msg) + MB = 1024.0 * 1024.0 + for obj in iterable: + data_time.update(time.time() - end) + yield obj + iter_time.update(time.time() - end) + if i % print_freq == 0 or i == len(iterable) - 1: + eta_seconds = iter_time.global_avg * (len(iterable) - i) + eta_string = str(datetime.timedelta(seconds=int(eta_seconds))) + if torch.cuda.is_available(): + print(log_msg.format( + i, len(iterable), eta=eta_string, + meters=str(self), + time=str(iter_time), data=str(data_time), + memory=torch.cuda.max_memory_allocated() / MB)) + else: + print(log_msg.format( + i, len(iterable), eta=eta_string, + meters=str(self), + time=str(iter_time), data=str(data_time))) + i += 1 + end = time.time() + total_time = time.time() - start_time + total_time_str = str(datetime.timedelta(seconds=int(total_time))) + print('{} Total time: {} ({:.4f} s / it)'.format( + header, total_time_str, total_time / len(iterable))) + + +def _load_checkpoint_for_ema(model_ema, checkpoint): + """ + Workaround for ModelEma._load_checkpoint to accept an already-loaded object + """ + mem_file = io.BytesIO() + torch.save(checkpoint, mem_file) + mem_file.seek(0) + model_ema._load_checkpoint(mem_file) + + +def setup_for_distributed(is_master): + """ + This function disables printing when not in master process + """ + import builtins as __builtin__ + builtin_print = __builtin__.print + + def print(*args, **kwargs): + force = kwargs.pop('force', False) + if is_master or force: + builtin_print(*args, **kwargs) + + __builtin__.print = print + + +def is_dist_avail_and_initialized(): + if not dist.is_available(): + return False + if not dist.is_initialized(): + return False + return True + + +def get_world_size(): + if not is_dist_avail_and_initialized(): + return 1 + return dist.get_world_size() + + +def get_rank(): + if not is_dist_avail_and_initialized(): + return 0 + return dist.get_rank() + + +def is_main_process(): + return get_rank() == 0 + + +def save_on_master(*args, **kwargs): + if is_main_process(): + torch.save(*args, **kwargs) + + +def init_distributed_mode(args): + if 'OMPI_COMM_WORLD_RANK' in os.environ: + args.rank = int(os.environ.get('OMPI_COMM_WORLD_RANK')) + args.world_size = int(os.environ.get('OMPI_COMM_WORLD_SIZE')) + args.gpu = args.rank % torch.cuda.device_count() + elif 'RANK' in os.environ and 'WORLD_SIZE' in os.environ: + args.rank = int(os.environ["RANK"]) + args.world_size = int(os.environ['WORLD_SIZE']) + args.gpu = int(os.environ['LOCAL_RANK']) + elif 'SLURM_PROCID' in os.environ: + args.rank = int(os.environ['SLURM_PROCID']) + args.gpu = args.rank % torch.cuda.device_count() + else: + print('Not using distributed mode') + args.distributed = False + return + + args.distributed = True + + torch.cuda.set_device(args.gpu) + args.dist_backend = 'nccl' + print('| distributed init (rank {}): {}'.format( + args.rank, args.dist_url), flush=True) + torch.distributed.init_process_group(backend=args.dist_backend, init_method=args.dist_url, + world_size=args.world_size, rank=args.rank) + torch.distributed.barrier() + setup_for_distributed(args.rank == 0) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/Linear_super.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/Linear_super.py new file mode 100644 index 000000000..ff179049d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/Linear_super.py @@ -0,0 +1,81 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +import numpy as np + +class LinearSuper(nn.Linear): + def __init__(self, super_in_dim, super_out_dim, bias=True, uniform_=None, non_linear='linear', scale=False): + super().__init__(super_in_dim, super_out_dim, bias=bias) + + # super_in_dim and super_out_dim indicate the largest network! + self.super_in_dim = super_in_dim + self.super_out_dim = super_out_dim + + # input_dim and output_dim indicate the current sampled size + self.sample_in_dim = None + self.sample_out_dim = None + + self.samples = {} + + self.scale = scale + self._reset_parameters(bias, uniform_, non_linear) + self.profiling = False + + def profile(self, mode=True): + self.profiling = mode + + def sample_parameters(self, resample=False): + if self.profiling or resample: + return self._sample_parameters() + return self.samples + + def _reset_parameters(self, bias, uniform_, non_linear): + nn.init.xavier_uniform_(self.weight) if uniform_ is None else uniform_( + self.weight, non_linear=non_linear) + if bias: + nn.init.constant_(self.bias, 0.) + + def set_sample_config(self, sample_in_dim, sample_out_dim): + self.sample_in_dim = sample_in_dim + self.sample_out_dim = sample_out_dim + + self._sample_parameters() + + def _sample_parameters(self): + self.samples['weight'] = sample_weight(self.weight, self.sample_in_dim, self.sample_out_dim) + self.samples['bias'] = self.bias + self.sample_scale = self.super_out_dim/self.sample_out_dim + if self.bias is not None: + self.samples['bias'] = sample_bias(self.bias, self.sample_out_dim) + return self.samples + + def forward(self, x): + self.sample_parameters() + return F.linear(x, self.samples['weight'], self.samples['bias']) * (self.sample_scale if self.scale else 1) + + def calc_sampled_param_num(self): + assert 'weight' in self.samples.keys() + weight_numel = self.samples['weight'].numel() + + if self.samples['bias'] is not None: + bias_numel = self.samples['bias'].numel() + else: + bias_numel = 0 + + return weight_numel + bias_numel + def get_complexity(self, sequence_length): + total_flops = 0 + total_flops += sequence_length * np.prod(self.samples['weight'].size()) + return total_flops + +def sample_weight(weight, sample_in_dim, sample_out_dim): + sample_weight = weight[:, :sample_in_dim] + sample_weight = sample_weight[:sample_out_dim, :] + + return sample_weight + + +def sample_bias(bias, sample_out_dim): + sample_bias = bias[:sample_out_dim] + + return sample_bias diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/embedding_super.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/embedding_super.py new file mode 100644 index 000000000..06bcfcda9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/embedding_super.py @@ -0,0 +1,49 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from model.utils import to_2tuple +import numpy as np + +class PatchembedSuper(nn.Module): + def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768, scale=False): + super(PatchembedSuper, self).__init__() + + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + num_patches = (img_size[1] // patch_size[1]) * (img_size[0] // patch_size[0]) + self.img_size = img_size + self.patch_size = patch_size + self.num_patches = num_patches + self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size) + self.super_embed_dim = embed_dim + self.scale = scale + + # sampled_ + self.sample_embed_dim = None + self.sampled_weight = None + self.sampled_bias = None + self.sampled_scale = None + + def set_sample_config(self, sample_embed_dim): + self.sample_embed_dim = sample_embed_dim + self.sampled_weight = self.proj.weight[:sample_embed_dim, ...] + self.sampled_bias = self.proj.bias[:self.sample_embed_dim, ...] + if self.scale: + self.sampled_scale = self.super_embed_dim / sample_embed_dim + def forward(self, x): + B, C, H, W = x.shape + assert H == self.img_size[0] and W == self.img_size[1], \ + f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})." + x = F.conv2d(x, self.sampled_weight, self.sampled_bias, stride=self.patch_size, padding=self.proj.padding, dilation=self.proj.dilation).flatten(2).transpose(1,2) + if self.scale: + return x * self.sampled_scale + return x + def calc_sampled_param_num(self): + return self.sampled_weight.numel() + self.sampled_bias.numel() + + def get_complexity(self, sequence_length): + total_flops = 0 + if self.sampled_bias is not None: + total_flops += self.sampled_bias.size(0) + total_flops += sequence_length * np.prod(self.sampled_weight.size()) + return total_flops \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/layernorm_super.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/layernorm_super.py new file mode 100644 index 000000000..06370c8fd --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/layernorm_super.py @@ -0,0 +1,45 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F + +class LayerNormSuper(torch.nn.LayerNorm): + def __init__(self, super_embed_dim): + super().__init__(super_embed_dim) + + # the largest embed dim + self.super_embed_dim = super_embed_dim + + # the current sampled embed dim + self.sample_embed_dim = None + + self.samples = {} + self.profiling = False + + def profile(self, mode=True): + self.profiling = mode + + def sample_parameters(self, resample=False): + if self.profiling or resample: + return self._sample_parameters() + return self.samples + + def _sample_parameters(self): + self.samples['weight'] = self.weight[:self.sample_embed_dim] + self.samples['bias'] = self.bias[:self.sample_embed_dim] + return self.samples + + def set_sample_config(self, sample_embed_dim): + self.sample_embed_dim = sample_embed_dim + self._sample_parameters() + + def forward(self, x): + self.sample_parameters() + return F.layer_norm(x, (self.sample_embed_dim,), weight=self.samples['weight'], bias=self.samples['bias'], eps=self.eps) + + def calc_sampled_param_num(self): + assert 'weight' in self.samples.keys() + assert 'bias' in self.samples.keys() + return self.samples['weight'].numel() + self.samples['bias'].numel() + + def get_complexity(self, sequence_length): + return sequence_length * self.sample_embed_dim diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/multihead_super.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/multihead_super.py new file mode 100644 index 000000000..3919be481 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/multihead_super.py @@ -0,0 +1,160 @@ +import torch +from torch import nn +from torch.nn import Parameter +import torch.nn.functional as F +from .Linear_super import LinearSuper +from .qkv_super import qkv_super +from ..utils import trunc_normal_ +def softmax(x, dim, onnx_trace=False): + if onnx_trace: + return F.softmax(x.float(), dim=dim) + else: + return F.softmax(x, dim=dim, dtype=torch.float32) + +class RelativePosition2D_super(nn.Module): + + def __init__(self, num_units, max_relative_position): + super().__init__() + + self.num_units = num_units + self.max_relative_position = max_relative_position + # The first element in embeddings_table_v is the vertical embedding for the class + self.embeddings_table_v = nn.Parameter(torch.randn(max_relative_position * 2 + 2, num_units)) + self.embeddings_table_h = nn.Parameter(torch.randn(max_relative_position * 2 + 2, num_units)) + + trunc_normal_(self.embeddings_table_v, std=.02) + trunc_normal_(self.embeddings_table_h, std=.02) + + self.sample_head_dim = None + self.sample_embeddings_table_h = None + self.sample_embeddings_table_v = None + + def set_sample_config(self, sample_head_dim): + self.sample_head_dim = sample_head_dim + self.sample_embeddings_table_h = self.embeddings_table_h[:,:sample_head_dim] + self.sample_embeddings_table_v = self.embeddings_table_v[:,:sample_head_dim] + + def calc_sampled_param_num(self): + return self.sample_embeddings_table_h.numel() + self.sample_embeddings_table_v.numel() + + def forward(self, length_q, length_k): + # remove the first cls token distance computation + length_q = length_q - 1 + length_k = length_k - 1 + device = self.embeddings_table_v.device + range_vec_q = torch.arange(length_q, device=device) + range_vec_k = torch.arange(length_k, device=device) + # compute the row and column distance + distance_mat_v = (range_vec_k[None, :] // int(length_q ** 0.5 ) - range_vec_q[:, None] // int(length_q ** 0.5 )) + distance_mat_h = (range_vec_k[None, :] % int(length_q ** 0.5 ) - range_vec_q[:, None] % int(length_q ** 0.5 )) + # clip the distance to the range of [-max_relative_position, max_relative_position] + distance_mat_clipped_v = torch.clamp(distance_mat_v, -self.max_relative_position, self.max_relative_position) + distance_mat_clipped_h = torch.clamp(distance_mat_h, -self.max_relative_position, self.max_relative_position) + + # translate the distance from [1, 2 * max_relative_position + 1], 0 is for the cls token + final_mat_v = distance_mat_clipped_v + self.max_relative_position + 1 + final_mat_h = distance_mat_clipped_h + self.max_relative_position + 1 + # pad the 0 which represent the cls token + final_mat_v = torch.nn.functional.pad(final_mat_v, (1,0,1,0), "constant", 0) + final_mat_h = torch.nn.functional.pad(final_mat_h, (1,0,1,0), "constant", 0) + + final_mat_v = final_mat_v.long() + final_mat_h = final_mat_h.long() + # get the embeddings with the corresponding distance + embeddings = self.sample_embeddings_table_v[final_mat_v] + self.sample_embeddings_table_h[final_mat_h] + + return embeddings + +class AttentionSuper(nn.Module): + def __init__(self, super_embed_dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0., normalization = False, relative_position = False, + num_patches = None, max_relative_position=14, scale=False, change_qkv = False): + super().__init__() + self.num_heads = num_heads + head_dim = super_embed_dim // num_heads + self.scale = qk_scale or head_dim ** -0.5 + self.super_embed_dim = super_embed_dim + + self.fc_scale = scale + self.change_qkv = change_qkv + if change_qkv: + self.qkv = qkv_super(super_embed_dim, 3 * super_embed_dim, bias=qkv_bias) + else: + self.qkv = LinearSuper(super_embed_dim, 3 * super_embed_dim, bias=qkv_bias) + + self.relative_position = relative_position + if self.relative_position: + self.rel_pos_embed_k = RelativePosition2D_super(super_embed_dim //num_heads, max_relative_position) + self.rel_pos_embed_v = RelativePosition2D_super(super_embed_dim //num_heads, max_relative_position) + self.max_relative_position = max_relative_position + self.sample_qk_embed_dim = None + self.sample_v_embed_dim = None + self.sample_num_heads = None + self.sample_scale = None + self.sample_in_embed_dim = None + + self.proj = LinearSuper(super_embed_dim, super_embed_dim) + + self.attn_drop = nn.Dropout(attn_drop) + self.proj_drop = nn.Dropout(proj_drop) + + def set_sample_config(self, sample_q_embed_dim=None, sample_num_heads=None, sample_in_embed_dim=None): + + self.sample_in_embed_dim = sample_in_embed_dim + self.sample_num_heads = sample_num_heads + if not self.change_qkv: + self.sample_qk_embed_dim = self.super_embed_dim + self.sample_scale = (sample_in_embed_dim // self.sample_num_heads) ** -0.5 + + else: + self.sample_qk_embed_dim = sample_q_embed_dim + self.sample_scale = (self.sample_qk_embed_dim // self.sample_num_heads) ** -0.5 + + self.qkv.set_sample_config(sample_in_dim=sample_in_embed_dim, sample_out_dim=3*self.sample_qk_embed_dim) + self.proj.set_sample_config(sample_in_dim=self.sample_qk_embed_dim, sample_out_dim=sample_in_embed_dim) + if self.relative_position: + self.rel_pos_embed_k.set_sample_config(self.sample_qk_embed_dim // sample_num_heads) + self.rel_pos_embed_v.set_sample_config(self.sample_qk_embed_dim // sample_num_heads) + def calc_sampled_param_num(self): + + return 0 + def get_complexity(self, sequence_length): + total_flops = 0 + total_flops += self.qkv.get_complexity(sequence_length) + # attn + total_flops += sequence_length * sequence_length * self.sample_qk_embed_dim + # x + total_flops += sequence_length * sequence_length * self.sample_qk_embed_dim + total_flops += self.proj.get_complexity(sequence_length) + if self.relative_position: + total_flops += self.max_relative_position * sequence_length * sequence_length + sequence_length * sequence_length / 2.0 + total_flops += self.max_relative_position * sequence_length * sequence_length + sequence_length * self.sample_qk_embed_dim / 2.0 + return total_flops + + def forward(self, x): + B, N, C = x.shape + qkv = self.qkv(x).reshape(B, N, 3, self.sample_num_heads, -1).permute(2, 0, 3, 1, 4) + q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) + + attn = (q @ k.transpose(-2, -1)) * self.sample_scale + if self.relative_position: + r_p_k = self.rel_pos_embed_k(N, N) + attn = attn + (q.permute(2, 0, 1, 3).reshape(N, self.sample_num_heads * B, -1) @ r_p_k.transpose(2, 1)) \ + .transpose(1, 0).reshape(B, self.sample_num_heads, N, N) * self.sample_scale + + attn = attn.softmax(dim=-1) + attn = self.attn_drop(attn) + + x = (attn @ v).transpose(1,2).reshape(B, N, -1) + if self.relative_position: + r_p_v = self.rel_pos_embed_v(N, N) + attn_1 = attn.permute(2, 0, 1, 3).reshape(N, B * self.sample_num_heads, -1) + # The size of attention is (B, num_heads, N, N), reshape it to (N, B*num_heads, N) and do batch matmul with + # the relative position embedding of V (N, N, head_dim) get shape like (N, B*num_heads, head_dim). We reshape it to the + # same size as x (B, num_heads, N, hidden_dim) + x = x + (attn_1 @ r_p_v).transpose(1, 0).reshape(B, self.sample_num_heads, N, -1).transpose(2,1).reshape(B, N, -1) + + if self.fc_scale: + x = x * (self.super_embed_dim / self.sample_qk_embed_dim) + x = self.proj(x) + x = self.proj_drop(x) + return x diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/qkv_super.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/qkv_super.py new file mode 100644 index 000000000..cc9f4e921 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/module/qkv_super.py @@ -0,0 +1,83 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +import numpy as np + + +class qkv_super(nn.Linear): + def __init__(self, super_in_dim, super_out_dim, bias=True, uniform_=None, non_linear='linear', scale=False): + super().__init__(super_in_dim, super_out_dim, bias=bias) + + # super_in_dim and super_out_dim indicate the largest network! + self.super_in_dim = super_in_dim + self.super_out_dim = super_out_dim + + # input_dim and output_dim indicate the current sampled size + self.sample_in_dim = None + self.sample_out_dim = None + + self.samples = {} + + self.scale = scale + # self._reset_parameters(bias, uniform_, non_linear) + self.profiling = False + + def profile(self, mode=True): + self.profiling = mode + + def sample_parameters(self, resample=False): + if self.profiling or resample: + return self._sample_parameters() + return self.samples + + def _reset_parameters(self, bias, uniform_, non_linear): + nn.init.xavier_uniform_(self.weight) if uniform_ is None else uniform_( + self.weight, non_linear=non_linear) + if bias: + nn.init.constant_(self.bias, 0.) + + def set_sample_config(self, sample_in_dim, sample_out_dim): + self.sample_in_dim = sample_in_dim + self.sample_out_dim = sample_out_dim + + self._sample_parameters() + + def _sample_parameters(self): + self.samples['weight'] = sample_weight(self.weight, self.sample_in_dim, self.sample_out_dim) + self.samples['bias'] = self.bias + self.sample_scale = self.super_out_dim/self.sample_out_dim + if self.bias is not None: + self.samples['bias'] = sample_bias(self.bias, self.sample_out_dim) + return self.samples + + def forward(self, x): + self.sample_parameters() + return F.linear(x, self.samples['weight'], self.samples['bias']) * (self.sample_scale if self.scale else 1) + + def calc_sampled_param_num(self): + assert 'weight' in self.samples.keys() + weight_numel = self.samples['weight'].numel() + + if self.samples['bias'] is not None: + bias_numel = self.samples['bias'].numel() + else: + bias_numel = 0 + + return weight_numel + bias_numel + def get_complexity(self, sequence_length): + total_flops = 0 + total_flops += sequence_length * np.prod(self.samples['weight'].size()) + return total_flops + +def sample_weight(weight, sample_in_dim, sample_out_dim): + + sample_weight = weight[:, :sample_in_dim] + sample_weight = torch.cat([sample_weight[i:sample_out_dim:3, :] for i in range(3)], dim =0) + + return sample_weight + + +def sample_bias(bias, sample_out_dim): + sample_bias = bias[:sample_out_dim] + + return sample_bias diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/supernet_transformer.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/supernet_transformer.py new file mode 100644 index 000000000..07126c678 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/supernet_transformer.py @@ -0,0 +1,312 @@ +import math + +import torch +import torch.nn as nn +import torch.nn.functional as F +from model.module.Linear_super import LinearSuper +from model.module.layernorm_super import LayerNormSuper +from model.module.multihead_super import AttentionSuper +from model.module.embedding_super import PatchembedSuper +from model.utils import trunc_normal_ +from model.utils import DropPath +import numpy as np + +def gelu(x: torch.Tensor) -> torch.Tensor: + if hasattr(torch.nn.functional, 'gelu'): + return torch.nn.functional.gelu(x.float()).type_as(x) + else: + return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0))) + + +class Vision_TransformerSuper(nn.Module): + + def __init__(self, img_size=224, patch_size=16, in_chans=3, num_classes=1000, embed_dim=768, depth=12, + num_heads=12, mlp_ratio=4., qkv_bias=False, qk_scale=None, drop_rate=0., attn_drop_rate=0., + drop_path_rate=0., pre_norm=True, scale=False, gp=False, relative_position=False, change_qkv=False, abs_pos = True, max_relative_position=14): + super(Vision_TransformerSuper, self).__init__() + # the configs of super arch + self.super_embed_dim = embed_dim + # self.super_embed_dim = args.embed_dim + self.super_mlp_ratio = mlp_ratio + self.super_layer_num = depth + self.super_num_heads = num_heads + self.super_dropout = drop_rate + self.super_attn_dropout = attn_drop_rate + self.num_classes = num_classes + self.pre_norm=pre_norm + self.scale=scale + self.patch_embed_super = PatchembedSuper(img_size=img_size, patch_size=patch_size, + in_chans=in_chans, embed_dim=embed_dim) + self.gp = gp + + # configs for the sampled subTransformer + self.sample_embed_dim = None + self.sample_mlp_ratio = None + self.sample_layer_num = None + self.sample_num_heads = None + self.sample_dropout = None + self.sample_output_dim = None + + self.blocks = nn.ModuleList() + dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)] # stochastic depth decay rule + + for i in range(depth): + self.blocks.append(TransformerEncoderLayer(dim=embed_dim, num_heads=num_heads, mlp_ratio=mlp_ratio, + qkv_bias=qkv_bias, qk_scale=qk_scale, dropout=drop_rate, + attn_drop=attn_drop_rate, drop_path=dpr[i], + pre_norm=pre_norm, scale=self.scale, + change_qkv=change_qkv, relative_position=relative_position, + max_relative_position=max_relative_position)) + + # parameters for vision transformer + num_patches = self.patch_embed_super.num_patches + + self.abs_pos = abs_pos + if self.abs_pos: + self.pos_embed = nn.Parameter(torch.zeros(1, num_patches + 1, embed_dim)) + trunc_normal_(self.pos_embed, std=.02) + + self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim)) + trunc_normal_(self.cls_token, std=.02) + + # self.pos_drop = nn.Dropout(p=drop_rate) + if self.pre_norm: + self.norm = LayerNormSuper(super_embed_dim=embed_dim) + + + # classifier head + self.head = LinearSuper(embed_dim, num_classes) if num_classes > 0 else nn.Identity() + + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight, std=.02) + if isinstance(m, nn.Linear) and m.bias is not None: + nn.init.constant_(m.bias, 0) + elif isinstance(m, nn.LayerNorm): + nn.init.constant_(m.bias, 0) + nn.init.constant_(m.weight, 1.0) + + @torch.jit.ignore + def no_weight_decay(self): + return {'pos_embed', 'cls_token', 'rel_pos_embed'} + + def get_classifier(self): + return self.head + + def reset_classifier(self, num_classes, global_pool=''): + self.num_classes = num_classes + self.head = nn.Linear(self.embed_dim, num_classes) if num_classes > 0 else nn.Identity() + + def set_sample_config(self, config: dict): + self.sample_embed_dim = config['embed_dim'] + self.sample_mlp_ratio = config['mlp_ratio'] + self.sample_layer_num = config['layer_num'] + self.sample_num_heads = config['num_heads'] + self.sample_dropout = calc_dropout(self.super_dropout, self.sample_embed_dim[0], self.super_embed_dim) + self.patch_embed_super.set_sample_config(self.sample_embed_dim[0]) + self.sample_output_dim = [out_dim for out_dim in self.sample_embed_dim[1:]] + [self.sample_embed_dim[-1]] + for i, blocks in enumerate(self.blocks): + # not exceed sample layer number + if i < self.sample_layer_num: + sample_dropout = calc_dropout(self.super_dropout, self.sample_embed_dim[i], self.super_embed_dim) + sample_attn_dropout = calc_dropout(self.super_attn_dropout, self.sample_embed_dim[i], self.super_embed_dim) + blocks.set_sample_config(is_identity_layer=False, + sample_embed_dim=self.sample_embed_dim[i], + sample_mlp_ratio=self.sample_mlp_ratio[i], + sample_num_heads=self.sample_num_heads[i], + sample_dropout=sample_dropout, + sample_out_dim=self.sample_output_dim[i], + sample_attn_dropout=sample_attn_dropout) + # exceeds sample layer number + else: + blocks.set_sample_config(is_identity_layer=True) + if self.pre_norm: + self.norm.set_sample_config(self.sample_embed_dim[-1]) + self.head.set_sample_config(self.sample_embed_dim[-1], self.num_classes) + + def get_sampled_params_numel(self, config): + self.set_sample_config(config) + numels = [] + for name, module in self.named_modules(): + if hasattr(module, 'calc_sampled_param_num'): + if name.split('.')[0] == 'blocks' and int(name.split('.')[1]) >= config['layer_num']: + continue + numels.append(module.calc_sampled_param_num()) + + return sum(numels) + self.sample_embed_dim[0]* (2 +self.patch_embed_super.num_patches) + def get_complexity(self, sequence_length): + total_flops = 0 + total_flops += self.patch_embed_super.get_complexity(sequence_length) + total_flops += np.prod(self.pos_embed[..., :self.sample_embed_dim[0]].size()) / 2.0 + for blk in self.blocks: + total_flops += blk.get_complexity(sequence_length+1) + total_flops += self.head.get_complexity(sequence_length+1) + return total_flops + def forward_features(self, x): + B = x.shape[0] + x = self.patch_embed_super(x) + cls_tokens = self.cls_token[..., :self.sample_embed_dim[0]].expand(B, -1, -1) + x = torch.cat((cls_tokens, x), dim=1) + if self.abs_pos: + x = x + self.pos_embed[..., :self.sample_embed_dim[0]] + + x = F.dropout(x, p=self.sample_dropout, training=self.training) + + # start_time = time.time() + for blk in self.blocks: + x = blk(x) + # print(time.time()-start_time) + if self.pre_norm: + x = self.norm(x) + + if self.gp: + return torch.mean(x[:, 1:] , dim=1) + + return x[:, 0] + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + return x + + +class TransformerEncoderLayer(nn.Module): + """Encoder layer block. + + Args: + args (argparse.Namespace): parsed command-line arguments which + """ + + def __init__(self, dim, num_heads, mlp_ratio=4., qkv_bias=False, qk_scale=None, dropout=0., attn_drop=0., + drop_path=0., act_layer=nn.GELU, pre_norm=True, scale=False, + relative_position=False, change_qkv=False, max_relative_position=14): + super().__init__() + + # the configs of super arch of the encoder, three dimension [embed_dim, mlp_ratio, and num_heads] + self.super_embed_dim = dim + self.super_mlp_ratio = mlp_ratio + self.super_ffn_embed_dim_this_layer = int(mlp_ratio * dim) + self.super_num_heads = num_heads + self.normalize_before = pre_norm + self.super_dropout = attn_drop + self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity() + self.scale = scale + self.relative_position = relative_position + # self.super_activation_dropout = getattr(args, 'activation_dropout', 0) + + # the configs of current sampled arch + self.sample_embed_dim = None + self.sample_mlp_ratio = None + self.sample_ffn_embed_dim_this_layer = None + self.sample_num_heads_this_layer = None + self.sample_scale = None + self.sample_dropout = None + self.sample_attn_dropout = None + + self.is_identity_layer = None + self.attn = AttentionSuper( + dim, num_heads=num_heads, qkv_bias=qkv_bias, qk_scale=qk_scale, attn_drop=attn_drop, + proj_drop=dropout, scale=self.scale, relative_position=self.relative_position, change_qkv=change_qkv, + max_relative_position=max_relative_position + ) + + self.attn_layer_norm = LayerNormSuper(self.super_embed_dim) + self.ffn_layer_norm = LayerNormSuper(self.super_embed_dim) + # self.dropout = dropout + self.activation_fn = gelu + # self.normalize_before = args.encoder_normalize_before + + self.fc1 = LinearSuper(super_in_dim=self.super_embed_dim, super_out_dim=self.super_ffn_embed_dim_this_layer) + self.fc2 = LinearSuper(super_in_dim=self.super_ffn_embed_dim_this_layer, super_out_dim=self.super_embed_dim) + + + def set_sample_config(self, is_identity_layer, sample_embed_dim=None, sample_mlp_ratio=None, sample_num_heads=None, sample_dropout=None, sample_attn_dropout=None, sample_out_dim=None): + + if is_identity_layer: + self.is_identity_layer = True + return + + self.is_identity_layer = False + + self.sample_embed_dim = sample_embed_dim + self.sample_out_dim = sample_out_dim + self.sample_mlp_ratio = sample_mlp_ratio + self.sample_ffn_embed_dim_this_layer = int(sample_embed_dim*sample_mlp_ratio) + self.sample_num_heads_this_layer = sample_num_heads + + self.sample_dropout = sample_dropout + self.sample_attn_dropout = sample_attn_dropout + self.attn_layer_norm.set_sample_config(sample_embed_dim=self.sample_embed_dim) + + self.attn.set_sample_config(sample_q_embed_dim=self.sample_num_heads_this_layer*64, sample_num_heads=self.sample_num_heads_this_layer, sample_in_embed_dim=self.sample_embed_dim) + + self.fc1.set_sample_config(sample_in_dim=self.sample_embed_dim, sample_out_dim=self.sample_ffn_embed_dim_this_layer) + self.fc2.set_sample_config(sample_in_dim=self.sample_ffn_embed_dim_this_layer, sample_out_dim=self.sample_out_dim) + + self.ffn_layer_norm.set_sample_config(sample_embed_dim=self.sample_embed_dim) + + + def forward(self, x): + """ + Args: + x (Tensor): input to the layer of shape `(batch, patch_num , sample_embed_dim)` + + Returns: + encoded output of shape `(batch, patch_num, sample_embed_dim)` + """ + if self.is_identity_layer: + return x + + # compute attn + # start_time = time.time() + + residual = x + x = self.maybe_layer_norm(self.attn_layer_norm, x, before=True) + x = self.attn(x) + x = F.dropout(x, p=self.sample_attn_dropout, training=self.training) + x = self.drop_path(x) + x = residual + x + x = self.maybe_layer_norm(self.attn_layer_norm, x, after=True) + # print("attn :", time.time() - start_time) + # compute the ffn + # start_time = time.time() + residual = x + x = self.maybe_layer_norm(self.ffn_layer_norm, x, before=True) + x = self.activation_fn(self.fc1(x)) + x = F.dropout(x, p=self.sample_dropout, training=self.training) + x = self.fc2(x) + x = F.dropout(x, p=self.sample_dropout, training=self.training) + if self.scale: + x = x * (self.super_mlp_ratio / self.sample_mlp_ratio) + x = self.drop_path(x) + x = residual + x + x = self.maybe_layer_norm(self.ffn_layer_norm, x, after=True) + # print("ffn :", time.time() - start_time) + return x + + def maybe_layer_norm(self, layer_norm, x, before=False, after=False): + assert before ^ after + if after ^ self.normalize_before: + return layer_norm(x) + else: + return x + def get_complexity(self, sequence_length): + total_flops = 0 + if self.is_identity_layer: + return total_flops + total_flops += self.attn_layer_norm.get_complexity(sequence_length+1) + total_flops += self.attn.get_complexity(sequence_length+1) + total_flops += self.ffn_layer_norm.get_complexity(sequence_length+1) + total_flops += self.fc1.get_complexity(sequence_length+1) + total_flops += self.fc2.get_complexity(sequence_length+1) + return total_flops + +def calc_dropout(dropout, sample_embed_dim, super_embed_dim): + return dropout * 1.0 * sample_embed_dim / super_embed_dim + + + + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/utils.py new file mode 100644 index 000000000..d3d05442d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/model/utils.py @@ -0,0 +1,106 @@ +import torch +import math +import warnings +from itertools import repeat +from torch._six import container_abcs +import torch.nn as nn + +def _no_grad_trunc_normal_(tensor, mean, std, a, b): + # Cut & paste from PyTorch official master until it's in a few official releases - RW + # Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf + def norm_cdf(x): + # Computes standard normal cumulative distribution function + return (1. + math.erf(x / math.sqrt(2.))) / 2. + + if (mean < a - 2 * std) or (mean > b + 2 * std): + warnings.warn("mean is more than 2 std from [a, b] in nn.init.trunc_normal_. " + "The distribution of values may be incorrect.", + stacklevel=2) + + with torch.no_grad(): + # Values are generated by using a truncated uniform distribution and + # then using the inverse CDF for the normal distribution. + # Get upper and lower cdf values + l = norm_cdf((a - mean) / std) + u = norm_cdf((b - mean) / std) + + # Uniformly fill tensor with values from [l, u], then translate to + # [2l-1, 2u-1]. + tensor.uniform_(2 * l - 1, 2 * u - 1) + + # Use inverse cdf transform for normal distribution to get truncated + # standard normal + tensor.erfinv_() + + # Transform to proper mean, std + tensor.mul_(std * math.sqrt(2.)) + tensor.add_(mean) + + # Clamp to ensure it's in the proper range + tensor.clamp_(min=a, max=b) + return tensor + + +def trunc_normal_(tensor, mean=0., std=1., a=-2., b=2.): + # type: (Tensor, float, float, float, float) -> Tensor + r"""Fills the input Tensor with values drawn from a truncated + normal distribution. The values are effectively drawn from the + normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)` + with values outside :math:`[a, b]` redrawn until they are within + the bounds. The method used for generating the random values works + best when :math:`a \leq \text{mean} \leq b`. + Args: + tensor: an n-dimensional `torch.Tensor` + mean: the mean of the normal distribution + std: the standard deviation of the normal distribution + a: the minimum cutoff value + b: the maximum cutoff value + Examples: + >>> w = torch.empty(3, 5) + >>> nn.init.trunc_normal_(w) + """ + return _no_grad_trunc_normal_(tensor, mean, std, a, b) + +def _ntuple(n): + def parse(x): + if isinstance(x, container_abcs.Iterable): + return x + return tuple(repeat(x, n)) + return parse + +def drop_path(x, drop_prob: float = 0., training: bool = False): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + + This is the same as the DropConnect impl I created for EfficientNet, etc networks, however, + the original name is misleading as 'Drop Connect' is a different form of dropout in a separate paper... + See discussion: https://github.com/tensorflow/tpu/issues/494#issuecomment-532968956 ... I've opted for + changing the layer and argument names to 'drop path' rather than mix DropConnect as a layer name and use + 'survival rate' as the argument. + + """ + if drop_prob == 0. or not training: + return x + keep_prob = 1 - drop_prob + shape = (x.shape[0],) + (1,) * (x.ndim - 1) # work with diff dim tensors, not just 2D ConvNets + random_tensor = keep_prob + torch.rand(shape, dtype=x.dtype, device=x.device) + random_tensor.floor_() # binarize + output = x.div(keep_prob) * random_tensor + return output + + +class DropPath(nn.Module): + """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). + """ + def __init__(self, drop_prob=None): + super(DropPath, self).__init__() + self.drop_prob = drop_prob + + def forward(self, x): + return drop_path(x, self.drop_prob, self.training) + + +to_1tuple = _ntuple(1) +to_2tuple = _ntuple(2) +to_3tuple = _ntuple(3) +to_4tuple = _ntuple(4) +to_ntuple = _ntuple \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/requirements.txt b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/requirements.txt new file mode 100644 index 000000000..b7a9bf1a5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/requirements.txt @@ -0,0 +1,9 @@ +torch==1.7.0 +timm==0.3.2 +scikit-image +ptflops +easydict +PyYAML +pillow +torchvision==0.2.1 +opencv-python diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_engine.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_engine.py new file mode 100644 index 000000000..67d11a192 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_engine.py @@ -0,0 +1,160 @@ +import math +import sys +from typing import Iterable, Optional +from timm.utils.model import unwrap_model +import torch + +from timm.data import Mixup +from timm.utils import accuracy, ModelEma +from lib import utils +import random +import time + +def sample_configs(choices): + + config = {} + dimensions = ['mlp_ratio', 'num_heads'] + depth = random.choice(choices['depth']) + for dimension in dimensions: + config[dimension] = [random.choice(choices[dimension]) for _ in range(depth)] + + config['embed_dim'] = [random.choice(choices['embed_dim'])]*depth + + config['layer_num'] = depth + return config + +def train_one_epoch(model: torch.nn.Module, criterion: torch.nn.Module, + data_loader: Iterable, optimizer: torch.optim.Optimizer, + device: torch.device, epoch: int, loss_scaler, max_norm: float = 0, + model_ema: Optional[ModelEma] = None, mixup_fn: Optional[Mixup] = None, + amp: bool = True, teacher_model: torch.nn.Module = None, + teach_loss: torch.nn.Module = None, choices=None, mode='super', retrain_config=None): + model.train() + criterion.train() + + # set random seed + random.seed(epoch) + + metric_logger = utils.MetricLogger(delimiter=" ") + metric_logger.add_meter('lr', utils.SmoothedValue(window_size=1, fmt='{value:.6f}')) + header = 'Epoch: [{}]'.format(epoch) + print_freq = 10 + if mode == 'retrain': + config = retrain_config + model_module = unwrap_model(model) + print(config) + model_module.set_sample_config(config=config) + print(model_module.get_sampled_params_numel(config)) + + for samples, targets in metric_logger.log_every(data_loader, print_freq, header): + samples = samples.to(device, non_blocking=True) + targets = targets.to(device, non_blocking=True) + + # sample random config + if mode == 'super': + config = sample_configs(choices=choices) + model_module = unwrap_model(model) + model_module.set_sample_config(config=config) + elif mode == 'retrain': + config = retrain_config + model_module = unwrap_model(model) + model_module.set_sample_config(config=config) + if mixup_fn is not None: + samples, targets = mixup_fn(samples, targets) + if amp: + with torch.cuda.amp.autocast(): + if teacher_model: + with torch.no_grad(): + teach_output = teacher_model(samples) + _, teacher_label = teach_output.topk(1, 1, True, True) + outputs = model(samples) + loss = 1/2 * criterion(outputs, targets) + 1/2 * teach_loss(outputs, teacher_label.squeeze()) + else: + outputs = model(samples) + loss = criterion(outputs, targets) + else: + outputs = model(samples) + if teacher_model: + with torch.no_grad(): + teach_output = teacher_model(samples) + _, teacher_label = teach_output.topk(1, 1, True, True) + loss = 1 / 2 * criterion(outputs, targets) + 1 / 2 * teach_loss(outputs, teacher_label.squeeze()) + else: + loss = criterion(outputs, targets) + + loss_value = loss.item() + + if not math.isfinite(loss_value): + print("Loss is {}, stopping training".format(loss_value)) + sys.exit(1) + + optimizer.zero_grad() + + # this attribute is added by timm on one optimizer (adahessian) + if amp: + is_second_order = hasattr(optimizer, 'is_second_order') and optimizer.is_second_order + loss_scaler(loss, optimizer, clip_grad=max_norm, + parameters=model.parameters(), create_graph=is_second_order) + else: + loss.backward() + optimizer.step() + + torch.cuda.synchronize() + if model_ema is not None: + model_ema.update(model) + + metric_logger.update(loss=loss_value) + metric_logger.update(lr=optimizer.param_groups[0]["lr"]) + + # gather the stats from all processes + metric_logger.synchronize_between_processes() + print("Averaged stats:", metric_logger) + return {k: meter.global_avg for k, meter in metric_logger.meters.items()} + +@torch.no_grad() +def evaluate(data_loader, model, device, amp=True, choices=None, mode='super', retrain_config=None): + criterion = torch.nn.CrossEntropyLoss() + + metric_logger = utils.MetricLogger(delimiter=" ") + header = 'Test:' + + # switch to evaluation mode + model.eval() + if mode == 'super': + config = sample_configs(choices=choices) + model_module = unwrap_model(model) + model_module.set_sample_config(config=config) + else: + config = retrain_config + model_module = unwrap_model(model) + model_module.set_sample_config(config=config) + + + print("sampled model config: {}".format(config)) + parameters = model_module.get_sampled_params_numel(config) + print("sampled model parameters: {}".format(parameters)) + + for images, target in metric_logger.log_every(data_loader, 10, header): + images = images.to(device, non_blocking=True) + target = target.to(device, non_blocking=True) + # compute output + if amp: + with torch.cuda.amp.autocast(): + output = model(images) + loss = criterion(output, target) + else: + output = model(images) + loss = criterion(output, target) + + acc1, acc5 = accuracy(output, target, topk=(1, 5)) + + batch_size = images.shape[0] + metric_logger.update(loss=loss.item()) + metric_logger.meters['acc1'].update(acc1.item(), n=batch_size) + metric_logger.meters['acc5'].update(acc5.item(), n=batch_size) + # gather the stats from all processes + metric_logger.synchronize_between_processes() + print('* Acc@1 {top1.global_avg:.3f} Acc@5 {top5.global_avg:.3f} loss {losses.global_avg:.3f}' + .format(top1=metric_logger.acc1, top5=metric_logger.acc5, losses=metric_logger.loss)) + + return {k: meter.global_avg for k, meter in metric_logger.meters.items()} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_train.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_train.py new file mode 100644 index 000000000..ba900752b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormer/supernet_train.py @@ -0,0 +1,397 @@ +import argparse +import datetime +import numpy as np +import time +import torch +import torch.backends.cudnn as cudnn +import json +import yaml +from pathlib import Path +from timm.data import Mixup +from timm.models import create_model +from timm.loss import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy +from timm.scheduler import create_scheduler +from timm.optim import create_optimizer +from timm.utils import NativeScaler +from lib.datasets import build_dataset +from supernet_engine import train_one_epoch, evaluate +from lib.samplers import RASampler +from lib import utils +from lib.config import cfg, update_config_from_file +from model.supernet_transformer import Vision_TransformerSuper + + +def get_args_parser(): + parser = argparse.ArgumentParser('AutoFormer training and evaluation script', add_help=False) + parser.add_argument('--batch-size', default=64, type=int) + parser.add_argument('--epochs', default=300, type=int) + # config file + parser.add_argument('--cfg',help='experiment configure file name',required=True,type=str) + + # custom parameters + parser.add_argument('--platform', default='pai', type=str, choices=['itp', 'pai', 'aml'], + help='Name of model to train') + parser.add_argument('--teacher_model', default='', type=str, + help='Name of teacher model to train') + parser.add_argument('--relative_position', action='store_true') + parser.add_argument('--gp', action='store_true') + parser.add_argument('--change_qkv', action='store_true') + parser.add_argument('--max_relative_position', type=int, default=14, help='max distance in relative position embedding') + + # Model parameters + parser.add_argument('--model', default='', type=str, metavar='MODEL', + help='Name of model to train') + # AutoFormer config + parser.add_argument('--mode', type=str, default='super', choices=['super', 'retrain'], help='mode of AutoFormer') + parser.add_argument('--input-size', default=224, type=int) + parser.add_argument('--patch_size', default=16, type=int) + + parser.add_argument('--drop', type=float, default=0.0, metavar='PCT', + help='Dropout rate (default: 0.)') + parser.add_argument('--drop-path', type=float, default=0.1, metavar='PCT', + help='Drop path rate (default: 0.1)') + parser.add_argument('--drop-block', type=float, default=None, metavar='PCT', + help='Drop block rate (default: None)') + + parser.add_argument('--model-ema', action='store_true') + parser.add_argument('--no-model-ema', action='store_false', dest='model_ema') + # parser.set_defaults(model_ema=True) + parser.add_argument('--model-ema-decay', type=float, default=0.99996, help='') + parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, help='') + parser.add_argument('--rpe_type', type=str, default='bias', choices=['bias', 'direct']) + parser.add_argument('--post_norm', action='store_true') + parser.add_argument('--no_abs_pos', action='store_true') + + # Optimizer parameters + parser.add_argument('--opt', default='adamw', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "adamw"') + parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') + parser.add_argument('--opt-betas', default=None, type=float, nargs='+', metavar='BETA', + help='Optimizer Betas (default: None, use opt default)') + parser.add_argument('--clip-grad', type=float, default=None, metavar='NORM', + help='Clip gradient norm (default: None, no clipping)') + parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') + parser.add_argument('--weight-decay', type=float, default=0.05, + help='weight decay (default: 0.05)') + + # Learning rate schedule parameters + parser.add_argument('--sched', default='cosine', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "cosine"') + parser.add_argument('--lr', type=float, default=5e-4, metavar='LR', + help='learning rate (default: 5e-4)') + parser.add_argument('--lr-noise', type=float, nargs='+', default=None, metavar='pct, pct', + help='learning rate noise on/off epoch percentages') + parser.add_argument('--lr-noise-pct', type=float, default=0.67, metavar='PERCENT', + help='learning rate noise limit percent (default: 0.67)') + parser.add_argument('--lr-noise-std', type=float, default=1.0, metavar='STDDEV', + help='learning rate noise std-dev (default: 1.0)') + parser.add_argument('--warmup-lr', type=float, default=1e-6, metavar='LR', + help='warmup learning rate (default: 1e-6)') + parser.add_argument('--min-lr', type=float, default=1e-5, metavar='LR', + help='lower lr bound for cyclic schedulers that hit 0 (1e-5)') + parser.add_argument('--lr-power', type=float, default=1.0, + help='power of the polynomial lr scheduler') + + parser.add_argument('--decay-epochs', type=float, default=30, metavar='N', + help='epoch interval to decay LR') + parser.add_argument('--warmup-epochs', type=int, default=5, metavar='N', + help='epochs to warmup LR, if scheduler supports') + parser.add_argument('--cooldown-epochs', type=int, default=10, metavar='N', + help='epochs to cooldown LR at min_lr, after cyclic schedule ends') + parser.add_argument('--patience-epochs', type=int, default=10, metavar='N', + help='patience epochs for Plateau LR scheduler (default: 10') + parser.add_argument('--decay-rate', '--dr', type=float, default=0.1, metavar='RATE', + help='LR decay rate (default: 0.1)') + + # Augmentation parameters + parser.add_argument('--color-jitter', type=float, default=0.4, metavar='PCT', + help='Color jitter factor (default: 0.4)') + parser.add_argument('--aa', type=str, default='rand-m9-mstd0.5-inc1', metavar='NAME', + help='Use AutoAugment policy. "v0" or "original". " + \ + "(default: rand-m9-mstd0.5-inc1)'), + parser.add_argument('--smoothing', type=float, default=0.1, help='Label smoothing (default: 0.1)') + parser.add_argument('--train-interpolation', type=str, default='bicubic', + help='Training interpolation (random, bilinear, bicubic default: "bicubic")') + + parser.add_argument('--repeated-aug', action='store_true') + parser.add_argument('--no-repeated-aug', action='store_false', dest='repeated_aug') + + + parser.set_defaults(repeated_aug=True) + + # * Random Erase params + parser.add_argument('--reprob', type=float, default=0.25, metavar='PCT', + help='Random erase prob (default: 0.25)') + parser.add_argument('--remode', type=str, default='pixel', + help='Random erase mode (default: "pixel")') + parser.add_argument('--recount', type=int, default=1, + help='Random erase count (default: 1)') + parser.add_argument('--resplit', action='store_true', default=False, + help='Do not random erase first (clean) augmentation split') + + # * Mixup params + parser.add_argument('--mixup', type=float, default=0.8, + help='mixup alpha, mixup enabled if > 0. (default: 0.8)') + parser.add_argument('--cutmix', type=float, default=1.0, + help='cutmix alpha, cutmix enabled if > 0. (default: 1.0)') + parser.add_argument('--cutmix-minmax', type=float, nargs='+', default=None, + help='cutmix min/max ratio, overrides alpha and enables cutmix if set (default: None)') + parser.add_argument('--mixup-prob', type=float, default=1.0, + help='Probability of performing mixup or cutmix when either/both is enabled') + parser.add_argument('--mixup-switch-prob', type=float, default=0.5, + help='Probability of switching to cutmix when both mixup and cutmix enabled') + parser.add_argument('--mixup-mode', type=str, default='batch', + help='How to apply mixup/cutmix params. Per "batch", "pair", or "elem"') + + # Dataset parameters + parser.add_argument('--data-path', default='./data/imagenet/', type=str, + help='dataset path') + parser.add_argument('--data-set', default='IMNET', choices=['CIFAR', 'IMNET', 'INAT', 'INAT19'], + type=str, help='Image Net dataset path') + parser.add_argument('--inat-category', default='name', + choices=['kingdom', 'phylum', 'class', 'order', 'supercategory', 'family', 'genus', 'name'], + type=str, help='semantic granularity') + + parser.add_argument('--output_dir', default='./', + help='path where to save, empty for no saving') + parser.add_argument('--device', default='cuda', + help='device to use for training / testing') + parser.add_argument('--seed', default=0, type=int) + parser.add_argument('--resume', default='', help='resume from checkpoint') + parser.add_argument('--start_epoch', default=0, type=int, metavar='N', + help='start epoch') + parser.add_argument('--eval', action='store_true', help='Perform evaluation only') + parser.add_argument('--num_workers', default=10, type=int) + parser.add_argument('--dist-eval', action='store_true', default=False, help='Enabling distributed evaluation') + parser.add_argument('--pin-mem', action='store_true', + help='Pin CPU memory in DataLoader for more efficient (sometimes) transfer to GPU.') + parser.add_argument('--no-pin-mem', action='store_false', dest='pin_mem', + help='') + parser.set_defaults(pin_mem=True) + + # distributed training parameters + parser.add_argument('--world_size', default=1, type=int, + help='number of distributed processes') + parser.add_argument('--dist_url', default='env://', help='url used to set up distributed training') + + parser.add_argument('--amp', action='store_true') + parser.add_argument('--no-amp', action='store_false', dest='amp') + parser.set_defaults(amp=True) + + + return parser + +def main(args): + + utils.init_distributed_mode(args) + update_config_from_file(args.cfg) + + print(args) + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + + device = torch.device(args.device) + + # fix the seed for reproducibility + seed = args.seed + utils.get_rank() + torch.manual_seed(seed) + np.random.seed(seed) + # random.seed(seed) + cudnn.benchmark = True + + dataset_train, args.nb_classes = build_dataset(is_train=True, args=args) + dataset_val, _ = build_dataset(is_train=False, args=args) + + if args.distributed: + num_tasks = utils.get_world_size() + global_rank = utils.get_rank() + if args.repeated_aug: + sampler_train = RASampler( + dataset_train, num_replicas=num_tasks, rank=global_rank, shuffle=True + ) + else: + sampler_train = torch.utils.data.DistributedSampler( + dataset_train, num_replicas=num_tasks, rank=global_rank, shuffle=True + ) + if args.dist_eval: + if len(dataset_val) % num_tasks != 0: + print( + 'Warning: Enabling distributed evaluation with an eval dataset not divisible by process number. ' + 'This will slightly alter validation results as extra duplicate entries are added to achieve ' + 'equal num of samples per-process.') + sampler_val = torch.utils.data.DistributedSampler( + dataset_val, num_replicas=num_tasks, rank=global_rank, shuffle=False) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + sampler_train = torch.utils.data.RandomSampler(dataset_train) + + data_loader_train = torch.utils.data.DataLoader( + dataset_train, sampler=sampler_train, + batch_size=args.batch_size, + num_workers=args.num_workers, + pin_memory=args.pin_mem, + drop_last=True, + ) + + data_loader_val = torch.utils.data.DataLoader( + dataset_val, batch_size=int(2 * args.batch_size), + sampler=sampler_val, num_workers=args.num_workers, + pin_memory=args.pin_mem, drop_last=False + ) + + mixup_fn = None + mixup_active = args.mixup > 0 or args.cutmix > 0. or args.cutmix_minmax is not None + if mixup_active: + mixup_fn = Mixup( + mixup_alpha=args.mixup, cutmix_alpha=args.cutmix, cutmix_minmax=args.cutmix_minmax, + prob=args.mixup_prob, switch_prob=args.mixup_switch_prob, mode=args.mixup_mode, + label_smoothing=args.smoothing, num_classes=args.nb_classes) + + print(f"Creating SuperVisionTransformer") + print(cfg) + model = Vision_TransformerSuper(img_size=args.input_size, + patch_size=args.patch_size, + embed_dim=cfg.SUPERNET.EMBED_DIM, depth=cfg.SUPERNET.DEPTH, + num_heads=cfg.SUPERNET.NUM_HEADS,mlp_ratio=cfg.SUPERNET.MLP_RATIO, + qkv_bias=True, drop_rate=args.drop, + drop_path_rate=args.drop_path, + gp=args.gp, + num_classes=args.nb_classes, + max_relative_position=args.max_relative_position, + relative_position=args.relative_position, + change_qkv=args.change_qkv, abs_pos=not args.no_abs_pos) + + choices = {'num_heads': cfg.SEARCH_SPACE.NUM_HEADS, 'mlp_ratio': cfg.SEARCH_SPACE.MLP_RATIO, + 'embed_dim': cfg.SEARCH_SPACE.EMBED_DIM , 'depth': cfg.SEARCH_SPACE.DEPTH} + + model.to(device) + if args.teacher_model: + teacher_model = create_model( + args.teacher_model, + pretrained=True, + num_classes=args.nb_classes, + ) + teacher_model.to(device) + teacher_loss = LabelSmoothingCrossEntropy(smoothing=args.smoothing) + else: + teacher_model = None + teacher_loss = None + + model_ema = None + + model_without_ddp = model + if args.distributed: + + model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], find_unused_parameters=True) + model_without_ddp = model.module + + n_parameters = sum(p.numel() for p in model.parameters() if p.requires_grad) + print('number of params:', n_parameters) + + linear_scaled_lr = args.lr * args.batch_size * utils.get_world_size() / 512.0 + args.lr = linear_scaled_lr + optimizer = create_optimizer(args, model_without_ddp) + loss_scaler = NativeScaler() + lr_scheduler, _ = create_scheduler(args, optimizer) + + # criterion = LabelSmoothingCrossEntropy() + + if args.mixup > 0.: + # smoothing is handled with mixup label transform + criterion = SoftTargetCrossEntropy() + elif args.smoothing: + criterion = LabelSmoothingCrossEntropy(smoothing=args.smoothing) + else: + criterion = torch.nn.CrossEntropyLoss() + + output_dir = Path(args.output_dir) + + if not output_dir.exists(): + output_dir.mkdir(parents=True) + # save config for later experiments + with open(output_dir / "config.yaml", 'w') as f: + f.write(args_text) + if args.resume: + if args.resume.startswith('https'): + checkpoint = torch.hub.load_state_dict_from_url( + args.resume, map_location='cpu', check_hash=True) + else: + checkpoint = torch.load(args.resume, map_location='cpu') + model_without_ddp.load_state_dict(checkpoint['model']) + if not args.eval and 'optimizer' in checkpoint and 'lr_scheduler' in checkpoint and 'epoch' in checkpoint: + optimizer.load_state_dict(checkpoint['optimizer']) + lr_scheduler.load_state_dict(checkpoint['lr_scheduler']) + args.start_epoch = checkpoint['epoch'] + 1 + if 'scaler' in checkpoint: + loss_scaler.load_state_dict(checkpoint['scaler']) + if args.model_ema: + utils._load_checkpoint_for_ema(model_ema, checkpoint['model_ema']) + + retrain_config = None + if args.mode == 'retrain' and "RETRAIN" in cfg: + retrain_config = {'layer_num': cfg.RETRAIN.DEPTH, 'embed_dim': [cfg.RETRAIN.EMBED_DIM]*cfg.RETRAIN.DEPTH, + 'num_heads': cfg.RETRAIN.NUM_HEADS,'mlp_ratio': cfg.RETRAIN.MLP_RATIO} + if args.eval: + test_stats = evaluate(data_loader_val, model, device, mode = args.mode, retrain_config=retrain_config) + print(f"Accuracy of the network on the {len(dataset_val)} test images: {test_stats['acc1']:.1f}%") + return + + print("Start training") + start_time = time.time() + max_accuracy = 0.0 + + for epoch in range(args.start_epoch, args.epochs): + if args.distributed: + data_loader_train.sampler.set_epoch(epoch) + + train_stats = train_one_epoch( + model, criterion, data_loader_train, + optimizer, device, epoch, loss_scaler, + args.clip_grad, model_ema, mixup_fn, + amp=args.amp, teacher_model=teacher_model, + teach_loss=teacher_loss, + choices=choices, mode = args.mode, retrain_config=retrain_config, + ) + + lr_scheduler.step(epoch) + if args.output_dir: + checkpoint_paths = [output_dir / 'checkpoint.pth'] + for checkpoint_path in checkpoint_paths: + utils.save_on_master({ + 'model': model_without_ddp.state_dict(), + 'optimizer': optimizer.state_dict(), + 'lr_scheduler': lr_scheduler.state_dict(), + 'epoch': epoch, + # 'model_ema': get_state_dict(model_ema), + 'scaler': loss_scaler.state_dict(), + 'args': args, + }, checkpoint_path) + + test_stats = evaluate(data_loader_val, model, device, amp=args.amp, choices=choices, mode = args.mode, retrain_config=retrain_config) + print(f"Accuracy of the network on the {len(dataset_val)} test images: {test_stats['acc1']:.1f}%") + max_accuracy = max(max_accuracy, test_stats["acc1"]) + print(f'Max accuracy: {max_accuracy:.2f}%') + + log_stats = {**{f'train_{k}': v for k, v in train_stats.items()}, + **{f'test_{k}': v for k, v in test_stats.items()}, + 'epoch': epoch, + 'n_parameters': n_parameters} + + if args.output_dir and utils.is_main_process(): + with (output_dir / "log.txt").open("a") as f: + f.write(json.dumps(log_stats) + "\n") + + total_time = time.time() - start_time + total_time_str = str(datetime.timedelta(seconds=int(total_time))) + print('Training time {}'.format(total_time_str)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser('AutoFormer training and evaluation script', parents=[get_args_parser()]) + args = parser.parse_args() + if args.output_dir: + Path(args.output_dir).mkdir(parents=True, exist_ok=True) + main(args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/README.md new file mode 100644 index 000000000..a68528e30 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/README.md @@ -0,0 +1,82 @@ +# Searching the Search Space of Vision Transformer + +**This is an official implementation of S3.** + +In this work, instead of searching the architecture in a predefined search space, with the help of AutoFormer, we proposed to search the search space to automatically find a great search space first. After that we search the architectures in the searched space. +In addition, we provide insightful observations and guidelines for general vision transformer design. + +
+ S3 overview +
+ + +## Environment Setup + +To set up the enviroment you can easily run the following command: +```buildoutcfg +conda create -n SSS python=3.6 +conda activate SSS +pip install -r requirements.txt +``` + +## Data Preparation +You need to first download the [ImageNet-2012](http://www.image-net.org/) to the folder `./data/imagenet` and move the validation set to the subfolder `./data/imagenet/val`. To move the validation set, you cloud use the following script: + +The directory structure is the standard layout as following. +``` +/path/to/imagenet/ + train/ + class1/ + img1.jpeg + class2/ + img2.jpeg + val/ + class1/ + img3.jpeg + class/2 + img4.jpeg +``` + + +## Model Zoo +For evaluation, we provide the checkpoints and configs of our models. + +After downloading the models, you can do the evaluation following the description in *Evaluation*). + +Model download links: + +Model | Params. | Top-1 Acc. % | Top-5 Acc. % | Model +--- |:---:|:---:|:---:|:---: +AutoFormerV2-T | 28M | 82.1 | 95.8 | [link](https://github.com/silent-chen/AutoFormerV2-model-zoo/releases/download/v1.0.0/S3-T.pth)/[config](./configs/S3-T.yaml) +AutoFormerV2-S | 50M | 83.7 | 96.4 | [link](https://github.com/silent-chen/AutoFormerV2-model-zoo/releases/download/v1.0.0/S3-S.pth)/[config](./configs/S3-S.yaml) +AutoFormerV2-B | 71M | 84.0 | 96.6 | [link](https://github.com/silent-chen/AutoFormerV2-model-zoo/releases/download/v1.0.0/S3-B.pth)/[config](./configs/S3-B.yaml) + +### Evaluation +To evaluate our trained models, you need to put the downloaded model in `/PATH/TO/CHECKPOINT`. After that you could use the following command to test the model (Please change your config file and model checkpoint according to different models. Here we use the AutoFormer-B as an example). +```buildoutcfg +python -m torch.distributed.launch --nproc_per_node=8 --use_env evaluation.py --data-path /PATH/TO/IMAGENT \ +--dist-eval --cfg ./config/S3-B.yaml --resume /PATH/TO/CHECKPOINT --eval +``` + +## Performance + +We give the performance comparison between S3 and other state-of-the-art methods under different resources constraint in terms of Top-1 accuracy on ImageNet. Our method achieves very competitive performance, being superior to the recent DeiT, ViT, Swin. +
+ Performance +
+ +## Bibtex + +If this repo is helpful for you, please consider to cite it. Thank you! :) +```bibtex +@article{S3, + title={Searching the Search Space of Vision Transformer}, + author={Minghao, Chen and Kan, Wu and Bolin, Ni and Houwen, Peng and Bei, Liu and Jianlong, Fu and Hongyang, Chao and Haibin, Ling}, + booktitle={Conference and Workshop on Neural Information Processing Systems (NeurIPS)}, + year={2021} +} +``` + +## Acknowledgements + +The codes are inspired by [HAT](https://github.com/mit-han-lab/hardware-aware-transformers), [timm](https://github.com/rwightman/pytorch-image-models), [DeiT](https://github.com/facebookresearch/deit), [SPOS](https://github.com/megvii-model/SinglePathOneShot), [AutoFormer](https://github.com/microsoft/Cream/tree/main/AutoFormer), [Swin](https://github.com/microsoft/Swin-Transformer) . diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-B.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-B.yaml new file mode 100644 index 000000000..c09893db4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-B.yaml @@ -0,0 +1,5 @@ +MLP_RATIO: [[4.0, 4.0], [4.0, 4.0], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0], [4.0, 4.0]] +NUM_HEADS: [[3,3], [6,6], [12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12], [24,24]] +EMBED_DIM: [96,192,384,768] +DEPTHS: [ 2, 2, 30, 2 ] +WINDOW_SIZE: [[7,7], [7,7], [14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14], [7,7]] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-S.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-S.yaml new file mode 100644 index 000000000..c665da2c8 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-S.yaml @@ -0,0 +1,5 @@ +MLP_RATIO: [[4.0, 4.0], [4.0, 4.0], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0], [4.0, 4.0]] +NUM_HEADS: [[3,3], [6,6], [12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12], [24,24]] +EMBED_DIM: [96,192,384,768] +DEPTHS: [ 2, 2, 18, 2 ] +WINDOW_SIZE: [[14,14], [14,14], [14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14], [14,14]] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-T.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-T.yaml new file mode 100644 index 000000000..4ae1c5895 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/configs/S3-T.yaml @@ -0,0 +1,5 @@ +MLP_RATIO: [[4.0, 4.0], [4.0, 4.0], [4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0], [4.0, 4.0]] +NUM_HEADS: [[3,3], [6,6], [12,12,12,12,12,12,12,12], [24,24]] +EMBED_DIM: [96,192,384,768] +DEPTHS: [ 2, 2, 6, 2 ] +WINDOW_SIZE: [[7,7], [7,7], [14,14,14,14,14,14,14,14], [7,7]] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/engine.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/engine.py new file mode 100644 index 000000000..c348c2701 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/engine.py @@ -0,0 +1,46 @@ +import math +import sys +from typing import Iterable, Optional +from timm.utils.model import unwrap_model +import torch + +from timm.data import Mixup +from timm.utils import accuracy, ModelEma +from lib import utils + + + +@torch.no_grad() +def evaluate(data_loader, model, device, amp=True): + criterion = torch.nn.CrossEntropyLoss() + + metric_logger = utils.MetricLogger(delimiter=" ") + header = 'Test:' + + # switch to evaluation mode + model.eval() + + for images, target in metric_logger.log_every(data_loader, 10, header): + images = images.to(device, non_blocking=True) + target = target.to(device, non_blocking=True) + # compute output + if amp: + with torch.cuda.amp.autocast(): + output = model(images) + loss = criterion(output, target) + else: + output = model(images) + loss = criterion(output, target) + + acc1, acc5 = accuracy(output, target, topk=(1, 5)) + + batch_size = images.shape[0] + metric_logger.update(loss=loss.item()) + metric_logger.meters['acc1'].update(acc1.item(), n=batch_size) + metric_logger.meters['acc5'].update(acc5.item(), n=batch_size) + # gather the stats from all processes + metric_logger.synchronize_between_processes() + print('* Acc@1 {top1.global_avg:.3f} Acc@5 {top5.global_avg:.3f} loss {losses.global_avg:.3f}' + .format(top1=metric_logger.acc1, top5=metric_logger.acc5, losses=metric_logger.loss)) + + return {k: meter.global_avg for k, meter in metric_logger.meters.items()} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/evaluation.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/evaluation.py new file mode 100644 index 000000000..68e64bd36 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/evaluation.py @@ -0,0 +1,292 @@ +import argparse +import datetime +import numpy as np +import time +import torch +import torch.backends.cudnn as cudnn +import json +import yaml +from pathlib import Path +from timm.data import Mixup +from timm.scheduler import create_scheduler +from timm.optim import create_optimizer +from timm.utils import NativeScaler +from lib.datasets import build_dataset +from engine import evaluate +from lib import utils +from lib.config import cfg, update_config_from_file +from model.SSS import SSSTransformer + + +def get_args_parser(): + parser = argparse.ArgumentParser('S3 and evaluation script', add_help=False) + parser.add_argument('--batch-size', default=64, type=int) + parser.add_argument('--epochs', default=300, type=int) + # config file + parser.add_argument('--cfg',help='experiment configure file name',required=True,type=str) + + # custom parameters + parser.add_argument('--platform', default='pai', type=str, choices=['itp', 'pai', 'aml'], + help='Name of model to train') + parser.add_argument('--teacher_model', default='', type=str, + help='Name of teacher model to train') + parser.add_argument('--relative_position', action='store_true') + parser.add_argument('--gp', action='store_true') + parser.add_argument('--change_qkv', action='store_true') + parser.add_argument('--max_relative_position', type=int, default=14, help='max distance in relative position embedding') + + # Model parameters + parser.add_argument('--model', default='', type=str, metavar='MODEL', + help='Name of model to train') + # AutoFormer config + parser.add_argument('--mode', type=str, default='super', choices=['super', 'retrain'], help='mode of AutoFormer') + parser.add_argument('--input-size', default=224, type=int) + parser.add_argument('--patch_size', default=4, type=int) + + parser.add_argument('--drop', type=float, default=0.0, metavar='PCT', + help='Dropout rate (default: 0.)') + parser.add_argument('--drop-path', type=float, default=0.1, metavar='PCT', + help='Drop path rate (default: 0.1)') + parser.add_argument('--drop-block', type=float, default=None, metavar='PCT', + help='Drop block rate (default: None)') + + parser.add_argument('--model-ema', action='store_true') + parser.add_argument('--no-model-ema', action='store_false', dest='model_ema') + # parser.set_defaults(model_ema=True) + parser.add_argument('--model-ema-decay', type=float, default=0.99996, help='') + parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, help='') + parser.add_argument('--rpe_type', type=str, default='bias', choices=['bias', 'direct']) + parser.add_argument('--post_norm', action='store_true') + parser.add_argument('--no_abs_pos', action='store_true') + + # Optimizer parameters + parser.add_argument('--opt', default='adamw', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "adamw"') + parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') + parser.add_argument('--opt-betas', default=None, type=float, nargs='+', metavar='BETA', + help='Optimizer Betas (default: None, use opt default)') + parser.add_argument('--clip-grad', type=float, default=None, metavar='NORM', + help='Clip gradient norm (default: None, no clipping)') + parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') + parser.add_argument('--weight-decay', type=float, default=0.05, + help='weight decay (default: 0.05)') + + # Learning rate schedule parameters + parser.add_argument('--sched', default='cosine', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "cosine"') + parser.add_argument('--lr', type=float, default=5e-4, metavar='LR', + help='learning rate (default: 5e-4)') + parser.add_argument('--lr-noise', type=float, nargs='+', default=None, metavar='pct, pct', + help='learning rate noise on/off epoch percentages') + parser.add_argument('--lr-noise-pct', type=float, default=0.67, metavar='PERCENT', + help='learning rate noise limit percent (default: 0.67)') + parser.add_argument('--lr-noise-std', type=float, default=1.0, metavar='STDDEV', + help='learning rate noise std-dev (default: 1.0)') + parser.add_argument('--warmup-lr', type=float, default=1e-6, metavar='LR', + help='warmup learning rate (default: 1e-6)') + parser.add_argument('--min-lr', type=float, default=1e-5, metavar='LR', + help='lower lr bound for cyclic schedulers that hit 0 (1e-5)') + parser.add_argument('--lr-power', type=float, default=1.0, + help='power of the polynomial lr scheduler') + + parser.add_argument('--decay-epochs', type=float, default=30, metavar='N', + help='epoch interval to decay LR') + parser.add_argument('--warmup-epochs', type=int, default=5, metavar='N', + help='epochs to warmup LR, if scheduler supports') + parser.add_argument('--cooldown-epochs', type=int, default=10, metavar='N', + help='epochs to cooldown LR at min_lr, after cyclic schedule ends') + parser.add_argument('--patience-epochs', type=int, default=10, metavar='N', + help='patience epochs for Plateau LR scheduler (default: 10') + parser.add_argument('--decay-rate', '--dr', type=float, default=0.1, metavar='RATE', + help='LR decay rate (default: 0.1)') + + # Augmentation parameters + parser.add_argument('--color-jitter', type=float, default=0.4, metavar='PCT', + help='Color jitter factor (default: 0.4)') + parser.add_argument('--aa', type=str, default='rand-m9-mstd0.5-inc1', metavar='NAME', + help='Use AutoAugment policy. "v0" or "original". " + \ + "(default: rand-m9-mstd0.5-inc1)'), + parser.add_argument('--smoothing', type=float, default=0.1, help='Label smoothing (default: 0.1)') + parser.add_argument('--train-interpolation', type=str, default='bicubic', + help='Training interpolation (random, bilinear, bicubic default: "bicubic")') + + parser.add_argument('--repeated-aug', action='store_true') + parser.add_argument('--no-repeated-aug', action='store_false', dest='repeated_aug') + + + parser.set_defaults(repeated_aug=True) + + # * Random Erase params + parser.add_argument('--reprob', type=float, default=0.25, metavar='PCT', + help='Random erase prob (default: 0.25)') + parser.add_argument('--remode', type=str, default='pixel', + help='Random erase mode (default: "pixel")') + parser.add_argument('--recount', type=int, default=1, + help='Random erase count (default: 1)') + parser.add_argument('--resplit', action='store_true', default=False, + help='Do not random erase first (clean) augmentation split') + + # * Mixup params + parser.add_argument('--mixup', type=float, default=0.8, + help='mixup alpha, mixup enabled if > 0. (default: 0.8)') + parser.add_argument('--cutmix', type=float, default=1.0, + help='cutmix alpha, cutmix enabled if > 0. (default: 1.0)') + parser.add_argument('--cutmix-minmax', type=float, nargs='+', default=None, + help='cutmix min/max ratio, overrides alpha and enables cutmix if set (default: None)') + parser.add_argument('--mixup-prob', type=float, default=1.0, + help='Probability of performing mixup or cutmix when either/both is enabled') + parser.add_argument('--mixup-switch-prob', type=float, default=0.5, + help='Probability of switching to cutmix when both mixup and cutmix enabled') + parser.add_argument('--mixup-mode', type=str, default='batch', + help='How to apply mixup/cutmix params. Per "batch", "pair", or "elem"') + + # Dataset parameters + parser.add_argument('--data-path', default='./data/imagenet/', type=str, + help='dataset path') + parser.add_argument('--data-set', default='IMNET', choices=['CIFAR', 'IMNET', 'INAT', 'INAT19'], + type=str, help='Image Net dataset path') + parser.add_argument('--inat-category', default='name', + choices=['kingdom', 'phylum', 'class', 'order', 'supercategory', 'family', 'genus', 'name'], + type=str, help='semantic granularity') + + parser.add_argument('--output_dir', default='./', + help='path where to save, empty for no saving') + parser.add_argument('--device', default='cuda', + help='device to use for training / testing') + parser.add_argument('--seed', default=0, type=int) + parser.add_argument('--resume', default='', help='resume from checkpoint') + parser.add_argument('--start_epoch', default=0, type=int, metavar='N', + help='start epoch') + parser.add_argument('--eval', action='store_true', help='Perform evaluation only') + parser.add_argument('--num_workers', default=10, type=int) + parser.add_argument('--dist-eval', action='store_true', default=False, help='Enabling distributed evaluation') + parser.add_argument('--pin-mem', action='store_true', + help='Pin CPU memory in DataLoader for more efficient (sometimes) transfer to GPU.') + parser.add_argument('--no-pin-mem', action='store_false', dest='pin_mem', + help='') + parser.set_defaults(pin_mem=True) + + # distributed training parameters + parser.add_argument('--world_size', default=1, type=int, + help='number of distributed processes') + parser.add_argument('--dist_url', default='env://', help='url used to set up distributed training') + + parser.add_argument('--amp', action='store_true') + parser.add_argument('--no-amp', action='store_false', dest='amp') + parser.set_defaults(amp=True) + + + return parser + +def main(args): + + utils.init_distributed_mode(args) + update_config_from_file(args.cfg) + + print(args) + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + + device = torch.device(args.device) + + # fix the seed for reproducibility + seed = args.seed + utils.get_rank() + torch.manual_seed(seed) + np.random.seed(seed) + # random.seed(seed) + cudnn.benchmark = True + + dataset_train, args.nb_classes = build_dataset(is_train=True, args=args) + dataset_val, _ = build_dataset(is_train=False, args=args) + + if args.distributed: + num_tasks = utils.get_world_size() + global_rank = utils.get_rank() + if args.dist_eval: + if len(dataset_val) % num_tasks != 0: + print( + 'Warning: Enabling distributed evaluation with an eval dataset not divisible by process number. ' + 'This will slightly alter validation results as extra duplicate entries are added to achieve ' + 'equal num of samples per-process.') + sampler_val = torch.utils.data.DistributedSampler( + dataset_val, num_replicas=num_tasks, rank=global_rank, shuffle=False) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + else: + sampler_val = torch.utils.data.SequentialSampler(dataset_val) + + data_loader_val = torch.utils.data.DataLoader( + dataset_val, batch_size=int(2 * args.batch_size), + sampler=sampler_val, num_workers=args.num_workers, + pin_memory=args.pin_mem, drop_last=False + ) + + mixup_fn = None + mixup_active = args.mixup > 0 or args.cutmix > 0. or args.cutmix_minmax is not None + if mixup_active: + mixup_fn = Mixup( + mixup_alpha=args.mixup, cutmix_alpha=args.cutmix, cutmix_minmax=args.cutmix_minmax, + prob=args.mixup_prob, switch_prob=args.mixup_switch_prob, mode=args.mixup_mode, + label_smoothing=args.smoothing, num_classes=args.nb_classes) + + print(f"Creating S3-Transformer") + + model = SSSTransformer(img_size=args.input_size, + patch_size=args.patch_size, + num_classes=args.nb_classes, + embed_dim=cfg.EMBED_DIM, + depths=cfg.DEPTHS, + num_heads=cfg.NUM_HEADS, + window_size=cfg.WINDOW_SIZE, + mlp_ratio=cfg.MLP_RATIO, + qkv_bias=True, + drop_rate=args.drop, + drop_path_rate=args.drop_path, + patch_norm=True) + model.to(device) + + model_ema = None + + model_without_ddp = model + if args.distributed: + + model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], find_unused_parameters=True) + model_without_ddp = model.module + + n_parameters = sum(p.numel() for p in model.parameters() if p.requires_grad) + print('number of params:', n_parameters) + + linear_scaled_lr = args.lr * args.batch_size * utils.get_world_size() / 512.0 + args.lr = linear_scaled_lr + optimizer = create_optimizer(args, model_without_ddp) + loss_scaler = NativeScaler() + lr_scheduler, _ = create_scheduler(args, optimizer) + + output_dir = Path(args.output_dir) + + if not output_dir.exists(): + output_dir.mkdir(parents=True) + # save config for later experiments + with open(output_dir / "config.yaml", 'w') as f: + f.write(args_text) + if args.resume: + if args.resume.startswith('https'): + checkpoint = torch.hub.load_state_dict_from_url( + args.resume, map_location='cpu', check_hash=True) + else: + checkpoint = torch.load(args.resume, map_location='cpu') + model_without_ddp.load_state_dict(checkpoint['model']) + + if args.eval: + test_stats = evaluate(data_loader_val, model, device) + print(f"Accuracy of the network on the {len(dataset_val)} test images: {test_stats['acc1']:.1f}%") + return + + +if __name__ == '__main__': + parser = argparse.ArgumentParser('S3 evaluation script', parents=[get_args_parser()]) + args = parser.parse_args() + if args.output_dir: + Path(args.output_dir).mkdir(parents=True, exist_ok=True) + main(args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/config.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/config.py new file mode 100644 index 000000000..ad62c16e3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/config.py @@ -0,0 +1,39 @@ +from easydict import EasyDict as edict +import yaml + +cfg = edict() + + +def _edict2dict(dest_dict, src_edict): + if isinstance(dest_dict, dict) and isinstance(src_edict, dict): + for k, v in src_edict.items(): + if not isinstance(v, edict): + dest_dict[k] = v + else: + dest_dict[k] = {} + _edict2dict(dest_dict[k], v) + else: + return + +def gen_config(config_file): + cfg_dict = {} + _edict2dict(cfg_dict, cfg) + with open(config_file, 'w') as f: + yaml.dump(cfg_dict, f, default_flow_style=False) + + +def _update_config(base_cfg, exp_cfg): + if isinstance(base_cfg, edict) and isinstance(exp_cfg, edict): + for k, v in exp_cfg.items(): + base_cfg[k] = v + else: + return + + +def update_config_from_file(filename): + exp_config = None + with open(filename) as f: + exp_config = edict(yaml.safe_load(f)) + _update_config(cfg, exp_config) + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/datasets.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/datasets.py new file mode 100644 index 000000000..654079237 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/datasets.py @@ -0,0 +1,220 @@ +import os +import cv2 +import json +import torch +import scipy +import scipy.io as sio +from skimage import io + +from torchvision import datasets, transforms +from torchvision.datasets.folder import ImageFolder, default_loader + +from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD +from timm.data import create_transform + +class Flowers(ImageFolder): + def __init__(self, root, train=True, transform=None, **kwargs): + self.dataset_root = root + self.loader = default_loader + self.target_transform = None + self.transform = transform + label_path = os.path.join(root, 'imagelabels.mat') + split_path = os.path.join(root, 'setid.mat') + + print('Dataset Flowers is trained with resolution 224!') + + # labels + labels = sio.loadmat(label_path)['labels'][0] + self.img_to_label = dict() + for i in range(len(labels)): + self.img_to_label[i] = labels[i] + + splits = sio.loadmat(split_path) + self.trnid, self.valid, self.tstid = sorted(splits['trnid'][0].tolist()), \ + sorted(splits['valid'][0].tolist()), \ + sorted(splits['tstid'][0].tolist()) + if train: + self.imgs = self.trnid + self.valid + else: + self.imgs = self.tstid + + self.samples = [] + for item in self.imgs: + self.samples.append((os.path.join(root, 'jpg', "image_{:05d}.jpg".format(item)), self.img_to_label[item-1]-1)) + +class Cars196(ImageFolder, datasets.CIFAR10): + base_folder_devkit = 'devkit' + base_folder_trainims = 'cars_train' + base_folder_testims = 'cars_test' + + filename_testanno = 'cars_test_annos.mat' + filename_trainanno = 'cars_train_annos.mat' + + base_folder = 'cars_train' + train_list = [ + ['00001.jpg', '8df595812fee3ca9a215e1ad4b0fb0c4'], + ['00002.jpg', '4b9e5efcc3612378ec63a22f618b5028'] + ] + test_list = [] + num_training_classes = 98 # 196/2 + + def __init__(self, root, train=False, transform=None, target_transform=None, **kwargs): + self.root = root + self.transform = transform + + self.target_transform = target_transform + self.loader = default_loader + print('Dataset Cars196 is trained with resolution 224!') + + self.samples = [] + self.nb_classes = 196 + + if train: + labels = \ + sio.loadmat(os.path.join(self.root, self.base_folder_devkit, self.filename_trainanno))['annotations'][0] + for item in labels: + img_name = item[-1].tolist()[0] + label = int(item[4]) - 1 + self.samples.append((os.path.join(self.root, self.base_folder_trainims, img_name), label)) + else: + labels = \ + sio.loadmat(os.path.join(self.root, 'cars_test_annos_withlabels.mat'))['annotations'][0] + for item in labels: + img_name = item[-1].tolist()[0] + label = int(item[-2]) - 1 + self.samples.append((os.path.join(self.root, self.base_folder_testims, img_name), label)) + +class Pets(ImageFolder): + def __init__(self, root, train=True, transform=None, target_transform=None, **kwargs): + self.dataset_root = root + self.loader = default_loader + self.target_transform = None + self.transform = transform + train_list_path = os.path.join(self.dataset_root, 'annotations', 'trainval.txt') + test_list_path = os.path.join(self.dataset_root, 'annotations', 'test.txt') + + self.samples = [] + if train: + with open(train_list_path, 'r') as f: + for line in f: + img_name = line.split(' ')[0] + label = int(line.split(' ')[1]) + self.samples.append((os.path.join(root, 'images', "{}.jpg".format(img_name)), label-1)) + else: + with open(test_list_path, 'r') as f: + for line in f: + img_name = line.split(' ')[0] + label = int(line.split(' ')[1]) + self.samples.append((os.path.join(root, 'images', "{}.jpg".format(img_name)), label-1)) + +class INatDataset(ImageFolder): + def __init__(self, root, train=True, year=2018, transform=None, target_transform=None, + category='name', loader=default_loader): + self.transform = transform + self.loader = loader + self.target_transform = target_transform + self.year = year + # assert category in ['kingdom','phylum','class','order','supercategory','family','genus','name'] + path_json = os.path.join(root, f'{"train" if train else "val"}{year}.json') + with open(path_json) as json_file: + data = json.load(json_file) + + with open(os.path.join(root, 'categories.json')) as json_file: + data_catg = json.load(json_file) + + path_json_for_targeter = os.path.join(root, f"train{year}.json") + + with open(path_json_for_targeter) as json_file: + data_for_targeter = json.load(json_file) + + targeter = {} + indexer = 0 + for elem in data_for_targeter['annotations']: + king = [] + king.append(data_catg[int(elem['category_id'])][category]) + if king[0] not in targeter.keys(): + targeter[king[0]] = indexer + indexer += 1 + self.nb_classes = len(targeter) + + self.samples = [] + for elem in data['images']: + cut = elem['file_name'].split('/') + target_current = int(cut[2]) + path_current = os.path.join(root, cut[0], cut[2], cut[3]) + + categors = data_catg[target_current] + target_current_true = targeter[categors[category]] + self.samples.append((path_current, target_current_true)) + + # __getitem__ and __len__ inherited from ImageFolder + +def build_dataset(is_train, args, folder_name=None): + transform = build_transform(is_train, args) + + if args.data_set == 'CIFAR10': + dataset = datasets.CIFAR10(args.data_path, train=is_train, transform=transform, download=True) + nb_classes = 10 + elif args.data_set == 'CIFAR100': + dataset = datasets.CIFAR100(args.data_path, train=is_train, transform=transform, download=True) + nb_classes = 100 + elif args.data_set == 'CARS': + dataset = Cars196(args.data_path, train=is_train, transform=transform) + nb_classes = 196 + elif args.data_set == 'PETS': + dataset = Pets(args.data_path, train=is_train, transform=transform) + nb_classes = 37 + elif args.data_set == 'FLOWERS': + dataset = Flowers(args.data_path, train=is_train, transform=transform) + nb_classes = 102 + elif args.data_set == 'IMNET': + root = os.path.join(args.data_path, 'train' if is_train else 'val') + dataset = datasets.ImageFolder(root, transform=transform) + nb_classes = 1000 + elif args.data_set == 'EVO_IMNET': + root = os.path.join(args.data_path, folder_name) + dataset = datasets.ImageFolder(root, transform=transform) + nb_classes = 1000 + elif args.data_set == 'INAT': + dataset = INatDataset(args.data_path, train=is_train, year=2018, + category=args.inat_category, transform=transform) + nb_classes = dataset.nb_classes + elif args.data_set == 'INAT19': + dataset = INatDataset(args.data_path, train=is_train, year=2019, + category=args.inat_category, transform=transform) + nb_classes = dataset.nb_classes + + return dataset, nb_classes + +def build_transform(is_train, args): + resize_im = args.input_size > 32 + if is_train: + # this should always dispatch to transforms_imagenet_train + transform = create_transform( + input_size=args.input_size, + is_training=True, + color_jitter=args.color_jitter, + auto_augment=args.aa, + interpolation=args.train_interpolation, + re_prob=args.reprob, + re_mode=args.remode, + re_count=args.recount, + ) + if not resize_im: + # replace RandomResizedCropAndInterpolation with + # RandomCrop + transform.transforms[0] = transforms.RandomCrop( + args.input_size, padding=4) + return transform + + t = [] + if resize_im: + size = int((256 / 224) * args.input_size) + t.append( + transforms.Resize(size, interpolation=3), # to maintain same ratio w.r.t. 224 images + ) + t.append(transforms.CenterCrop(args.input_size)) + + t.append(transforms.ToTensor()) + t.append(transforms.Normalize(IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD)) + return transforms.Compose(t) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/samplers.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/samplers.py new file mode 100644 index 000000000..870a7cdf3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/samplers.py @@ -0,0 +1,57 @@ +import torch +import torch.distributed as dist +import math + + +class RASampler(torch.utils.data.Sampler): + """Sampler that restricts data loading to a subset of the dataset for distributed, + with repeated augmentation. + It ensures that different each augmented version of a sample will be visible to a + different process (GPU) + Heavily based on torch.utils.data.DistributedSampler + """ + + def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): + if num_replicas is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + num_replicas = dist.get_world_size() + if rank is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + rank = dist.get_rank() + self.dataset = dataset + self.num_replicas = num_replicas + self.rank = rank + self.epoch = 0 + self.num_samples = int(math.ceil(len(self.dataset) * 3.0 / self.num_replicas)) + self.total_size = self.num_samples * self.num_replicas + # self.num_selected_samples = int(math.ceil(len(self.dataset) / self.num_replicas)) + self.num_selected_samples = int(math.floor(len(self.dataset) // 256 * 256 / self.num_replicas)) + self.shuffle = shuffle + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch) + if self.shuffle: + indices = torch.randperm(len(self.dataset), generator=g).tolist() + else: + indices = list(range(len(self.dataset))) + + # add extra samples to make it evenly divisible + indices = [ele for ele in indices for i in range(3)] + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + + assert len(indices) == self.num_samples + return iter(indices[:self.num_selected_samples]) + + def __len__(self): + return self.num_selected_samples + + def set_epoch(self, epoch): + self.epoch = epoch diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/utils.py new file mode 100644 index 000000000..347b790aa --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/lib/utils.py @@ -0,0 +1,235 @@ +import io +import os +import time +from collections import defaultdict, deque +import datetime + +import torch +import torch.distributed as dist + + +class SmoothedValue(object): + """Track a series of values and provide access to smoothed values over a + window or the global series average. + """ + + def __init__(self, window_size=20, fmt=None): + if fmt is None: + fmt = "{median:.4f} ({global_avg:.4f})" + self.deque = deque(maxlen=window_size) + self.total = 0.0 + self.count = 0 + self.fmt = fmt + + def update(self, value, n=1): + self.deque.append(value) + self.count += n + self.total += value * n + + def synchronize_between_processes(self): + """ + Warning: does not synchronize the deque! + """ + if not is_dist_avail_and_initialized(): + return + t = torch.tensor([self.count, self.total], dtype=torch.float64, device='cuda') + dist.barrier() + dist.all_reduce(t) + t = t.tolist() + self.count = int(t[0]) + self.total = t[1] + + @property + def median(self): + d = torch.tensor(list(self.deque)) + return d.median().item() + + @property + def avg(self): + d = torch.tensor(list(self.deque), dtype=torch.float32) + return d.mean().item() + + @property + def global_avg(self): + return self.total / self.count + + @property + def max(self): + return max(self.deque) + + @property + def value(self): + return self.deque[-1] + + def __str__(self): + return self.fmt.format( + median=self.median, + avg=self.avg, + global_avg=self.global_avg, + max=self.max, + value=self.value) + + +class MetricLogger(object): + def __init__(self, delimiter="\t"): + self.meters = defaultdict(SmoothedValue) + self.delimiter = delimiter + + def update(self, **kwargs): + for k, v in kwargs.items(): + if isinstance(v, torch.Tensor): + v = v.item() + assert isinstance(v, (float, int)) + self.meters[k].update(v) + + def __getattr__(self, attr): + if attr in self.meters: + return self.meters[attr] + if attr in self.__dict__: + return self.__dict__[attr] + raise AttributeError("'{}' object has no attribute '{}'".format( + type(self).__name__, attr)) + + def __str__(self): + loss_str = [] + for name, meter in self.meters.items(): + loss_str.append( + "{}: {}".format(name, str(meter)) + ) + return self.delimiter.join(loss_str) + + def synchronize_between_processes(self): + for meter in self.meters.values(): + meter.synchronize_between_processes() + + def add_meter(self, name, meter): + self.meters[name] = meter + + def log_every(self, iterable, print_freq, header=None): + i = 0 + if not header: + header = '' + start_time = time.time() + end = time.time() + iter_time = SmoothedValue(fmt='{avg:.4f}') + data_time = SmoothedValue(fmt='{avg:.4f}') + space_fmt = ':' + str(len(str(len(iterable)))) + 'd' + log_msg = [ + header, + '[{0' + space_fmt + '}/{1}]', + 'eta: {eta}', + '{meters}', + 'time: {time}', + 'data: {data}' + ] + if torch.cuda.is_available(): + log_msg.append('max mem: {memory:.0f}') + log_msg = self.delimiter.join(log_msg) + MB = 1024.0 * 1024.0 + for obj in iterable: + data_time.update(time.time() - end) + yield obj + iter_time.update(time.time() - end) + if i % print_freq == 0 or i == len(iterable) - 1: + eta_seconds = iter_time.global_avg * (len(iterable) - i) + eta_string = str(datetime.timedelta(seconds=int(eta_seconds))) + if torch.cuda.is_available(): + print(log_msg.format( + i, len(iterable), eta=eta_string, + meters=str(self), + time=str(iter_time), data=str(data_time), + memory=torch.cuda.max_memory_allocated() / MB)) + else: + print(log_msg.format( + i, len(iterable), eta=eta_string, + meters=str(self), + time=str(iter_time), data=str(data_time))) + i += 1 + end = time.time() + total_time = time.time() - start_time + total_time_str = str(datetime.timedelta(seconds=int(total_time))) + print('{} Total time: {} ({:.4f} s / it)'.format( + header, total_time_str, total_time / len(iterable))) + + +def _load_checkpoint_for_ema(model_ema, checkpoint): + """ + Workaround for ModelEma._load_checkpoint to accept an already-loaded object + """ + mem_file = io.BytesIO() + torch.save(checkpoint, mem_file) + mem_file.seek(0) + model_ema._load_checkpoint(mem_file) + + +def setup_for_distributed(is_master): + """ + This function disables printing when not in master process + """ + import builtins as __builtin__ + builtin_print = __builtin__.print + + def print(*args, **kwargs): + force = kwargs.pop('force', False) + if is_master or force: + builtin_print(*args, **kwargs) + + __builtin__.print = print + + +def is_dist_avail_and_initialized(): + if not dist.is_available(): + return False + if not dist.is_initialized(): + return False + return True + + +def get_world_size(): + if not is_dist_avail_and_initialized(): + return 1 + return dist.get_world_size() + + +def get_rank(): + if not is_dist_avail_and_initialized(): + return 0 + return dist.get_rank() + + +def is_main_process(): + return get_rank() == 0 + + +def save_on_master(*args, **kwargs): + if is_main_process(): + torch.save(*args, **kwargs) + + +def init_distributed_mode(args): + if 'OMPI_COMM_WORLD_RANK' in os.environ: + args.rank = int(os.environ.get('OMPI_COMM_WORLD_RANK')) + args.world_size = int(os.environ.get('OMPI_COMM_WORLD_SIZE')) + args.gpu = args.rank % torch.cuda.device_count() + elif 'RANK' in os.environ and 'WORLD_SIZE' in os.environ: + args.rank = int(os.environ["RANK"]) + args.world_size = int(os.environ['WORLD_SIZE']) + args.gpu = int(os.environ['LOCAL_RANK']) + elif 'SLURM_PROCID' in os.environ: + args.rank = int(os.environ['SLURM_PROCID']) + args.gpu = args.rank % torch.cuda.device_count() + else: + print('Not using distributed mode') + args.distributed = False + return + + args.distributed = True + + torch.cuda.set_device(args.gpu) + args.dist_backend = 'nccl' + print('| distributed init (rank {}): {}'.format( + args.rank, args.dist_url), flush=True) + torch.distributed.init_process_group(backend=args.dist_backend, init_method=args.dist_url, + world_size=args.world_size, rank=args.rank) + torch.distributed.barrier() + setup_for_distributed(args.rank == 0) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/model/SSS.py b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/model/SSS.py new file mode 100644 index 000000000..5d5e322ba --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/model/SSS.py @@ -0,0 +1,577 @@ +import torch +import torch.nn as nn +import torch.utils.checkpoint as checkpoint +from timm.models.layers import DropPath, to_2tuple, trunc_normal_ + + +class Mlp(nn.Module): + def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.): + super().__init__() + out_features = out_features or in_features + hidden_features = hidden_features or in_features + self.fc1 = nn.Linear(in_features, hidden_features) + self.act = act_layer() + self.fc2 = nn.Linear(hidden_features, out_features) + self.drop = nn.Dropout(drop) + + def forward(self, x): + x = self.fc1(x) + x = self.act(x) + x = self.drop(x) + x = self.fc2(x) + x = self.drop(x) + return x + + +def window_partition(x, window_size): + """ + Args: + x: (B, H, W, C) + window_size (int): window size + + Returns: + windows: (num_windows*B, window_size, window_size, C) + """ + B, H, W, C = x.shape + x = x.view(B, H // window_size, window_size, W // window_size, window_size, C) + windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C) + return windows + + +def window_reverse(windows, window_size, H, W): + """ + Args: + windows: (num_windows*B, window_size, window_size, C) + window_size (int): Window size + H (int): Height of image + W (int): Width of image + + Returns: + x: (B, H, W, C) + """ + B = int(windows.shape[0] / (H * W / window_size / window_size)) + x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1) + x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1) + return x + + +class WindowAttention(nn.Module): + r""" Window based multi-head self attention (W-MSA) module with relative position bias. + It supports both of shifted and non-shifted window. + + Args: + dim (int): Number of input channels. + window_size (tuple[int]): The height and width of the window. + num_heads (int): Number of attention heads. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set + attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0 + proj_drop (float, optional): Dropout ratio of output. Default: 0.0 + """ + + def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.): + + super().__init__() + self.dim = dim + self.window_size = window_size # Wh, Ww + self.num_heads = num_heads + head_dim = 32 + self.scale = qk_scale or head_dim ** -0.5 + + # define a parameter table of relative position bias + self.relative_position_bias_table = nn.Parameter( + torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # 2*Wh-1 * 2*Ww-1, nH + + # get pair-wise relative position index for each token inside the window + coords_h = torch.arange(self.window_size[0]) + coords_w = torch.arange(self.window_size[1]) + coords = torch.stack(torch.meshgrid([coords_h, coords_w])) # 2, Wh, Ww + coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww + relative_coords = coords_flatten[:, :, None] - coords_flatten[:, None, :] # 2, Wh*Ww, Wh*Ww + relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2 + relative_coords[:, :, 0] += self.window_size[0] - 1 # shift to start from 0 + relative_coords[:, :, 1] += self.window_size[1] - 1 + relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1 + relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww + self.register_buffer("relative_position_index", relative_position_index) + + self.qkv = nn.Linear(dim, num_heads * 32 * 3, bias=qkv_bias) + self.attn_drop = nn.Dropout(attn_drop) + self.proj = nn.Linear(dim, dim) + self.proj_drop = nn.Dropout(proj_drop) + + trunc_normal_(self.relative_position_bias_table, std=.02) + self.softmax = nn.Softmax(dim=-1) + + def forward(self, x, mask=None): + """ + Args: + x: input features with shape of (num_windows*B, N, C) + mask: (0/-inf) mask with shape of (num_windows, Wh*Ww, Wh*Ww) or None + """ + B_, N, C = x.shape + qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4) + q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple) + + q = q * self.scale + attn = (q @ k.transpose(-2, -1)) + + relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view( + self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH + relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww + attn = attn + relative_position_bias.unsqueeze(0) + + if mask is not None: + nW = mask.shape[0] + attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0) + attn = attn.view(-1, self.num_heads, N, N) + attn = self.softmax(attn) + else: + attn = self.softmax(attn) + + attn = self.attn_drop(attn) + + x = (attn @ v).transpose(1, 2).reshape(B_, N, C) + x = self.proj(x) + x = self.proj_drop(x) + return x + + def extra_repr(self) -> str: + return f'dim={self.dim}, window_size={self.window_size}, num_heads={self.num_heads}' + + def flops(self, N): + # calculate flops for 1 window with token length of N + flops = 0 + # qkv = self.qkv(x) + flops += N * self.dim * 3 * self.dim + # attn = (q @ k.transpose(-2, -1)) + flops += self.num_heads * N * (self.dim // self.num_heads) * N + # x = (attn @ v) + flops += self.num_heads * N * N * (self.dim // self.num_heads) + # x = self.proj(x) + flops += N * self.dim * self.dim + return flops + + +class SwinTransformerBlock(nn.Module): + r""" Swin Transformer Block. + + Args: + dim (int): Number of input channels. + input_resolution (tuple[int]): Input resulotion. + num_heads (int): Number of attention heads. + window_size (int): Window size. + shift_size (int): Shift size for SW-MSA. + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set. + drop (float, optional): Dropout rate. Default: 0.0 + attn_drop (float, optional): Attention dropout rate. Default: 0.0 + drop_path (float, optional): Stochastic depth rate. Default: 0.0 + act_layer (nn.Module, optional): Activation layer. Default: nn.GELU + norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm + """ + + def __init__(self, dim, input_resolution, num_heads, window_size=7, shift_size=0, + mlp_ratio=4., qkv_bias=True, qk_scale=None, drop=0., attn_drop=0., drop_path=0., + act_layer=nn.GELU, norm_layer=nn.LayerNorm): + super().__init__() + self.dim = dim + self.input_resolution = input_resolution + self.num_heads = num_heads + self.window_size = window_size + self.shift_size = shift_size + self.mlp_ratio = mlp_ratio + if min(self.input_resolution) <= self.window_size: + # if window size is larger than input resolution, we don't partition windows + self.shift_size = 0 + self.window_size = min(self.input_resolution) + assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size" + + self.norm1 = norm_layer(dim) + self.attn = WindowAttention( + dim, window_size=to_2tuple(self.window_size), num_heads=num_heads, + qkv_bias=qkv_bias, qk_scale=qk_scale, attn_drop=attn_drop, proj_drop=drop) + + self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity() + self.norm2 = norm_layer(dim) + mlp_hidden_dim = int(dim * mlp_ratio) + self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop) + + if self.shift_size > 0: + # calculate attention mask for SW-MSA + H, W = self.input_resolution + img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1 + h_slices = (slice(0, -self.window_size), + slice(-self.window_size, -self.shift_size), + slice(-self.shift_size, None)) + w_slices = (slice(0, -self.window_size), + slice(-self.window_size, -self.shift_size), + slice(-self.shift_size, None)) + cnt = 0 + for h in h_slices: + for w in w_slices: + img_mask[:, h, w, :] = cnt + cnt += 1 + + mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1 + mask_windows = mask_windows.view(-1, self.window_size * self.window_size) + attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2) + attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0)) + else: + attn_mask = None + + self.register_buffer("attn_mask", attn_mask) + + def forward(self, x): + H, W = self.input_resolution + B, L, C = x.shape + assert L == H * W, "input feature has wrong size" + + shortcut = x + x = self.norm1(x) + x = x.view(B, H, W, C) + + # cyclic shift + if self.shift_size > 0: + shifted_x = torch.roll(x, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2)) + else: + shifted_x = x + + # partition windows + x_windows = window_partition(shifted_x, self.window_size) # nW*B, window_size, window_size, C + x_windows = x_windows.view(-1, self.window_size * self.window_size, C) # nW*B, window_size*window_size, C + + # W-MSA/SW-MSA + attn_windows = self.attn(x_windows, mask=self.attn_mask) # nW*B, window_size*window_size, C + + # merge windows + attn_windows = attn_windows.view(-1, self.window_size, self.window_size, C) + shifted_x = window_reverse(attn_windows, self.window_size, H, W) # B H' W' C + + # reverse cyclic shift + if self.shift_size > 0: + x = torch.roll(shifted_x, shifts=(self.shift_size, self.shift_size), dims=(1, 2)) + else: + x = shifted_x + x = x.view(B, H * W, C) + + # FFN + x = shortcut + self.drop_path(x) + x = x + self.drop_path(self.mlp(self.norm2(x))) + + return x + + def extra_repr(self) -> str: + return f"dim={self.dim}, input_resolution={self.input_resolution}, num_heads={self.num_heads}, " \ + f"window_size={self.window_size}, shift_size={self.shift_size}, mlp_ratio={self.mlp_ratio}" + + def flops(self): + flops = 0 + H, W = self.input_resolution + # norm1 + flops += self.dim * H * W + # W-MSA/SW-MSA + nW = H * W / self.window_size / self.window_size + flops += nW * self.attn.flops(self.window_size * self.window_size) + # mlp + flops += 2 * H * W * self.dim * self.dim * self.mlp_ratio + # norm2 + flops += self.dim * H * W + return flops + + +class PatchMerging(nn.Module): + r""" Patch Merging Layer. + + Args: + input_resolution (tuple[int]): Resolution of input feature. + dim (int): Number of input channels. + norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm + """ + + def __init__(self, input_resolution, dim, out_dim, norm_layer=nn.LayerNorm): + super().__init__() + self.input_resolution = input_resolution + self.dim = dim + self.reduction = nn.Linear(4 * dim, out_dim, bias=False) + self.norm = norm_layer(4 * dim) + + def forward(self, x): + """ + x: B, H*W, C + """ + H, W = self.input_resolution + B, L, C = x.shape + assert L == H * W, "input feature has wrong size" + assert H % 2 == 0 and W % 2 == 0, f"x size ({H}*{W}) are not even." + + x = x.view(B, H, W, C) + + x0 = x[:, 0::2, 0::2, :] # B H/2 W/2 C + x1 = x[:, 1::2, 0::2, :] # B H/2 W/2 C + x2 = x[:, 0::2, 1::2, :] # B H/2 W/2 C + x3 = x[:, 1::2, 1::2, :] # B H/2 W/2 C + x = torch.cat([x0, x1, x2, x3], -1) # B H/2 W/2 4*C + x = x.view(B, -1, 4 * C) # B H/2*W/2 4*C + + x = self.norm(x) + x = self.reduction(x) + + return x + + def extra_repr(self) -> str: + return f"input_resolution={self.input_resolution}, dim={self.dim}" + + def flops(self): + H, W = self.input_resolution + flops = H * W * self.dim + flops += (H // 2) * (W // 2) * 4 * self.dim * 2 * self.dim + return flops + + +class BasicLayer(nn.Module): + """ A basic Swin Transformer layer for one stage. + + Args: + dim (int): Number of input channels. + input_resolution (tuple[int]): Input resolution. + depth (int): Number of blocks. + num_heads (int): Number of attention heads. + window_size (int): Local window size. + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. + qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set. + drop (float, optional): Dropout rate. Default: 0.0 + attn_drop (float, optional): Attention dropout rate. Default: 0.0 + drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0 + norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm + downsample (nn.Module | None, optional): Downsample layer at the end of the layer. Default: None + use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False. + """ + + def __init__(self, dim, out_dim, input_resolution, depth, num_heads, window_size, + mlp_ratio=4., qkv_bias=True, qk_scale=None, drop=0., attn_drop=0., + drop_path=0., norm_layer=nn.LayerNorm, downsample=None, use_checkpoint=False): + + super().__init__() + self.dim = dim + self.input_resolution = input_resolution + self.depth = depth + self.use_checkpoint = use_checkpoint + + # build blocks + self.blocks = nn.ModuleList([ + SwinTransformerBlock(dim=dim, input_resolution=input_resolution, + num_heads=num_heads[i], window_size=window_size[i], + shift_size=0 if (i % 2 == 0) else window_size[i] // 2, + mlp_ratio=mlp_ratio[i], + qkv_bias=qkv_bias, qk_scale=qk_scale, + drop=drop, attn_drop=attn_drop, + drop_path=drop_path[i] if isinstance(drop_path, list) else drop_path, + norm_layer=norm_layer) + for i in range(depth)]) + + # patch merging layer + if downsample is not None: + self.downsample = downsample(input_resolution, dim=dim, out_dim=out_dim, norm_layer=norm_layer) + else: + self.downsample = None + + def forward(self, x): + for blk in self.blocks: + if self.use_checkpoint: + x = checkpoint.checkpoint(blk, x) + else: + x = blk(x) + if self.downsample is not None: + x = self.downsample(x) + return x + + def extra_repr(self) -> str: + return f"dim={self.dim}, input_resolution={self.input_resolution}, depth={self.depth}" + + def flops(self): + flops = 0 + for blk in self.blocks: + flops += blk.flops() + if self.downsample is not None: + flops += self.downsample.flops() + return flops + + +class PatchEmbed(nn.Module): + r""" Image to Patch Embedding + + Args: + img_size (int): Image size. Default: 224. + patch_size (int): Patch token size. Default: 4. + in_chans (int): Number of input image channels. Default: 3. + embed_dim (int): Number of linear projection output channels. Default: 96. + norm_layer (nn.Module, optional): Normalization layer. Default: None + """ + + def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=96, norm_layer=None): + super().__init__() + img_size = to_2tuple(img_size) + patch_size = to_2tuple(patch_size) + patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1]] + self.img_size = img_size + self.patch_size = patch_size + self.patches_resolution = patches_resolution + self.num_patches = patches_resolution[0] * patches_resolution[1] + + self.in_chans = in_chans + self.embed_dim = embed_dim + + self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size) + if norm_layer is not None: + self.norm = norm_layer(embed_dim) + else: + self.norm = None + + def forward(self, x): + B, C, H, W = x.shape + # FIXME look at relaxing size constraints + assert H == self.img_size[0] and W == self.img_size[1], \ + f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})." + x = self.proj(x).flatten(2).transpose(1, 2) # B Ph*Pw C + if self.norm is not None: + x = self.norm(x) + return x + + def flops(self): + Ho, Wo = self.patches_resolution + flops = Ho * Wo * self.embed_dim * self.in_chans * (self.patch_size[0] * self.patch_size[1]) + if self.norm is not None: + flops += Ho * Wo * self.embed_dim + return flops + + +class SSSTransformer(nn.Module): + r""" + + Args: + img_size (int | tuple(int)): Input image size. Default 224 + patch_size (int | tuple(int)): Patch size. Default: 4 + in_chans (int): Number of input image channels. Default: 3 + num_classes (int): Number of classes for classification head. Default: 1000 + embed_dim (int): Patch embedding dimension. Default: 96 + depths (tuple(int)): Depth of each Swin Transformer layer. + num_heads (tuple(int)): Number of attention heads in different layers. + window_size (int): Window size. Default: 7 + mlp_ratio (float): Ratio of mlp hidden dim to embedding dim. Default: 4 + qkv_bias (bool): If True, add a learnable bias to query, key, value. Default: True + qk_scale (float): Override default qk scale of head_dim ** -0.5 if set. Default: None + drop_rate (float): Dropout rate. Default: 0 + attn_drop_rate (float): Attention dropout rate. Default: 0 + drop_path_rate (float): Stochastic depth rate. Default: 0.1 + norm_layer (nn.Module): Normalization layer. Default: nn.LayerNorm. + ape (bool): If True, add absolute position embedding to the patch embedding. Default: False + patch_norm (bool): If True, add normalization after patch embedding. Default: True + use_checkpoint (bool): Whether to use checkpointing to save memory. Default: False + """ + + def __init__(self, img_size=224, patch_size=4, in_chans=3, num_classes=1000, + embed_dim=[96, 192, 384, 768], depths=[2, 2, 6, 2], num_heads=[3, 6, 12, 24], + window_size=[7, 7, 7, 7], mlp_ratio=[4., 4., 4., 4.], qkv_bias=True, qk_scale=None, + drop_rate=0., attn_drop_rate=0., drop_path_rate=0.1, + norm_layer=nn.LayerNorm, ape=False, patch_norm=True, + use_checkpoint=False, **kwargs): + super().__init__() + + self.num_classes = num_classes + self.num_layers = len(depths) + self.embed_dim = embed_dim + self.ape = ape + self.patch_norm = patch_norm + self.num_features = int(embed_dim[-1]) + self.mlp_ratio = mlp_ratio + + # split image into non-overlapping patches + self.patch_embed = PatchEmbed( + img_size=img_size, patch_size=patch_size, in_chans=in_chans, embed_dim=embed_dim[0], + norm_layer=norm_layer if self.patch_norm else None) + num_patches = self.patch_embed.num_patches + patches_resolution = self.patch_embed.patches_resolution + self.patches_resolution = patches_resolution + + # absolute position embedding + if self.ape: + self.absolute_pos_embed = nn.Parameter(torch.zeros(1, num_patches, embed_dim)) + trunc_normal_(self.absolute_pos_embed, std=.02) + + self.pos_drop = nn.Dropout(p=drop_rate) + + # stochastic depth + dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(depths))] # stochastic depth decay rule + + # build layers + self.layers = nn.ModuleList() + for i_layer in range(self.num_layers): + layer = BasicLayer(dim=int(embed_dim[i_layer]), + out_dim=int(embed_dim[i_layer+1]) if (i_layer < self.num_layers - 1) else None, + input_resolution=(patches_resolution[0] // (2 ** i_layer), + patches_resolution[1] // (2 ** i_layer)), + depth=depths[i_layer], + num_heads=num_heads[i_layer], + window_size=window_size[i_layer], + mlp_ratio=self.mlp_ratio[i_layer], + qkv_bias=qkv_bias, qk_scale=qk_scale, + drop=drop_rate, attn_drop=attn_drop_rate, + drop_path=dpr[sum(depths[:i_layer]):sum(depths[:i_layer + 1])], + norm_layer=norm_layer, + downsample=PatchMerging if (i_layer < self.num_layers - 1) else None, + use_checkpoint=use_checkpoint) + self.layers.append(layer) + + self.norm = norm_layer(self.num_features) + self.avgpool = nn.AdaptiveAvgPool1d(1) + self.head = nn.Linear(self.num_features, num_classes) if num_classes > 0 else nn.Identity() + + self.apply(self._init_weights) + + def _init_weights(self, m): + if isinstance(m, nn.Linear): + trunc_normal_(m.weight, std=.02) + if isinstance(m, nn.Linear) and m.bias is not None: + nn.init.constant_(m.bias, 0) + elif isinstance(m, nn.LayerNorm): + nn.init.constant_(m.bias, 0) + nn.init.constant_(m.weight, 1.0) + + @torch.jit.ignore + def no_weight_decay(self): + return {'absolute_pos_embed'} + + @torch.jit.ignore + def no_weight_decay_keywords(self): + return {'relative_position_bias_table'} + + def forward_features(self, x): + x = self.patch_embed(x) + if self.ape: + x = x + self.absolute_pos_embed + x = self.pos_drop(x) + + for layer in self.layers: + x = layer(x) + + x = self.norm(x) # B L C + x = self.avgpool(x.transpose(1, 2)) # B C 1 + x = torch.flatten(x, 1) + return x + + def forward(self, x): + x = self.forward_features(x) + x = self.head(x) + return x + + def flops(self): + flops = 0 + flops += self.patch_embed.flops() + for i, layer in enumerate(self.layers): + flops += layer.flops() + flops += self.num_features * self.patches_resolution[0] * self.patches_resolution[1] // (2 ** self.num_layers) + flops += self.num_features * self.num_classes + return flops diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/requirements.txt b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/requirements.txt new file mode 100644 index 000000000..9cbe6fff9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/AutoFormerV2/requirements.txt @@ -0,0 +1,10 @@ +torch==1.7.1 +timm==0.3.2 +scikit-image +ptflops +easydict +PyYAML +pillow +torchvision==0.8.2 +opencv-python +yacs==0.1.8 \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/_init_paths.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/_init_paths.py new file mode 100644 index 000000000..abeae7732 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/_init_paths.py @@ -0,0 +1,19 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os.path as osp +import sys + + +def add_path(path): + if path not in sys.path: + sys.path.insert(0, path) + + +this_dir = osp.dirname(__file__) +lib_path = osp.join(this_dir, '..', 'lib') +add_path(lib_path) + +lib_path = osp.join(this_dir, '..') +add_path(lib_path) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/cifar_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/cifar_genotype.json new file mode 100644 index 000000000..ff406c7c1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/cifar_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('skip_connect', 2)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('dil_conv_5x5', 2), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)]], reduce_concat=range(2, 6))", "1": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('skip_connect', 2)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('dil_conv_5x5', 2), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)]], reduce_concat=range(2, 6))", "2": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('skip_connect', 2)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('dil_conv_5x5', 2), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)]], reduce_concat=range(2, 6))"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv1_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv1_genotype.json new file mode 100644 index 000000000..9b1a02006 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv1_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('skip_connect', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 0)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('avg_pool_3x3', 0)]], reduce_concat=[2, 3, 4, 5])", "1": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('skip_connect', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 0)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('avg_pool_3x3', 0)]], reduce_concat=[2, 3, 4, 5])", "2": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('skip_connect', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('skip_connect', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 0)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('avg_pool_3x3', 0)]], reduce_concat=[2, 3, 4, 5])"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv2_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv2_genotype.json new file mode 100644 index 000000000..a51a1f3b6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/dartsv2_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('skip_connect', 0)], [('skip_connect', 0), ('dil_conv_3x3', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('max_pool_3x3', 1)]], reduce_concat=[2, 3, 4, 5])", "1": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('skip_connect', 0)], [('skip_connect', 0), ('dil_conv_3x3', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('max_pool_3x3', 1)]], reduce_concat=[2, 3, 4, 5])", "2": "Genotype(normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('skip_connect', 0)], [('skip_connect', 0), ('dil_conv_3x3', 2)]], normal_concat=[2, 3, 4, 5], reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('skip_connect', 2), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('skip_connect', 2), ('max_pool_3x3', 1)]], reduce_concat=[2, 3, 4, 5])"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/imagenet_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/imagenet_genotype.json new file mode 100644 index 000000000..f952122ed --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/imagenet_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 2)], [('sep_conv_5x5', 2), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('avg_pool_3x3', 0)], [('max_pool_3x3', 1), ('dil_conv_5x5', 2)], [('sep_conv_5x5', 1), ('dil_conv_5x5', 2)], [('sep_conv_3x3', 3), ('dil_conv_3x3', 4)]], reduce_concat=range(2, 6))", "1": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 2)], [('sep_conv_5x5', 2), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('avg_pool_3x3', 0)], [('max_pool_3x3', 1), ('dil_conv_5x5', 2)], [('sep_conv_5x5', 1), ('dil_conv_5x5', 2)], [('sep_conv_3x3', 3), ('dil_conv_3x3', 4)]], reduce_concat=range(2, 6))", "2": "Genotype(normal=[[('sep_conv_3x3', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('sep_conv_5x5', 2)], [('sep_conv_5x5', 2), ('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('avg_pool_3x3', 0)], [('max_pool_3x3', 1), ('dil_conv_5x5', 2)], [('sep_conv_5x5', 1), ('dil_conv_5x5', 2)], [('sep_conv_3x3', 3), ('dil_conv_3x3', 4)]], reduce_concat=range(2, 6))"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_cifar_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_cifar_genotype.json new file mode 100644 index 000000000..e9cf74111 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_cifar_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('sep_conv_3x3', 1), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('dil_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 1)], [('avg_pool_3x3', 0), ('dil_conv_3x3', 1)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('sep_conv_5x5', 1), ('sep_conv_5x5', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)]], reduce_concat=range(2, 6))", "1": "Genotype(normal=[[('sep_conv_3x3', 1), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('dil_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 1)], [('avg_pool_3x3', 0), ('dil_conv_3x3', 1)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('sep_conv_5x5', 1), ('sep_conv_5x5', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)]], reduce_concat=range(2, 6))", "2": "Genotype(normal=[[('sep_conv_3x3', 1), ('skip_connect', 0)], [('sep_conv_3x3', 0), ('dil_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 1)], [('avg_pool_3x3', 0), ('dil_conv_3x3', 1)]], normal_concat=range(2, 6), reduce=[[('sep_conv_5x5', 1), ('max_pool_3x3', 0)], [('sep_conv_5x5', 1), ('sep_conv_5x5', 2)], [('sep_conv_3x3', 0), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)]], reduce_concat=range(2, 6))"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_imagenet_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_imagenet_genotype.json new file mode 100644 index 000000000..1d51b5e69 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pcdarts_imagenet_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('skip_connect', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('skip_connect', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_3x3', 0), ('skip_connect', 1)], [('dil_conv_5x5', 2), ('max_pool_3x3', 1)], [('sep_conv_3x3', 2), ('sep_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 3)]], reduce_concat=range(2, 6))", "1": "Genotype(normal=[[('skip_connect', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('skip_connect', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_3x3', 0), ('skip_connect', 1)], [('dil_conv_5x5', 2), ('max_pool_3x3', 1)], [('sep_conv_3x3', 2), ('sep_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 3)]], reduce_concat=range(2, 6))", "2": "Genotype(normal=[[('skip_connect', 1), ('sep_conv_3x3', 0)], [('sep_conv_3x3', 0), ('skip_connect', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3', 1), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('sep_conv_3x3', 0), ('skip_connect', 1)], [('dil_conv_5x5', 2), ('max_pool_3x3', 1)], [('sep_conv_3x3', 2), ('sep_conv_3x3', 1)], [('sep_conv_5x5', 0), ('sep_conv_3x3', 3)]], reduce_concat=range(2, 6))"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pdarts_genotype.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pdarts_genotype.json new file mode 100644 index 000000000..763a8474f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/cells/pdarts_genotype.json @@ -0,0 +1 @@ +{"0": "Genotype(normal=[[('skip_connect', 0), ('dil_conv_3x3', 1)], [('skip_connect', 0),('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3',0), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('avg_pool_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)], [('max_pool_3x3', 0), ('dil_conv_3x3', 1)], [('dil_conv_3x3', 1), ('dil_conv_5x5', 3)]], reduce_concat=range(2, 6))", "1": "Genotype(normal=[[('skip_connect', 0), ('dil_conv_3x3', 1)], [('skip_connect', 0),('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3',0), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('avg_pool_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)], [('max_pool_3x3', 0), ('dil_conv_3x3', 1)], [('dil_conv_3x3', 1), ('dil_conv_5x5', 3)]], reduce_concat=range(2, 6))", "2": "Genotype(normal=[[('skip_connect', 0), ('dil_conv_3x3', 1)], [('skip_connect', 0),('sep_conv_3x3', 1)], [('sep_conv_3x3', 1), ('sep_conv_3x3', 3)], [('sep_conv_3x3',0), ('dil_conv_5x5', 4)]], normal_concat=range(2, 6), reduce=[[('avg_pool_3x3', 0), ('sep_conv_5x5', 1)], [('sep_conv_3x3', 0), ('dil_conv_5x5', 2)], [('max_pool_3x3', 0), ('dil_conv_3x3', 1)], [('dil_conv_3x3', 1), ('dil_conv_5x5', 3)]], reduce_concat=range(2, 6))"} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/retrain.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/retrain.py new file mode 100644 index 000000000..749acacbc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/retrain.py @@ -0,0 +1,206 @@ +""" Retrain cell """ +import _init_paths +import os +import torch +import json +import torch.nn as nn +import numpy as np +import lib.utils.genotypes as gt + +from tensorboardX import SummaryWriter +from lib.models.cdarts_controller import CDARTSController +from lib.utils import utils +from lib.config import AugmentConfig +from lib.core.augment_function import train, validate + +# config +config = AugmentConfig() + +# make apex optional +if config.distributed: + # DDP = torch.nn.parallel.DistributedDataParallel + try: + import apex + from apex.parallel import DistributedDataParallel as DDP + from apex import amp, optimizers + from apex.fp16_utils import * + except ImportError: + raise ImportError("Please install apex from https://www.github.com/nvidia/apex to run this example.") + + +# tensorboard +writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) +writer.add_text('config', config.as_markdown(), 0) + +logger = utils.get_logger(os.path.join(config.path, "{}.log".format(config.name))) +if config.local_rank == 0: + config.print_params(logger.info) + +if 'cifar' in config.dataset: + from lib.datasets.cifar import get_augment_datasets +elif 'imagenet' in config.dataset: + from lib.datasets.imagenet import get_augment_datasets +else: + raise Exception("Not support dataset!") + +def main(): + logger.info("Logger is set - training start") + + # set seed + np.random.seed(config.seed) + torch.manual_seed(config.seed) + torch.cuda.manual_seed_all(config.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = True + + if config.distributed: + config.gpu = config.local_rank % torch.cuda.device_count() + torch.cuda.set_device(config.gpu) + # distributed init + torch.distributed.init_process_group(backend='nccl', init_method=config.dist_url, + world_size=config.world_size, rank=config.local_rank) + + config.world_size = torch.distributed.get_world_size() + + config.total_batch_size = config.world_size * config.batch_size + else: + config.total_batch_size = config.batch_size + + + loaders, samplers = get_augment_datasets(config) + train_loader, valid_loader = loaders + train_sampler, valid_sampler = samplers + + net_crit = nn.CrossEntropyLoss().cuda() + controller = CDARTSController(config, net_crit, n_nodes=4, stem_multiplier=config.stem_multiplier) + + file = open(config.cell_file, 'r') + js = file.read() + r_dict = json.loads(js) + if config.local_rank == 0: + logger.info(r_dict) + file.close() + genotypes_dict = {} + for layer_idx, genotype in r_dict.items(): + genotypes_dict[int(layer_idx)] = gt.from_str(genotype) + + controller.build_augment_model(controller.init_channel, genotypes_dict) + resume_state = None + if config.resume: + resume_state = torch.load(config.resume_path, map_location='cpu') + controller.model_main.load_state_dict(resume_state['model_main']) + + controller.model_main = controller.model_main.cuda() + param_size = utils.param_size(controller.model_main) + logger.info("param size = %fMB", param_size) + + # change training hyper parameters according to cell type + if 'cifar' in config.dataset: + if param_size < 3.0: + config.weight_decay = 3e-4 + config.drop_path_prob = 0.2 + elif param_size > 3.0 and param_size < 3.5: + config.weight_decay = 3e-4 + config.drop_path_prob = 0.3 + else: + config.weight_decay = 5e-4 + config.drop_path_prob = 0.3 + + if config.local_rank == 0: + logger.info("Current weight decay: {}".format(config.weight_decay)) + logger.info("Current drop path prob: {}".format(config.drop_path_prob)) + + controller.model_main = apex.parallel.convert_syncbn_model(controller.model_main) + # weights optimizer + optimizer = torch.optim.SGD(controller.model_main.parameters(), lr=config.lr, momentum=config.momentum, weight_decay=config.weight_decay) + # optimizer = torch.optim.SGD(controller.model_main.parameters(), lr=config.lr, momentum=config.momentum, weight_decay=config.weight_decay, nesterov=True) + lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, config.epochs) + + if config.use_amp: + controller.model_main, optimizer = amp.initialize(controller.model_main, optimizer, opt_level=config.opt_level) + + if config.distributed: + controller.model_main = DDP(controller.model_main, delay_allreduce=True) + + best_top1 = 0. + best_top5 = 0. + sta_epoch = 0 + # training loop + if config.resume: + optimizer.load_state_dict(resume_state['optimizer']) + lr_scheduler.load_state_dict(resume_state['lr_scheduler']) + best_top1 = resume_state['best_top1'] + best_top5 = resume_state['best_top5'] + sta_epoch = resume_state['sta_epoch'] + + epoch_pool = [220, 230, 235, 240, 245] + for epoch in range(sta_epoch, config.epochs): + # reset iterators + train_sampler.set_epoch(epoch) + valid_sampler.set_epoch(epoch) + current_lr = lr_scheduler.get_lr()[0] + # current_lr = utils.adjust_lr(optimizer, epoch, config) + + if config.local_rank == 0: + logger.info('Epoch: %d lr %e', epoch, current_lr) + if epoch < config.warmup_epochs and config.total_batch_size > 256: + for param_group in optimizer.param_groups: + param_group['lr'] = current_lr * (epoch + 1) / 5.0 + if config.local_rank == 0: + logger.info('Warming-up Epoch: %d, LR: %e', epoch, current_lr * (epoch + 1) / 5.0) + + drop_prob = config.drop_path_prob * epoch / config.epochs + controller.model_main.module.drop_path_prob(drop_prob) + + # training + train(train_loader, controller.model_main, optimizer, epoch, writer, logger, config) + + # validation + cur_step = (epoch+1) * len(train_loader) + top1, top5 = validate(valid_loader, controller.model_main, epoch, cur_step, writer, logger, config) + + if 'cifar' in config.dataset: + lr_scheduler.step() + elif 'imagenet' in config.dataset: + lr_scheduler.step() + # current_lr = utils.adjust_lr(optimizer, epoch, config) + else: + raise Exception('Lr error!') + + # save + if best_top1 < top1: + best_top1 = top1 + best_top5 = top5 + is_best = True + else: + is_best = False + + # save + if config.local_rank == 0: + if ('imagenet' in config.dataset) and ((epoch+1) in epoch_pool) and (not config.resume) and (config.local_rank == 0): + torch.save({ + "model_main":controller.model_main.module.state_dict(), + "optimizer":optimizer.state_dict(), + "lr_scheduler":lr_scheduler.state_dict(), + "best_top1":best_top1, + "best_top5":best_top5, + "sta_epoch":epoch + 1 + }, os.path.join(config.path, "epoch_{}.pth.tar".format(epoch+1))) + utils.save_checkpoint(controller.model_main.module.state_dict(), config.path, is_best) + + torch.save({ + "model_main":controller.model_main.module.state_dict(), + "optimizer":optimizer.state_dict(), + "lr_scheduler":lr_scheduler.state_dict(), + "best_top1":best_top1, + "best_top5":best_top5, + "sta_epoch":epoch + 1 + }, os.path.join(config.path, "retrain_resume.pth.tar")) + utils.save_checkpoint(controller.model_main.module.state_dict(), config.path, is_best) + + if config.local_rank == 0: + logger.info("Final best Prec@1 = {:.4%}, Prec@5 = {:.4%}".format(best_top1, best_top5)) + + +if __name__ == "__main__": + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/search.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/search.py new file mode 100644 index 000000000..02575a83d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/search.py @@ -0,0 +1,403 @@ +""" Search cell """ +import _init_paths +import os +import copy +import json +import torch +import time +import math +import torch.nn as nn +import numpy as np + +from tensorboardX import SummaryWriter +from lib.models.cdarts_controller import CDARTSController +from lib.utils.visualize import plot +from lib.utils import utils +from lib.core.search_function import search, retrain_warmup + +from lib.config import SearchConfig +config = SearchConfig() + +if 'cifar' in config.dataset: + from lib.datasets.cifar import get_search_datasets +elif 'imagenet' in config.dataset: + from lib.datasets.imagenet import get_search_datasets + +# tensorboard +writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) +writer.add_text('config', config.as_markdown(), 0) + +logger = utils.get_logger(os.path.join(config.path, "{}.log".format(config.name))) +if config.local_rank == 0: + config.print_params(logger.info) + +try: + os.makedirs(config.retrain_path) +except: + pass + +if config.use_apex: + import apex + from apex.parallel import DistributedDataParallel as DDP +else: + DDP = torch.nn.parallel.DistributedDataParallel + + +def main(): + logger.info("Logger is set - training start") + + + # set seed + np.random.seed(config.seed) + torch.manual_seed(config.seed) + torch.cuda.manual_seed_all(config.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = True + + if config.distributed: + config.gpu = config.local_rank % torch.cuda.device_count() + torch.cuda.set_device(config.gpu) + # distributed init + torch.distributed.init_process_group(backend='nccl', init_method=config.dist_url, + world_size=config.world_size, rank=config.local_rank) + + config.world_size = torch.distributed.get_world_size() + + config.total_batch_size = config.world_size * config.batch_size + else: + config.total_batch_size = config.batch_size + + + loaders, samplers = get_search_datasets(config) + train_loader, valid_loader = loaders + train_sampler, valid_sampler = samplers + + net_crit = nn.CrossEntropyLoss().cuda() + controller = CDARTSController(config, net_crit, n_nodes=4, stem_multiplier=config.stem_multiplier) + if config.param_pool_path is not None: + param_pool = torch.load(config.param_pool_path, map_location='cpu') + controller.load_state_dict(param_pool, strict=False) + + resume_state = None + if config.resume: + resume_state = torch.load(config.resume_path, map_location='cpu') + + sta_layer_idx = 0 + if config.resume: + controller.load_state_dict(resume_state['controller']) + sta_layer_idx = resume_state['sta_layer_idx'] + + controller = controller.cuda() + if config.sync_bn: + if config.use_apex: + controller = apex.parallel.convert_syncbn_model(controller) + else: + controller = torch.nn.SyncBatchNorm.convert_sync_batchnorm(controller) + + if config.use_apex: + controller = DDP(controller, delay_allreduce=True) + else: + controller = DDP(controller, device_ids=[config.gpu]) + + # warm up model_search + layer_idx=0 + if config.ensemble_param: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers[layer_idx].parameters(), 'lr':config.w_lr}, + {"params": controller.module.super_layers[layer_idx+1:].parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.ensemble_param}, + {"params": controller.module.nas_layers[:layer_idx].parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers[layer_idx].parameters(), 'lr':config.w_lr}, + {"params": controller.module.super_layers[layer_idx+1:].parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.nas_layers[:layer_idx].parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + + + + for layer_idx in range(sta_layer_idx, config.layer_num): + if config.one_stage: + if layer_idx > 0: + break + + # clean arch params in model_search + if config.clean_arch: + controller.module.init_arch_params(layer_idx) + + # search training loop + best_top1 = 0. + best_genotypes = [] + best_connects = [] + sta_search_iter, sta_search_epoch = 0, 0 + is_best = True + if (layer_idx == sta_layer_idx) and (resume_state is not None): + sta_search_iter = resume_state['sta_search_iter'] + sta_search_epoch = resume_state['sta_search_epoch'] + best_top1 = resume_state['best_top1'] + best_genotypes = resume_state['best_genotypes'] + best_connects = resume_state['best_connects'] + else: + # init model main + if config.gumbel_sample: + genotype, connect = controller.module.generate_genotype_gumbel(0) + else: + genotype, connect = controller.module.generate_genotype(0) + for i in range(config.layer_num): + best_genotypes.append(genotype) + best_connects.append(connect) + + for i in range(config.layer_num): + controller.module.genotypes[i] = best_genotypes[i] + controller.module.connects[i] = best_connects[i] + + lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( + w_optim, config.search_iter * config.search_iter_epochs, eta_min=config.w_lr_min) + lr_scheduler_retrain = nn.ModuleList() + alpha_optim = nn.ModuleList() + optimizer = nn.ModuleList() + sub_epoch = 0 + + for search_iter in range(sta_search_iter, config.search_iter): + if search_iter < config.pretrain_epochs: + if config.local_rank == 0: + logger.info("####### Super model warmup #######") + train_sampler.set_epoch(search_iter) + retrain_warmup(train_loader, controller, w_optim, layer_idx, search_iter, writer, logger, True, config.pretrain_epochs, config) + #lr_scheduler.step() + else: + # build new controller + for i, genotype in enumerate(best_genotypes): + controller.module.build_nas_layers(i, genotype, config.same_structure) + + controller_b = copy.deepcopy(controller.module) + del controller + controller = controller_b.cuda() + controller.fix_pre_layers(layer_idx) + + #if search_iter > config.regular_ratio * config.search_iter: + # config.regular = False + + # sync params from super layer pool + for i in range(layer_idx, config.layer_num): + controller.copy_params_from_super_layer(i) + + if config.sync_bn: + if config.use_apex: + controller = apex.parallel.convert_syncbn_model(controller) + else: + controller = torch.nn.SyncBatchNorm.convert_sync_batchnorm(controller) + + if config.use_apex: + controller = DDP(controller, delay_allreduce=True) + else: + controller = DDP(controller, device_ids=[config.gpu]) + + # weights optimizer + if config.ensemble_param: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers[layer_idx].parameters(), 'lr':config.w_lr}, + {"params": controller.module.super_layers[layer_idx+1:].parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.ensemble_param}, + {"params": controller.module.nas_layers[:layer_idx].parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers[layer_idx].parameters(), 'lr':config.w_lr}, + {"params": controller.module.super_layers[layer_idx+1:].parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.nas_layers[:layer_idx].parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + # arch_params optimizer + if config.repeat_cell: + alpha_optim = torch.optim.Adam(controller.module.super_layers_arch[0].parameters(), config.alpha_lr, betas=(0.5, 0.999), + weight_decay=config.alpha_weight_decay) + else: + alpha_optim = torch.optim.Adam(controller.module.super_layers_arch[layer_idx:].parameters(), config.alpha_lr, betas=(0.5, 0.999), + weight_decay=config.alpha_weight_decay) + + if config.ensemble_param: + optimizer = torch.optim.SGD([{"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.nas_layers.parameters(), 'lr':config.nasnet_lr*0.1 if config.param_pool_path else config.nasnet_lr}, + {"params": controller.module.ensemble_param}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.fc_nas.parameters()}], + lr=config.nasnet_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + optimizer = torch.optim.SGD([{"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.nas_layers.parameters(), 'lr':config.nasnet_lr*0.1 if config.param_pool_path else config.nasnet_lr}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.fc_nas.parameters()}], + lr=config.nasnet_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + + lr_scheduler_retrain = torch.optim.lr_scheduler.CosineAnnealingLR( + optimizer, config.search_iter_epochs, eta_min=config.w_lr_min) + lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( + w_optim, config.search_iter * config.search_iter_epochs, eta_min=config.w_lr_min) + + if (layer_idx == sta_layer_idx) and (resume_state is not None) and (resume_state['sta_search_epoch'] > config.pretrain_epochs): + w_optim.load_state_dict(resume_state['w_optim']) + alpha_optim.load_state_dict(resume_state['alpha_optim']) + lr_scheduler.load_state_dict(resume_state['lr_scheduler']) + lr_scheduler_retrain.load_state_dict(resume_state['lr_scheduler_retrain']) + else: + # lr_scheduler + pass + #for i in range(search_iter * config.search_iter_epochs): + # lr_scheduler.step() + + # warmup model main + if config.local_rank == 0: + logger.info("####### Sub model warmup #######") + for warmup_epoch in range(config.nasnet_warmup): + valid_sampler.set_epoch(warmup_epoch) + retrain_warmup(valid_loader, controller, optimizer, layer_idx, warmup_epoch, writer, logger, False, config.nasnet_warmup, config) + + + best_top1 = 0. + sub_epoch = 0 + + for sub_epoch in range(sta_search_epoch, config.search_iter_epochs): + + lr_search = lr_scheduler.get_lr()[0] + lr_main = lr_scheduler_retrain.get_lr()[0] + + search_epoch = search_iter * config.search_iter_epochs + sub_epoch + + # reset iterators + train_sampler.set_epoch(search_epoch) + valid_sampler.set_epoch(search_epoch) + + # training + search(train_loader, valid_loader, controller, optimizer, w_optim, alpha_optim, layer_idx, search_epoch, writer, logger, config) + + # validation + step_num = len(valid_loader) + cur_step = (search_epoch+1) * step_num + top1 = 1. + + genotypes = [] + connects = [] + + if config.gumbel_sample: + genotype, connect = controller.module.generate_genotype_gumbel(0) + else: + genotype, connect = controller.module.generate_genotype(0) + + for i in range(config.layer_num): + genotypes.append(genotype) + connects.append(connect) + + if config.local_rank == 0: + # for i in range(config.layer_num - layer_idx): + # logger.info ("Stage: {} Layer: {}".format(layer_idx, i+layer_idx+1)) + logger.info ("Genotypes: ") + # controller.module.print_arch_params(logger, i+layer_idx) + controller.module.print_arch_params(logger, 0) + + for i in range(config.layer_num - layer_idx): + if config.local_rank == 0: + # genotype + genotype = genotypes[i] + logger.info("Stage: {} Layer: {} genotype = {}".format(layer_idx, i+layer_idx+1, genotype)) + # genotype as a image + plot_path = os.path.join(config.plot_path, "Stage_{}_Layer_{}_EP_{:02d}".format(layer_idx, layer_idx+i+1, search_epoch+1)) + caption = "Stage_{}_Layer_{}_Epoch_{}".format(layer_idx, layer_idx+i+1, search_epoch+1) + plot(genotype.normal, plot_path + "-normal", caption) + plot(genotype.reduce, plot_path + "-reduce", caption) + + + # sync params to super layer pool + for i in range(layer_idx, config.layer_num): + controller.module.copy_params_from_nas_layer(i) + + # save + best_top1 = top1 + best_genotypes = genotypes + best_connects = connects + + for i in range(config.layer_num): + controller.module.genotypes[i] = best_genotypes[i] + controller.module.connects[i] = best_connects[i] + + #lr_scheduler.step() + #lr_scheduler_retrain.step() + + if config.local_rank == 0: + utils.save_checkpoint(controller.module, config.path, is_best) + torch.save({ + 'controller': controller.module.state_dict(), + 'sta_layer_idx': layer_idx, + 'w_optim': w_optim.state_dict(), + 'alpha_optim': alpha_optim.state_dict(), + 'lr_scheduler': lr_scheduler.state_dict(), + 'sta_search_iter': search_iter, + 'sta_search_epoch': sub_epoch + 1, + 'best_top1': best_top1, + 'best_genotypes': best_genotypes, + 'best_connects': best_connects, + 'lr_scheduler_retrain': lr_scheduler_retrain.state_dict(), + 'optimizer': optimizer.state_dict() + }, os.path.join(config.path, 'search_resume.pth.tar')) + + + torch.cuda.empty_cache() + sta_search_epoch = 0 + + # clean + del w_optim + del alpha_optim + del optimizer + torch.cuda.empty_cache() + config.pretrain_epochs = max(config.pretrain_epochs - config.pretrain_decay, 0) + + + # genotype as a image + for i in range(config.layer_num): + genotype, connect = controller.module.generate_genotype(i) + controller.module.genotypes[i] = genotype + controller.module.connects[i] = connect + + if config.local_rank == 0: + for layer_idx, genotype in controller.module.genotypes.items(): + logger.info("layer_idx : {}".format(layer_idx+1)) + logger.info("genotype = {}".format(genotype)) + + plot_path = os.path.join(config.plot_path, "Final_Layer_{}_genotype".format(layer_idx+1)) + caption = "Layer_{}".format(layer_idx+1) + plot(genotype.normal, plot_path + "-normal", caption) + plot(genotype.reduce, plot_path + "-reduce", caption) + + + # save dict as json + if config.local_rank == 0: + for layer_idx, genotype in controller.module.genotypes.items(): + controller.module.genotypes[layer_idx] = str(genotype) + + js = json.dumps(controller.module.genotypes) + file = open('genotypes.json', 'w') + file.write(js) + file.close() + +if __name__ == "__main__": + sta_time = time.time() + main() + search_time = time.time() - sta_time + search_hour = math.floor(search_time / 3600) + search_min = math.floor(search_time / 60 - search_hour * 60) + if config.local_rank==0: + logger.info("Search time: hour: {} minute: {}".format(search_hour, search_min)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/test.py new file mode 100644 index 000000000..e7e177174 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS/test.py @@ -0,0 +1,96 @@ +""" Search cell """ +import _init_paths +import os +import torch +import json +import numpy as np +import lib.utils.genotypes as gt + +from tensorboardX import SummaryWriter +from lib.models.model_test import ModelTest +from lib.utils import utils +from lib.config import AugmentConfig +from lib.core.augment_function import validate + +# config +config = AugmentConfig() + +# make apex optional +if config.distributed: + # DDP = torch.nn.parallel.DistributedDataParallel + try: + import apex + from apex.parallel import DistributedDataParallel as DDP + from apex import amp, optimizers + from apex.fp16_utils import * + except ImportError: + raise ImportError("Please install apex from https://www.github.com/nvidia/apex to run this example.") + + +# tensorboard +writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) +writer.add_text('config', config.as_markdown(), 0) + +logger = utils.get_logger(os.path.join(config.path, "{}.log".format(config.name))) +if config.local_rank == 0: + config.print_params(logger.info) + +if 'cifar' in config.dataset: + from lib.datasets.cifar import get_augment_datasets +elif 'imagenet' in config.dataset: + from lib.datasets.imagenet import get_augment_datasets +else: + raise Exception("Not support dataser!") + +def main(): + logger.info("Logger is set - training start") + + # set seed + np.random.seed(config.seed) + torch.manual_seed(config.seed) + torch.cuda.manual_seed_all(config.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = True + + if config.distributed: + config.gpu = config.local_rank % torch.cuda.device_count() + torch.cuda.set_device(config.gpu) + # distributed init + torch.distributed.init_process_group(backend='nccl', init_method=config.dist_url, + world_size=config.world_size, rank=config.local_rank) + + config.world_size = torch.distributed.get_world_size() + + config.total_batch_size = config.world_size * config.batch_size + else: + config.total_batch_size = config.batch_size + + loaders, samplers = get_augment_datasets(config) + train_loader, valid_loader = loaders + train_sampler, valid_sampler = samplers + + file = open(config.cell_file, 'r') + js = file.read() + r_dict = json.loads(js) + if config.local_rank == 0: + logger.info(r_dict) + file.close() + genotypes_dict = {} + for layer_idx, genotype in r_dict.items(): + genotypes_dict[int(layer_idx)] = gt.from_str(genotype) + + model_main = ModelTest(genotypes_dict, config.model_type, config.res_stem, init_channel=config.init_channels, \ + stem_multiplier=config.stem_multiplier, n_nodes=4, num_classes=config.n_classes) + resume_state = torch.load(config.resume_path, map_location='cpu') + model_main.load_state_dict(resume_state, strict=False) + model_main = model_main.cuda() + + if config.distributed: + model_main = DDP(model_main, delay_allreduce=True) + + top1, top5 = validate(valid_loader, model_main, 0, 0, writer, logger, config) + if config.local_rank == 0: + print("Final best Prec@1 = {:.4%}, Prec@5 = {:.4%}".format(top1, top5)) + +if __name__ == "__main__": + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/README.md new file mode 100644 index 000000000..63103a034 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/README.md @@ -0,0 +1,58 @@ +# CyDAS Detection Code Base + +### Environments +- Python 3.7 +- Pytorch>=1.8.2 +- Torchvision == 0.9.2 + +You can directly run the code ```sh env.sh``` and ```sh compile.sh``` to setup the running environment. +We use 8 GPUs (24GB RTX 3090) to train our detector, you can adjust the batch size in configs by yourselves. + +### Data Preparatoin + +Your directory tree should be look like this: + +````bash +$HitDet.pytorch/data +├── coco +│   ├── annotations +│   ├── train2017 +│   └── val2017 +│ +├── VOCdevkit +│   ├── VOC2007 +│   │   ├── Annotations +│   │ ├── ImageSets +│   │ ├── JPEGImages +│   │ ├── SegmentationClass +│   │   └── SegmentationObject +│   └── VOC2012 +│      ├── Annotations +│   ├── ImageSets +│   ├── JPEGImages +│   ├── SegmentationClass +│      └── SegmentationObject +```` + +### Getting Start + +Our pretrained backbone params can be found in [GoogleDrive](https://drive.google.com/drive/folders/1CkFp24bEDq0wUp504BQ68jn5Vs069qox) + +Installation +* Clone this repo: +```bash +cd CDARTS_detection +``` +* Install dependencies: +```bash +bash env.sh +bash compile.sh +``` + +Train: +``` +sh train.sh +``` + +## Acknowledgement +Our code is based on the open source project [MMDetection](https://github.com/open-mmlab/mmdetection). diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/configs/CyDAS_retinanet_1x.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/configs/CyDAS_retinanet_1x.py new file mode 100644 index 000000000..5ac2f1cb5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/configs/CyDAS_retinanet_1x.py @@ -0,0 +1,129 @@ +# model settings +input_size = 300 +model = dict( + type='RetinaNet', + pretrained='/home2/hongyuan/cydas/spos/mmdetection/390.pth.tar', + backbone=dict( + type='SSDMobilenetV3', + input_size=input_size, + activation_type='relu6', + single_scale=True + ), + neck=dict( + type='FPN', + in_channels=[24, 40, 96, 960], + out_channels=256, + start_level=1, + add_extra_convs=True, + num_outs=5), + bbox_head=dict( + type='RetinaHead', + num_classes=81, + in_channels=256, + stacked_convs=4, + feat_channels=256, + octave_base_scale=4, + scales_per_octave=3, + anchor_ratios=[0.5, 1.0, 2.0], + anchor_strides=[8, 16, 32, 64, 128], + target_means=[.0, .0, .0, .0], + target_stds=[1.0, 1.0, 1.0, 1.0], + loss_cls=dict( + type='FocalLoss', + use_sigmoid=True, + gamma=2.0, + alpha=0.25, + loss_weight=1.0), + loss_bbox=dict(type='SmoothL1Loss', beta=0.11, loss_weight=1.0))) +# training and testing settings +train_cfg = dict( + assigner=dict( + type='MaxIoUAssigner', + pos_iou_thr=0.5, + neg_iou_thr=0.4, + min_pos_iou=0, + ignore_iof_thr=-1), + allowed_border=-1, + pos_weight=-1, + debug=False) +test_cfg = dict( + nms_pre=1000, + min_bbox_size=0, + score_thr=0.05, + nms=dict(type='nms', iou_thr=0.5), + max_per_img=100) +# dataset settings +dataset_type = 'CocoDataset' +data_root = '/home2/hongyuan/data/coco/' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', with_bbox=True), + dict(type='Resize', img_scale=(1333, 800), keep_ratio=True), + dict(type='RandomFlip', flip_ratio=0.5), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']), +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(1333, 800), + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size_divisor=32), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +data = dict( + imgs_per_gpu=2, + workers_per_gpu=2, + train=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_train2017.json', + img_prefix=data_root + 'train2017/', + pipeline=train_pipeline), + val=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + ann_file=data_root + 'annotations/instances_val2017.json', + img_prefix=data_root + 'val2017/', + pipeline=test_pipeline)) +# optimizer +optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) +optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) +# learning policy +lr_config = dict( + policy='step', + warmup='linear', + warmup_iters=500, + warmup_ratio=1.0 / 3, + step=[8, 11]) +checkpoint_config = dict(interval=1) +# yapf:disable +log_config = dict( + interval=100, + hooks=[ + dict(type='TextLoggerHook'), + # dict(type='TensorboardLoggerHook') + ]) +# yapf:enable +# runtime settings +total_epochs = 12 +dist_params = dict(backend='nccl') +log_level = 'INFO' +work_dir = './work_dirs/CyDAS_390' +load_from = None +resume_from = None +workflow = [('train', 1)] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/__init__.py new file mode 100644 index 000000000..796b1defe --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/__init__.py @@ -0,0 +1,13 @@ +# flake8: noqa +from .arraymisc import * +from .utils import * +from .fileio import * +from .opencv_info import * +from .image import * +from .video import * +from .visualization import * +from .version import __version__ +# The following modules are not imported to this level, so mmcv may be used +# without PyTorch. +# - runner +# - parallel diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/__init__.py new file mode 100644 index 000000000..50f5aae17 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/__init__.py @@ -0,0 +1,3 @@ +from .quantization import quantize, dequantize + +__all__ = ['quantize', 'dequantize'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/quantization.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/quantization.py new file mode 100644 index 000000000..ab7f36c8d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/arraymisc/quantization.py @@ -0,0 +1,56 @@ +import numpy as np + + +def quantize(arr, min_val, max_val, levels, dtype=np.int64): + """Quantize an array of (-inf, inf) to [0, levels-1]. + + Args: + arr (ndarray): Input array. + min_val (scalar): Minimum value to be clipped. + max_val (scalar): Maximum value to be clipped. + levels (int): Quantization levels. + dtype (np.type): The type of the quantized array. + + Returns: + tuple: Quantized array. + """ + if not (isinstance(levels, int) and levels > 1): + raise ValueError( + 'levels must be a positive integer, but got {}'.format(levels)) + if min_val >= max_val: + raise ValueError( + 'min_val ({}) must be smaller than max_val ({})'.format( + min_val, max_val)) + + arr = np.clip(arr, min_val, max_val) - min_val + quantized_arr = np.minimum( + np.floor(levels * arr / (max_val - min_val)).astype(dtype), levels - 1) + + return quantized_arr + + +def dequantize(arr, min_val, max_val, levels, dtype=np.float64): + """Dequantize an array. + + Args: + arr (ndarray): Input array. + min_val (scalar): Minimum value to be clipped. + max_val (scalar): Maximum value to be clipped. + levels (int): Quantization levels. + dtype (np.type): The type of the dequantized array. + + Returns: + tuple: Dequantized array. + """ + if not (isinstance(levels, int) and levels > 1): + raise ValueError( + 'levels must be a positive integer, but got {}'.format(levels)) + if min_val >= max_val: + raise ValueError( + 'min_val ({}) must be smaller than max_val ({})'.format( + min_val, max_val)) + + dequantized_arr = (arr + 0.5).astype(dtype) * (max_val - + min_val) / levels + min_val + + return dequantized_arr diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py new file mode 100644 index 000000000..10293abdf --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/__init__.py @@ -0,0 +1,11 @@ +from .alexnet import AlexNet +from .vgg import VGG, make_vgg_layer +from .resnet import ResNet, make_res_layer +from .weight_init import (constant_init, xavier_init, normal_init, + uniform_init, kaiming_init, caffe2_xavier_init) + +__all__ = [ + 'AlexNet', 'VGG', 'make_vgg_layer', 'ResNet', 'make_res_layer', + 'constant_init', 'xavier_init', 'normal_init', 'uniform_init', + 'kaiming_init', 'caffe2_xavier_init' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py new file mode 100644 index 000000000..1230ee575 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py @@ -0,0 +1,61 @@ +import logging + +import torch.nn as nn + +from ..runner import load_checkpoint + + +class AlexNet(nn.Module): + """AlexNet backbone. + + Args: + num_classes (int): number of classes for classification. + """ + + def __init__(self, num_classes=-1): + super(AlexNet, self).__init__() + self.num_classes = num_classes + self.features = nn.Sequential( + nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + nn.Conv2d(64, 192, kernel_size=5, padding=2), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + nn.Conv2d(192, 384, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.Conv2d(384, 256, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.Conv2d(256, 256, kernel_size=3, padding=1), + nn.ReLU(inplace=True), + nn.MaxPool2d(kernel_size=3, stride=2), + ) + if self.num_classes > 0: + self.classifier = nn.Sequential( + nn.Dropout(), + nn.Linear(256 * 6 * 6, 4096), + nn.ReLU(inplace=True), + nn.Dropout(), + nn.Linear(4096, 4096), + nn.ReLU(inplace=True), + nn.Linear(4096, num_classes), + ) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + # use default initializer + pass + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + + x = self.features(x) + if self.num_classes > 0: + x = x.view(x.size(0), 256 * 6 * 6) + x = self.classifier(x) + + return x diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/resnet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/resnet.py new file mode 100644 index 000000000..e98f6fcdd --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/resnet.py @@ -0,0 +1,314 @@ +import logging + +import torch.nn as nn +import torch.utils.checkpoint as cp + +from ..runner import load_checkpoint +from .weight_init import constant_init, kaiming_init + + +def conv3x3(in_planes, out_planes, stride=1, dilation=1): + "3x3 convolution with padding" + return nn.Conv2d( + in_planes, + out_planes, + kernel_size=3, + stride=stride, + padding=dilation, + dilation=dilation, + bias=False) + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False): + super(BasicBlock, self).__init__() + self.conv1 = conv3x3(inplanes, planes, stride, dilation) + self.bn1 = nn.BatchNorm2d(planes) + self.relu = nn.ReLU(inplace=True) + self.conv2 = conv3x3(planes, planes) + self.bn2 = nn.BatchNorm2d(planes) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + assert not with_cp + + def forward(self, x): + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + if self.downsample is not None: + residual = self.downsample(x) + + out += residual + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + expansion = 4 + + def __init__(self, + inplanes, + planes, + stride=1, + dilation=1, + downsample=None, + style='pytorch', + with_cp=False): + """Bottleneck block. + + If style is "pytorch", the stride-two layer is the 3x3 conv layer, + if it is "caffe", the stride-two layer is the first 1x1 conv layer. + """ + super(Bottleneck, self).__init__() + assert style in ['pytorch', 'caffe'] + if style == 'pytorch': + conv1_stride = 1 + conv2_stride = stride + else: + conv1_stride = stride + conv2_stride = 1 + self.conv1 = nn.Conv2d( + inplanes, planes, kernel_size=1, stride=conv1_stride, bias=False) + self.conv2 = nn.Conv2d( + planes, + planes, + kernel_size=3, + stride=conv2_stride, + padding=dilation, + dilation=dilation, + bias=False) + + self.bn1 = nn.BatchNorm2d(planes) + self.bn2 = nn.BatchNorm2d(planes) + self.conv3 = nn.Conv2d( + planes, planes * self.expansion, kernel_size=1, bias=False) + self.bn3 = nn.BatchNorm2d(planes * self.expansion) + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + self.dilation = dilation + self.with_cp = with_cp + + def forward(self, x): + + def _inner_forward(x): + residual = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + if self.downsample is not None: + residual = self.downsample(x) + + out += residual + + return out + + if self.with_cp and x.requires_grad: + out = cp.checkpoint(_inner_forward, x) + else: + out = _inner_forward(x) + + out = self.relu(out) + + return out + + +def make_res_layer(block, + inplanes, + planes, + blocks, + stride=1, + dilation=1, + style='pytorch', + with_cp=False): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + nn.Conv2d( + inplanes, + planes * block.expansion, + kernel_size=1, + stride=stride, + bias=False), + nn.BatchNorm2d(planes * block.expansion), + ) + + layers = [] + layers.append( + block( + inplanes, + planes, + stride, + dilation, + downsample, + style=style, + with_cp=with_cp)) + inplanes = planes * block.expansion + for i in range(1, blocks): + layers.append( + block(inplanes, planes, 1, dilation, style=style, with_cp=with_cp)) + + return nn.Sequential(*layers) + + +class ResNet(nn.Module): + """ResNet backbone. + + Args: + depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. + num_stages (int): Resnet stages, normally 4. + strides (Sequence[int]): Strides of the first block of each stage. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two + layer is the 3x3 conv layer, otherwise the stride-two layer is + the first 1x1 conv layer. + frozen_stages (int): Stages to be frozen (all param fixed). -1 means + not freezing any parameters. + bn_eval (bool): Whether to set BN layers as eval mode, namely, freeze + running stats (mean and var). + bn_frozen (bool): Whether to freeze weight and bias of BN layers. + with_cp (bool): Use checkpoint or not. Using checkpoint will save some + memory while slowing down the training speed. + """ + + arch_settings = { + 18: (BasicBlock, (2, 2, 2, 2)), + 34: (BasicBlock, (3, 4, 6, 3)), + 50: (Bottleneck, (3, 4, 6, 3)), + 101: (Bottleneck, (3, 4, 23, 3)), + 152: (Bottleneck, (3, 8, 36, 3)) + } + + def __init__(self, + depth, + num_stages=4, + strides=(1, 2, 2, 2), + dilations=(1, 1, 1, 1), + out_indices=(0, 1, 2, 3), + style='pytorch', + frozen_stages=-1, + bn_eval=True, + bn_frozen=False, + with_cp=False): + super(ResNet, self).__init__() + if depth not in self.arch_settings: + raise KeyError('invalid depth {} for resnet'.format(depth)) + assert num_stages >= 1 and num_stages <= 4 + block, stage_blocks = self.arch_settings[depth] + stage_blocks = stage_blocks[:num_stages] + assert len(strides) == len(dilations) == num_stages + assert max(out_indices) < num_stages + + self.out_indices = out_indices + self.style = style + self.frozen_stages = frozen_stages + self.bn_eval = bn_eval + self.bn_frozen = bn_frozen + self.with_cp = with_cp + + self.inplanes = 64 + self.conv1 = nn.Conv2d( + 3, 64, kernel_size=7, stride=2, padding=3, bias=False) + self.bn1 = nn.BatchNorm2d(64) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + + self.res_layers = [] + for i, num_blocks in enumerate(stage_blocks): + stride = strides[i] + dilation = dilations[i] + planes = 64 * 2**i + res_layer = make_res_layer( + block, + self.inplanes, + planes, + num_blocks, + stride=stride, + dilation=dilation, + style=self.style, + with_cp=with_cp) + self.inplanes = planes * block.expansion + layer_name = 'layer{}'.format(i + 1) + self.add_module(layer_name, res_layer) + self.res_layers.append(layer_name) + + self.feat_dim = block.expansion * 64 * 2**(len(stage_blocks) - 1) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + outs = [] + for i, layer_name in enumerate(self.res_layers): + res_layer = getattr(self, layer_name) + x = res_layer(x) + if i in self.out_indices: + outs.append(x) + if len(outs) == 1: + return outs[0] + else: + return tuple(outs) + + def train(self, mode=True): + super(ResNet, self).train(mode) + if self.bn_eval: + for m in self.modules(): + if isinstance(m, nn.BatchNorm2d): + m.eval() + if self.bn_frozen: + for params in m.parameters(): + params.requires_grad = False + if mode and self.frozen_stages >= 0: + for param in self.conv1.parameters(): + param.requires_grad = False + for param in self.bn1.parameters(): + param.requires_grad = False + self.bn1.eval() + self.bn1.weight.requires_grad = False + self.bn1.bias.requires_grad = False + for i in range(1, self.frozen_stages + 1): + mod = getattr(self, 'layer{}'.format(i)) + mod.eval() + for param in mod.parameters(): + param.requires_grad = False diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/vgg.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/vgg.py new file mode 100644 index 000000000..67dc22d84 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/vgg.py @@ -0,0 +1,174 @@ +import logging + +import torch.nn as nn + +from ..runner import load_checkpoint +from .weight_init import constant_init, kaiming_init, normal_init + + +def conv3x3(in_planes, out_planes, dilation=1): + "3x3 convolution with padding" + return nn.Conv2d( + in_planes, + out_planes, + kernel_size=3, + padding=dilation, + dilation=dilation) + + +def make_vgg_layer(inplanes, + planes, + num_blocks, + dilation=1, + with_bn=False, + ceil_mode=False): + layers = [] + for _ in range(num_blocks): + layers.append(conv3x3(inplanes, planes, dilation)) + if with_bn: + layers.append(nn.BatchNorm2d(planes)) + layers.append(nn.ReLU(inplace=True)) + inplanes = planes + layers.append(nn.MaxPool2d(kernel_size=2, stride=2, ceil_mode=ceil_mode)) + + return layers + + +class VGG(nn.Module): + """VGG backbone. + + Args: + depth (int): Depth of vgg, from {11, 13, 16, 19}. + with_bn (bool): Use BatchNorm or not. + num_classes (int): number of classes for classification. + num_stages (int): VGG stages, normally 5. + dilations (Sequence[int]): Dilation of each stage. + out_indices (Sequence[int]): Output from which stages. + frozen_stages (int): Stages to be frozen (all param fixed). -1 means + not freezing any parameters. + bn_eval (bool): Whether to set BN layers as eval mode, namely, freeze + running stats (mean and var). + bn_frozen (bool): Whether to freeze weight and bias of BN layers. + """ + + arch_settings = { + 11: (1, 1, 2, 2, 2), + 13: (2, 2, 2, 2, 2), + 16: (2, 2, 3, 3, 3), + 19: (2, 2, 4, 4, 4) + } + + def __init__(self, + depth, + with_bn=False, + num_classes=-1, + num_stages=5, + dilations=(1, 1, 1, 1, 1), + out_indices=(0, 1, 2, 3, 4), + frozen_stages=-1, + bn_eval=True, + bn_frozen=False, + ceil_mode=False, + with_last_pool=True): + super(VGG, self).__init__() + if depth not in self.arch_settings: + raise KeyError('invalid depth {} for vgg'.format(depth)) + assert num_stages >= 1 and num_stages <= 5 + stage_blocks = self.arch_settings[depth] + self.stage_blocks = stage_blocks[:num_stages] + assert len(dilations) == num_stages + assert max(out_indices) <= num_stages + + self.num_classes = num_classes + self.out_indices = out_indices + self.frozen_stages = frozen_stages + self.bn_eval = bn_eval + self.bn_frozen = bn_frozen + + self.inplanes = 3 + start_idx = 0 + vgg_layers = [] + self.range_sub_modules = [] + for i, num_blocks in enumerate(self.stage_blocks): + num_modules = num_blocks * (2 + with_bn) + 1 + end_idx = start_idx + num_modules + dilation = dilations[i] + planes = 64 * 2**i if i < 4 else 512 + vgg_layer = make_vgg_layer( + self.inplanes, + planes, + num_blocks, + dilation=dilation, + with_bn=with_bn, + ceil_mode=ceil_mode) + vgg_layers.extend(vgg_layer) + self.inplanes = planes + self.range_sub_modules.append([start_idx, end_idx]) + start_idx = end_idx + if not with_last_pool: + vgg_layers.pop(-1) + self.range_sub_modules[-1][1] -= 1 + self.module_name = 'features' + self.add_module(self.module_name, nn.Sequential(*vgg_layers)) + + if self.num_classes > 0: + self.classifier = nn.Sequential( + nn.Linear(512 * 7 * 7, 4096), + nn.ReLU(True), + nn.Dropout(), + nn.Linear(4096, 4096), + nn.ReLU(True), + nn.Dropout(), + nn.Linear(4096, num_classes), + ) + + def init_weights(self, pretrained=None): + if isinstance(pretrained, str): + logger = logging.getLogger() + load_checkpoint(self, pretrained, strict=False, logger=logger) + elif pretrained is None: + for m in self.modules(): + if isinstance(m, nn.Conv2d): + kaiming_init(m) + elif isinstance(m, nn.BatchNorm2d): + constant_init(m, 1) + elif isinstance(m, nn.Linear): + normal_init(m, std=0.01) + else: + raise TypeError('pretrained must be a str or None') + + def forward(self, x): + outs = [] + vgg_layers = getattr(self, self.module_name) + for i, num_blocks in enumerate(self.stage_blocks): + for j in range(*self.range_sub_modules[i]): + vgg_layer = vgg_layers[j] + x = vgg_layer(x) + if i in self.out_indices: + outs.append(x) + if self.num_classes > 0: + x = x.view(x.size(0), -1) + x = self.classifier(x) + outs.append(x) + if len(outs) == 1: + return outs[0] + else: + return tuple(outs) + + def train(self, mode=True): + super(VGG, self).train(mode) + if self.bn_eval: + for m in self.modules(): + if isinstance(m, nn.BatchNorm2d): + m.eval() + if self.bn_frozen: + for params in m.parameters(): + params.requires_grad = False + vgg_layers = getattr(self, self.module_name) + if mode and self.frozen_stages >= 0: + for i in range(self.frozen_stages): + for j in range(*self.range_sub_modules[i]): + mod = vgg_layers[j] + mod.eval() + for param in mod.parameters(): + param.requires_grad = False diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/weight_init.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/weight_init.py new file mode 100644 index 000000000..1f807cd13 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/cnn/weight_init.py @@ -0,0 +1,57 @@ +import torch.nn as nn + + +def constant_init(module, val, bias=0): + nn.init.constant_(module.weight, val) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def xavier_init(module, gain=1, bias=0, distribution='normal'): + assert distribution in ['uniform', 'normal'] + if distribution == 'uniform': + nn.init.xavier_uniform_(module.weight, gain=gain) + else: + nn.init.xavier_normal_(module.weight, gain=gain) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def normal_init(module, mean=0, std=1, bias=0): + nn.init.normal_(module.weight, mean, std) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def uniform_init(module, a=0, b=1, bias=0): + nn.init.uniform_(module.weight, a, b) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def kaiming_init(module, + a=0, + mode='fan_out', + nonlinearity='relu', + bias=0, + distribution='normal'): + assert distribution in ['uniform', 'normal'] + if distribution == 'uniform': + nn.init.kaiming_uniform_( + module.weight, a=a, mode=mode, nonlinearity=nonlinearity) + else: + nn.init.kaiming_normal_( + module.weight, a=a, mode=mode, nonlinearity=nonlinearity) + if hasattr(module, 'bias') and module.bias is not None: + nn.init.constant_(module.bias, bias) + + +def caffe2_xavier_init(module, bias=0): + # `XavierFill` in Caffe2 corresponds to `kaiming_uniform_` in PyTorch + # Acknowledgment to FAIR's internal code + kaiming_init( + module, + a=1, + mode='fan_in', + nonlinearity='leaky_relu', + distribution='uniform') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py new file mode 100644 index 000000000..b804e0bcc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/__init__.py @@ -0,0 +1,8 @@ +from .io import load, dump, register_handler +from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler +from .parse import list_from_file, dict_from_file + +__all__ = [ + 'load', 'dump', 'register_handler', 'BaseFileHandler', 'JsonHandler', + 'PickleHandler', 'YamlHandler', 'list_from_file', 'dict_from_file' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/__init__.py new file mode 100644 index 000000000..8f763ec5b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/__init__.py @@ -0,0 +1,6 @@ +from .base import BaseFileHandler +from .json_handler import JsonHandler +from .pickle_handler import PickleHandler +from .yaml_handler import YamlHandler + +__all__ = ['BaseFileHandler', 'JsonHandler', 'PickleHandler', 'YamlHandler'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/base.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/base.py new file mode 100644 index 000000000..7614d2404 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/base.py @@ -0,0 +1,26 @@ +from abc import ABCMeta, abstractmethod + + +class BaseFileHandler(object): + + __metaclass__ = ABCMeta # python 2 compatibility + + @abstractmethod + def load_from_fileobj(self, file, **kwargs): + pass + + @abstractmethod + def dump_to_fileobj(self, obj, file, **kwargs): + pass + + @abstractmethod + def dump_to_str(self, obj, **kwargs): + pass + + def load_from_path(self, filepath, mode='r', **kwargs): + with open(filepath, mode) as f: + return self.load_from_fileobj(f, **kwargs) + + def dump_to_path(self, obj, filepath, mode='w', **kwargs): + with open(filepath, mode) as f: + self.dump_to_fileobj(obj, f, **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/json_handler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/json_handler.py new file mode 100644 index 000000000..4bb4e6d1b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/json_handler.py @@ -0,0 +1,15 @@ +import json + +from .base import BaseFileHandler + + +class JsonHandler(BaseFileHandler): + + def load_from_fileobj(self, file): + return json.load(file) + + def dump_to_fileobj(self, obj, file, **kwargs): + json.dump(obj, file, **kwargs) + + def dump_to_str(self, obj, **kwargs): + return json.dumps(obj, **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/pickle_handler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/pickle_handler.py new file mode 100644 index 000000000..2f11c30b2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/pickle_handler.py @@ -0,0 +1,25 @@ +from six.moves import cPickle as pickle + +from .base import BaseFileHandler + + +class PickleHandler(BaseFileHandler): + + def load_from_fileobj(self, file, **kwargs): + return pickle.load(file, **kwargs) + + def load_from_path(self, filepath, **kwargs): + return super(PickleHandler, self).load_from_path( + filepath, mode='rb', **kwargs) + + def dump_to_str(self, obj, **kwargs): + kwargs.setdefault('protocol', 2) + return pickle.dumps(obj, **kwargs) + + def dump_to_fileobj(self, obj, file, **kwargs): + kwargs.setdefault('protocol', 2) + pickle.dump(obj, file, **kwargs) + + def dump_to_path(self, obj, filepath, **kwargs): + super(PickleHandler, self).dump_to_path( + obj, filepath, mode='wb', **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/yaml_handler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/yaml_handler.py new file mode 100644 index 000000000..03f179c5a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/handlers/yaml_handler.py @@ -0,0 +1,23 @@ +import yaml + +try: + from yaml import CLoader as Loader, CDumper as Dumper +except ImportError: + from yaml import Loader, Dumper + +from .base import BaseFileHandler # isort:skip + + +class YamlHandler(BaseFileHandler): + + def load_from_fileobj(self, file, **kwargs): + kwargs.setdefault('Loader', Loader) + return yaml.load(file, **kwargs) + + def dump_to_fileobj(self, obj, file, **kwargs): + kwargs.setdefault('Dumper', Dumper) + yaml.dump(obj, file, **kwargs) + + def dump_to_str(self, obj, **kwargs): + kwargs.setdefault('Dumper', Dumper) + return yaml.dump(obj, **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/io.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/io.py new file mode 100644 index 000000000..13658672a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/io.py @@ -0,0 +1,112 @@ +from pathlib import Path + +from ..utils import is_list_of, is_str +from .handlers import BaseFileHandler, JsonHandler, PickleHandler, YamlHandler + +file_handlers = { + 'json': JsonHandler(), + 'yaml': YamlHandler(), + 'yml': YamlHandler(), + 'pickle': PickleHandler(), + 'pkl': PickleHandler() +} + + +def load(file, file_format=None, **kwargs): + """Load data from json/yaml/pickle files. + + This method provides a unified api for loading data from serialized files. + + Args: + file (str or :obj:`Path` or file-like object): Filename or a file-like + object. + file_format (str, optional): If not specified, the file format will be + inferred from the file extension, otherwise use the specified one. + Currently supported formats include "json", "yaml/yml" and + "pickle/pkl". + + Returns: + The content from the file. + """ + if isinstance(file, Path): + file = str(file) + if file_format is None and is_str(file): + file_format = file.split('.')[-1] + if file_format not in file_handlers: + raise TypeError('Unsupported format: {}'.format(file_format)) + + handler = file_handlers[file_format] + if is_str(file): + obj = handler.load_from_path(file, **kwargs) + elif hasattr(file, 'read'): + obj = handler.load_from_fileobj(file, **kwargs) + else: + raise TypeError('"file" must be a filepath str or a file-object') + return obj + + +def dump(obj, file=None, file_format=None, **kwargs): + """Dump data to json/yaml/pickle strings or files. + + This method provides a unified api for dumping data as strings or to files, + and also supports custom arguments for each file format. + + Args: + obj (any): The python object to be dumped. + file (str or :obj:`Path` or file-like object, optional): If not + specified, then the object is dump to a str, otherwise to a file + specified by the filename or file-like object. + file_format (str, optional): Same as :func:`load`. + + Returns: + bool: True for success, False otherwise. + """ + if isinstance(file, Path): + file = str(file) + if file_format is None: + if is_str(file): + file_format = file.split('.')[-1] + elif file is None: + raise ValueError( + 'file_format must be specified since file is None') + if file_format not in file_handlers: + raise TypeError('Unsupported format: {}'.format(file_format)) + + handler = file_handlers[file_format] + if file is None: + return handler.dump_to_str(obj, **kwargs) + elif is_str(file): + handler.dump_to_path(obj, file, **kwargs) + elif hasattr(file, 'write'): + handler.dump_to_fileobj(obj, file, **kwargs) + else: + raise TypeError('"file" must be a filename str or a file-object') + + +def _register_handler(handler, file_formats): + """Register a handler for some file extensions. + + Args: + handler (:obj:`BaseFileHandler`): Handler to be registered. + file_formats (str or list[str]): File formats to be handled by this + handler. + """ + if not isinstance(handler, BaseFileHandler): + raise TypeError( + 'handler must be a child of BaseFileHandler, not {}'.format( + type(handler))) + if isinstance(file_formats, str): + file_formats = [file_formats] + if not is_list_of(file_formats, str): + raise TypeError('file_formats must be a str or a list of str') + for ext in file_formats: + file_handlers[ext] = handler + + +def register_handler(file_formats, **kwargs): + + def wrap(cls): + _register_handler(cls(**kwargs), file_formats) + return cls + + return wrap diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py new file mode 100644 index 000000000..c712422c0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/fileio/parse.py @@ -0,0 +1,50 @@ +def list_from_file(filename, prefix='', offset=0, max_num=0): + """Load a text file and parse the content as a list of strings. + + Args: + filename (str): Filename. + prefix (str): The prefix to be inserted to the begining of each item. + offset (int): The offset of lines. + max_num (int): The maximum number of lines to be read, + zeros and negatives mean no limitation. + + Returns: + list[str]: A list of strings. + """ + cnt = 0 + item_list = [] + with open(filename, 'r') as f: + for _ in range(offset): + f.readline() + for line in f: + if max_num > 0 and cnt >= max_num: + break + item_list.append(prefix + line.rstrip('\n')) + cnt += 1 + return item_list + + +def dict_from_file(filename, key_type=str): + """Load a text file and parse the content as a dict. + + Each line of the text file will be two or more columns splited by + whitespaces or tabs. The first column will be parsed as dict keys, and + the following columns will be parsed as dict values. + + Args: + filename(str): Filename. + key_type(type): Type of the dict's keys. str is user by default and + type conversion will be performed if specified. + + Returns: + dict: The parsed contents. + """ + mapping = {} + with open(filename, 'r') as f: + for line in f: + items = line.rstrip('\n').split() + assert len(items) >= 2 + key = key_type(items[0]) + val = items[1:] if len(items) > 2 else items[1] + mapping[key] = val + return mapping diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/__init__.py new file mode 100644 index 000000000..3d2c98bf2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/__init__.py @@ -0,0 +1,12 @@ +from .io import imread, imwrite, imfrombytes +from .transforms import (bgr2gray, gray2bgr, bgr2rgb, rgb2bgr, bgr2hsv, + hsv2bgr, bgr2hls, hls2bgr, iminvert, imflip, imrotate, + imcrop, impad, impad_to_multiple, imnormalize, + imdenormalize, imresize, imresize_like, imrescale) + +__all__ = [ + 'imread', 'imwrite', 'imfrombytes', 'bgr2gray', 'gray2bgr', 'bgr2rgb', + 'rgb2bgr', 'bgr2hsv', 'hsv2bgr', 'bgr2hls', 'hls2bgr', 'iminvert', + 'imflip', 'imrotate', 'imcrop', 'impad', 'impad_to_multiple', + 'imnormalize', 'imdenormalize', 'imresize', 'imresize_like', 'imrescale' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/io.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/io.py new file mode 100644 index 000000000..c5b70c34d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/io.py @@ -0,0 +1,79 @@ +import os.path as osp + +import cv2 +import numpy as np + +from mmcv.opencv_info import USE_OPENCV2 +from mmcv.utils import check_file_exist, is_str, mkdir_or_exist + +if not USE_OPENCV2: + from cv2 import IMREAD_COLOR, IMREAD_GRAYSCALE, IMREAD_UNCHANGED +else: + from cv2 import CV_LOAD_IMAGE_COLOR as IMREAD_COLOR + from cv2 import CV_LOAD_IMAGE_GRAYSCALE as IMREAD_GRAYSCALE + from cv2 import CV_LOAD_IMAGE_UNCHANGED as IMREAD_UNCHANGED + +imread_flags = { + 'color': IMREAD_COLOR, + 'grayscale': IMREAD_GRAYSCALE, + 'unchanged': IMREAD_UNCHANGED +} + + +def imread(img_or_path, flag='color'): + """Read an image. + + Args: + img_or_path (ndarray or str): Either a numpy array or image path. + If it is a numpy array (loaded image), then it will be returned + as is. + flag (str): Flags specifying the color type of a loaded image, + candidates are `color`, `grayscale` and `unchanged`. + + Returns: + ndarray: Loaded image array. + """ + if isinstance(img_or_path, np.ndarray): + return img_or_path + elif is_str(img_or_path): + flag = imread_flags[flag] if is_str(flag) else flag + check_file_exist(img_or_path, + 'img file does not exist: {}'.format(img_or_path)) + return cv2.imread(img_or_path, flag) + else: + raise TypeError('"img" must be a numpy array or a filename') + + +def imfrombytes(content, flag='color'): + """Read an image from bytes. + + Args: + content (bytes): Image bytes got from files or other streams. + flag (str): Same as :func:`imread`. + + Returns: + ndarray: Loaded image array. + """ + img_np = np.frombuffer(content, np.uint8) + flag = imread_flags[flag] if is_str(flag) else flag + img = cv2.imdecode(img_np, flag) + return img + + +def imwrite(img, file_path, params=None, auto_mkdir=True): + """Write image to file + + Args: + img (ndarray): Image array to be written. + file_path (str): Image file path. + params (None or list): Same as opencv's :func:`imwrite` interface. + auto_mkdir (bool): If the parent folder of `file_path` does not exist, + whether to create it automatically. + + Returns: + bool: Successful or not. + """ + if auto_mkdir: + dir_name = osp.abspath(osp.dirname(file_path)) + mkdir_or_exist(dir_name) + return cv2.imwrite(file_path, img, params) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/__init__.py new file mode 100644 index 000000000..918e56a47 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/__init__.py @@ -0,0 +1,12 @@ +from .colorspace import (bgr2gray, gray2bgr, bgr2rgb, rgb2bgr, bgr2hsv, + hsv2bgr, bgr2hls, hls2bgr, iminvert) +from .geometry import imflip, imrotate, imcrop, impad, impad_to_multiple +from .normalize import imnormalize, imdenormalize +from .resize import imresize, imresize_like, imrescale + +__all__ = [ + 'bgr2gray', 'gray2bgr', 'bgr2rgb', 'rgb2bgr', 'bgr2hsv', 'hsv2bgr', + 'bgr2hls', 'hls2bgr', 'iminvert', 'imflip', 'imrotate', 'imcrop', 'impad', + 'impad_to_multiple', 'imnormalize', 'imdenormalize', 'imresize', + 'imresize_like', 'imrescale' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py new file mode 100644 index 000000000..975d14e51 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/colorspace.py @@ -0,0 +1,77 @@ +import cv2 +import numpy as np + + +def iminvert(img): + """Invert (negate) an image + Args: + img (ndarray): Image to be inverted. + + Returns: + ndarray: The inverted image. + """ + return np.full_like(img, 255) - img + + +def bgr2gray(img, keepdim=False): + """Convert a BGR image to grayscale image. + + Args: + img (ndarray): The input image. + keepdim (bool): If False (by default), then return the grayscale image + with 2 dims, otherwise 3 dims. + + Returns: + ndarray: The converted grayscale image. + """ + out_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + if keepdim: + out_img = out_img[..., None] + return out_img + + +def gray2bgr(img): + """Convert a grayscale image to BGR image. + + Args: + img (ndarray or str): The input image. + + Returns: + ndarray: The converted BGR image. + """ + img = img[..., None] if img.ndim == 2 else img + out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + return out_img + + +def convert_color_factory(src, dst): + + code = getattr(cv2, 'COLOR_{}2{}'.format(src.upper(), dst.upper())) + + def convert_color(img): + out_img = cv2.cvtColor(img, code) + return out_img + + convert_color.__doc__ = """Convert a {0} image to {1} image. + + Args: + img (ndarray or str): The input image. + + Returns: + ndarray: The converted {1} image. + """.format(src.upper(), dst.upper()) + + return convert_color + + +bgr2rgb = convert_color_factory('bgr', 'rgb') + +rgb2bgr = convert_color_factory('rgb', 'bgr') + +bgr2hsv = convert_color_factory('bgr', 'hsv') + +hsv2bgr = convert_color_factory('hsv', 'bgr') + +bgr2hls = convert_color_factory('bgr', 'hls') + +hls2bgr = convert_color_factory('hls', 'bgr') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py new file mode 100644 index 000000000..ad136d50b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py @@ -0,0 +1,203 @@ +from __future__ import division + +import cv2 +import numpy as np + + +def imflip(img, direction='horizontal'): + """Flip an image horizontally or vertically. + + Args: + img (ndarray): Image to be flipped. + direction (str): The flip direction, either "horizontal" or "vertical". + + Returns: + ndarray: The flipped image. + """ + assert direction in ['horizontal', 'vertical'] + if direction == 'horizontal': + return np.flip(img, axis=1) + else: + return np.flip(img, axis=0) + + +def imrotate(img, + angle, + center=None, + scale=1.0, + border_value=0, + auto_bound=False): + """Rotate an image. + + Args: + img (ndarray): Image to be rotated. + angle (float): Rotation angle in degrees, positive values mean + clockwise rotation. + center (tuple): Center of the rotation in the source image, by default + it is the center of the image. + scale (float): Isotropic scale factor. + border_value (int): Border value. + auto_bound (bool): Whether to adjust the image size to cover the whole + rotated image. + + Returns: + ndarray: The rotated image. + """ + if center is not None and auto_bound: + raise ValueError('`auto_bound` conflicts with `center`') + h, w = img.shape[:2] + if center is None: + center = ((w - 1) * 0.5, (h - 1) * 0.5) + assert isinstance(center, tuple) + + matrix = cv2.getRotationMatrix2D(center, -angle, scale) + if auto_bound: + cos = np.abs(matrix[0, 0]) + sin = np.abs(matrix[0, 1]) + new_w = h * sin + w * cos + new_h = h * cos + w * sin + matrix[0, 2] += (new_w - w) * 0.5 + matrix[1, 2] += (new_h - h) * 0.5 + w = int(np.round(new_w)) + h = int(np.round(new_h)) + rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value) + return rotated + + +def bbox_clip(bboxes, img_shape): + """Clip bboxes to fit the image shape. + + Args: + bboxes (ndarray): Shape (..., 4*k) + img_shape (tuple): (height, width) of the image. + + Returns: + ndarray: Clipped bboxes. + """ + assert bboxes.shape[-1] % 4 == 0 + clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype) + clipped_bboxes[..., 0::2] = np.maximum( + np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0) + clipped_bboxes[..., 1::2] = np.maximum( + np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0) + return clipped_bboxes + + +def bbox_scaling(bboxes, scale, clip_shape=None): + """Scaling bboxes w.r.t the box center. + + Args: + bboxes (ndarray): Shape(..., 4). + scale (float): Scaling factor. + clip_shape (tuple, optional): If specified, bboxes that exceed the + boundary will be clipped according to the given shape (h, w). + + Returns: + ndarray: Scaled bboxes. + """ + if float(scale) == 1.0: + scaled_bboxes = bboxes.copy() + else: + w = bboxes[..., 2] - bboxes[..., 0] + 1 + h = bboxes[..., 3] - bboxes[..., 1] + 1 + dw = (w * (scale - 1)) * 0.5 + dh = (h * (scale - 1)) * 0.5 + scaled_bboxes = bboxes + np.stack((-dw, -dh, dw, dh), axis=-1) + if clip_shape is not None: + return bbox_clip(scaled_bboxes, clip_shape) + else: + return scaled_bboxes + + +def imcrop(img, bboxes, scale=1.0, pad_fill=None): + """Crop image patches. + + 3 steps: scale the bboxes -> clip bboxes -> crop and pad. + + Args: + img (ndarray): Image to be cropped. + bboxes (ndarray): Shape (k, 4) or (4, ), location of cropped bboxes. + scale (float, optional): Scale ratio of bboxes, the default value + 1.0 means no padding. + pad_fill (number or list): Value to be filled for padding, None for + no padding. + + Returns: + list or ndarray: The cropped image patches. + """ + chn = 1 if img.ndim == 2 else img.shape[2] + if pad_fill is not None: + if isinstance(pad_fill, (int, float)): + pad_fill = [pad_fill for _ in range(chn)] + assert len(pad_fill) == chn + + _bboxes = bboxes[None, ...] if bboxes.ndim == 1 else bboxes + scaled_bboxes = bbox_scaling(_bboxes, scale).astype(np.int32) + clipped_bbox = bbox_clip(scaled_bboxes, img.shape) + + patches = [] + for i in range(clipped_bbox.shape[0]): + x1, y1, x2, y2 = tuple(clipped_bbox[i, :]) + if pad_fill is None: + patch = img[y1:y2 + 1, x1:x2 + 1, ...] + else: + _x1, _y1, _x2, _y2 = tuple(scaled_bboxes[i, :]) + if chn == 1: + patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1) + else: + patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1, chn) + patch = np.array( + pad_fill, dtype=img.dtype) * np.ones( + patch_shape, dtype=img.dtype) + x_start = 0 if _x1 >= 0 else -_x1 + y_start = 0 if _y1 >= 0 else -_y1 + w = x2 - x1 + 1 + h = y2 - y1 + 1 + patch[y_start:y_start + h, x_start:x_start + + w, ...] = img[y1:y1 + h, x1:x1 + w, ...] + patches.append(patch) + + if bboxes.ndim == 1: + return patches[0] + else: + return patches + + +def impad(img, shape, pad_val=0): + """Pad an image to a certain shape. + + Args: + img (ndarray): Image to be padded. + shape (tuple): Expected padding shape. + pad_val (number or sequence): Values to be filled in padding areas. + + Returns: + ndarray: The padded image. + """ + if not isinstance(pad_val, (int, float)): + assert len(pad_val) == img.shape[-1] + if len(shape) < len(img.shape): + shape = shape + (img.shape[-1], ) + assert len(shape) == len(img.shape) + for i in range(len(shape) - 1): + assert shape[i] >= img.shape[i] + pad = np.empty(shape, dtype=img.dtype) + pad[...] = pad_val + pad[:img.shape[0], :img.shape[1], ...] = img + return pad + + +def impad_to_multiple(img, divisor, pad_val=0): + """Pad an image to ensure each edge to be multiple to some number. + + Args: + img (ndarray): Image to be padded. + divisor (int): Padded image edges will be multiple to divisor. + pad_val (number or sequence): Same as :func:`impad`. + + Returns: + ndarray: The padded image. + """ + pad_h = int(np.ceil(img.shape[0] / divisor)) * divisor + pad_w = int(np.ceil(img.shape[1] / divisor)) * divisor + return impad(img, (pad_h, pad_w), pad_val) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/normalize.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/normalize.py new file mode 100644 index 000000000..6e450a144 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/normalize.py @@ -0,0 +1,17 @@ +import numpy as np + +from .colorspace import bgr2rgb, rgb2bgr + + +def imnormalize(img, mean, std, to_rgb=True): + img = img.astype(np.float32) + if to_rgb: + img = bgr2rgb(img) + return (img - mean) / std + + +def imdenormalize(img, mean, std, to_bgr=True): + img = (img * std) + mean + if to_bgr: + img = rgb2bgr(img) + return img diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/resize.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/resize.py new file mode 100644 index 000000000..9c4a0646d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/resize.py @@ -0,0 +1,107 @@ +from __future__ import division + +import cv2 + + +def _scale_size(size, scale): + """Rescale a size by a ratio. + + Args: + size (tuple): w, h. + scale (float): Scaling factor. + + Returns: + tuple[int]: scaled size. + """ + w, h = size + return int(w * float(scale) + 0.5), int(h * float(scale) + 0.5) + + +interp_codes = { + 'nearest': cv2.INTER_NEAREST, + 'bilinear': cv2.INTER_LINEAR, + 'bicubic': cv2.INTER_CUBIC, + 'area': cv2.INTER_AREA, + 'lanczos': cv2.INTER_LANCZOS4 +} + + +def imresize(img, size, return_scale=False, interpolation='bilinear'): + """Resize image to a given size. + + Args: + img (ndarray): The input image. + size (tuple): Target (w, h). + return_scale (bool): Whether to return `w_scale` and `h_scale`. + interpolation (str): Interpolation method, accepted values are + "nearest", "bilinear", "bicubic", "area", "lanczos". + + Returns: + tuple or ndarray: (`resized_img`, `w_scale`, `h_scale`) or + `resized_img`. + """ + h, w = img.shape[:2] + resized_img = cv2.resize( + img, size, interpolation=interp_codes[interpolation]) + if not return_scale: + return resized_img + else: + w_scale = size[0] / w + h_scale = size[1] / h + return resized_img, w_scale, h_scale + + +def imresize_like(img, dst_img, return_scale=False, interpolation='bilinear'): + """Resize image to the same size of a given image. + + Args: + img (ndarray): The input image. + dst_img (ndarray): The target image. + return_scale (bool): Whether to return `w_scale` and `h_scale`. + interpolation (str): Same as :func:`resize`. + + Returns: + tuple or ndarray: (`resized_img`, `w_scale`, `h_scale`) or + `resized_img`. + """ + h, w = dst_img.shape[:2] + return imresize(img, (w, h), return_scale, interpolation) + + +def imrescale(img, scale, return_scale=False, interpolation='bilinear'): + """Resize image while keeping the aspect ratio. + + Args: + img (ndarray): The input image. + scale (float or tuple[int]): The scaling factor or maximum size. + If it is a float number, then the image will be rescaled by this + factor, else if it is a tuple of 2 integers, then the image will + be rescaled as large as possible within the scale. + return_scale (bool): Whether to return the scaling factor besides the + rescaled image. + interpolation (str): Same as :func:`resize`. + + Returns: + ndarray: The rescaled image. + """ + h, w = img.shape[:2] + if isinstance(scale, (float, int)): + if scale <= 0: + raise ValueError( + 'Invalid scale {}, must be positive.'.format(scale)) + scale_factor = scale + elif isinstance(scale, tuple): + max_long_edge = max(scale) + max_short_edge = min(scale) + scale_factor = min(max_long_edge / max(h, w), + max_short_edge / min(h, w)) + else: + raise TypeError( + 'Scale must be a number or tuple of int, but got {}'.format( + type(scale))) + new_size = _scale_size((w, h), scale_factor) + rescaled_img = imresize(img, new_size, interpolation=interpolation) + if return_scale: + return rescaled_img, scale_factor + else: + return rescaled_img diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/opencv_info.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/opencv_info.py new file mode 100644 index 000000000..521ee0f3a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/opencv_info.py @@ -0,0 +1,12 @@ +import cv2 + + +def use_opencv2(): + try: + major_version = cv2.__version__.split('.')[0] + except TypeError: # solves doc generation issue + major_version = 4 + return major_version == '2' + + +USE_OPENCV2 = use_opencv2() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py new file mode 100644 index 000000000..cb20d1a6a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/__init__.py @@ -0,0 +1,10 @@ +from .collate import collate +from .data_container import DataContainer +from .data_parallel import MMDataParallel +from .distributed import MMDistributedDataParallel +from .scatter_gather import scatter, scatter_kwargs + +__all__ = [ + 'collate', 'DataContainer', 'MMDataParallel', 'MMDistributedDataParallel', + 'scatter', 'scatter_kwargs' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/_functions.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/_functions.py new file mode 100644 index 000000000..75bb954dc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/_functions.py @@ -0,0 +1,74 @@ +import torch +from torch.nn.parallel._functions import _get_stream + + +def scatter(input, devices, streams=None): + """Scatters tensor across multiple GPUs. + """ + if streams is None: + streams = [None] * len(devices) + + if isinstance(input, list): + chunk_size = (len(input) - 1) // len(devices) + 1 + outputs = [ + scatter(input[i], [devices[i // chunk_size]], + [streams[i // chunk_size]]) for i in range(len(input)) + ] + return outputs + elif isinstance(input, torch.Tensor): + output = input.contiguous() + # TODO: copy to a pinned buffer first (if copying from CPU) + stream = streams[0] if output.numel() > 0 else None + with torch.cuda.device(devices[0]), torch.cuda.stream(stream): + output = output.cuda(devices[0], non_blocking=True) + return output + else: + raise Exception('Unknown type {}.'.format(type(input))) + + +def synchronize_stream(output, devices, streams): + if isinstance(output, list): + chunk_size = len(output) // len(devices) + for i in range(len(devices)): + for j in range(chunk_size): + synchronize_stream(output[i * chunk_size + j], [devices[i]], + [streams[i]]) + elif isinstance(output, torch.Tensor): + if output.numel() != 0: + with torch.cuda.device(devices[0]): + main_stream = torch.cuda.current_stream() + main_stream.wait_stream(streams[0]) + output.record_stream(main_stream) + else: + raise Exception('Unknown type {}.'.format(type(output))) + + +def get_input_device(input): + if isinstance(input, list): + for item in input: + input_device = get_input_device(item) + if input_device != -1: + return input_device + return -1 + elif isinstance(input, torch.Tensor): + return input.get_device() if input.is_cuda else -1 + else: + raise Exception('Unknown type {}.'.format(type(input))) + + +class Scatter(object): + + @staticmethod + def forward(target_gpus, input): + input_device = get_input_device(input) + streams = None + if input_device == -1: + # Perform CPU to GPU copies in a background stream + streams = [_get_stream(device) for device in target_gpus] + + outputs = scatter(input, target_gpus, streams) + # Synchronize with the copy stream + if streams is not None: + synchronize_stream(outputs, target_gpus, streams) + + return tuple(outputs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/collate.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/collate.py new file mode 100644 index 000000000..6e625ed79 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/collate.py @@ -0,0 +1,84 @@ +import collections + +import torch +import torch.nn.functional as F +from torch.utils.data.dataloader import default_collate + +from .data_container import DataContainer + + +def collate(batch, samples_per_gpu=1): + """Puts each data field into a tensor/DataContainer with outer dimension + batch size. + + Extend default_collate to add support for + :type:`~mmcv.parallel.DataContainer`. There are 3 cases. + + 1. cpu_only = True, e.g., meta data + 2. cpu_only = False, stack = True, e.g., images tensors + 3. cpu_only = False, stack = False, e.g., gt bboxes + """ + + if not isinstance(batch, collections.Sequence): + raise TypeError("{} is not supported.".format(batch.dtype)) + + if isinstance(batch[0], DataContainer): + assert len(batch) % samples_per_gpu == 0 + stacked = [] + if batch[0].cpu_only: + for i in range(0, len(batch), samples_per_gpu): + stacked.append( + [sample.data for sample in batch[i:i + samples_per_gpu]]) + return DataContainer( + stacked, batch[0].stack, batch[0].padding_value, cpu_only=True) + elif batch[0].stack: + for i in range(0, len(batch), samples_per_gpu): + assert isinstance(batch[i].data, torch.Tensor) + + if batch[i].pad_dims is not None: + ndim = batch[i].dim() + assert ndim > batch[i].pad_dims + max_shape = [0 for _ in range(batch[i].pad_dims)] + for dim in range(1, batch[i].pad_dims + 1): + max_shape[dim - 1] = batch[i].size(-dim) + for sample in batch[i:i + samples_per_gpu]: + for dim in range(0, ndim - batch[i].pad_dims): + assert batch[i].size(dim) == sample.size(dim) + for dim in range(1, batch[i].pad_dims + 1): + max_shape[dim - 1] = max(max_shape[dim - 1], + sample.size(-dim)) + padded_samples = [] + for sample in batch[i:i + samples_per_gpu]: + pad = [0 for _ in range(batch[i].pad_dims * 2)] + for dim in range(1, batch[i].pad_dims + 1): + pad[2 * dim - + 1] = max_shape[dim - 1] - sample.size(-dim) + padded_samples.append( + F.pad( + sample.data, pad, value=sample.padding_value)) + stacked.append(default_collate(padded_samples)) + elif batch[i].pad_dims is None: + stacked.append( + default_collate([ + sample.data + for sample in batch[i:i + samples_per_gpu] + ])) + else: + raise ValueError( + 'pad_dims should be either None or integers (1-3)') + + else: + for i in range(0, len(batch), samples_per_gpu): + stacked.append( + [sample.data for sample in batch[i:i + samples_per_gpu]]) + return DataContainer(stacked, batch[0].stack, batch[0].padding_value) + elif isinstance(batch[0], collections.Sequence): + transposed = zip(*batch) + return [collate(samples, samples_per_gpu) for samples in transposed] + elif isinstance(batch[0], collections.Mapping): + return { + key: collate([d[key] for d in batch], samples_per_gpu) + for key in batch[0] + } + else: + return default_collate(batch) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_container.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_container.py new file mode 100644 index 000000000..9beac6610 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_container.py @@ -0,0 +1,84 @@ +import functools + +import torch + + +def assert_tensor_type(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + if not isinstance(args[0].data, torch.Tensor): + raise AttributeError('{} has no attribute {} for type {}'.format( + args[0].__class__.__name__, func.__name__, args[0].datatype)) + return func(*args, **kwargs) + + return wrapper + + +class DataContainer(object): + """A container for any type of objects. + + Typically tensors will be stacked in the collate function and sliced along + some dimension in the scatter function. This behavior has some limitations. + 1. All tensors have to be the same size. + 2. Types are limited (numpy array or Tensor). + + We design `DataContainer` and `MMDataParallel` to overcome these + limitations. The behavior can be either of the following. + + - copy to GPU, pad all tensors to the same size and stack them + - copy to GPU without stacking + - leave the objects as is and pass it to the model + - pad_dims specifies the number of last few dimensions to do padding + """ + + def __init__(self, + data, + stack=False, + padding_value=0, + cpu_only=False, + pad_dims=2): + self._data = data + self._cpu_only = cpu_only + self._stack = stack + self._padding_value = padding_value + assert pad_dims in [None, 1, 2, 3] + self._pad_dims = pad_dims + + def __repr__(self): + return '{}({})'.format(self.__class__.__name__, repr(self.data)) + + @property + def data(self): + return self._data + + @property + def datatype(self): + if isinstance(self.data, torch.Tensor): + return self.data.type() + else: + return type(self.data) + + @property + def cpu_only(self): + return self._cpu_only + + @property + def stack(self): + return self._stack + + @property + def padding_value(self): + return self._padding_value + + @property + def pad_dims(self): + return self._pad_dims + + @assert_tensor_type + def size(self, *args, **kwargs): + return self.data.size(*args, **kwargs) + + @assert_tensor_type + def dim(self): + return self.data.dim() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_parallel.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_parallel.py new file mode 100644 index 000000000..6735cb4af --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/data_parallel.py @@ -0,0 +1,9 @@ +from torch.nn.parallel import DataParallel + +from .scatter_gather import scatter_kwargs + + +class MMDataParallel(DataParallel): + + def scatter(self, inputs, kwargs, device_ids): + return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/distributed.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/distributed.py new file mode 100644 index 000000000..1930b6772 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/distributed.py @@ -0,0 +1,50 @@ +import torch +import torch.distributed as dist +import torch.nn as nn +from torch._utils import (_flatten_dense_tensors, _take_tensors, + _unflatten_dense_tensors) + +from .scatter_gather import scatter_kwargs + + +class MMDistributedDataParallel(nn.Module): + + def __init__(self, module, dim=0, broadcast_buffers=True, + bucket_cap_mb=25): + super(MMDistributedDataParallel, self).__init__() + self.module = module + self.dim = dim + self.broadcast_buffers = broadcast_buffers + + self.broadcast_bucket_size = bucket_cap_mb * 1024 * 1024 + self._sync_params() + + def _dist_broadcast_coalesced(self, tensors, buffer_size): + for tensors in _take_tensors(tensors, buffer_size): + flat_tensors = _flatten_dense_tensors(tensors) + dist.broadcast(flat_tensors, 0) + for tensor, synced in zip( + tensors, _unflatten_dense_tensors(flat_tensors, tensors)): + tensor.copy_(synced) + + def _sync_params(self): + module_states = list(self.module.state_dict().values()) + if len(module_states) > 0: + self._dist_broadcast_coalesced(module_states, + self.broadcast_bucket_size) + if self.broadcast_buffers: + if torch.__version__ < '1.0': + buffers = [b.data for b in self.module._all_buffers()] + else: + buffers = [b.data for b in self.module.buffers()] + if len(buffers) > 0: + self._dist_broadcast_coalesced(buffers, + self.broadcast_bucket_size) + + def scatter(self, inputs, kwargs, device_ids): + return scatter_kwargs(inputs, kwargs, device_ids, dim=self.dim) + + def forward(self, *inputs, **kwargs): + inputs, kwargs = self.scatter(inputs, kwargs, + [torch.cuda.current_device()]) + return self.module(*inputs[0], **kwargs[0]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/scatter_gather.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/scatter_gather.py new file mode 100644 index 000000000..1ea64d3d4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/parallel/scatter_gather.py @@ -0,0 +1,54 @@ +import torch +from torch.nn.parallel._functions import Scatter as OrigScatter + +from ._functions import Scatter +from .data_container import DataContainer + + +def scatter(inputs, target_gpus, dim=0): + """Scatter inputs to target gpus. + + The only difference from original :func:`scatter` is to add support for + :type:`~mmcv.parallel.DataContainer`. + """ + + def scatter_map(obj): + if isinstance(obj, torch.Tensor): + return OrigScatter.apply(target_gpus, None, dim, obj) + if isinstance(obj, DataContainer): + if obj.cpu_only: + return obj.data + else: + return Scatter.forward(target_gpus, obj.data) + if isinstance(obj, tuple) and len(obj) > 0: + return list(zip(*map(scatter_map, obj))) + if isinstance(obj, list) and len(obj) > 0: + out = list(map(list, zip(*map(scatter_map, obj)))) + return out + if isinstance(obj, dict) and len(obj) > 0: + out = list(map(type(obj), zip(*map(scatter_map, obj.items())))) + return out + return [obj for targets in target_gpus] + + # After scatter_map is called, a scatter_map cell will exist. This cell + # has a reference to the actual function scatter_map, which has references + # to a closure that has a reference to the scatter_map cell (because the + # fn is recursive). To avoid this reference cycle, we set the function to + # None, clearing the cell + try: + return scatter_map(inputs) + finally: + scatter_map = None + + +def scatter_kwargs(inputs, kwargs, target_gpus, dim=0): + """Scatter with support for kwargs dictionary""" + inputs = scatter(inputs, target_gpus, dim) if inputs else [] + kwargs = scatter(kwargs, target_gpus, dim) if kwargs else [] + if len(inputs) < len(kwargs): + inputs.extend([() for _ in range(len(kwargs) - len(inputs))]) + elif len(kwargs) < len(inputs): + kwargs.extend([{} for _ in range(len(inputs) - len(kwargs))]) + inputs = tuple(inputs) + kwargs = tuple(kwargs) + return inputs, kwargs diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py new file mode 100644 index 000000000..af255cc10 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/__init__.py @@ -0,0 +1,23 @@ +from .runner import Runner +from .log_buffer import LogBuffer +from .dist_utils import get_dist_info, init_dist, master_only +from .hooks import (Hook, CheckpointHook, ClosureHook, LrUpdaterHook, + OptimizerHook, OptimizerArchHook, IterTimerHook, DistSamplerSeedHook, + LoggerHook, TextLoggerHook, PaviLoggerHook, + TensorboardLoggerHook) +from .checkpoint import (load_state_dict, load_checkpoint, weights_to_cpu, + save_checkpoint) +from .parallel_test import parallel_test +from .priority import Priority, get_priority +from .utils import (get_host_info, get_dist_info, master_only, get_time_str, + obj_from_dict) + +__all__ = [ + 'Runner', 'LogBuffer', 'Hook', 'CheckpointHook', 'ClosureHook', + 'LrUpdaterHook', 'OptimizerHook', 'OptimizerArchHook', 'IterTimerHook', 'DistSamplerSeedHook', + 'LoggerHook', 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook', + 'load_state_dict', 'load_checkpoint', 'weights_to_cpu', 'save_checkpoint', + 'parallel_test', 'Priority', 'get_priority', 'get_host_info', + 'get_dist_info', 'master_only', 'get_time_str', 'obj_from_dict', + 'init_dist', 'get_dist_info', 'master_only' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/checkpoint.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/checkpoint.py new file mode 100644 index 000000000..0b58cf982 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/checkpoint.py @@ -0,0 +1,217 @@ +import os +import os.path as osp +import pkgutil +import time +import warnings +from collections import OrderedDict +from importlib import import_module + +import torch +import torchvision +from terminaltables import AsciiTable +from torch.utils import model_zoo + +import mmcv +from .utils import get_dist_info + +open_mmlab_model_urls = { +} # yapf: disable + + +def load_state_dict(module, state_dict, strict=False, logger=None): + """Load state_dict to a module. + + This method is modified from :meth:`torch.nn.Module.load_state_dict`. + Default value for ``strict`` is set to ``False`` and the message for + param mismatch will be shown even if strict is False. + + Args: + module (Module): Module that receives the state_dict. + state_dict (OrderedDict): Weights. + strict (bool): whether to strictly enforce that the keys + in :attr:`state_dict` match the keys returned by this module's + :meth:`~torch.nn.Module.state_dict` function. Default: ``False``. + logger (:obj:`logging.Logger`, optional): Logger to log the error + message. If not specified, print function will be used. + """ + unexpected_keys = [] + shape_mismatch_pairs = [] + + own_state = module.state_dict() + for name, param in state_dict.items(): + if name not in own_state: + unexpected_keys.append(name) + continue + if isinstance(param, torch.nn.Parameter): + # backwards compatibility for serialized parameters + param = param.data + if param.size() != own_state[name].size(): + shape_mismatch_pairs.append( + [name, own_state[name].size(), + param.size()]) + continue + own_state[name].copy_(param) + + all_missing_keys = set(own_state.keys()) - set(state_dict.keys()) + # ignore "num_batches_tracked" of BN layers + missing_keys = [ + key for key in all_missing_keys if 'num_batches_tracked' not in key + ] + + err_msg = [] + if unexpected_keys: + err_msg.append('unexpected key in source state_dict: {}\n'.format( + ', '.join(unexpected_keys))) + if missing_keys: + err_msg.append('missing keys in source state_dict: {}\n'.format( + ', '.join(missing_keys))) + if shape_mismatch_pairs: + mismatch_info = 'these keys have mismatched shape:\n' + header = ['key', 'expected shape', 'loaded shape'] + table_data = [header] + shape_mismatch_pairs + table = AsciiTable(table_data) + err_msg.append(mismatch_info + table.table) + + rank, _ = get_dist_info() + if len(err_msg) > 0 and rank == 0: + err_msg.insert( + 0, 'The model and loaded state dict do not match exactly\n') + err_msg = '\n'.join(err_msg) + if strict: + raise RuntimeError(err_msg) + elif logger is not None: + logger.warning(err_msg) + else: + print(err_msg) + + +def load_url_dist(url): + """ In distributed setting, this function only download checkpoint at + local rank 0 """ + rank, world_size = get_dist_info() + rank = int(os.environ.get('LOCAL_RANK', rank)) + if rank == 0: + checkpoint = model_zoo.load_url(url) + if world_size > 1: + torch.distributed.barrier() + if rank > 0: + checkpoint = model_zoo.load_url(url) + return checkpoint + + +def get_torchvision_models(): + model_urls = dict() + for _, name, ispkg in pkgutil.walk_packages(torchvision.models.__path__): + if ispkg: + continue + _zoo = import_module('torchvision.models.{}'.format(name)) + if hasattr(_zoo, 'model_urls'): + _urls = getattr(_zoo, 'model_urls') + model_urls.update(_urls) + return model_urls + + +def load_checkpoint(model, + filename, + map_location=None, + strict=False, + logger=None): + """Load checkpoint from a file or URI. + + Args: + model (Module): Module to load checkpoint. + filename (str): Either a filepath or URL or modelzoo://xxxxxxx. + map_location (str): Same as :func:`torch.load`. + strict (bool): Whether to allow different params for the model and + checkpoint. + logger (:mod:`logging.Logger` or None): The logger for error message. + + Returns: + dict or OrderedDict: The loaded checkpoint. + """ + # load checkpoint from modelzoo or file or url + if filename.startswith('modelzoo://'): + warnings.warn('The URL scheme of "modelzoo://" is deprecated, please ' + 'use "torchvision://" instead') + model_urls = get_torchvision_models() + model_name = filename[11:] + checkpoint = load_url_dist(model_urls[model_name]) + elif filename.startswith('torchvision://'): + model_urls = get_torchvision_models() + model_name = filename[14:] + checkpoint = load_url_dist(model_urls[model_name]) + elif filename.startswith('open-mmlab://'): + model_name = filename[13:] + checkpoint = load_url_dist(open_mmlab_model_urls[model_name]) + elif filename.startswith(('http://', 'https://')): + checkpoint = load_url_dist(filename) + else: + if not osp.isfile(filename): + raise IOError('{} is not a checkpoint file'.format(filename)) + checkpoint = torch.load(filename, map_location=map_location) + # get state_dict from checkpoint + if isinstance(checkpoint, OrderedDict): + state_dict = checkpoint + elif isinstance(checkpoint, dict) and 'state_dict' in checkpoint: + state_dict = checkpoint['state_dict'] + else: + raise RuntimeError( + 'No state_dict found in checkpoint file {}'.format(filename)) + # strip prefix of state_dict + """2019/11/15 for resume one-stage module""" + if list(state_dict.keys())[0].startswith('module.'): + state_dict = {k[7:]: v for k, v in checkpoint['state_dict'].items()} + # load state_dict + if hasattr(model, 'module'): + load_state_dict(model.module, state_dict, strict, logger) + else: + load_state_dict(model, state_dict, strict, logger) + return checkpoint + + +def weights_to_cpu(state_dict): + """Copy a model state_dict to cpu. + + Args: + state_dict (OrderedDict): Model weights on GPU. + + Returns: + OrderedDict: Model weights on GPU. + """ + state_dict_cpu = OrderedDict() + for key, val in state_dict.items(): + state_dict_cpu[key] = val.cpu() + return state_dict_cpu + + +def save_checkpoint(model, filename, optimizer=None, meta=None): + """Save checkpoint to file. + + The checkpoint will have 3 fields: ``meta``, ``state_dict`` and + ``optimizer``. By default ``meta`` will contain version and time info. + + Args: + model (Module): Module whose params are to be saved. + filename (str): Checkpoint filename. + optimizer (:obj:`Optimizer`, optional): Optimizer to be saved. + meta (dict, optional): Metadata to be saved in checkpoint. + """ + if meta is None: + meta = {} + elif not isinstance(meta, dict): + raise TypeError('meta must be a dict or None, but got {}'.format( + type(meta))) + meta.update(mmcv_version=mmcv.__version__, time=time.asctime()) + + mmcv.mkdir_or_exist(osp.dirname(filename)) + if hasattr(model, 'module'): + model = model.module + + checkpoint = { + 'meta': meta, + 'state_dict': weights_to_cpu(model.state_dict()) + } + if optimizer is not None: + checkpoint['optimizer'] = optimizer.state_dict() + + torch.save(checkpoint, filename) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/dist_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/dist_utils.py new file mode 100644 index 000000000..7c92b8f37 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/dist_utils.py @@ -0,0 +1,76 @@ +# Copyright (c) Open-MMLab. All rights reserved. +import functools +import os +import subprocess + +import torch +import torch.distributed as dist +import torch.multiprocessing as mp + + +def init_dist(launcher, backend='nccl', **kwargs): + if mp.get_start_method(allow_none=True) is None: + mp.set_start_method('spawn') + if launcher == 'pytorch': + _init_dist_pytorch(backend, **kwargs) + elif launcher == 'mpi': + _init_dist_mpi(backend, **kwargs) + elif launcher == 'slurm': + _init_dist_slurm(backend, **kwargs) + else: + raise ValueError('Invalid launcher type: {}'.format(launcher)) + + +def _init_dist_pytorch(backend, **kwargs): + # TODO: use local_rank instead of rank % num_gpus + rank = int(os.environ['RANK']) + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(rank % num_gpus) + dist.init_process_group(backend=backend, **kwargs) + + +def _init_dist_mpi(backend, **kwargs): + raise NotImplementedError + + +def _init_dist_slurm(backend, port=29500, **kwargs): + proc_id = int(os.environ['SLURM_PROCID']) + ntasks = int(os.environ['SLURM_NTASKS']) + node_list = os.environ['SLURM_NODELIST'] + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(proc_id % num_gpus) + addr = subprocess.getoutput( + 'scontrol show hostname {} | head -n1'.format(node_list)) + os.environ['MASTER_PORT'] = str(port) + os.environ['MASTER_ADDR'] = addr + os.environ['WORLD_SIZE'] = str(ntasks) + os.environ['RANK'] = str(proc_id) + dist.init_process_group(backend=backend) + + +def get_dist_info(): + if torch.__version__ < '1.0': + initialized = dist._initialized + else: + if dist.is_available(): + initialized = dist.is_initialized() + else: + initialized = False + if initialized: + rank = dist.get_rank() + world_size = dist.get_world_size() + else: + rank = 0 + world_size = 1 + return rank, world_size + + +def master_only(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + rank, _ = get_dist_info() + if rank == 0: + return func(*args, **kwargs) + + return wrapper \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/__init__.py new file mode 100644 index 000000000..991c4341d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/__init__.py @@ -0,0 +1,16 @@ +from .hook import Hook +from .checkpoint import CheckpointHook +from .closure import ClosureHook +from .lr_updater import LrUpdaterHook +from .optimizer import OptimizerHook, OptimizerArchHook +from .iter_timer import IterTimerHook +from .sampler_seed import DistSamplerSeedHook +from .memory import EmptyCacheHook +from .logger import (LoggerHook, TextLoggerHook, PaviLoggerHook, + TensorboardLoggerHook) + +__all__ = [ + 'Hook', 'CheckpointHook', 'ClosureHook', 'LrUpdaterHook', 'OptimizerHook', 'OptimizerArchHook', + 'IterTimerHook', 'DistSamplerSeedHook', 'EmptyCacheHook', 'LoggerHook', + 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py new file mode 100644 index 000000000..c27fc00c0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/checkpoint.py @@ -0,0 +1,25 @@ +from ..utils import master_only +from .hook import Hook + + +class CheckpointHook(Hook): + + def __init__(self, + interval=-1, + save_optimizer=True, + out_dir=None, + **kwargs): + self.interval = interval + self.save_optimizer = save_optimizer + self.out_dir = out_dir + self.args = kwargs + + @master_only + def after_train_epoch(self, runner): + if not self.every_n_epochs(runner, self.interval): + return + + if not self.out_dir: + self.out_dir = runner.work_dir + runner.save_checkpoint( + self.out_dir, save_optimizer=self.save_optimizer, **self.args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py new file mode 100644 index 000000000..8087d985b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py @@ -0,0 +1,9 @@ +from .hook import Hook + + +class ClosureHook(Hook): + + def __init__(self, fn_name, fn): + assert hasattr(self, fn_name) + assert callable(fn) + setattr(self, fn_name, fn) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/hook.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/hook.py new file mode 100644 index 000000000..c7c1797d0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/hook.py @@ -0,0 +1,58 @@ +class Hook(object): + + def before_run(self, runner): + pass + + def after_run(self, runner): + pass + + def before_epoch(self, runner): + pass + + def after_epoch(self, runner): + pass + + def before_iter(self, runner): + pass + + def after_iter(self, runner): + pass + + def before_train_epoch(self, runner): + self.before_epoch(runner) + + def before_val_epoch(self, runner): + self.before_epoch(runner) + + def after_train_epoch(self, runner): + self.after_epoch(runner) + + def after_val_epoch(self, runner): + self.after_epoch(runner) + + def before_train_iter(self, runner): + self.before_iter(runner) + + def before_val_iter(self, runner): + self.before_iter(runner) + + def after_train_iter(self, runner): + self.after_iter(runner) + + def arch_after_train_iter(self, runner): + self.after_iter(runner) + + def after_val_iter(self, runner): + self.after_iter(runner) + + def every_n_epochs(self, runner, n): + return (runner.epoch + 1) % n == 0 if n > 0 else False + + def every_n_inner_iters(self, runner, n): + return (runner.inner_iter + 1) % n == 0 if n > 0 else False + + def every_n_iters(self, runner, n): + return (runner.iter + 1) % n == 0 if n > 0 else False + + def end_of_epoch(self, runner): + return runner.inner_iter + 1 == len(runner.data_loader) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/iter_timer.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/iter_timer.py new file mode 100644 index 000000000..13b2876ff --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/iter_timer.py @@ -0,0 +1,16 @@ +import time + +from .hook import Hook + + +class IterTimerHook(Hook): + + def before_epoch(self, runner): + self.t = time.time() + + def before_iter(self, runner): + runner.log_buffer.update({'data_time': time.time() - self.t}) + + def after_iter(self, runner): + runner.log_buffer.update({'time': time.time() - self.t}) + self.t = time.time() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/__init__.py new file mode 100644 index 000000000..8cbaf12b1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/__init__.py @@ -0,0 +1,8 @@ +from .base import LoggerHook +from .pavi import PaviLoggerHook +from .tensorboard import TensorboardLoggerHook +from .text import TextLoggerHook + +__all__ = [ + 'LoggerHook', 'TextLoggerHook', 'PaviLoggerHook', 'TensorboardLoggerHook' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py new file mode 100644 index 000000000..71eca4ac0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/base.py @@ -0,0 +1,70 @@ +from abc import ABCMeta, abstractmethod + +from ..hook import Hook + + +class LoggerHook(Hook): + """Base class for logger hooks. + + Args: + interval (int): Logging interval (every k iterations). + ignore_last (bool): Ignore the log of last iterations in each epoch + if less than `interval`. + reset_flag (bool): Whether to clear the output buffer after logging. + """ + + __metaclass__ = ABCMeta + + def __init__(self, interval=10, ignore_last=True, reset_flag=False): + self.interval = interval + self.ignore_last = ignore_last + self.reset_flag = reset_flag + + @abstractmethod + def log(self, runner): + pass + + def before_run(self, runner): + for hook in runner.hooks[::-1]: + if isinstance(hook, LoggerHook): + hook.reset_flag = True + break + + def before_epoch(self, runner): + runner.log_buffer.clear() # clear logs of last epoch + + def after_train_iter(self, runner): + if self.every_n_inner_iters(runner, self.interval): + runner.log_buffer.average(self.interval) + elif self.end_of_epoch(runner) and not self.ignore_last: + # not precise but more stable + runner.log_buffer.average(self.interval) + + if runner.log_buffer.ready: + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() + + def arch_after_train_iter(self, runner): + if self.every_n_inner_iters(runner, self.interval): + runner.log_buffer.average(self.interval) + elif self.end_of_epoch(runner) and not self.ignore_last: + # not precise but more stable + runner.log_buffer.average(self.interval) + + if runner.log_buffer.ready: + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() + + def after_train_epoch(self, runner): + if runner.log_buffer.ready: + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() + + def after_val_epoch(self, runner): + runner.log_buffer.average() + self.log(runner) + if self.reset_flag: + runner.log_buffer.clear_output() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/pavi.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/pavi.py new file mode 100644 index 000000000..670b10326 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/pavi.py @@ -0,0 +1,176 @@ +from __future__ import print_function +import logging +import os +import os.path as osp +import time +from datetime import datetime +from threading import Thread + +import requests +from six.moves.queue import Empty, Queue + +from ...utils import get_host_info, master_only +from .base import LoggerHook + + +class PaviClient(object): + + def __init__(self, url, username=None, password=None, instance_id=None): + self.url = url + self.username = self._get_env_var(username, 'PAVI_USERNAME') + self.password = self._get_env_var(password, 'PAVI_PASSWORD') + self.instance_id = instance_id + self.log_queue = None + self.logger = None + + def _get_env_var(self, var, env_var): + if var is not None: + return str(var) + + var = os.getenv(env_var) + if not var: + raise ValueError( + '"{}" is neither specified nor defined as env variables'. + format(env_var)) + return var + + def _print_log(self, msg, level=logging.INFO, *args, **kwargs): + if self.logger is not None: + self.logger.log(level, msg, *args, **kwargs) + else: + print(msg, *args, **kwargs) + + def connect(self, + model_name, + work_dir=None, + info=dict(), + timeout=5, + logger=None): + if logger is not None: + self.logger = logger + self._print_log('connecting pavi service {}...'.format(self.url)) + post_data = dict( + time=str(datetime.now()), + username=self.username, + password=self.password, + instance_id=self.instance_id, + model=model_name, + work_dir=osp.abspath(work_dir) if work_dir else '', + session_file=info.get('session_file', ''), + session_text=info.get('session_text', ''), + model_text=info.get('model_text', ''), + device=get_host_info()) + try: + response = requests.post(self.url, json=post_data, timeout=timeout) + except Exception as ex: + self._print_log( + 'fail to connect to pavi service: {}'.format(ex), + level=logging.ERROR) + else: + if response.status_code == 200: + self.instance_id = response.text + self._print_log( + 'pavi service connected, instance_id: {}'.format( + self.instance_id)) + self.log_queue = Queue() + self.log_thread = Thread(target=self.post_worker_fn) + self.log_thread.daemon = True + self.log_thread.start() + return True + else: + self._print_log( + 'fail to connect to pavi service, status code: ' + '{}, err message: {}'.format(response.status_code, + response.reason), + level=logging.ERROR) + return False + + def post_worker_fn(self, max_retry=3, queue_timeout=1, req_timeout=3): + while True: + try: + log = self.log_queue.get(timeout=queue_timeout) + except Empty: + time.sleep(1) + except Exception as ex: + self._print_log( + 'fail to get logs from queue: {}'.format(ex), + level=logging.ERROR) + else: + retry = 0 + while retry < max_retry: + try: + response = requests.post( + self.url, json=log, timeout=req_timeout) + except Exception as ex: + retry += 1 + self._print_log( + 'error when posting logs to pavi: {}'.format(ex), + level=logging.ERROR) + else: + status_code = response.status_code + if status_code == 200: + break + else: + self._print_log( + 'unexpected status code: {}, err msg: {}'. + format(status_code, response.reason), + level=logging.ERROR) + retry += 1 + if retry == max_retry: + self._print_log( + 'fail to send logs of iteration {}'.format( + log['iter_num']), + level=logging.ERROR) + + def log(self, phase, iter, outputs): + if self.log_queue is not None: + logs = { + 'time': str(datetime.now()), + 'instance_id': self.instance_id, + 'flow_id': phase, + 'iter_num': iter, + 'outputs': outputs, + 'msg': '' + } + self.log_queue.put(logs) + + +class PaviLoggerHook(LoggerHook): + + def __init__(self, + url, + username=None, + password=None, + instance_id=None, + config_file=None, + interval=10, + ignore_last=True, + reset_flag=True): + self.pavi = PaviClient(url, username, password, instance_id) + self.config_file = config_file + super(PaviLoggerHook, self).__init__(interval, ignore_last, reset_flag) + + def before_run(self, runner): + super(PaviLoggerHook, self).before_run(runner) + self.connect(runner) + + @master_only + def connect(self, runner, timeout=5): + cfg_info = dict() + if self.config_file is not None: + with open(self.config_file, 'r') as f: + config_text = f.read() + cfg_info.update( + session_file=self.config_file, session_text=config_text) + return self.pavi.connect(runner.model_name, runner.work_dir, cfg_info, + timeout, runner.logger) + + @master_only + def log(self, runner): + log_outs = runner.log_buffer.output.copy() + log_outs.pop('time', None) + log_outs.pop('data_time', None) + for k, v in log_outs.items(): + if isinstance(v, str): + log_outs.pop(k) + self.pavi.log(runner.mode, runner.iter + 1, log_outs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/tensorboard.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/tensorboard.py new file mode 100644 index 000000000..7ed95f860 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/tensorboard.py @@ -0,0 +1,55 @@ +import os.path as osp + +import torch + +from ...utils import master_only +from .base import LoggerHook + + +class TensorboardLoggerHook(LoggerHook): + + def __init__(self, + log_dir=None, + interval=10, + ignore_last=True, + reset_flag=True): + super(TensorboardLoggerHook, self).__init__(interval, ignore_last, + reset_flag) + self.log_dir = log_dir + + @master_only + def before_run(self, runner): + if torch.__version__ >= '1.1': + try: + from torch.utils.tensorboard import SummaryWriter + except ImportError: + raise ImportError( + 'Please run "pip install future tensorboard" to install ' + 'the dependencies to use torch.utils.tensorboard ' + '(applicable to PyTorch 1.1 or higher)') + else: + try: + from tensorboardX import SummaryWriter + except ImportError: + raise ImportError('Please install tensorboardX to use ' + 'TensorboardLoggerHook.') + if self.log_dir is None: + self.log_dir = osp.join(runner.work_dir, 'tf_logs') + self.writer = SummaryWriter(self.log_dir) + + @master_only + def log(self, runner): + for var in runner.log_buffer.output: + if var in ['time', 'data_time']: + continue + tag = '{}/{}'.format(var, runner.mode) + record = runner.log_buffer.output[var] + if isinstance(record, str): + self.writer.add_text(tag, record, runner.iter) + else: + self.writer.add_scalar(tag, runner.log_buffer.output[var], + runner.iter) + + @master_only + def after_run(self, runner): + self.writer.close() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/text.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/text.py new file mode 100644 index 000000000..e397a172c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/logger/text.py @@ -0,0 +1,123 @@ +import datetime +import torch.nn.functional as F +import os +import os.path as osp +from collections import OrderedDict + +import numpy as np +import torch +import torch.distributed as dist + +import mmcv +from .base import LoggerHook + + +class TextLoggerHook(LoggerHook): + + def __init__(self, interval=10, ignore_last=True, reset_flag=False): + super(TextLoggerHook, self).__init__(interval, ignore_last, reset_flag) + self.time_sec_tot = 0 + + def before_run(self, runner): + super(TextLoggerHook, self).before_run(runner) + self.start_iter = runner.iter + self.json_log_path = osp.join(runner.work_dir, + '{}.log.json'.format(runner.timestamp)) + + def _get_max_memory(self, runner): + mem = torch.cuda.max_memory_allocated() + mem_mb = torch.tensor([mem / (1024 * 1024)], + dtype=torch.int, + device=torch.device('cuda')) + if runner.world_size > 1: + dist.reduce(mem_mb, 0, op=dist.ReduceOp.MAX) + return mem_mb.item() + + def _log_info(self, log_dict, runner): + if runner.mode == 'train': + log_str = 'Epoch [{}][{}/{}]\tlr: {:.5f}, '.format( + log_dict['epoch'], log_dict['iter'], len(runner.data_loader), + log_dict['lr']) + if 'time' in log_dict.keys(): + self.time_sec_tot += (log_dict['time'] * self.interval) + time_sec_avg = self.time_sec_tot / ( + runner.iter - self.start_iter + 1) + eta_sec = time_sec_avg * (runner.max_iters - runner.iter - 1) + eta_str = str(datetime.timedelta(seconds=int(eta_sec))) + log_str += 'eta: {}, '.format(eta_str) + log_str += ('time: {:.3f}, data_time: {:.3f}, '.format( + log_dict['time'], log_dict['data_time'])) + log_str += 'memory: {}, '.format(log_dict['memory']) + else: + log_str = 'Epoch({}) [{}][{}]\t'.format(log_dict['mode'], + log_dict['epoch'] - 1, + log_dict['iter']) + log_items = [] + for name, val in log_dict.items(): + # TODO: resolve this hack + # these items have been in log_str + if name in [ + 'mode', 'Epoch', 'iter', 'lr', 'time', 'data_time', + 'memory', 'epoch' + ]: + continue + if isinstance(val, float): + val = '{:.4f}'.format(val) + log_items.append('{}: {}'.format(name, val)) + log_str += ', '.join(log_items) + runner.logger.info(log_str) + + def _dump_log(self, log_dict, runner): + # dump log in json format + json_log = OrderedDict() + for k, v in log_dict.items(): + json_log[k] = self._round_float(v) + # only append log at last line + if runner.rank == 0: + with open(self.json_log_path, 'a+') as f: + mmcv.dump(json_log, f, file_format='json') + f.write('\n') + + def _round_float(self, items): + if isinstance(items, list): + return [self._round_float(item) for item in items] + elif isinstance(items, float): + return round(items, 5) + else: + return items + + def log(self, runner): + log_dict = OrderedDict() + # training mode if the output contains the key "time" + mode = 'train' if 'time' in runner.log_buffer.output else 'val' + log_dict['mode'] = mode + log_dict['epoch'] = runner.epoch + 1 + log_dict['iter'] = runner.inner_iter + 1 + # only record lr of the first param group + log_dict['lr'] = runner.current_lr()[0] + if runner.optimizer_arch is not None and (runner.rank == 0): + # os.system('df -h /dev/shm/') + detector = runner.model.module.module + # searching code can not be open sourced now. + if 'backbone' in runner.arch_name: + raise NotImplementedError + if 'neck' in runner.arch_name: + raise NotImplementedError + if 'head' in runner.arch_name: + raise NotImplementedError + + if mode == 'train': + log_dict['time'] = runner.log_buffer.output['time'] + log_dict['data_time'] = runner.log_buffer.output['data_time'] + # statistic memory + if torch.cuda.is_available(): + log_dict['memory'] = self._get_max_memory(runner) + for name, val in runner.log_buffer.output.items(): + if name in ['time', 'data_time']: + continue + log_dict[name] = val + + self._log_info(log_dict, runner) + self._dump_log(log_dict, runner) + if runner.rank == 0: + print() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/lr_updater.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/lr_updater.py new file mode 100644 index 000000000..bd443e666 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/lr_updater.py @@ -0,0 +1,183 @@ +from __future__ import division +from math import cos, pi + +from .hook import Hook + + +class LrUpdaterHook(Hook): + + def __init__(self, + by_epoch=True, + warmup=None, + warmup_iters=0, + warmup_ratio=0.1, + **kwargs): + # validate the "warmup" argument + if warmup is not None: + if warmup not in ['constant', 'linear', 'exp']: + raise ValueError( + '"{}" is not a supported type for warming up, valid types' + ' are "constant" and "linear"'.format(warmup)) + if warmup is not None: + assert warmup_iters > 0, \ + '"warmup_iters" must be a positive integer' + assert 0 < warmup_ratio <= 1.0, \ + '"warmup_ratio" must be in range (0,1]' + + self.by_epoch = by_epoch + self.warmup = warmup + self.warmup_iters = warmup_iters + self.warmup_ratio = warmup_ratio + + self.base_lr = [] # initial lr for all param groups + self.regular_lr = [] # expected lr if no warming up is performed + + def _set_lr(self, runner, lr_groups): + for param_group, lr in zip(runner.optimizer.param_groups, lr_groups): + param_group['lr'] = lr + + def get_lr(self, runner, base_lr): + raise NotImplementedError + + def get_regular_lr(self, runner): + return [self.get_lr(runner, _base_lr) for _base_lr in self.base_lr] + + def get_warmup_lr(self, cur_iters): + if self.warmup == 'constant': + warmup_lr = [_lr * self.warmup_ratio for _lr in self.regular_lr] + elif self.warmup == 'linear': + k = (1 - cur_iters / self.warmup_iters) * (1 - self.warmup_ratio) + warmup_lr = [_lr * (1 - k) for _lr in self.regular_lr] + elif self.warmup == 'exp': + k = self.warmup_ratio**(1 - cur_iters / self.warmup_iters) + warmup_lr = [_lr * k for _lr in self.regular_lr] + return warmup_lr + + def before_run(self, runner): + # NOTE: when resuming from a checkpoint, if 'initial_lr' is not saved, + # it will be set according to the optimizer params + for group in runner.optimizer.param_groups: + group.setdefault('initial_lr', group['lr']) + self.base_lr = [ + group['initial_lr'] for group in runner.optimizer.param_groups + ] + + def before_train_epoch(self, runner): + if not self.by_epoch: + return + self.regular_lr = self.get_regular_lr(runner) + self._set_lr(runner, self.regular_lr) + + def before_train_iter(self, runner): + cur_iter = runner.iter + if not self.by_epoch: + self.regular_lr = self.get_regular_lr(runner) + if self.warmup is None or cur_iter >= self.warmup_iters: + self._set_lr(runner, self.regular_lr) + else: + warmup_lr = self.get_warmup_lr(cur_iter) + self._set_lr(runner, warmup_lr) + elif self.by_epoch: + if self.warmup is None or cur_iter > self.warmup_iters: + return + elif cur_iter == self.warmup_iters: + self._set_lr(runner, self.regular_lr) + else: + warmup_lr = self.get_warmup_lr(cur_iter) + self._set_lr(runner, warmup_lr) + + +class FixedLrUpdaterHook(LrUpdaterHook): + + def __init__(self, **kwargs): + super(FixedLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + return base_lr + + +class StepLrUpdaterHook(LrUpdaterHook): + + def __init__(self, step, gamma=0.1, **kwargs): + assert isinstance(step, (list, int)) + if isinstance(step, list): + for s in step: + assert isinstance(s, int) and s > 0 + elif isinstance(step, int): + assert step > 0 + else: + raise TypeError('"step" must be a list or integer') + self.step = step + self.gamma = gamma + super(StepLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + + if isinstance(self.step, int): + return base_lr * (self.gamma**(progress // self.step)) + + exp = len(self.step) + for i, s in enumerate(self.step): + if progress < s: + exp = i + break + return base_lr * self.gamma**exp + + +class ExpLrUpdaterHook(LrUpdaterHook): + + def __init__(self, gamma, **kwargs): + self.gamma = gamma + super(ExpLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + return base_lr * self.gamma**progress + + +class PolyLrUpdaterHook(LrUpdaterHook): + + def __init__(self, power=1., min_lr=0., **kwargs): + self.power = power + self.min_lr = min_lr + super(PolyLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + coeff = (1 - progress / max_progress)**self.power + return (base_lr - self.min_lr) * coeff + self.min_lr + + +class InvLrUpdaterHook(LrUpdaterHook): + + def __init__(self, gamma, power=1., **kwargs): + self.gamma = gamma + self.power = power + super(InvLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + progress = runner.epoch if self.by_epoch else runner.iter + return base_lr * (1 + self.gamma * progress)**(-self.power) + + +class CosineLrUpdaterHook(LrUpdaterHook): + + def __init__(self, target_lr=0.001, **kwargs): + self.target_lr = target_lr + super(CosineLrUpdaterHook, self).__init__(**kwargs) + + def get_lr(self, runner, base_lr): + if self.by_epoch: + progress = runner.epoch + max_progress = runner.max_epochs + else: + progress = runner.iter + max_progress = runner.max_iters + return self.target_lr + 0.5 * (base_lr - self.target_lr) * \ + (1 + cos(pi * (progress / max_progress))) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/memory.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/memory.py new file mode 100644 index 000000000..6bd11d0d6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/memory.py @@ -0,0 +1,23 @@ +import torch + +from .hook import Hook + + +class EmptyCacheHook(Hook): + + def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): + self._before_epoch = before_epoch + self._after_epoch = after_epoch + self._after_iter = after_iter + + def after_iter(self, runner): + if self._after_iter: + torch.cuda.empty_cache() + + def before_epoch(self, runner): + if self._before_epoch: + torch.cuda.empty_cache() + + def after_epoch(self, runner): + if self._after_epoch: + torch.cuda.empty_cache() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/optimizer.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/optimizer.py new file mode 100644 index 000000000..b2ef579e0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/optimizer.py @@ -0,0 +1,35 @@ +from torch.nn.utils import clip_grad + +from .hook import Hook + + +class OptimizerHook(Hook): + def __init__(self, grad_clip=None): + self.grad_clip = grad_clip + + def clip_grads(self, params): + clip_grad.clip_grad_norm_( + filter(lambda p: p.requires_grad, params), **self.grad_clip) + + def after_train_iter(self, runner): + runner.optimizer.zero_grad() + runner.outputs['loss'].backward() + if self.grad_clip is not None: + self.clip_grads(runner.model.parameters()) + runner.optimizer.step() + + +class OptimizerArchHook(Hook): + def __init__(self, grad_clip=None): + self.grad_clip = grad_clip + + def clip_grads(self, params): + clip_grad.clip_grad_norm_( + filter(lambda p: p.requires_grad, params), **self.grad_clip) + + def arch_after_train_iter(self, runner): + if runner.optimizer_arch is not None: + runner.optimizer_arch.zero_grad() + runner.outputs_arch['loss'].backward() + if runner.optimizer_arch is not None: + runner.optimizer_arch.step() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py new file mode 100644 index 000000000..43cc228ec --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/sampler_seed.py @@ -0,0 +1,7 @@ +from .hook import Hook + + +class DistSamplerSeedHook(Hook): + + def before_epoch(self, runner): + runner.data_loader.sampler.set_epoch(runner.epoch) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/log_buffer.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/log_buffer.py new file mode 100644 index 000000000..7cb8b3c7a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/log_buffer.py @@ -0,0 +1,40 @@ +from collections import OrderedDict + +import numpy as np + + +class LogBuffer(object): + + def __init__(self): + self.val_history = OrderedDict() + self.n_history = OrderedDict() + self.output = OrderedDict() + self.ready = False + + def clear(self): + self.val_history.clear() + self.n_history.clear() + self.clear_output() + + def clear_output(self): + self.output.clear() + self.ready = False + + def update(self, vars, count=1): + assert isinstance(vars, dict) + for key, var in vars.items(): + if key not in self.val_history: + self.val_history[key] = [] + self.n_history[key] = [] + self.val_history[key].append(var) + self.n_history[key].append(count) + + def average(self, n=0): + """Average latest n values or all values""" + assert n >= 0 + for key in self.val_history: + values = np.array(self.val_history[key][-n:]) + nums = np.array(self.n_history[key][-n:]) + avg = np.sum(values * nums) / np.sum(nums) + self.output[key] = avg + self.ready = True diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/parallel_test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/parallel_test.py new file mode 100644 index 000000000..1f5a3ecae --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/parallel_test.py @@ -0,0 +1,74 @@ +import multiprocessing + +import torch + +import mmcv +from .checkpoint import load_checkpoint + + +def worker_func(model_cls, model_kwargs, checkpoint, dataset, data_func, + gpu_id, idx_queue, result_queue): + model = model_cls(**model_kwargs) + load_checkpoint(model, checkpoint, map_location='cpu') + torch.cuda.set_device(gpu_id) + model.cuda() + model.eval() + with torch.no_grad(): + while True: + idx = idx_queue.get() + data = dataset[idx] + result = model(**data_func(data, gpu_id)) + result_queue.put((idx, result)) + + +def parallel_test(model_cls, + model_kwargs, + checkpoint, + dataset, + data_func, + gpus, + workers_per_gpu=1): + """Parallel testing on multiple GPUs. + + Args: + model_cls (type): Model class type. + model_kwargs (dict): Arguments to init the model. + checkpoint (str): Checkpoint filepath. + dataset (:obj:`Dataset`): The dataset to be tested. + data_func (callable): The function that generates model inputs. + gpus (list[int]): GPU ids to be used. + workers_per_gpu (int): Number of processes on each GPU. It is possible + to run multiple workers on each GPU. + + Returns: + list: Test results. + """ + ctx = multiprocessing.get_context('spawn') + idx_queue = ctx.Queue() + result_queue = ctx.Queue() + num_workers = len(gpus) * workers_per_gpu + workers = [ + ctx.Process( + target=worker_func, + args=(model_cls, model_kwargs, checkpoint, dataset, data_func, + gpus[i % len(gpus)], idx_queue, result_queue)) + for i in range(num_workers) + ] + for w in workers: + w.daemon = True + w.start() + + for i in range(len(dataset)): + idx_queue.put(i) + + results = [None for _ in range(len(dataset))] + prog_bar = mmcv.ProgressBar(task_num=len(dataset)) + for _ in range(len(dataset)): + idx, res = result_queue.get() + results[idx] = res + prog_bar.update() + print('\n') + for worker in workers: + worker.terminate() + + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/priority.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/priority.py new file mode 100644 index 000000000..caf14395c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/priority.py @@ -0,0 +1,53 @@ +from enum import Enum + + +class Priority(Enum): + """Hook priority levels. + + +------------+------------+ + | Level | Value | + +============+============+ + | HIGHEST | 0 | + +------------+------------+ + | VERY_HIGH | 10 | + +------------+------------+ + | HIGH | 30 | + +------------+------------+ + | NORMAL | 50 | + +------------+------------+ + | LOW | 70 | + +------------+------------+ + | VERY_LOW | 90 | + +------------+------------+ + | LOWEST | 100 | + +------------+------------+ + """ + + HIGHEST = 0 + VERY_HIGH = 10 + HIGH = 30 + NORMAL = 50 + LOW = 70 + VERY_LOW = 90 + LOWEST = 100 + + +def get_priority(priority): + """Get priority value. + + Args: + priority (int or str or :obj:`Priority`): Priority. + + Returns: + int: The priority value. + """ + if isinstance(priority, int): + if priority < 0 or priority > 100: + raise ValueError('priority must be between 0 and 100') + return priority + elif isinstance(priority, Priority): + return priority.value + elif isinstance(priority, str): + return Priority[priority.upper()].value + else: + raise TypeError('priority must be an integer or Priority enum value') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py new file mode 100644 index 000000000..c070f5bed --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/runner.py @@ -0,0 +1,426 @@ +import logging +import os +import os.path as osp +import time + +import math +import torch +import numpy as np +import mmcv +from . import hooks +from .checkpoint import load_checkpoint, save_checkpoint +from .hooks import (CheckpointHook, Hook, IterTimerHook, LrUpdaterHook, + OptimizerHook, OptimizerArchHook, lr_updater) +from .log_buffer import LogBuffer +from .priority import get_priority +from .utils import get_dist_info, get_host_info, get_time_str, obj_from_dict + + +class Runner(object): + """A training helper for PyTorch. + + Args: + model (:obj:`torch.nn.Module`): The model to be run. + batch_processor (callable): A callable method that process a data + batch. The interface of this method should be + `batch_processor(model, data, train_mode) -> dict` + optimizer (dict or :obj:`torch.optim.Optimizer`): If it is a dict, + runner will construct an optimizer according to it. + work_dir (str, optional): The working directory to save checkpoints + and logs. + log_level (int): Logging level. + logger (:obj:`logging.Logger`): Custom logger. If `None`, use the + default logger. + """ + + def __init__(self, + model, + batch_processor, + optimizer=None, + optimizer_arch=None, + work_dir=None, + log_level=logging.INFO, + logger=None, + arch_name=None): + assert callable(batch_processor) + self.model = model + self.arch_name = arch_name + if optimizer is not None: + self.optimizer = self.init_optimizer(optimizer) + else: + self.optimizer = None + if optimizer_arch is not None: + self.optimizer_arch = self.init_optimizer(optimizer_arch) + else: + self.optimizer_arch = None + self.batch_processor = batch_processor + + # create work_dir + if mmcv.is_str(work_dir): + self.work_dir = osp.abspath(work_dir) + mmcv.mkdir_or_exist(self.work_dir) + elif work_dir is None: + self.work_dir = None + else: + raise TypeError('"work_dir" must be a str or None') + + # get model name from the model class + if hasattr(self.model, 'module'): + self._model_name = self.model.module.__class__.__name__ + else: + self._model_name = self.model.__class__.__name__ + + self._rank, self._world_size = get_dist_info() + self.timestamp = get_time_str() + if logger is None: + self.logger = self.init_logger(work_dir, log_level) + else: + self.logger = logger + self.log_buffer = LogBuffer() + + self.mode = None + self._hooks = [] + self._epoch = 0 + self._iter = 0 + self._inner_iter = 0 + self._max_epochs = 0 + self._max_iters = 0 + + @property + def model_name(self): + """str: Name of the model, usually the module class name.""" + return self._model_name + + @property + def rank(self): + """int: Rank of current process. (distributed training)""" + return self._rank + + @property + def world_size(self): + """int: Number of processes participating in the job. + (distributed training)""" + return self._world_size + + @property + def hooks(self): + """list[:obj:`Hook`]: A list of registered hooks.""" + return self._hooks + + @property + def epoch(self): + """int: Current epoch.""" + return self._epoch + + @property + def iter(self): + """int: Current iteration.""" + return self._iter + + @property + def inner_iter(self): + """int: Iteration in an epoch.""" + return self._inner_iter + + @property + def max_epochs(self): + """int: Maximum training epochs.""" + return self._max_epochs + + @property + def max_iters(self): + """int: Maximum training iterations.""" + return self._max_iters + + def init_optimizer(self, optimizer): + """Init the optimizer. + + Args: + optimizer (dict or :obj:`~torch.optim.Optimizer`): Either an + optimizer object or a dict used for constructing the optimizer. + + Returns: + :obj:`~torch.optim.Optimizer`: An optimizer object. + + Examples: + >>> optimizer = dict(type='SGD', lr=0.01, momentum=0.9) + >>> type(runner.init_optimizer(optimizer)) + + """ + if isinstance(optimizer, dict): + optimizer = obj_from_dict(optimizer, torch.optim, + dict(params=self.model.parameters())) + elif not isinstance(optimizer, torch.optim.Optimizer): + raise TypeError( + 'optimizer must be either an Optimizer object or a dict, ' + 'but got {}'.format(type(optimizer))) + return optimizer + + def _add_file_handler(self, + logger, + filename=None, + mode='w', + level=logging.INFO): + # TODO: move this method out of runner + file_handler = logging.FileHandler(filename, mode) + file_handler.setFormatter( + logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) + file_handler.setLevel(level) + logger.addHandler(file_handler) + return logger + + def init_logger(self, log_dir=None, level=logging.INFO): + """Init the logger. + + Args: + log_dir(str, optional): Log file directory. If not specified, no + log file will be used. + level (int or str): See the built-in python logging module. + + Returns: + :obj:`~logging.Logger`: Python logger. + """ + logging.basicConfig( + format='%(asctime)s - %(levelname)s - %(message)s', level=level) + logger = logging.getLogger(__name__) + if log_dir and self.rank == 0: + filename = '{}.log'.format(self.timestamp) + log_file = osp.join(log_dir, filename) + self._add_file_handler(logger, log_file, level=level) + return logger + + def current_lr(self): + """Get current learning rates. + + Returns: + list: Current learning rate of all param groups. + """ + if self.optimizer is None: + raise RuntimeError( + 'lr is not applicable because optimizer does not exist.') + return [group['lr'] for group in self.optimizer.param_groups] + + def register_hook(self, hook, priority='NORMAL'): + """Register a hook into the hook list. + + Args: + hook (:obj:`Hook`): The hook to be registered. + priority (int or str or :obj:`Priority`): Hook priority. + Lower value means higher priority. + """ + assert isinstance(hook, Hook) + if hasattr(hook, 'priority'): + raise ValueError('"priority" is a reserved attribute for hooks') + priority = get_priority(priority) + hook.priority = priority + # insert the hook to a sorted list + inserted = False + for i in range(len(self._hooks) - 1, -1, -1): + if priority >= self._hooks[i].priority: + self._hooks.insert(i + 1, hook) + inserted = True + break + if not inserted: + self._hooks.insert(0, hook) + + def build_hook(self, args, hook_type=None): + if isinstance(args, Hook): + return args + elif isinstance(args, dict): + assert issubclass(hook_type, Hook) + return hook_type(**args) + else: + raise TypeError('"args" must be either a Hook object' + ' or dict, not {}'.format(type(args))) + + def call_hook(self, fn_name): + for hook in self._hooks: + getattr(hook, fn_name)(self) + + def load_checkpoint(self, filename, map_location='cpu', strict=False): + self.logger.info('load checkpoint from %s', filename) + return load_checkpoint(self.model, filename, map_location, strict, + self.logger) + + def save_checkpoint(self, + out_dir, + filename_tmpl='epoch_{}.pth', + save_optimizer=True, + meta=None): + if meta is None: + meta = dict(epoch=self.epoch + 1, iter=self.iter) + else: + meta.update(epoch=self.epoch + 1, iter=self.iter) + + filename = filename_tmpl.format(self.epoch + 1) + filepath = osp.join(out_dir, filename) + linkpath = osp.join(out_dir, 'latest.pth') + optimizer = self.optimizer if save_optimizer else None + save_checkpoint(self.model, filepath, optimizer=optimizer, meta=meta) + # use relative symlink + mmcv.symlink(filename, linkpath) + + def train(self, data_loader, data_loader_arch, **kwargs): + self.model.train() + self.mode = 'train' + self.data_loader = data_loader + self._max_iters = self._max_epochs * len(data_loader) + self.call_hook('before_train_epoch') + + for i, data_batch in enumerate(data_loader): + self._inner_iter = i + self.call_hook('before_train_iter') + + outputs = self.batch_processor( + self.model, data_batch, train_mode=True, **kwargs) + if not isinstance(outputs, dict): + raise TypeError('batch_processor() must return a dict') + if 'log_vars' in outputs: + self.log_buffer.update(outputs['log_vars'], + outputs['num_samples']) + self.outputs = outputs + self.call_hook('after_train_iter') + + self._iter += 1 + + self.call_hook('after_train_epoch') + self._epoch += 1 + + def val(self, data_loader, data_loader_arch, **kwargs): + self.model.eval() + self.mode = 'val' + self.data_loader = data_loader + self.call_hook('before_val_epoch') + + for i, data_batch in enumerate(data_loader): + self._inner_iter = i + self.call_hook('before_val_iter') + with torch.no_grad(): + outputs = self.batch_processor( + self.model, data_batch, train_mode=False, **kwargs) + if not isinstance(outputs, dict): + raise TypeError('batch_processor() must return a dict') + if 'log_vars' in outputs: + self.log_buffer.update(outputs['log_vars'], + outputs['num_samples']) + self.outputs = outputs + self.call_hook('after_val_iter') + + self.call_hook('after_val_epoch') + + def resume(self, checkpoint, resume_optimizer=True, + map_location='default'): + if map_location == 'default': + device_id = torch.cuda.current_device() + checkpoint = self.load_checkpoint( + checkpoint, + map_location=lambda storage, loc: storage.cuda(device_id)) + else: + checkpoint = self.load_checkpoint( + checkpoint, map_location=map_location) + + self._epoch = checkpoint['meta']['epoch'] + self._iter = checkpoint['meta']['iter'] + if 'optimizer' in checkpoint and resume_optimizer: + self.optimizer.load_state_dict(checkpoint['optimizer']) + + self.logger.info('resumed epoch %d, iter %d', self.epoch, self.iter) + + def run(self, data_loaders, data_loaders_arch, workflow, max_epochs, **kwargs): + """Start running. + + Args: + data_loaders (list[:obj:`DataLoader`]): Dataloaders for training + and validation. + workflow (list[tuple]): A list of (phase, epochs) to specify the + running order and epochs. E.g, [('train', 2), ('val', 1)] means + running 2 epochs for training and 1 epoch for validation, + iteratively. + max_epochs (int): Total training epochs. + """ + assert isinstance(data_loaders, list) + assert mmcv.is_list_of(workflow, tuple) + assert len(data_loaders) == len(workflow) + + self._max_epochs = max_epochs + work_dir = self.work_dir if self.work_dir is not None else 'NONE' + self.logger.info('Start running, host: %s, work_dir: %s', + get_host_info(), work_dir) + self.logger.info('workflow: %s, max: %d epochs', workflow, max_epochs) + self.call_hook('before_run') + + while self.epoch < max_epochs: + for i, flow in enumerate(workflow): + mode, epochs = flow + if isinstance(mode, str): # self.train() + if not hasattr(self, mode): + raise ValueError( + 'runner has no method named "{}" to run an epoch'. + format(mode)) + epoch_runner = getattr(self, mode) + elif callable(mode): # custom train() + epoch_runner = mode + else: + raise TypeError('mode in workflow must be a str or ' + 'callable function, not {}'.format( + type(mode))) + for _ in range(epochs): + if mode == 'train' and self.epoch >= max_epochs: + return + if data_loaders_arch is not None: + epoch_runner(data_loaders[i], data_loaders_arch[i], **kwargs) + else: + epoch_runner(data_loaders[i], None, **kwargs) + + time.sleep(1) # wait for some hooks like loggers to finish + self.call_hook('after_run') + + def register_lr_hooks(self, lr_config): + if isinstance(lr_config, LrUpdaterHook): + self.register_hook(lr_config) + elif isinstance(lr_config, dict): + assert 'policy' in lr_config + # from .hooks import lr_updater + hook_name = lr_config['policy'].title() + 'LrUpdaterHook' + if not hasattr(lr_updater, hook_name): + raise ValueError('"{}" does not exist'.format(hook_name)) + hook_cls = getattr(lr_updater, hook_name) + self.register_hook(hook_cls(**lr_config)) + else: + raise TypeError('"lr_config" must be either a LrUpdaterHook object' + ' or dict, not {}'.format(type(lr_config))) + + def register_logger_hooks(self, log_config): + log_interval = log_config['interval'] + for info in log_config['hooks']: + logger_hook = obj_from_dict( + info, hooks, default_args=dict(interval=log_interval)) + self.register_hook(logger_hook, priority='VERY_LOW') + + def register_training_hooks(self, + lr_config, + optimizer_config=None, + optimizer_arch_config=None, + checkpoint_config=None, + log_config=None): + """Register default hooks for training. + + Default hooks include: + + - LrUpdaterHook + - OptimizerStepperHook + - CheckpointSaverHook + - IterTimerHook + - LoggerHook(s) + """ + if optimizer_config is None: + optimizer_config = {} + if checkpoint_config is None: + checkpoint_config = {} + self.register_lr_hooks(lr_config) + self.register_hook(self.build_hook(optimizer_config, OptimizerHook)) + self.register_hook(self.build_hook(optimizer_arch_config, OptimizerArchHook)) + self.register_hook(self.build_hook(checkpoint_config, CheckpointHook)) + self.register_hook(IterTimerHook()) + if log_config is not None: + self.register_logger_hooks(log_config) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py new file mode 100644 index 000000000..710f7eb8c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py @@ -0,0 +1,78 @@ +import functools +import sys +import time +from getpass import getuser +from socket import gethostname + +import torch +import torch.distributed as dist + +import mmcv + + +def get_host_info(): + return '{}@{}'.format(getuser(), gethostname()) + + +def get_dist_info(): + if torch.__version__ < '1.0': + initialized = dist._initialized + else: + initialized = dist.is_initialized() + if initialized: + rank = dist.get_rank() + world_size = dist.get_world_size() + else: + rank = 0 + world_size = 1 + return rank, world_size + + +def master_only(func): + + @functools.wraps(func) + def wrapper(*args, **kwargs): + rank, _ = get_dist_info() + if rank == 0: + return func(*args, **kwargs) + + return wrapper + + +def get_time_str(): + return time.strftime('%Y%m%d_%H%M%S', time.localtime()) + + +def obj_from_dict(info, parent=None, default_args=None): + """Initialize an object from dict. + + The dict must contain the key "type", which indicates the object type, it + can be either a string or type, such as "list" or ``list``. Remaining + fields are treated as the arguments for constructing the object. + + Args: + info (dict): Object types and arguments. + parent (:class:`module`): Module which may containing expected object + classes. + default_args (dict, optional): Default arguments for initializing the + object. + + Returns: + any type: Object built from the dict. + """ + assert isinstance(info, dict) and 'type' in info + assert isinstance(default_args, dict) or default_args is None + args = info.copy() + obj_type = args.pop('type') + if mmcv.is_str(obj_type): + if parent is not None: + obj_type = getattr(parent, obj_type) + else: + obj_type = sys.modules[obj_type] + elif not isinstance(obj_type, type): + raise TypeError('type must be a str or valid type, but got {}'.format( + type(obj_type))) + if default_args is not None: + for name, value in default_args.items(): + args.setdefault(name, value) + return obj_type(**args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/__init__.py new file mode 100644 index 000000000..b540b7c22 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/__init__.py @@ -0,0 +1,17 @@ +from .config import ConfigDict, Config +from .misc import (is_str, iter_cast, list_cast, tuple_cast, is_seq_of, + is_list_of, is_tuple_of, slice_list, concat_list, + check_prerequisites, requires_package, requires_executable) +from .path import (is_filepath, fopen, check_file_exist, mkdir_or_exist, + symlink, scandir, FileNotFoundError) +from .progressbar import ProgressBar, track_progress, track_parallel_progress +from .timer import Timer, TimerError, check_time + +__all__ = [ + 'ConfigDict', 'Config', 'is_str', 'iter_cast', 'list_cast', 'tuple_cast', + 'is_seq_of', 'is_list_of', 'is_tuple_of', 'slice_list', 'concat_list', + 'check_prerequisites', 'requires_package', 'requires_executable', + 'is_filepath', 'fopen', 'check_file_exist', 'mkdir_or_exist', 'symlink', + 'scandir', 'FileNotFoundError', 'ProgressBar', 'track_progress', + 'track_parallel_progress', 'Timer', 'TimerError', 'check_time' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/config.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/config.py new file mode 100644 index 000000000..9de6700eb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/config.py @@ -0,0 +1,159 @@ +import os.path as osp +import sys +from argparse import ArgumentParser +from importlib import import_module + +from addict import Dict + +from .misc import collections_abc +from .path import check_file_exist + + +class ConfigDict(Dict): + + def __missing__(self, name): + raise KeyError(name) + + def __getattr__(self, name): + try: + value = super(ConfigDict, self).__getattr__(name) + except KeyError: + ex = AttributeError("'{}' object has no attribute '{}'".format( + self.__class__.__name__, name)) + except Exception as e: + ex = e + else: + return value + raise ex + + +def add_args(parser, cfg, prefix=''): + for k, v in cfg.items(): + if isinstance(v, str): + parser.add_argument('--' + prefix + k) + elif isinstance(v, int): + parser.add_argument('--' + prefix + k, type=int) + elif isinstance(v, float): + parser.add_argument('--' + prefix + k, type=float) + elif isinstance(v, bool): + parser.add_argument('--' + prefix + k, action='store_true') + elif isinstance(v, dict): + add_args(parser, v, k + '.') + elif isinstance(v, collections_abc.Iterable): + parser.add_argument('--' + prefix + k, type=type(v[0]), nargs='+') + else: + print('connot parse key {} of type {}'.format(prefix + k, type(v))) + return parser + + +class Config(object): + """A facility for config and config files. + + It supports common file formats as configs: python/json/yaml. The interface + is the same as a dict object and also allows access config values as + attributes. + + Example: + >>> cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) + >>> cfg.a + 1 + >>> cfg.b + {'b1': [0, 1]} + >>> cfg.b.b1 + [0, 1] + >>> cfg = Config.fromfile('tests/data/config/a.py') + >>> cfg.filename + "/home/kchen/projects/mmcv/tests/data/config/a.py" + >>> cfg.item4 + 'test' + >>> cfg + "Config [path: /home/kchen/projects/mmcv/tests/data/config/a.py]: " + "{'item1': [1, 2], 'item2': {'a': 0}, 'item3': True, 'item4': 'test'}" + + """ + + @staticmethod + def fromfile(filename): + filename = osp.abspath(osp.expanduser(filename)) + check_file_exist(filename) + if filename.endswith('.py'): + module_name = osp.basename(filename)[:-3] + if '.' in module_name: + raise ValueError('Dots are not allowed in config file path.') + config_dir = osp.dirname(filename) + sys.path.insert(0, config_dir) + mod = import_module(module_name) + sys.path.pop(0) + cfg_dict = { + name: value + for name, value in mod.__dict__.items() + if not name.startswith('__') + } + elif filename.endswith(('.yml', '.yaml', '.json')): + import mmcv + cfg_dict = mmcv.load(filename) + else: + raise IOError('Only py/yml/yaml/json type are supported now!') + return Config(cfg_dict, filename=filename) + + @staticmethod + def auto_argparser(description=None): + """Generate argparser from config file automatically (experimental) + """ + partial_parser = ArgumentParser(description=description) + partial_parser.add_argument('config', help='config file path') + cfg_file = partial_parser.parse_known_args()[0].config + cfg = Config.fromfile(cfg_file) + parser = ArgumentParser(description=description) + parser.add_argument('config', help='config file path') + add_args(parser, cfg) + return parser, cfg + + def __init__(self, cfg_dict=None, filename=None): + if cfg_dict is None: + cfg_dict = dict() + elif not isinstance(cfg_dict, dict): + raise TypeError('cfg_dict must be a dict, but got {}'.format( + type(cfg_dict))) + + super(Config, self).__setattr__('_cfg_dict', ConfigDict(cfg_dict)) + super(Config, self).__setattr__('_filename', filename) + if filename: + with open(filename, 'r') as f: + super(Config, self).__setattr__('_text', f.read()) + else: + super(Config, self).__setattr__('_text', '') + + @property + def filename(self): + return self._filename + + @property + def text(self): + return self._text + + def __repr__(self): + return 'Config (path: {}): {}'.format(self.filename, + self._cfg_dict.__repr__()) + + def __len__(self): + return len(self._cfg_dict) + + def __getattr__(self, name): + return getattr(self._cfg_dict, name) + + def __getitem__(self, name): + return self._cfg_dict.__getitem__(name) + + def __setattr__(self, name, value): + if isinstance(value, dict): + value = ConfigDict(value) + self._cfg_dict.__setattr__(name, value) + + def __setitem__(self, name, value): + if isinstance(value, dict): + value = ConfigDict(value) + self._cfg_dict.__setitem__(name, value) + + def __iter__(self): + return iter(self._cfg_dict) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/misc.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/misc.py new file mode 100644 index 000000000..e83e6d9d1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/misc.py @@ -0,0 +1,218 @@ +import collections +import functools +import itertools +import subprocess +from importlib import import_module + +import six + +# ABCs from collections will be deprecated in python 3.8+, +# while collections.abc is not available in python 2.7 +try: + import collections.abc as collections_abc +except ImportError: + import collections as collections_abc + + +def is_str(x): + """Whether the input is an string instance.""" + return isinstance(x, six.string_types) + + +def iter_cast(inputs, dst_type, return_type=None): + """Cast elements of an iterable object into some type. + + Args: + inputs (Iterable): The input object. + dst_type (type): Destination type. + return_type (type, optional): If specified, the output object will be + converted to this type, otherwise an iterator. + + Returns: + iterator or specified type: The converted object. + """ + if not isinstance(inputs, collections_abc.Iterable): + raise TypeError('inputs must be an iterable object') + if not isinstance(dst_type, type): + raise TypeError('"dst_type" must be a valid type') + + out_iterable = six.moves.map(dst_type, inputs) + + if return_type is None: + return out_iterable + else: + return return_type(out_iterable) + + +def list_cast(inputs, dst_type): + """Cast elements of an iterable object into a list of some type. + + A partial method of :func:`iter_cast`. + """ + return iter_cast(inputs, dst_type, return_type=list) + + +def tuple_cast(inputs, dst_type): + """Cast elements of an iterable object into a tuple of some type. + + A partial method of :func:`iter_cast`. + """ + return iter_cast(inputs, dst_type, return_type=tuple) + + +def is_seq_of(seq, expected_type, seq_type=None): + """Check whether it is a sequence of some type. + + Args: + seq (Sequence): The sequence to be checked. + expected_type (type): Expected type of sequence items. + seq_type (type, optional): Expected sequence type. + + Returns: + bool: Whether the sequence is valid. + """ + if seq_type is None: + exp_seq_type = collections_abc.Sequence + else: + assert isinstance(seq_type, type) + exp_seq_type = seq_type + if not isinstance(seq, exp_seq_type): + return False + for item in seq: + if not isinstance(item, expected_type): + return False + return True + + +def is_list_of(seq, expected_type): + """Check whether it is a list of some type. + + A partial method of :func:`is_seq_of`. + """ + return is_seq_of(seq, expected_type, seq_type=list) + + +def is_tuple_of(seq, expected_type): + """Check whether it is a tuple of some type. + + A partial method of :func:`is_seq_of`. + """ + return is_seq_of(seq, expected_type, seq_type=tuple) + + +def slice_list(in_list, lens): + """Slice a list into several sub lists by a list of given length. + + Args: + in_list (list): The list to be sliced. + lens(int or list): The expected length of each out list. + + Returns: + list: A list of sliced list. + """ + if not isinstance(lens, list): + raise TypeError('"indices" must be a list of integers') + elif sum(lens) != len(in_list): + raise ValueError( + 'sum of lens and list length does not match: {} != {}'.format( + sum(lens), len(in_list))) + out_list = [] + idx = 0 + for i in range(len(lens)): + out_list.append(in_list[idx:idx + lens[i]]) + idx += lens[i] + return out_list + + +def concat_list(in_list): + """Concatenate a list of list into a single list. + + Args: + in_list (list): The list of list to be merged. + + Returns: + list: The concatenated flat list. + """ + return list(itertools.chain(*in_list)) + + +def check_prerequisites( + prerequisites, + checker, + msg_tmpl='Prerequisites "{}" are required in method "{}" but not ' + 'found, please install them first.'): + """A decorator factory to check if prerequisites are satisfied. + + Args: + prerequisites (str of list[str]): Prerequisites to be checked. + checker (callable): The checker method that returns True if a + prerequisite is meet, False otherwise. + msg_tmpl (str): The message template with two variables. + + Returns: + decorator: A specific decorator. + """ + + def wrap(func): + + @functools.wraps(func) + def wrapped_func(*args, **kwargs): + requirements = [prerequisites] if isinstance( + prerequisites, str) else prerequisites + missing = [] + for item in requirements: + if not checker(item): + missing.append(item) + if missing: + print(msg_tmpl.format(', '.join(missing), func.__name__)) + raise RuntimeError('Prerequisites not meet.') + else: + return func(*args, **kwargs) + + return wrapped_func + + return wrap + + +def _check_py_package(package): + try: + import_module(package) + except ImportError: + return False + else: + return True + + +def _check_executable(cmd): + if subprocess.call('which {}'.format(cmd), shell=True) != 0: + return False + else: + return True + + +def requires_package(prerequisites): + """A decorator to check if some python packages are installed. + + Example: + >>> @requires_package('numpy') + >>> func(arg1, args): + >>> return numpy.zeros(1) + array([0.]) + >>> @requires_package(['numpy', 'non_package']) + >>> func(arg1, args): + >>> return numpy.zeros(1) + ImportError + """ + return check_prerequisites(prerequisites, checker=_check_py_package) + + +def requires_executable(prerequisites): + """A decorator to check if some executable files are installed. + + Example: + >>> @requires_executable('ffmpeg') + >>> func(arg1, args): + >>> print(1) + 1 + """ + return check_prerequisites(prerequisites, checker=_check_executable) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py new file mode 100644 index 000000000..d390da23c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/path.py @@ -0,0 +1,79 @@ +import os +import os.path as osp +import sys +from pathlib import Path + +import six + +from .misc import is_str + +if sys.version_info <= (3, 3): + FileNotFoundError = IOError +else: + FileNotFoundError = FileNotFoundError + + +def is_filepath(x): + if is_str(x) or isinstance(x, Path): + return True + else: + return False + + +def fopen(filepath, *args, **kwargs): + if is_str(filepath): + return open(filepath, *args, **kwargs) + elif isinstance(filepath, Path): + return filepath.open(*args, **kwargs) + + +def check_file_exist(filename, msg_tmpl='file "{}" does not exist'): + if not osp.isfile(filename): + raise FileNotFoundError(msg_tmpl.format(filename)) + + +def mkdir_or_exist(dir_name, mode=0o777): + if dir_name == '': + return + dir_name = osp.expanduser(dir_name) + if six.PY3: + os.makedirs(dir_name, mode=mode, exist_ok=True) + else: + if not osp.isdir(dir_name): + os.makedirs(dir_name, mode=mode) + + +def symlink(src, dst, overwrite=True, **kwargs): + if os.path.lexists(dst) and overwrite: + os.remove(dst) + os.symlink(src, dst, **kwargs) + + +def _scandir_py35(dir_path, suffix=None): + for entry in os.scandir(dir_path): + if not entry.is_file(): + continue + filename = entry.name + if suffix is None: + yield filename + elif filename.endswith(suffix): + yield filename + + +def _scandir_py(dir_path, suffix=None): + for filename in os.listdir(dir_path): + if not osp.isfile(osp.join(dir_path, filename)): + continue + if suffix is None: + yield filename + elif filename.endswith(suffix): + yield filename + + +def scandir(dir_path, suffix=None): + if suffix is not None and not isinstance(suffix, (str, tuple)): + raise TypeError('"suffix" must be a string or tuple of strings') + if sys.version_info >= (3, 5): + return _scandir_py35(dir_path, suffix) + else: + return _scandir_py(dir_path, suffix) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/progressbar.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/progressbar.py new file mode 100644 index 000000000..0687a3d0b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/progressbar.py @@ -0,0 +1,174 @@ +import sys +from multiprocessing import Pool + +from .misc import collections_abc +from .timer import Timer + + +class ProgressBar(object): + """A progress bar which can print the progress""" + + def __init__(self, task_num=0, bar_width=50, start=True): + self.task_num = task_num + max_bar_width = self._get_max_bar_width() + self.bar_width = ( + bar_width if bar_width <= max_bar_width else max_bar_width) + self.completed = 0 + if start: + self.start() + + def _get_max_bar_width(self): + if sys.version_info > (3, 3): + from shutil import get_terminal_size + else: + from backports.shutil_get_terminal_size import get_terminal_size + terminal_width, _ = get_terminal_size() + max_bar_width = min(int(terminal_width * 0.6), terminal_width - 50) + if max_bar_width < 10: + print('terminal width is too small ({}), please consider ' + 'widen the terminal for better progressbar ' + 'visualization'.format(terminal_width)) + max_bar_width = 10 + return max_bar_width + + def start(self): + if self.task_num > 0: + sys.stdout.write('[{}] 0/{}, elapsed: 0s, ETA:'.format( + ' ' * self.bar_width, self.task_num)) + else: + sys.stdout.write('completed: 0, elapsed: 0s') + sys.stdout.flush() + self.timer = Timer() + + def update(self): + self.completed += 1 + elapsed = self.timer.since_start() + fps = self.completed / elapsed + if self.task_num > 0: + percentage = self.completed / float(self.task_num) + eta = int(elapsed * (1 - percentage) / percentage + 0.5) + mark_width = int(self.bar_width * percentage) + bar_chars = '>' * mark_width + ' ' * (self.bar_width - mark_width) + sys.stdout.write( + '\r[{}] {}/{}, {:.1f} task/s, elapsed: {}s, ETA: {:5}s'.format( + bar_chars, self.completed, self.task_num, fps, + int(elapsed + 0.5), eta)) + else: + sys.stdout.write( + 'completed: {}, elapsed: {}s, {:.1f} tasks/s'.format( + self.completed, int(elapsed + 0.5), fps)) + sys.stdout.flush() + + +def track_progress(func, tasks, bar_width=50, **kwargs): + """Track the progress of tasks execution with a progress bar. + + Tasks are done with a simple for-loop. + + Args: + func (callable): The function to be applied to each task. + tasks (list or tuple[Iterable, int]): A list of tasks or + (tasks, total num). + bar_width (int): Width of progress bar. + + Returns: + list: The task results. + """ + if isinstance(tasks, tuple): + assert len(tasks) == 2 + assert isinstance(tasks[0], collections_abc.Iterable) + assert isinstance(tasks[1], int) + task_num = tasks[1] + tasks = tasks[0] + elif isinstance(tasks, collections_abc.Iterable): + task_num = len(tasks) + else: + raise TypeError( + '"tasks" must be an iterable object or a (iterator, int) tuple') + prog_bar = ProgressBar(task_num, bar_width) + results = [] + for task in tasks: + results.append(func(task, **kwargs)) + prog_bar.update() + sys.stdout.write('\n') + return results + + +def init_pool(process_num, initializer=None, initargs=None): + if initializer is None: + return Pool(process_num) + elif initargs is None: + return Pool(process_num, initializer) + else: + if not isinstance(initargs, tuple): + raise TypeError('"initargs" must be a tuple') + return Pool(process_num, initializer, initargs) + + +def track_parallel_progress(func, + tasks, + nproc, + initializer=None, + initargs=None, + bar_width=50, + chunksize=1, + skip_first=False, + keep_order=True): + """Track the progress of parallel task execution with a progress bar. + + The built-in :mod:`multiprocessing` module is used for process pools and + tasks are done with :func:`Pool.map` or :func:`Pool.imap_unordered`. + + Args: + func (callable): The function to be applied to each task. + tasks (list or tuple[Iterable, int]): A list of tasks or + (tasks, total num). + nproc (int): Process (worker) number. + initializer (None or callable): Refer to :class:`multiprocessing.Pool` + for details. + initargs (None or tuple): Refer to :class:`multiprocessing.Pool` for + details. + chunksize (int): Refer to :class:`multiprocessing.Pool` for details. + bar_width (int): Width of progress bar. + skip_first (bool): Whether to skip the first sample for each worker + when estimating fps, since the initialization step may takes + longer. + keep_order (bool): If True, :func:`Pool.imap` is used, otherwise + :func:`Pool.imap_unordered` is used. + + Returns: + list: The task results. + """ + if isinstance(tasks, tuple): + assert len(tasks) == 2 + assert isinstance(tasks[0], collections_abc.Iterable) + assert isinstance(tasks[1], int) + task_num = tasks[1] + tasks = tasks[0] + elif isinstance(tasks, collections_abc.Iterable): + task_num = len(tasks) + else: + raise TypeError( + '"tasks" must be an iterable object or a (iterator, int) tuple') + pool = init_pool(nproc, initializer, initargs) + start = not skip_first + task_num -= nproc * chunksize * int(skip_first) + prog_bar = ProgressBar(task_num, bar_width, start) + results = [] + if keep_order: + gen = pool.imap(func, tasks, chunksize) + else: + gen = pool.imap_unordered(func, tasks, chunksize) + for result in gen: + results.append(result) + if skip_first: + if len(results) < nproc * chunksize: + continue + elif len(results) == nproc * chunksize: + prog_bar.start() + continue + prog_bar.update() + sys.stdout.write('\n') + pool.close() + pool.join() + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/timer.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/timer.py new file mode 100644 index 000000000..3214ecab6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/utils/timer.py @@ -0,0 +1,117 @@ +from time import time + + +class TimerError(Exception): + + def __init__(self, message): + self.message = message + super(TimerError, self).__init__(message) + + +class Timer(object): + """A flexible Timer class. + + :Example: + + >>> import time + >>> import mmcv + >>> with mmcv.Timer(): + >>> # simulate a code block that will run for 1s + >>> time.sleep(1) + 1.000 + >>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'): + >>> # simulate a code block that will run for 1s + >>> time.sleep(1) + it takes 1.0 seconds + >>> timer = mmcv.Timer() + >>> time.sleep(0.5) + >>> print(timer.since_start()) + 0.500 + >>> time.sleep(0.5) + >>> print(timer.since_last_check()) + 0.500 + >>> print(timer.since_start()) + 1.000 + """ + + def __init__(self, start=True, print_tmpl=None): + self._is_running = False + self.print_tmpl = print_tmpl if print_tmpl else '{:.3f}' + if start: + self.start() + + @property + def is_running(self): + """bool: indicate whether the timer is running""" + return self._is_running + + def __enter__(self): + self.start() + return self + + def __exit__(self, type, value, traceback): + print(self.print_tmpl.format(self.since_last_check())) + self._is_running = False + + def start(self): + """Start the timer.""" + if not self._is_running: + self._t_start = time() + self._is_running = True + self._t_last = time() + + def since_start(self): + """Total time since the timer is started. + + Returns (float): Time in seconds. + """ + if not self._is_running: + raise TimerError('timer is not running') + self._t_last = time() + return self._t_last - self._t_start + + def since_last_check(self): + """Time since the last checking. + + Either :func:`since_start` or :func:`since_last_check` is a checking + operation. + + Returns (float): Time in seconds. + """ + if not self._is_running: + raise TimerError('timer is not running') + dur = time() - self._t_last + self._t_last = time() + return dur + + +_g_timers = {} # global timers + + +def check_time(timer_id): + """Add check points in a single line. + + This method is suitable for running a task on a list of items. A timer will + be registered when the method is called for the first time. + + :Example: + + >>> import time + >>> import mmcv + >>> for i in range(1, 6): + >>> # simulate a code block + >>> time.sleep(i) + >>> mmcv.check_time('task1') + 2.000 + 3.000 + 4.000 + 5.000 + + Args: + timer_id (str): Timer identifier. + """ + if timer_id not in _g_timers: + _g_timers[timer_id] = Timer() + return 0 + else: + return _g_timers[timer_id].since_last_check() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/version.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/version.py new file mode 100644 index 000000000..51e2f03f2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/version.py @@ -0,0 +1 @@ +__version__ = '0.2.12' diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/__init__.py new file mode 100644 index 000000000..ed05cc1b1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/__init__.py @@ -0,0 +1,10 @@ +from .io import Cache, VideoReader, frames2video +from .processing import convert_video, resize_video, cut_video, concat_video +from .optflow import (flowread, flowwrite, quantize_flow, dequantize_flow, + flow_warp) + +__all__ = [ + 'Cache', 'VideoReader', 'frames2video', 'convert_video', 'resize_video', + 'cut_video', 'concat_video', 'flowread', 'flowwrite', 'quantize_flow', + 'dequantize_flow', 'flow_warp' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/io.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/io.py new file mode 100644 index 000000000..76b226076 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/io.py @@ -0,0 +1,332 @@ +import os.path as osp +from collections import OrderedDict + +import cv2 + +from mmcv.opencv_info import USE_OPENCV2 +from mmcv.utils import (check_file_exist, mkdir_or_exist, scandir, + track_progress) + +if not USE_OPENCV2: + from cv2 import (CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT, CAP_PROP_FPS, + CAP_PROP_FRAME_COUNT, CAP_PROP_FOURCC, + CAP_PROP_POS_FRAMES, VideoWriter_fourcc) +else: + from cv2.cv import CV_CAP_PROP_FRAME_WIDTH as CAP_PROP_FRAME_WIDTH + from cv2.cv import CV_CAP_PROP_FRAME_HEIGHT as CAP_PROP_FRAME_HEIGHT + from cv2.cv import CV_CAP_PROP_FPS as CAP_PROP_FPS + from cv2.cv import CV_CAP_PROP_FRAME_COUNT as CAP_PROP_FRAME_COUNT + from cv2.cv import CV_CAP_PROP_FOURCC as CAP_PROP_FOURCC + from cv2.cv import CV_CAP_PROP_POS_FRAMES as CAP_PROP_POS_FRAMES + from cv2.cv import CV_FOURCC as VideoWriter_fourcc + + +class Cache(object): + + def __init__(self, capacity): + self._cache = OrderedDict() + self._capacity = int(capacity) + if capacity <= 0: + raise ValueError('capacity must be a positive integer') + + @property + def capacity(self): + return self._capacity + + @property + def size(self): + return len(self._cache) + + def put(self, key, val): + if key in self._cache: + return + if len(self._cache) >= self.capacity: + self._cache.popitem(last=False) + self._cache[key] = val + + def get(self, key, default=None): + val = self._cache[key] if key in self._cache else default + return val + + +class VideoReader(object): + """Video class with similar usage to a list object. + + This video warpper class provides convenient apis to access frames. + There exists an issue of OpenCV's VideoCapture class that jumping to a + certain frame may be inaccurate. It is fixed in this class by checking + the position after jumping each time. + Cache is used when decoding videos. So if the same frame is visited for + the second time, there is no need to decode again if it is stored in the + cache. + + :Example: + + >>> import mmcv + >>> v = mmcv.VideoReader('sample.mp4') + >>> len(v) # get the total frame number with `len()` + 120 + >>> for img in v: # v is iterable + >>> mmcv.imshow(img) + >>> v[5] # get the 6th frame + """ + + def __init__(self, filename, cache_capacity=10): + check_file_exist(filename, 'Video file not found: ' + filename) + self._vcap = cv2.VideoCapture(filename) + assert cache_capacity > 0 + self._cache = Cache(cache_capacity) + self._position = 0 + # get basic info + self._width = int(self._vcap.get(CAP_PROP_FRAME_WIDTH)) + self._height = int(self._vcap.get(CAP_PROP_FRAME_HEIGHT)) + self._fps = self._vcap.get(CAP_PROP_FPS) + self._frame_cnt = int(self._vcap.get(CAP_PROP_FRAME_COUNT)) + self._fourcc = self._vcap.get(CAP_PROP_FOURCC) + + @property + def vcap(self): + """:obj:`cv2.VideoCapture`: The raw VideoCapture object.""" + return self._vcap + + @property + def opened(self): + """bool: Indicate whether the video is opened.""" + return self._vcap.isOpened() + + @property + def width(self): + """int: Width of video frames.""" + return self._width + + @property + def height(self): + """int: Height of video frames.""" + return self._height + + @property + def resolution(self): + """tuple: Video resolution (width, height).""" + return (self._width, self._height) + + @property + def fps(self): + """float: FPS of the video.""" + return self._fps + + @property + def frame_cnt(self): + """int: Total frames of the video.""" + return self._frame_cnt + + @property + def fourcc(self): + """str: "Four character code" of the video.""" + return self._fourcc + + @property + def position(self): + """int: Current cursor position, indicating frame decoded.""" + return self._position + + def _get_real_position(self): + return int(round(self._vcap.get(CAP_PROP_POS_FRAMES))) + + def _set_real_position(self, frame_id): + self._vcap.set(CAP_PROP_POS_FRAMES, frame_id) + pos = self._get_real_position() + for _ in range(frame_id - pos): + self._vcap.read() + self._position = frame_id + + def read(self): + """Read the next frame. + + If the next frame have been decoded before and in the cache, then + return it directly, otherwise decode, cache and return it. + + Returns: + ndarray or None: Return the frame if successful, otherwise None. + """ + # pos = self._position + if self._cache: + img = self._cache.get(self._position) + if img is not None: + ret = True + else: + if self._position != self._get_real_position(): + self._set_real_position(self._position) + ret, img = self._vcap.read() + if ret: + self._cache.put(self._position, img) + else: + ret, img = self._vcap.read() + if ret: + self._position += 1 + return img + + def get_frame(self, frame_id): + """Get frame by index. + + Args: + frame_id (int): Index of the expected frame, 0-based. + + Returns: + ndarray or None: Return the frame if successful, otherwise None. + """ + if frame_id < 0 or frame_id >= self._frame_cnt: + raise IndexError( + '"frame_id" must be between 0 and {}'.format(self._frame_cnt - + 1)) + if frame_id == self._position: + return self.read() + if self._cache: + img = self._cache.get(frame_id) + if img is not None: + self._position = frame_id + 1 + return img + self._set_real_position(frame_id) + ret, img = self._vcap.read() + if ret: + if self._cache: + self._cache.put(self._position, img) + self._position += 1 + return img + + def current_frame(self): + """Get the current frame (frame that is just visited). + + Returns: + ndarray or None: If the video is fresh, return None, otherwise + return the frame. + """ + if self._position == 0: + return None + return self._cache.get(self._position - 1) + + def cvt2frames(self, + frame_dir, + file_start=0, + filename_tmpl='{:06d}.jpg', + start=0, + max_num=0, + show_progress=True): + """Convert a video to frame images + + Args: + frame_dir (str): Output directory to store all the frame images. + file_start (int): Filenames will start from the specified number. + filename_tmpl (str): Filename template with the index as the + placeholder. + start (int): The starting frame index. + max_num (int): Maximum number of frames to be written. + show_progress (bool): Whether to show a progress bar. + """ + mkdir_or_exist(frame_dir) + if max_num == 0: + task_num = self.frame_cnt - start + else: + task_num = min(self.frame_cnt - start, max_num) + if task_num <= 0: + raise ValueError('start must be less than total frame number') + if start > 0: + self._set_real_position(start) + + def write_frame(file_idx): + img = self.read() + filename = osp.join(frame_dir, filename_tmpl.format(file_idx)) + cv2.imwrite(filename, img) + + if show_progress: + track_progress(write_frame, range(file_start, + file_start + task_num)) + else: + for i in range(task_num): + img = self.read() + if img is None: + break + filename = osp.join(frame_dir, + filename_tmpl.format(i + file_start)) + cv2.imwrite(filename, img) + + def __len__(self): + return self.frame_cnt + + def __getitem__(self, index): + if isinstance(index, slice): + return [ + self.get_frame(i) + for i in range(*index.indices(self.frame_cnt)) + ] + # support negative indexing + if index < 0: + index += self.frame_cnt + if index < 0: + raise IndexError('index out of range') + return self.get_frame(index) + + def __iter__(self): + self._set_real_position(0) + return self + + def __next__(self): + img = self.read() + if img is not None: + return img + else: + raise StopIteration + + next = __next__ + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self._vcap.release() + + +def frames2video(frame_dir, + video_file, + fps=30, + fourcc='XVID', + filename_tmpl='{:06d}.jpg', + start=0, + end=0, + show_progress=True): + """Read the frame images from a directory and join them as a video + + Args: + frame_dir (str): The directory containing video frames. + video_file (str): Output filename. + fps (float): FPS of the output video. + fourcc (str): Fourcc of the output video, this should be compatible + with the output file type. + filename_tmpl (str): Filename template with the index as the variable. + start (int): Starting frame index. + end (int): Ending frame index. + show_progress (bool): Whether to show a progress bar. + """ + if end == 0: + ext = filename_tmpl.split('.')[-1] + end = len([name for name in scandir(frame_dir, ext)]) + first_file = osp.join(frame_dir, filename_tmpl.format(start)) + check_file_exist(first_file, 'The start frame not found: ' + first_file) + img = cv2.imread(first_file) + height, width = img.shape[:2] + resolution = (width, height) + vwriter = cv2.VideoWriter(video_file, VideoWriter_fourcc(*fourcc), fps, + resolution) + + def write_frame(file_idx): + filename = osp.join(frame_dir, filename_tmpl.format(file_idx)) + img = cv2.imread(filename) + vwriter.write(img) + + if show_progress: + track_progress(write_frame, range(start, end)) + else: + for i in range(start, end): + filename = osp.join(frame_dir, filename_tmpl.format(i)) + img = cv2.imread(filename) + vwriter.write(img) + vwriter.release() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow.py new file mode 100644 index 000000000..6404ea41e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow.py @@ -0,0 +1,171 @@ +import numpy as np + +from mmcv._ext import flow_warp_c +from mmcv.arraymisc import dequantize, quantize +from mmcv.image import imread, imwrite +from mmcv.utils import is_str + + +def flowread(flow_or_path, quantize=False, concat_axis=0, *args, **kwargs): + """Read an optical flow map. + + Args: + flow_or_path (ndarray or str): A flow map or filepath. + quantize (bool): whether to read quantized pair, if set to True, + remaining args will be passed to :func:`dequantize_flow`. + concat_axis (int): The axis that dx and dy are concatenated, + can be either 0 or 1. Ignored if quantize is False. + + Returns: + ndarray: Optical flow represented as a (h, w, 2) numpy array + """ + if isinstance(flow_or_path, np.ndarray): + if (flow_or_path.ndim != 3) or (flow_or_path.shape[-1] != 2): + raise ValueError('Invalid flow with shape {}'.format( + flow_or_path.shape)) + return flow_or_path + elif not is_str(flow_or_path): + raise TypeError( + '"flow_or_path" must be a filename or numpy array, not {}'.format( + type(flow_or_path))) + + if not quantize: + with open(flow_or_path, 'rb') as f: + try: + header = f.read(4).decode('utf-8') + except Exception: + raise IOError('Invalid flow file: {}'.format(flow_or_path)) + else: + if header != 'PIEH': + raise IOError( + 'Invalid flow file: {}, header does not contain PIEH'. + format(flow_or_path)) + + w = np.fromfile(f, np.int32, 1).squeeze() + h = np.fromfile(f, np.int32, 1).squeeze() + flow = np.fromfile(f, np.float32, w * h * 2).reshape((h, w, 2)) + else: + assert concat_axis in [0, 1] + cat_flow = imread(flow_or_path, flag='unchanged') + if cat_flow.ndim != 2: + raise IOError( + '{} is not a valid quantized flow file, its dimension is {}.'. + format(flow_or_path, cat_flow.ndim)) + assert cat_flow.shape[concat_axis] % 2 == 0 + dx, dy = np.split(cat_flow, 2, axis=concat_axis) + flow = dequantize_flow(dx, dy, *args, **kwargs) + + return flow.astype(np.float32) + + +def flowwrite(flow, filename, quantize=False, concat_axis=0, *args, **kwargs): + """Write optical flow to file. + + If the flow is not quantized, it will be saved as a .flo file losslessly, + otherwise a jpeg image which is lossy but of much smaller size. (dx and dy + will be concatenated horizontally into a single image if quantize is True.) + + Args: + flow (ndarray): (h, w, 2) array of optical flow. + filename (str): Output filepath. + quantize (bool): Whether to quantize the flow and save it to 2 jpeg + images. If set to True, remaining args will be passed to + :func:`quantize_flow`. + concat_axis (int): The axis that dx and dy are concatenated, + can be either 0 or 1. Ignored if quantize is False. + """ + if not quantize: + with open(filename, 'wb') as f: + f.write('PIEH'.encode('utf-8')) + np.array([flow.shape[1], flow.shape[0]], dtype=np.int32).tofile(f) + flow = flow.astype(np.float32) + flow.tofile(f) + f.flush() + else: + assert concat_axis in [0, 1] + dx, dy = quantize_flow(flow, *args, **kwargs) + dxdy = np.concatenate((dx, dy), axis=concat_axis) + imwrite(dxdy, filename) + + +def quantize_flow(flow, max_val=0.02, norm=True): + """Quantize flow to [0, 255]. + + After this step, the size of flow will be much smaller, and can be + dumped as jpeg images. + + Args: + flow (ndarray): (h, w, 2) array of optical flow. + max_val (float): Maximum value of flow, values beyond + [-max_val, max_val] will be truncated. + norm (bool): Whether to divide flow values by image width/height. + + Returns: + tuple[ndarray]: Quantized dx and dy. + """ + h, w, _ = flow.shape + dx = flow[..., 0] + dy = flow[..., 1] + if norm: + dx = dx / w # avoid inplace operations + dy = dy / h + # use 255 levels instead of 256 to make sure 0 is 0 after dequantization. + flow_comps = [ + quantize(d, -max_val, max_val, 255, np.uint8) for d in [dx, dy] + ] + return tuple(flow_comps) + + +def dequantize_flow(dx, dy, max_val=0.02, denorm=True): + """Recover from quantized flow. + + Args: + dx (ndarray): Quantized dx. + dy (ndarray): Quantized dy. + max_val (float): Maximum value used when quantizing. + denorm (bool): Whether to multiply flow values with width/height. + + Returns: + ndarray: Dequantized flow. + """ + assert dx.shape == dy.shape + assert dx.ndim == 2 or (dx.ndim == 3 and dx.shape[-1] == 1) + + dx, dy = [dequantize(d, -max_val, max_val, 255) for d in [dx, dy]] + + if denorm: + dx *= dx.shape[1] + dy *= dx.shape[0] + flow = np.dstack((dx, dy)) + return flow + + +def flow_warp(img, flow, filling_value=0, interpolate_mode='nearest'): + """Use flow to warp img + + Args: + img (ndarray, float or uint8): Image to be warped. + flow (ndarray, float): Optical Flow. + filling_value (int): The missing pixels will be set with filling_value. + interpolate_mode (str): bilinear -> Bilinear Interpolation; + nearest -> Nearest Neighbor. + + Returns: + ndarray: Warped image with the same shape of img + """ + interpolate_mode_dict = {'bilinear': 0, 'nearest': 1} + assert len(img.shape) == 3 + assert len(flow.shape) == 3 and flow.shape[2] == 2 + assert flow.shape[:2] == img.shape[:2] + assert interpolate_mode in interpolate_mode_dict.keys() + + interpolate_mode = interpolate_mode_dict[interpolate_mode] + img_float = img.astype(np.float64) + + out = flow_warp_c( + img_float, + flow.astype(np.float64), + filling_value=filling_value, + interpolate_mode=interpolate_mode) + + return out diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.cpp new file mode 100644 index 000000000..ad16fc066 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.cpp @@ -0,0 +1,75 @@ +#include "flow_warp.hpp" + +void FlowWarp(double* img, double* flow, double* out, const int height, + const int width, const int channels, const int filling_value = 0, + const int interpolateMode = 0) { + for (int h = 0; h < height; h++) { + for (int w = 0; w < width; w++) { + int offset_cur = h * width + w; + int offset_img = offset_cur * channels; + int offset_flow = offset_cur * 2; + double x, y; + x = h + flow[offset_flow + 1]; + y = w + flow[offset_flow]; + + if (x < 0 || x >= height - 1 || y < 0 || y >= width - 1) { + for (int k = 0; k < channels; k++) { + out[offset_img + k] = filling_value; + } + continue; + } + + if (interpolateMode == 0) + BilinearInterpolate(img, width, height, channels, x, y, + out + offset_img); + else if (interpolateMode == 1) + NNInterpolate(img, width, height, channels, x, y, out + offset_img); + else + throw "Not Implemented Interpolation Method"; + } + } +} + +void BilinearInterpolate(const double* img, int width, int height, int channels, + double x, double y, double* out) { + int xx, yy, m, n, u, v, offset, offset_img, l; + xx = x; + yy = y; + + double dx, dy, s; + + dx = __max__(__min__(x - xx, double(1)), double(0)); + dy = __max__(__min__(y - yy, double(1)), double(0)); + + for (m = 0; m <= 1; m++) + for (n = 0; n <= 1; n++) { + u = EnforceRange(yy + n, width); + v = EnforceRange(xx + m, height); + offset = v * width + u; + offset_img = offset * channels; + s = fabs(1 - m - dx) * fabs(1 - n - dy); + for (l = 0; l < channels; l++) out[l] += img[offset_img + l] * s; + } +} + +void NNInterpolate(const double* img, int width, int height, int channels, + double x, double y, double* out) { + int xx, yy, m, n, u, v, offset, offset_img, l; + xx = x; + yy = y; + + double dx, dy; + + dx = __max__(__min__(x - xx, double(1)), double(0)); + dy = __max__(__min__(y - yy, double(1)), double(0)); + + m = (dx < 0.5) ? 0 : 1; + n = (dy < 0.5) ? 0 : 1; + + u = EnforceRange(yy + n, width); + v = EnforceRange(xx + m, height); + offset = v * width + u; + offset_img = offset * channels; + + for (l = 0; l < channels; l++) out[l] = img[offset_img + l]; +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.hpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.hpp new file mode 100644 index 000000000..53d873835 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp.hpp @@ -0,0 +1,29 @@ +#include +#include + +using namespace std; + +void FlowWarp(double* img, double* flow1, double* out, const int height, + const int width, const int channels, const int filling_value, + const int interpolateMode); + +void BilinearInterpolate(const double* img, int width, int height, int channels, + double x, double y, double* out); + +void NNInterpolate(const double* img, int width, int height, int channels, + double x, double y, double* out); + +template +inline T __min__(T a, T b) { + return a > b ? b : a; +} + +template +inline T __max__(T a, T b) { + return (a < b) ? b : a; +} + +template +inline T EnforceRange(const T x, const int MaxValue) { + return __min__(__max__(x, 0), MaxValue); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.cpp new file mode 100644 index 000000000..5f3a987e7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.cpp @@ -0,0 +1,7928 @@ +/* Generated by Cython 0.27.3 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. +#else +#define CYTHON_ABI "0_27_3" +#define CYTHON_FUTURE_DIVISION 0 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__mmcv___ext +#define __PYX_HAVE_API__mmcv___ext +#include +#include +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "flow_warp.hpp" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +static PyObject *__pyx_m = NULL; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +/* Header.proto */ +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "mmcv/video/optflow_warp/flow_warp_module.pyx", + "__init__.pxd", + "type.pxd", +}; +/* BufferFormatStructs.proto */ +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; + struct __Pyx_StructField_* fields; + size_t size; + size_t arraysize[8]; + int ndim; + char typegroup; + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":743 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":744 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":745 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":746 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":750 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":751 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":752 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":753 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":757 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":758 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":767 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":768 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":769 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":771 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":772 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":775 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":778 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":780 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + + +/*--- Type declarations ---*/ + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":783 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":784 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":786 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); + +/* IsLittleEndian.proto */ +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); + +/* BufferFormatCheck.proto */ +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type); + +/* BufferGetAndValidate.proto */ +#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ + ((obj == Py_None || obj == NULL) ?\ + (__Pyx_ZeroBuffer(buf), 0) :\ + __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) +static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static void __Pyx_ZeroBuffer(Py_buffer* buf); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; +static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* BufferStructDeclare.proto */ +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* RealImag.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(__cplusplus) && CYTHON_CCOMPLEX\ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_float(a, b) ((a)==(b)) + #define __Pyx_c_sum_float(a, b) ((a)+(b)) + #define __Pyx_c_diff_float(a, b) ((a)-(b)) + #define __Pyx_c_prod_float(a, b) ((a)*(b)) + #define __Pyx_c_quot_float(a, b) ((a)/(b)) + #define __Pyx_c_neg_float(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_float(z) ((z)==(float)0) + #define __Pyx_c_conj_float(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_float(z) (::std::abs(z)) + #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_float(z) ((z)==0) + #define __Pyx_c_conj_float(z) (conjf(z)) + #if 1 + #define __Pyx_c_abs_float(z) (cabsf(z)) + #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_double(a, b) ((a)==(b)) + #define __Pyx_c_sum_double(a, b) ((a)+(b)) + #define __Pyx_c_diff_double(a, b) ((a)-(b)) + #define __Pyx_c_prod_double(a, b) ((a)*(b)) + #define __Pyx_c_quot_double(a, b) ((a)/(b)) + #define __Pyx_c_neg_double(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_double(z) ((z)==(double)0) + #define __Pyx_c_conj_double(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (::std::abs(z)) + #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_double(z) ((z)==0) + #define __Pyx_c_conj_double(z) (conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (cabs(z)) + #define __Pyx_c_pow_double(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* PyIdentifierFromString.proto */ +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +/* ModuleImport.proto */ +static PyObject *__Pyx_ImportModule(const char *name); + +/* TypeImport.proto */ +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'cpython' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'cpython.mem' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ +static CYTHON_INLINE int __pyx_f_5numpy_import_array(void); /*proto*/ + +/* Module declarations from 'mmcv._ext' */ +static __Pyx_TypeInfo __Pyx_TypeInfo_double = { "double", NULL, sizeof(double), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "mmcv._ext" +extern int __pyx_module_is_main_mmcv___ext; +int __pyx_module_is_main_mmcv___ext = 0; + +/* Implementation of 'mmcv._ext' */ +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_ImportError; +static const char __pyx_k_Hi[] = "Hi"; +static const char __pyx_k_np[] = "np"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_STUFF[] = "STUFF"; +static const char __pyx_k_numpy[] = "numpy"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_shape[] = "shape"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_img_array[] = "img_array"; +static const char __pyx_k_mmcv__ext[] = "mmcv._ext"; +static const char __pyx_k_out_array[] = "out_array"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_flow_array[] = "flow_array"; +static const char __pyx_k_zeros_like[] = "zeros_like"; +static const char __pyx_k_ImportError[] = "ImportError"; +static const char __pyx_k_flow_warp_c[] = "flow_warp_c"; +static const char __pyx_k_RuntimeError[] = "RuntimeError"; +static const char __pyx_k_filling_value[] = "filling_value"; +static const char __pyx_k_interpolate_mode[] = "interpolate_mode"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; +static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; +static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; +static const char __pyx_k_mmcv_video_optflow_warp_flow_war[] = "mmcv/video/optflow_warp/flow_warp_module.pyx"; +static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; +static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_Hi; +static PyObject *__pyx_n_s_ImportError; +static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_n_s_STUFF; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_filling_value; +static PyObject *__pyx_n_s_flow_array; +static PyObject *__pyx_n_s_flow_warp_c; +static PyObject *__pyx_n_s_img_array; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_interpolate_mode; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_mmcv__ext; +static PyObject *__pyx_kp_s_mmcv_video_optflow_warp_flow_war; +static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; +static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_kp_s_numpy_core_multiarray_failed_to; +static PyObject *__pyx_kp_s_numpy_core_umath_failed_to_impor; +static PyObject *__pyx_n_s_out_array; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_shape; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; +static PyObject *__pyx_n_s_zeros_like; +static PyObject *__pyx_pf_4mmcv_4_ext_flow_warp_c(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_img_array, PyArrayObject *__pyx_v_flow_array, int __pyx_v_filling_value, int __pyx_v_interpolate_mode); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_codeobj__11; + +/* "mmcv/video/optflow_warp/flow_warp_module.pyx":11 + * void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) + * + * def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, # <<<<<<<<<<<<<< + * np.ndarray[double, ndim=3, mode="c"] flow_array not None, + * int filling_value=0, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_4mmcv_4_ext_1flow_warp_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_4mmcv_4_ext_1flow_warp_c = {"flow_warp_c", (PyCFunction)__pyx_pw_4mmcv_4_ext_1flow_warp_c, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_4mmcv_4_ext_1flow_warp_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_img_array = 0; + PyArrayObject *__pyx_v_flow_array = 0; + int __pyx_v_filling_value; + int __pyx_v_interpolate_mode; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("flow_warp_c (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_img_array,&__pyx_n_s_flow_array,&__pyx_n_s_filling_value,&__pyx_n_s_interpolate_mode,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_img_array)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flow_array)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("flow_warp_c", 0, 2, 4, 1); __PYX_ERR(0, 11, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filling_value); + if (value) { values[2] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_interpolate_mode); + if (value) { values[3] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "flow_warp_c") < 0)) __PYX_ERR(0, 11, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_img_array = ((PyArrayObject *)values[0]); + __pyx_v_flow_array = ((PyArrayObject *)values[1]); + if (values[2]) { + __pyx_v_filling_value = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_filling_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 13, __pyx_L3_error) + } else { + __pyx_v_filling_value = ((int)0); + } + if (values[3]) { + __pyx_v_interpolate_mode = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_interpolate_mode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error) + } else { + __pyx_v_interpolate_mode = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("flow_warp_c", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("mmcv._ext.flow_warp_c", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_img_array), __pyx_ptype_5numpy_ndarray, 0, "img_array", 0))) __PYX_ERR(0, 11, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_flow_array), __pyx_ptype_5numpy_ndarray, 0, "flow_array", 0))) __PYX_ERR(0, 12, __pyx_L1_error) + __pyx_r = __pyx_pf_4mmcv_4_ext_flow_warp_c(__pyx_self, __pyx_v_img_array, __pyx_v_flow_array, __pyx_v_filling_value, __pyx_v_interpolate_mode); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_4mmcv_4_ext_flow_warp_c(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_img_array, PyArrayObject *__pyx_v_flow_array, int __pyx_v_filling_value, int __pyx_v_interpolate_mode) { + PyObject *__pyx_v_out_array = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_flow_array; + __Pyx_Buffer __pyx_pybuffer_flow_array; + __Pyx_LocalBuf_ND __pyx_pybuffernd_img_array; + __Pyx_Buffer __pyx_pybuffer_img_array; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + __Pyx_RefNannySetupContext("flow_warp_c", 0); + __pyx_pybuffer_img_array.pybuffer.buf = NULL; + __pyx_pybuffer_img_array.refcount = 0; + __pyx_pybuffernd_img_array.data = NULL; + __pyx_pybuffernd_img_array.rcbuffer = &__pyx_pybuffer_img_array; + __pyx_pybuffer_flow_array.pybuffer.buf = NULL; + __pyx_pybuffer_flow_array.refcount = 0; + __pyx_pybuffernd_flow_array.data = NULL; + __pyx_pybuffernd_flow_array.rcbuffer = &__pyx_pybuffer_flow_array; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_img_array.rcbuffer->pybuffer, (PyObject*)__pyx_v_img_array, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 11, __pyx_L1_error) + } + __pyx_pybuffernd_img_array.diminfo[0].strides = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_img_array.diminfo[0].shape = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_img_array.diminfo[1].strides = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_img_array.diminfo[1].shape = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_img_array.diminfo[2].strides = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_img_array.diminfo[2].shape = __pyx_pybuffernd_img_array.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flow_array.rcbuffer->pybuffer, (PyObject*)__pyx_v_flow_array, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 11, __pyx_L1_error) + } + __pyx_pybuffernd_flow_array.diminfo[0].strides = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_flow_array.diminfo[0].shape = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_flow_array.diminfo[1].strides = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_flow_array.diminfo[1].shape = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_flow_array.diminfo[2].strides = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_flow_array.diminfo[2].shape = __pyx_pybuffernd_flow_array.rcbuffer->pybuffer.shape[2]; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":16 + * int interpolate_mode=1): + * + * out_array = np.zeros_like(img_array) # <<<<<<<<<<<<<< + * + * FlowWarp( np.PyArray_DATA(img_array), + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_2) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_img_array)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_img_array)}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)__pyx_v_img_array)}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_img_array)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_img_array)); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_img_array)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_out_array = __pyx_t_1; + __pyx_t_1 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":20 + * FlowWarp( np.PyArray_DATA(img_array), + * np.PyArray_DATA(flow_array), + * np.PyArray_DATA(out_array), # <<<<<<<<<<<<<< + * out_array.shape[0], + * out_array.shape[1], + */ + if (!(likely(((__pyx_v_out_array) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out_array, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 20, __pyx_L1_error) + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":21 + * np.PyArray_DATA(flow_array), + * np.PyArray_DATA(out_array), + * out_array.shape[0], # <<<<<<<<<<<<<< + * out_array.shape[1], + * out_array.shape[2], + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_array, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":22 + * np.PyArray_DATA(out_array), + * out_array.shape[0], + * out_array.shape[1], # <<<<<<<<<<<<<< + * out_array.shape[2], + * filling_value, + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_array, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":23 + * out_array.shape[0], + * out_array.shape[1], + * out_array.shape[2], # <<<<<<<<<<<<<< + * filling_value, + * interpolate_mode) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out_array, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 23, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":18 + * out_array = np.zeros_like(img_array) + * + * FlowWarp( np.PyArray_DATA(img_array), # <<<<<<<<<<<<<< + * np.PyArray_DATA(flow_array), + * np.PyArray_DATA(out_array), + */ + FlowWarp(((double *)PyArray_DATA(((PyArrayObject *)__pyx_v_img_array))), ((double *)PyArray_DATA(((PyArrayObject *)__pyx_v_flow_array))), ((double *)PyArray_DATA(((PyArrayObject *)__pyx_v_out_array))), __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_v_filling_value, __pyx_v_interpolate_mode); + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":27 + * interpolate_mode) + * + * return out_array # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_out_array); + __pyx_r = __pyx_v_out_array; + goto __pyx_L0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":11 + * void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) + * + * def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, # <<<<<<<<<<<<<< + * np.ndarray[double, ndim=3, mode="c"] flow_array not None, + * int filling_value=0, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flow_array.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img_array.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("mmcv._ext.flow_warp_c", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flow_array.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_img_array.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF(__pyx_v_out_array); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":214 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":223 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":224 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":228 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":228 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + goto __pyx_L4; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + /*else*/ { + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L6_bool_binop_done; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":234 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L6_bool_binop_done:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 235, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L9_bool_binop_done; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":238 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L9_bool_binop_done:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":239 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 239, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":241 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":242 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (__pyx_v_copy_shape != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":246 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":247 + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_4 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":249 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":250 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + goto __pyx_L11; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":252 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + /*else*/ { + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":253 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L11:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":254 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":255 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":256 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef int offset + */ + __pyx_v_f = NULL; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef int offset + * + */ + __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L15_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L15_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":267 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + goto __pyx_L14; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + /*else*/ { + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L14:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":273 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L20_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_L20_next_or:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L19_bool_binop_done:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 276, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":277 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = ((char *)"b"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":278 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = ((char *)"B"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = ((char *)"h"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = ((char *)"H"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":281 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = ((char *)"i"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":282 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = ((char *)"I"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = ((char *)"l"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = ((char *)"L"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = ((char *)"q"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":286 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = ((char *)"Q"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":287 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = ((char *)"f"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":288 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = ((char *)"d"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":289 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = ((char *)"g"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = ((char *)"Zf"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = ((char *)"Zd"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = ((char *)"Zg"); + break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = ((char *)"O"); + break; + default: + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":295 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 295, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(1, 295, __pyx_L1_error) + break; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":296 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":297 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":299 + * return + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + /*else*/ { + __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":300 + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":301 + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) + */ + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(1, 302, __pyx_L1_error) + __pyx_v_f = __pyx_t_7; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":305 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":214 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":307 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":308 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":309 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) + */ + PyObject_Free(__pyx_v_info->format); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":308 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":310 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":311 + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + PyObject_Free(__pyx_v_info->strides); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":310 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":307 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":788 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":789 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 789, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":788 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":792 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 792, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":795 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 795, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":797 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 798, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":797 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":800 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 801, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":800 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":804 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":805 + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape # <<<<<<<<<<<<<< + * else: + * return () + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); + __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":804 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":807 + * return d.subarray.shape + * else: + * return () # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_empty_tuple); + __pyx_r = __pyx_empty_tuple; + goto __pyx_L0; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":803 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":809 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":814 + * + * cdef dtype child + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":815 + * cdef dtype child + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":818 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(1, 818, __pyx_L1_error) + } + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 818, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 818, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":819 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 819, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 819, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 819, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":820 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + #if !CYTHON_COMPILING_IN_PYPY + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 820, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 820, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 820, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 820, __pyx_L1_error) + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 820, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 822, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 822, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 822, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (__pyx_t_6) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 823, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":826 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (__pyx_t_6) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 827, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 0x78; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":839 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":845 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 845, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":846 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_6) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":847 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 847, __pyx_L1_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":846 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":850 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":851 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":852 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x68; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":853 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":854 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 854, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 854, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 854, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x69; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":855 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 855, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 855, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 855, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":856 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 856, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 856, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 856, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x6C; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":857 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 857, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 857, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 857, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":858 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 858, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 858, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 858, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x71; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":859 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 859, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 859, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 859, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":860 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 860, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 860, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 860, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x66; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":861 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 861, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 861, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 861, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x64; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":862 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 862, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 862, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 862, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x67; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":863 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 863, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 863, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 863, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x66; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":864 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 864, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 864, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 864, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x64; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":865 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 865, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 865, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 865, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x67; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":866 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 866, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 866, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 866, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":868 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + /*else*/ { + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 868, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 868, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 868, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 868, __pyx_L1_error) + } + __pyx_L15:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":869 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + goto __pyx_L13; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":873 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + /*else*/ { + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 873, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":818 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":874 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":809 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":990 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":993 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":992 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + goto __pyx_L3; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":995 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + /*else*/ { + Py_INCREF(__pyx_v_base); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":996 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":990 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1002 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1001 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1004 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1009 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_array", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1010 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1011 + * cdef inline int import_array() except -1: + * try: + * _import_array() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") + */ + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1011, __pyx_L3_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1010 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1012 + * try: + * _import_array() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.multiarray failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1012, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1013 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1013, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1013, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1010 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1009 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1015 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_umath", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1016 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1017 + * cdef inline int import_umath() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1017, __pyx_L3_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1016 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1018 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1018, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1019 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1019, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1019, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1016 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1015 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1021 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_ufunc", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + * cdef inline int import_ufunc() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1023, __pyx_L3_error) + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1024, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1025 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1025, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1025, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1021 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec__ext(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec__ext}, + {0, NULL} +}; +#endif + +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + "_ext", + 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_Hi, __pyx_k_Hi, sizeof(__pyx_k_Hi), 0, 0, 1, 1}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s_STUFF, __pyx_k_STUFF, sizeof(__pyx_k_STUFF), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_filling_value, __pyx_k_filling_value, sizeof(__pyx_k_filling_value), 0, 0, 1, 1}, + {&__pyx_n_s_flow_array, __pyx_k_flow_array, sizeof(__pyx_k_flow_array), 0, 0, 1, 1}, + {&__pyx_n_s_flow_warp_c, __pyx_k_flow_warp_c, sizeof(__pyx_k_flow_warp_c), 0, 0, 1, 1}, + {&__pyx_n_s_img_array, __pyx_k_img_array, sizeof(__pyx_k_img_array), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_interpolate_mode, __pyx_k_interpolate_mode, sizeof(__pyx_k_interpolate_mode), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_mmcv__ext, __pyx_k_mmcv__ext, sizeof(__pyx_k_mmcv__ext), 0, 0, 1, 1}, + {&__pyx_kp_s_mmcv_video_optflow_warp_flow_war, __pyx_k_mmcv_video_optflow_warp_flow_war, sizeof(__pyx_k_mmcv_video_optflow_warp_flow_war), 0, 0, 1, 0}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_kp_s_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 0, 1, 0}, + {&__pyx_kp_s_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 0, 1, 0}, + {&__pyx_n_s_out_array, __pyx_k_out_array, sizeof(__pyx_k_out_array), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_n_s_zeros_like, __pyx_k_zeros_like, sizeof(__pyx_k_zeros_like), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 235, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 248, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 823, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 1013, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":239 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 823, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 827, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":847 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 847, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1013 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 1013, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1019 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 1019, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1025 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 1025, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":11 + * void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) + * + * def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, # <<<<<<<<<<<<<< + * np.ndarray[double, ndim=3, mode="c"] flow_array not None, + * int filling_value=0, + */ + __pyx_tuple__10 = PyTuple_Pack(5, __pyx_n_s_img_array, __pyx_n_s_flow_array, __pyx_n_s_filling_value, __pyx_n_s_interpolate_mode, __pyx_n_s_out_array); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_mmcv_video_optflow_warp_flow_war, __pyx_n_s_flow_warp_c, 11, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC init_ext(void); /*proto*/ +PyMODINIT_FUNC init_ext(void) +#else +PyMODINIT_FUNC PyInit__ext(void); /*proto*/ +PyMODINIT_FUNC PyInit__ext(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec__ext(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #endif + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__ext(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("_ext", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_mmcv___ext) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "mmcv._ext")) { + if (unlikely(PyDict_SetItemString(modules, "mmcv._ext", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 163, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 185, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 189, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 198, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 885, __pyx_L1_error) + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":1 + * STUFF = "Hi" # <<<<<<<<<<<<<< + * + * import numpy as np + */ + if (PyDict_SetItem(__pyx_d, __pyx_n_s_STUFF, __pyx_n_s_Hi) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":3 + * STUFF = "Hi" + * + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":6 + * cimport numpy as np + * + * np.import_array() # <<<<<<<<<<<<<< + * + * cdef extern from "flow_warp.hpp": + */ + __pyx_t_2 = __pyx_f_5numpy_import_array(); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 6, __pyx_L1_error) + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":11 + * void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) + * + * def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, # <<<<<<<<<<<<<< + * np.ndarray[double, ndim=3, mode="c"] flow_array not None, + * int filling_value=0, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4mmcv_4_ext_1flow_warp_c, NULL, __pyx_n_s_mmcv__ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_flow_warp_c, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "mmcv/video/optflow_warp/flow_warp_module.pyx":1 + * STUFF = "Hi" # <<<<<<<<<<<<<< + * + * import numpy as np + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../anaconda3/envs/PySpark-2.3.2/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1021 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init mmcv._ext", 0, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init mmcv._ext"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* ArgTypeTest */ +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(__Pyx_TypeCheck(obj, type))) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +/* IsLittleEndian */ +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) +{ + union { + uint32_t u32; + uint8_t u8[4]; + } S; + S.u32 = 0x01020304; + return S.u8[0] == 4; +} + +/* BufferFormatCheck */ +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; + } + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; + } + case 's': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} + +/* BufferGetAndValidate */ + static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (unlikely(info->buf == NULL)) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} +static void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static int __Pyx__GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + buf->buf = NULL; + if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { + __Pyx_ZeroBuffer(buf); + return -1; + } + if (unlikely(buf->ndim != nd)) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if (unlikely((unsigned)buf->itemsize != dtype->size)) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_SafeReleaseBuffer(buf); + return -1; +} + +/* GetBuiltinName */ + static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* GetModuleGlobalName */ + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); + } +} +#endif + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* GetItemInt */ + static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* PyErrFetchRestore */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseNoneIterError */ + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if PY_VERSION_HEX >= 0x030700A2 + *type = tstate->exc_state.exc_type; + *value = tstate->exc_state.exc_value; + *tb = tstate->exc_state.exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if PY_VERSION_HEX >= 0x030700A2 + tmp_type = tstate->exc_state.exc_type; + tmp_value = tstate->exc_state.exc_value; + tmp_tb = tstate->exc_state.exc_traceback; + tstate->exc_state.exc_type = type; + tstate->exc_state.exc_value = value; + tstate->exc_state.exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if PY_VERSION_HEX >= 0x030700A2 + tmp_type = tstate->exc_state.exc_type; + tmp_value = tstate->exc_state.exc_value; + tmp_tb = tstate->exc_state.exc_traceback; + tstate->exc_state.exc_type = local_type; + tstate->exc_state.exc_value = local_value; + tstate->exc_state.exc_traceback = local_tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* Import */ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* CLineInTraceback */ + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (PyObject_Not(use_cline) != 0) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + if ((0)) {} + else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); + view->obj = NULL; + Py_DECREF(obj); +} +#endif + + + /* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabsf(b.real) >= fabsf(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + float r = b.imag / b.real; + float s = 1.0 / (b.real + b.imag * r); + return __pyx_t_float_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + float r = b.real / b.imag; + float s = 1.0 / (b.imag + b.real * r); + return __pyx_t_float_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + float denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_float_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(a, a); + case 3: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, a); + case 4: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = powf(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2f(0, -1); + } + } else { + r = __Pyx_c_abs_float(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs(b.real) >= fabs(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + double r = b.imag / b.real; + double s = 1.0 / (b.real + b.imag * r); + return __pyx_t_double_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + double r = b.real / b.imag; + double s = 1.0 / (b.imag + b.real * r); + return __pyx_t_double_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + double denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_double_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(a, a); + case 3: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, a); + case 4: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = pow(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2(0, -1); + } + } else { + r = __Pyx_c_abs_double(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(enum NPY_TYPES) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(enum NPY_TYPES) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* ModuleImport */ + #ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + PyErr_Clear(); + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx new file mode 100644 index 000000000..0aca1b6cb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/optflow_warp/flow_warp_module.pyx @@ -0,0 +1,27 @@ +STUFF = "Hi" + +import numpy as np +cimport numpy as np + +np.import_array() + +cdef extern from "flow_warp.hpp": + void FlowWarp(double* img, double* flow1, double* out, const int height, const int width, const int channels, const int filling_value, const int interpolateMode) + +def flow_warp_c(np.ndarray[double, ndim=3, mode="c"] img_array not None, + np.ndarray[double, ndim=3, mode="c"] flow_array not None, + int filling_value=0, + int interpolate_mode=1): + + out_array = np.zeros_like(img_array) + + FlowWarp( np.PyArray_DATA(img_array), + np.PyArray_DATA(flow_array), + np.PyArray_DATA(out_array), + out_array.shape[0], + out_array.shape[1], + out_array.shape[2], + filling_value, + interpolate_mode) + + return out_array diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py new file mode 100644 index 000000000..ca3235482 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py @@ -0,0 +1,159 @@ +import os +import os.path as osp +import subprocess +import tempfile + +from mmcv.utils import requires_executable + + +@requires_executable('ffmpeg') +def convert_video(in_file, out_file, print_cmd=False, pre_options='', + **kwargs): + """Convert a video with ffmpeg. + + This provides a general api to ffmpeg, the executed command is:: + + `ffmpeg -y -i ` + + Options(kwargs) are mapped to ffmpeg commands with the following rules: + + - key=val: "-key val" + - key=True: "-key" + - key=False: "" + + Args: + in_file (str): Input video filename. + out_file (str): Output video filename. + pre_options (str): Options appears before "-i ". + print_cmd (bool): Whether to print the final ffmpeg command. + """ + options = [] + for k, v in kwargs.items(): + if isinstance(v, bool): + if v: + options.append('-{}'.format(k)) + elif k == 'log_level': + assert v in [ + 'quiet', 'panic', 'fatal', 'error', 'warning', 'info', + 'verbose', 'debug', 'trace' + ] + options.append('-loglevel {}'.format(v)) + else: + options.append('-{} {}'.format(k, v)) + cmd = 'ffmpeg -y {} -i {} {} {}'.format(pre_options, in_file, + ' '.join(options), out_file) + if print_cmd: + print(cmd) + subprocess.call(cmd, shell=True) + + +@requires_executable('ffmpeg') +def resize_video(in_file, + out_file, + size=None, + ratio=None, + keep_ar=False, + log_level='info', + print_cmd=False, + **kwargs): + """Resize a video. + + Args: + in_file (str): Input video filename. + out_file (str): Output video filename. + size (tuple): Expected size (w, h), eg, (320, 240) or (320, -1). + ratio (tuple or float): Expected resize ratio, (2, 0.5) means + (w*2, h*0.5). + keep_ar (bool): Whether to keep original aspect ratio. + log_level (str): Logging level of ffmpeg. + print_cmd (bool): Whether to print the final ffmpeg command. + """ + if size is None and ratio is None: + raise ValueError('expected size or ratio must be specified') + elif size is not None and ratio is not None: + raise ValueError('size and ratio cannot be specified at the same time') + options = {'log_level': log_level} + if size: + if not keep_ar: + options['vf'] = 'scale={}:{}'.format(size[0], size[1]) + else: + options['vf'] = ('scale=w={}:h={}:force_original_aspect_ratio' + '=decrease'.format(size[0], size[1])) + else: + if not isinstance(ratio, tuple): + ratio = (ratio, ratio) + options['vf'] = 'scale="trunc(iw*{}):trunc(ih*{})"'.format( + ratio[0], ratio[1]) + convert_video(in_file, out_file, print_cmd, **options) + + +@requires_executable('ffmpeg') +def cut_video(in_file, + out_file, + start=None, + end=None, + vcodec=None, + acodec=None, + log_level='info', + print_cmd=False, + **kwargs): + """Cut a clip from a video. + + Args: + in_file (str): Input video filename. + out_file (str): Output video filename. + start (None or float): Start time (in seconds). + end (None or float): End time (in seconds). + vcodec (None or str): Output video codec, None for unchanged. + acodec (None or str): Output audio codec, None for unchanged. + log_level (str): Logging level of ffmpeg. + print_cmd (bool): Whether to print the final ffmpeg command. + """ + options = {'log_level': log_level} + if vcodec is None: + options['vcodec'] = 'copy' + if acodec is None: + options['acodec'] = 'copy' + if start: + options['ss'] = start + else: + start = 0 + if end: + options['t'] = end - start + convert_video(in_file, out_file, print_cmd, **options) + + +@requires_executable('ffmpeg') +def concat_video(video_list, + out_file, + vcodec=None, + acodec=None, + log_level='info', + print_cmd=False, + **kwargs): + """Concatenate multiple videos into a single one. + + Args: + video_list (list): A list of video filenames + out_file (str): Output video filename + vcodec (None or str): Output video codec, None for unchanged + acodec (None or str): Output audio codec, None for unchanged + log_level (str): Logging level of ffmpeg. + print_cmd (bool): Whether to print the final ffmpeg command. + """ + _, tmp_filename = tempfile.mkstemp(suffix='.txt', text=True) + with open(tmp_filename, 'w') as f: + for filename in video_list: + f.write('file {}\n'.format(osp.abspath(filename))) + options = {'log_level': log_level} + if vcodec is None: + options['vcodec'] = 'copy' + if acodec is None: + options['acodec'] = 'copy' + convert_video( + tmp_filename, + out_file, + print_cmd, + pre_options='-f concat -safe 0', + **options) + os.remove(tmp_filename) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/__init__.py new file mode 100644 index 000000000..f0c06c430 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/__init__.py @@ -0,0 +1,8 @@ +from .color import Color, color_val +from .image import imshow, imshow_bboxes, imshow_det_bboxes +from .optflow import flowshow, flow2rgb, make_color_wheel + +__all__ = [ + 'Color', 'color_val', 'imshow', 'imshow_bboxes', 'imshow_det_bboxes', + 'flowshow', 'flow2rgb', 'make_color_wheel' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/color.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/color.py new file mode 100644 index 000000000..1983a2986 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/color.py @@ -0,0 +1,50 @@ +from enum import Enum + +import numpy as np + +from mmcv.utils import is_str + + +class Color(Enum): + """An enum that defines common colors. + + Contains red, green, blue, cyan, yellow, magenta, white and black. + """ + red = (0, 0, 255) + green = (0, 255, 0) + blue = (255, 0, 0) + cyan = (255, 255, 0) + yellow = (0, 255, 255) + magenta = (255, 0, 255) + white = (255, 255, 255) + black = (0, 0, 0) + + +def color_val(color): + """Convert various input to color tuples. + + Args: + color (:obj:`Color`/str/tuple/int/ndarray): Color inputs + + Returns: + tuple[int]: A tuple of 3 integers indicating BGR channels. + """ + if is_str(color): + return Color[color].value + elif isinstance(color, Color): + return color.value + elif isinstance(color, tuple): + assert len(color) == 3 + for channel in color: + assert channel >= 0 and channel <= 255 + return color + elif isinstance(color, int): + assert color >= 0 and color <= 255 + return color, color, color + elif isinstance(color, np.ndarray): + assert color.ndim == 1 and color.size == 3 + assert np.all((color >= 0) & (color <= 255)) + color = color.astype(np.uint8) + return tuple(color) + else: + raise TypeError('Invalid type for color: {}'.format(type(color))) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/image.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/image.py new file mode 100644 index 000000000..d999662b6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/image.py @@ -0,0 +1,146 @@ +import cv2 +import numpy as np + +from mmcv.image import imread, imwrite +from .color import color_val +import colorsys + +def imshow(img, win_name='', wait_time=0): + """Show an image. + + Args: + img (str or ndarray): The image to be displayed. + win_name (str): The window name. + wait_time (int): Value of waitKey param. + """ + cv2.imshow(win_name, imread(img)) + cv2.waitKey(wait_time) + + +def imshow_bboxes(img, + bboxes, + colors='green', + top_k=-1, + thickness=1, + show=True, + win_name='', + wait_time=0, + out_file=None): + """Draw bboxes on an image. + + Args: + img (str or ndarray): The image to be displayed. + bboxes (list or ndarray): A list of ndarray of shape (k, 4). + colors (list[str or tuple or Color]): A list of colors. + top_k (int): Plot the first k bboxes only if set positive. + thickness (int): Thickness of lines. + show (bool): Whether to show the image. + win_name (str): The window name. + wait_time (int): Value of waitKey param. + out_file (str, optional): The filename to write the image. + """ + img = imread(img) + + if isinstance(bboxes, np.ndarray): + bboxes = [bboxes] + if not isinstance(colors, list): + colors = [colors for _ in range(len(bboxes))] + colors = [color_val(c) for c in colors] + assert len(bboxes) == len(colors) + + for i, _bboxes in enumerate(bboxes): + _bboxes = _bboxes.astype(np.int32) + if top_k <= 0: + _top_k = _bboxes.shape[0] + else: + _top_k = min(top_k, _bboxes.shape[0]) + for j in range(_top_k): + left_top = (_bboxes[j, 0], _bboxes[j, 1]) + right_bottom = (_bboxes[j, 2], _bboxes[j, 3]) + cv2.rectangle( + img, left_top, right_bottom, colors[i], thickness=thickness) + + if show: + imshow(img, win_name, wait_time) + if out_file is not None: + imwrite(img, out_file) + + +def random_colors(N, bright=False): + """ + Generate random colors. + To get visually distinct colors, generate them in HSV space then + convert to RGB. + """ + brightness = 1.0 if bright else 0.7 + hsv = [(i / N, 1, brightness) for i in range(N)] + colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv)) + return colors + + +def imshow_det_bboxes(img, + bboxes, + labels, + class_names=None, + score_thr=0, + bbox_color='green', + text_color='green', + thickness=3, + font_scale=0.8, + show=True, + win_name='', + wait_time=0, + out_file=None): + """Draw bboxes and class labels (with scores) on an image. + + Args: + img (str or ndarray): The image to be displayed. + bboxes (ndarray): Bounding boxes (with scores), shaped (n, 4) or + (n, 5). + labels (ndarray): Labels of bboxes. + class_names (list[str]): Names of each classes. + score_thr (float): Minimum score of bboxes to be shown. + bbox_color (str or tuple or :obj:`Color`): Color of bbox lines. + text_color (str or tuple or :obj:`Color`): Color of texts. + thickness (int): Thickness of lines. + font_scale (float): Font scales of texts. + show (bool): Whether to show the image. + win_name (str): The window name. + wait_time (int): Value of waitKey param. + out_file (str or None): The filename to write the image. + """ + assert bboxes.ndim == 2 + assert labels.ndim == 1 + assert bboxes.shape[0] == labels.shape[0] + assert bboxes.shape[1] == 4 or bboxes.shape[1] == 5 + img = imread(img) + + if score_thr > 0: + assert bboxes.shape[1] == 5 + scores = bboxes[:, -1] + inds = scores > score_thr + bboxes = bboxes[inds, :] + labels = labels[inds] + + bbox_color = random_colors(80) # color_val(bbox_color) + text_color = random_colors(80) # color_val(text_color) + + for bbox, label in zip(bboxes, labels): + bbox_int = bbox.astype(np.int32) + left_top = (bbox_int[0], bbox_int[1]) + right_bottom = (bbox_int[2], bbox_int[3]) + tmp_bbox_color = bbox_color[label] + tmp_bbox_color = (int(tmp_bbox_color[2]*255), int(tmp_bbox_color[1]*255), int(tmp_bbox_color[0]*255)) + cv2.rectangle( + img, left_top, right_bottom, tmp_bbox_color, thickness=thickness) + label_text = class_names[ + label] if class_names is not None else 'cls {}'.format(label) + if len(bbox) > 4: + label_text += '|{:.02f}'.format(bbox[-1]) + cv2.putText(img, label_text, (bbox_int[0], bbox_int[1] - 2), + cv2.FONT_HERSHEY_COMPLEX, font_scale, tmp_bbox_color) + + if show: + imshow(img, win_name, wait_time) + if out_file is not None: + imwrite(img, out_file) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py new file mode 100644 index 000000000..0068a742d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmcv/visualization/optflow.py @@ -0,0 +1,113 @@ +from __future__ import division + +import numpy as np + +from mmcv.image import rgb2bgr +from mmcv.video import flowread +from .image import imshow + + +def flowshow(flow, win_name='', wait_time=0): + """Show optical flow. + + Args: + flow (ndarray or str): The optical flow to be displayed. + win_name (str): The window name. + wait_time (int): Value of waitKey param. + """ + flow = flowread(flow) + flow_img = flow2rgb(flow) + imshow(rgb2bgr(flow_img), win_name, wait_time) + + +def flow2rgb(flow, color_wheel=None, unknown_thr=1e6): + """Convert flow map to RGB image. + + Args: + flow (ndarray): Array of optical flow. + color_wheel (ndarray or None): Color wheel used to map flow field to + RGB colorspace. Default color wheel will be used if not specified. + unknown_thr (str): Values above this threshold will be marked as + unknown and thus ignored. + + Returns: + ndarray: RGB image that can be visualized. + """ + assert flow.ndim == 3 and flow.shape[-1] == 2 + if color_wheel is None: + color_wheel = make_color_wheel() + assert color_wheel.ndim == 2 and color_wheel.shape[1] == 3 + num_bins = color_wheel.shape[0] + + dx = flow[:, :, 0].copy() + dy = flow[:, :, 1].copy() + + ignore_inds = ( + np.isnan(dx) | np.isnan(dy) | (np.abs(dx) > unknown_thr) | + (np.abs(dy) > unknown_thr)) + dx[ignore_inds] = 0 + dy[ignore_inds] = 0 + + rad = np.sqrt(dx**2 + dy**2) + if np.any(rad > np.finfo(float).eps): + max_rad = np.max(rad) + dx /= max_rad + dy /= max_rad + + [h, w] = dx.shape + + rad = np.sqrt(dx**2 + dy**2) + angle = np.arctan2(-dy, -dx) / np.pi + + bin_real = (angle + 1) / 2 * (num_bins - 1) + bin_left = np.floor(bin_real).astype(int) + bin_right = (bin_left + 1) % num_bins + w = (bin_real - bin_left.astype(np.float32))[..., None] + flow_img = (1 - + w) * color_wheel[bin_left, :] + w * color_wheel[bin_right, :] + small_ind = rad <= 1 + flow_img[small_ind] = 1 - rad[small_ind, None] * (1 - flow_img[small_ind]) + flow_img[np.logical_not(small_ind)] *= 0.75 + + flow_img[ignore_inds, :] = 0 + + return flow_img + + +def make_color_wheel(bins=None): + """Build a color wheel. + + Args: + bins(list or tuple, optional): Specify the number of bins for each + color range, corresponding to six ranges: red -> yellow, + yellow -> green, green -> cyan, cyan -> blue, blue -> magenta, + magenta -> red. [15, 6, 4, 11, 13, 6] is used for default + (see Middlebury). + + Returns: + ndarray: Color wheel of shape (total_bins, 3). + """ + if bins is None: + bins = [15, 6, 4, 11, 13, 6] + assert len(bins) == 6 + + RY, YG, GC, CB, BM, MR = tuple(bins) + + ry = [1, np.arange(RY) / RY, 0] + yg = [1 - np.arange(YG) / YG, 1, 0] + gc = [0, 1, np.arange(GC) / GC] + cb = [0, 1 - np.arange(CB) / CB, 1] + bm = [np.arange(BM) / BM, 0, 1] + mr = [1, 0, 1 - np.arange(MR) / MR] + + num_bins = RY + YG + GC + CB + BM + MR + + color_wheel = np.zeros((3, num_bins), dtype=np.float32) + + col = 0 + for i, color in enumerate([ry, yg, gc, cb, bm, mr]): + for j in range(3): + color_wheel[j, col:col + bins[i]] = color[j] + col += bins[i] + + return color_wheel.T diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/__init__.py new file mode 100644 index 000000000..1c4f7e8fc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/__init__.py @@ -0,0 +1,3 @@ +from .version import __version__, short_version + +__all__ = ['__version__', 'short_version'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/__init__.py new file mode 100644 index 000000000..f85c7af68 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/__init__.py @@ -0,0 +1,9 @@ +from .env import get_root_logger, init_dist, set_random_seed +from .inference import (inference_detector, init_detector, show_result, + show_result_pyplot) +from .train import train_detector + +__all__ = [ + 'init_dist', 'get_root_logger', 'set_random_seed', 'train_detector', + 'init_detector', 'inference_detector', 'show_result', 'show_result_pyplot' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/env.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/env.py new file mode 100644 index 000000000..19b0f86db --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/env.py @@ -0,0 +1,69 @@ +import logging +import os +import random +import subprocess + +import numpy as np +import torch +import torch.distributed as dist +import torch.multiprocessing as mp +from mmcv.runner import get_dist_info + + +def init_dist(launcher, backend='nccl', **kwargs): + if mp.get_start_method(allow_none=True) is None: + mp.set_start_method('spawn') + if launcher == 'pytorch': + _init_dist_pytorch(backend, **kwargs) + elif launcher == 'mpi': + _init_dist_mpi(backend, **kwargs) + elif launcher == 'slurm': + _init_dist_slurm(backend, **kwargs) + else: + raise ValueError('Invalid launcher type: {}'.format(launcher)) + + +def _init_dist_pytorch(backend, **kwargs): + # TODO: use local_rank instead of rank % num_gpus + rank = int(os.environ['RANK']) + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(rank % num_gpus) + dist.init_process_group(backend=backend, **kwargs) + + +def _init_dist_mpi(backend, **kwargs): + raise NotImplementedError + + +def _init_dist_slurm(backend, port=29500, **kwargs): + proc_id = int(os.environ['SLURM_PROCID']) + ntasks = int(os.environ['SLURM_NTASKS']) + node_list = os.environ['SLURM_NODELIST'] + num_gpus = torch.cuda.device_count() + torch.cuda.set_device(proc_id % num_gpus) + addr = subprocess.getoutput( + 'scontrol show hostname {} | head -n1'.format(node_list)) + os.environ['MASTER_PORT'] = str(port) + os.environ['MASTER_ADDR'] = addr + os.environ['WORLD_SIZE'] = str(ntasks) + os.environ['RANK'] = str(proc_id) + dist.init_process_group(backend=backend) + + +def set_random_seed(seed): + random.seed(seed) + np.random.seed(seed) + torch.manual_seed(seed) + torch.cuda.manual_seed_all(seed) + + +def get_root_logger(log_level=logging.INFO): + logger = logging.getLogger() + if not logger.hasHandlers(): + logging.basicConfig( + format='%(asctime)s - %(levelname)s - %(message)s', + level=log_level) + rank, _ = get_dist_info() + if rank != 0: + logger.setLevel('ERROR') + return logger diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/inference.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/inference.py new file mode 100644 index 000000000..d921ba47d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/inference.py @@ -0,0 +1,171 @@ +import warnings + +import matplotlib.pyplot as plt +import mmcv +import numpy as np +import pycocotools.mask as maskUtils +import torch +from mmcv.parallel import collate, scatter +from mmcv.runner import load_checkpoint + +from mmdet.core import get_classes +from mmdet.datasets.pipelines import Compose +from mmdet.models import build_detector + + +def init_detector(config, checkpoint=None, device='cuda:0'): + """Initialize a detector from config file. + + Args: + config (str or :obj:`mmcv.Config`): Config file path or the config + object. + checkpoint (str, optional): Checkpoint path. If left as None, the model + will not load any weights. + + Returns: + nn.Module: The constructed detector. + """ + if isinstance(config, str): + config = mmcv.Config.fromfile(config) + elif not isinstance(config, mmcv.Config): + raise TypeError('config must be a filename or Config object, ' + 'but got {}'.format(type(config))) + config.model.pretrained = None + model = build_detector(config.model, test_cfg=config.test_cfg) + if checkpoint is not None: + checkpoint = load_checkpoint(model, checkpoint) + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + warnings.warn('Class names are not saved in the checkpoint\'s ' + 'meta data, use COCO classes by default.') + model.CLASSES = get_classes('coco') + model.cfg = config # save the config in the model for convenience + model.to(device) + model.eval() + return model + + +class LoadImage(object): + + def __call__(self, results): + if isinstance(results['img'], str): + results['filename'] = results['img'] + else: + results['filename'] = None + img = mmcv.imread(results['img']) + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + return results + + +def inference_detector(model, img): + """Inference image(s) with the detector. + + Args: + model (nn.Module): The loaded detector. + imgs (str/ndarray or list[str/ndarray]): Either image files or loaded + images. + + Returns: + If imgs is a str, a generator will be returned, otherwise return the + detection results directly. + """ + cfg = model.cfg + device = next(model.parameters()).device # model device + # build the data pipeline + test_pipeline = [LoadImage()] + cfg.data.test.pipeline[1:] + test_pipeline = Compose(test_pipeline) + # prepare data + data = dict(img=img) + data = test_pipeline(data) + data = scatter(collate([data], samples_per_gpu=1), [device])[0] + # forward the model + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + + return result + + +# TODO: merge this method with the one in BaseDetector +def show_result(img, + result, + class_names, + score_thr=0.3, + wait_time=0, + show=True, + out_file=None): + """Visualize the detection results on the image. + + Args: + img (str or np.ndarray): Image filename or loaded image. + result (tuple[list] or list): The detection result, can be either + (bbox, segm) or just bbox. + class_names (list[str] or tuple[str]): A list of class names. + score_thr (float): The threshold to visualize the bboxes and masks. + wait_time (int): Value of waitKey param. + show (bool, optional): Whether to show the image with opencv or not. + out_file (str, optional): If specified, the visualization result will + be written to the out file instead of shown in a window. + + Returns: + np.ndarray or None: If neither `show` nor `out_file` is specified, the + visualized image is returned, otherwise None is returned. + """ + assert isinstance(class_names, (tuple, list)) + img = mmcv.imread(img) + img = img.copy() + if isinstance(result, tuple): + bbox_result, segm_result = result + else: + bbox_result, segm_result = result, None + bboxes = np.vstack(bbox_result) + # draw segmentation masks + if segm_result is not None: + segms = mmcv.concat_list(segm_result) + inds = np.where(bboxes[:, -1] > score_thr)[0] + for i in inds: + color_mask = np.random.randint(0, 256, (1, 3), dtype=np.uint8) + mask = maskUtils.decode(segms[i]).astype(np.bool) + img[mask] = img[mask] * 0.5 + color_mask * 0.5 + # draw bounding boxes + labels = [ + np.full(bbox.shape[0], i, dtype=np.int32) + for i, bbox in enumerate(bbox_result) + ] + labels = np.concatenate(labels) + mmcv.imshow_det_bboxes( + img, + bboxes, + labels, + class_names=class_names, + score_thr=score_thr, + show=show, + wait_time=wait_time, + out_file=out_file) + if not (show or out_file): + return img + + +def show_result_pyplot(img, + result, + class_names, + score_thr=0.3, + fig_size=(15, 10)): + """Visualize the detection results on the image. + + Args: + img (str or np.ndarray): Image filename or loaded image. + result (tuple[list] or list): The detection result, can be either + (bbox, segm) or just bbox. + class_names (list[str] or tuple[str]): A list of class names. + score_thr (float): The threshold to visualize the bboxes and masks. + fig_size (tuple): Figure size of the pyplot figure. + out_file (str, optional): If specified, the visualization result will + be written to the out file instead of shown in a window. + """ + img = show_result( + img, result, class_names, score_thr=score_thr, show=False) + plt.figure(figsize=fig_size) + plt.imshow(mmcv.bgr2rgb(img)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py new file mode 100644 index 000000000..8fcba8fb9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/apis/train.py @@ -0,0 +1,256 @@ +from __future__ import division +import re +from collections import OrderedDict + +import torch +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import Runner, DistSamplerSeedHook, obj_from_dict + +from mmdet import datasets +from mmdet.core import (DistEvalHook, DistOptimizerHook, + DistOptimizerArchHook, Fp16OptimizerHook) +from mmdet.datasets import DATASETS, build_dataloader, build_dataloader_arch +from mmdet.models import RPN +from .env import get_root_logger + + +def parse_losses(losses): + log_vars = OrderedDict() + for loss_name, loss_value in losses.items(): + if isinstance(loss_value, torch.Tensor): + log_vars[loss_name] = loss_value.mean() + elif isinstance(loss_value, list): + log_vars[loss_name] = sum(_loss.mean() for _loss in loss_value) + else: + raise TypeError( + '{} is not a tensor or list of tensors'.format(loss_name)) + + loss = sum(_value for _key, _value in log_vars.items() if 'loss' in _key) + + log_vars['loss'] = loss + for name in log_vars: + log_vars[name] = log_vars[name].item() + + return loss, log_vars + + +def batch_processor(model, data, train_mode, **kwargs): + losses = model(**data) + + losses_ = losses[0] + loss_latency = losses[1] + if loss_latency is not None: + losses_['loss_latency'] = loss_latency + + loss, log_vars = parse_losses(losses_) + + outputs = dict( + loss=loss, log_vars=log_vars, num_samples=len(data['img'].data)) + + return outputs + + +def train_detector(model, + dataset, + cfg, + distributed=False, + validate=False, + logger=None): + if logger is None: + logger = get_root_logger(cfg.log_level) + + # start training + if distributed: + _dist_train(model, dataset, cfg, validate=validate) + else: + _non_dist_train(model, dataset, cfg, validate=validate) + + +def build_optimizer(model, optimizer_cfg, optimizer_exclude_arch): + """Build optimizer from configs. + + Args: + model (:obj:`nn.Module`): The model with parameters to be optimized. + optimizer_cfg (dict): The config dict of the optimizer. + Positional fields are: + - type: class name of the optimizer. + - lr: base learning rate. + Optional fields are: + - any arguments of the corresponding optimizer type, e.g., + weight_decay, momentum, etc. + - paramwise_options: a dict with 3 accepted fileds + (bias_lr_mult, bias_decay_mult, norm_decay_mult). + `bias_lr_mult` and `bias_decay_mult` will be multiplied to + the lr and weight decay respectively for all bias parameters + (except for the normalization layers), and + `norm_decay_mult` will be multiplied to the weight decay + for all weight and bias parameters of normalization layers. + + Returns: + torch.optim.Optimizer: The initialized optimizer. + + Example: + >>> model = torch.nn.modules.Conv1d(1, 1, 1) + >>> optimizer_cfg = dict(type='SGD', lr=0.01, momentum=0.9, + >>> weight_decay=0.0001) + >>> optimizer = build_optimizer(model, optimizer_cfg) + """ + if hasattr(model, 'module'): + model = model.module + if hasattr(model, 'module'): # For distributed model + model = model.module + + optimizer_cfg = optimizer_cfg.copy() + paramwise_options = optimizer_cfg.pop('paramwise_options', None) + # if no paramwise option is specified, just use the global setting + if paramwise_options is None: + if not optimizer_exclude_arch: + params = model.parameters() + else: + params = [p for n, p in model.named_parameters() if 'alpha' not in n] + + return obj_from_dict(optimizer_cfg, torch.optim, dict(params=params)) + else: + assert isinstance(paramwise_options, dict) + # get base lr and weight decay + base_lr = optimizer_cfg['lr'] + base_wd = optimizer_cfg.get('weight_decay', None) + # weight_decay must be explicitly specified if mult is specified + if ('bias_decay_mult' in paramwise_options + or 'norm_decay_mult' in paramwise_options): + assert base_wd is not None + # get param-wise options + bias_lr_mult = paramwise_options.get('bias_lr_mult', 1.) + bias_decay_mult = paramwise_options.get('bias_decay_mult', 1.) + norm_decay_mult = paramwise_options.get('norm_decay_mult', 1.) + offset_lr_mult = paramwise_options.get('bias_decay_mult', 1.) # Noted by Jianyuan, for offset lr + # set param-wise lr and weight decay + params = [] + for name, param in model.named_parameters(): + param_group = {'params': [param]} + if not param.requires_grad: + # FP16 training needs to copy gradient/weight between master + # weight copy and model weight, it is convenient to keep all + # parameters here to align with model.parameters() + params.append(param_group) + continue + # Noted by Jianyuan, for huang lang offset + if 'offset' in name: + param_group['lr'] = base_lr * offset_lr_mult + + # for norm layers, overwrite the weight decay of weight and bias + # TODO: obtain the norm layer prefixes dynamically + if re.search(r'(bn|gn)(\d+)?.(weight|bias)', name): + if base_wd is not None: + param_group['weight_decay'] = base_wd * norm_decay_mult + # for other layers, overwrite both lr and weight decay of bias + elif name.endswith('.bias'): + param_group['lr'] = base_lr * bias_lr_mult + if base_wd is not None: + param_group['weight_decay'] = base_wd * bias_decay_mult + # otherwise use the global settings + + params.append(param_group) + + optimizer_cls = getattr(torch.optim, optimizer_cfg.pop('type')) + return optimizer_cls(params, **optimizer_cfg) + + +def _dist_train(model, dataset, cfg, validate=False): + # put model on gpus + model = MMDistributedDataParallel(model.cuda()) + + # build runner + optimizer = build_optimizer(model, cfg.optimizer, cfg.get('optimizer_exclude_arch')) + + arch_name = None + optimizer_arch = None + if 'optimizer_arch' in cfg: + raise NotImplementedError + + runner = Runner(model, batch_processor, optimizer, optimizer_arch, cfg.work_dir, cfg.log_level, arch_name=arch_name) + + # fp16 setting + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + optimizer_config = Fp16OptimizerHook(**cfg.optimizer_config, + **fp16_cfg) + else: + optimizer_config = DistOptimizerHook(**cfg.optimizer_config) + optimizer_arch_config = DistOptimizerArchHook(**cfg.optimizer_config) + + # register hooks + runner.register_training_hooks(cfg.lr_config, optimizer_config, optimizer_arch_config, + cfg.checkpoint_config, cfg.log_config) + runner.register_hook(DistSamplerSeedHook()) + # register eval hooks + if validate: + val_dataset_cfg = cfg.data.val + eval_cfg = cfg.get('evaluation', {}) + runner.register_hook(DistEvalHook(val_dataset_cfg, **eval_cfg)) + + if cfg.resume_from: + runner.resume(cfg.resume_from) + elif cfg.load_from: + runner.load_checkpoint(cfg.load_from) + + if 'optimizer_arch' in cfg: + raise NotImplementedError + else: + data_loaders = [ + build_dataloader( + dataset, + cfg.data.imgs_per_gpu, + cfg.data.workers_per_gpu, + dist=True) + ] + runner.run(data_loaders, None, cfg.workflow, cfg.total_epochs) + + +def _non_dist_train(model, dataset, cfg, validate=False): + if validate: + raise NotImplementedError('Built-in validation is not implemented ' + 'yet in not-distributed training. Use ' + 'distributed training or test.py and ' + '*eval.py scripts instead.') + # put model on gpus + model = MMDataParallel(model, device_ids=range(cfg.gpus)).cuda() + + # build runner + optimizer = build_optimizer(model, cfg.optimizer, cfg.get('optimizer_exclude_arch')) + + arch_name = None + optimizer_arch = None + if 'optimizer_arch' in cfg: + raise NotImplementedError + + runner = Runner(model, batch_processor, optimizer, optimizer_arch, cfg.work_dir, cfg.log_level, arch_name=arch_name) + + # fp16 setting + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + optimizer_config = Fp16OptimizerHook( + **cfg.optimizer_config, **fp16_cfg, distributed=False) + else: + optimizer_config = cfg.optimizer_config + optimizer_arch_config = cfg.optimizer_config + runner.register_training_hooks(cfg.lr_config, optimizer_config, optimizer_arch_config, + cfg.checkpoint_config, cfg.log_config) + + if cfg.resume_from: + runner.resume(cfg.resume_from) + elif cfg.load_from: + runner.load_checkpoint(cfg.load_from) + + if 'optimizer_arch' in cfg: + raise NotImplementedError + else: + data_loaders = [ + build_dataloader( + dataset, + cfg.data.imgs_per_gpu, + cfg.data.workers_per_gpu, + cfg.gpus, + dist=False) + ] + runner.run(data_loaders, None, cfg.workflow, cfg.total_epochs) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py new file mode 100644 index 000000000..f8eb6cba5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py @@ -0,0 +1,7 @@ +from .anchor import * # noqa: F401, F403 +from .bbox import * # noqa: F401, F403 +from .evaluation import * # noqa: F401, F403 +from .fp16 import * # noqa: F401, F403 +from .mask import * # noqa: F401, F403 +from .post_processing import * # noqa: F401, F403 +from .utils import * # noqa: F401, F403 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/__init__.py new file mode 100644 index 000000000..304d4938a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/__init__.py @@ -0,0 +1,8 @@ +from .anchor_generator import AnchorGenerator +from .anchor_target import anchor_target, anchor_inside_flags +from .guided_anchor_target import ga_loc_target, ga_shape_target + +__all__ = [ + 'AnchorGenerator', 'anchor_target', 'anchor_inside_flags', 'ga_loc_target', + 'ga_shape_target' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_generator.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_generator.py new file mode 100644 index 000000000..8995ea61d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_generator.py @@ -0,0 +1,84 @@ +import torch + + +class AnchorGenerator(object): + + def __init__(self, base_size, scales, ratios, scale_major=True, ctr=None): + self.base_size = base_size + self.scales = torch.Tensor(scales) + self.ratios = torch.Tensor(ratios) + self.scale_major = scale_major + self.ctr = ctr + self.base_anchors = self.gen_base_anchors() + + @property + def num_base_anchors(self): + return self.base_anchors.size(0) + + def gen_base_anchors(self): + w = self.base_size + h = self.base_size + if self.ctr is None: + x_ctr = 0.5 * (w - 1) + y_ctr = 0.5 * (h - 1) + else: + x_ctr, y_ctr = self.ctr + + h_ratios = torch.sqrt(self.ratios) + w_ratios = 1 / h_ratios + if self.scale_major: + ws = (w * w_ratios[:, None] * self.scales[None, :]).view(-1) + hs = (h * h_ratios[:, None] * self.scales[None, :]).view(-1) + else: + ws = (w * self.scales[:, None] * w_ratios[None, :]).view(-1) + hs = (h * self.scales[:, None] * h_ratios[None, :]).view(-1) + + base_anchors = torch.stack( + [ + x_ctr - 0.5 * (ws - 1), y_ctr - 0.5 * (hs - 1), + x_ctr + 0.5 * (ws - 1), y_ctr + 0.5 * (hs - 1) + ], + dim=-1).round() + + return base_anchors + + def _meshgrid(self, x, y, row_major=True): + xx = x.repeat(len(y)) + yy = y.view(-1, 1).repeat(1, len(x)).view(-1) + if row_major: + return xx, yy + else: + return yy, xx + + def grid_anchors(self, featmap_size, stride=16, device='cuda'): + base_anchors = self.base_anchors.to(device) + + feat_h, feat_w = featmap_size + shift_x = torch.arange(0, feat_w, device=device) * stride + shift_y = torch.arange(0, feat_h, device=device) * stride + shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) + shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1) + shifts = shifts.type_as(base_anchors) + # first feat_w elements correspond to the first row of shifts + # add A anchors (1, A, 4) to K shifts (K, 1, 4) to get + # shifted anchors (K, A, 4), reshape to (K*A, 4) + + all_anchors = base_anchors[None, :, :] + shifts[:, None, :] + all_anchors = all_anchors.view(-1, 4) + # first A rows correspond to A anchors of (0, 0) in feature map, + # then (0, 1), (0, 2), ... + return all_anchors + + def valid_flags(self, featmap_size, valid_size, device='cuda'): + feat_h, feat_w = featmap_size + valid_h, valid_w = valid_size + assert valid_h <= feat_h and valid_w <= feat_w + valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) + valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) + valid_x[:valid_w] = 1 + valid_y[:valid_h] = 1 + valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) + valid = valid_xx & valid_yy + valid = valid[:, None].expand( + valid.size(0), self.num_base_anchors).contiguous().view(-1) + return valid diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_target.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_target.py new file mode 100644 index 000000000..60c902eaa --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/anchor_target.py @@ -0,0 +1,186 @@ +import torch + +from ..bbox import assign_and_sample, build_assigner, PseudoSampler, bbox2delta +from ..utils import multi_apply + + +def anchor_target(anchor_list, + valid_flag_list, + gt_bboxes_list, + img_metas, + target_means, + target_stds, + cfg, + gt_bboxes_ignore_list=None, + gt_labels_list=None, + label_channels=1, + sampling=True, + unmap_outputs=True): + """Compute regression and classification targets for anchors. + + Args: + anchor_list (list[list]): Multi level anchors of each image. + valid_flag_list (list[list]): Multi level valid flags of each image. + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + target_means (Iterable): Mean value of regression targets. + target_stds (Iterable): Std value of regression targets. + cfg (dict): RPN train configs. + + Returns: + tuple + """ + num_imgs = len(img_metas) + assert len(anchor_list) == len(valid_flag_list) == num_imgs + + # anchor number of multi levels + num_level_anchors = [anchors.size(0) for anchors in anchor_list[0]] + # concat all level anchors and flags to a single tensor + for i in range(num_imgs): + assert len(anchor_list[i]) == len(valid_flag_list[i]) + anchor_list[i] = torch.cat(anchor_list[i]) + valid_flag_list[i] = torch.cat(valid_flag_list[i]) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + if gt_labels_list is None: + gt_labels_list = [None for _ in range(num_imgs)] + (all_labels, all_label_weights, all_bbox_targets, all_bbox_weights, + pos_inds_list, neg_inds_list) = multi_apply( + anchor_target_single, + anchor_list, + valid_flag_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + gt_labels_list, + img_metas, + target_means=target_means, + target_stds=target_stds, + cfg=cfg, + label_channels=label_channels, + sampling=sampling, + unmap_outputs=unmap_outputs) + # no valid anchors + if any([labels is None for labels in all_labels]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + labels_list = images_to_levels(all_labels, num_level_anchors) + label_weights_list = images_to_levels(all_label_weights, num_level_anchors) + bbox_targets_list = images_to_levels(all_bbox_targets, num_level_anchors) + bbox_weights_list = images_to_levels(all_bbox_weights, num_level_anchors) + return (labels_list, label_weights_list, bbox_targets_list, + bbox_weights_list, num_total_pos, num_total_neg) + + +def images_to_levels(target, num_level_anchors): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_level_anchors: + end = start + n + level_targets.append(target[:, start:end].squeeze(0)) + start = end + return level_targets + + +def anchor_target_single(flat_anchors, + valid_flags, + gt_bboxes, + gt_bboxes_ignore, + gt_labels, + img_meta, + target_means, + target_stds, + cfg, + label_channels=1, + sampling=True, + unmap_outputs=True): + inside_flags = anchor_inside_flags(flat_anchors, valid_flags, + img_meta['img_shape'][:2], + cfg.allowed_border) + if not inside_flags.any(): + return (None, ) * 6 + # assign gt and sample anchors + anchors = flat_anchors[inside_flags, :] + + if sampling: + assign_result, sampling_result = assign_and_sample( + anchors, gt_bboxes, gt_bboxes_ignore, None, cfg) + else: + bbox_assigner = build_assigner(cfg.assigner) + assign_result = bbox_assigner.assign(anchors, gt_bboxes, + gt_bboxes_ignore, gt_labels) + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, anchors, + gt_bboxes) + + num_valid_anchors = anchors.shape[0] + bbox_targets = torch.zeros_like(anchors) + bbox_weights = torch.zeros_like(anchors) + labels = anchors.new_zeros(num_valid_anchors, dtype=torch.long) + label_weights = anchors.new_zeros(num_valid_anchors, dtype=torch.float) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + pos_bbox_targets = bbox2delta(sampling_result.pos_bboxes, + sampling_result.pos_gt_bboxes, + target_means, target_stds) + bbox_targets[pos_inds, :] = pos_bbox_targets + bbox_weights[pos_inds, :] = 1.0 + if gt_labels is None: + labels[pos_inds] = 1 + else: + labels[pos_inds] = gt_labels[sampling_result.pos_assigned_gt_inds] + if cfg.pos_weight <= 0: + label_weights[pos_inds] = 1.0 + else: + label_weights[pos_inds] = cfg.pos_weight + if len(neg_inds) > 0: + label_weights[neg_inds] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_anchors.size(0) + labels = unmap(labels, num_total_anchors, inside_flags) + label_weights = unmap(label_weights, num_total_anchors, inside_flags) + bbox_targets = unmap(bbox_targets, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (labels, label_weights, bbox_targets, bbox_weights, pos_inds, + neg_inds) + + +def anchor_inside_flags(flat_anchors, valid_flags, img_shape, + allowed_border=0): + img_h, img_w = img_shape[:2] + if allowed_border >= 0: + inside_flags = valid_flags & \ + (flat_anchors[:, 0] >= -allowed_border) & \ + (flat_anchors[:, 1] >= -allowed_border) & \ + (flat_anchors[:, 2] < img_w + allowed_border) & \ + (flat_anchors[:, 3] < img_h + allowed_border) + else: + inside_flags = valid_flags + return inside_flags + + +def unmap(data, count, inds, fill=0): + """ Unmap a subset of item (data) back to the original set of items (of + size count) """ + if data.dim() == 1: + ret = data.new_full((count, ), fill) + ret[inds] = data + else: + new_size = (count, ) + data.size()[1:] + ret = data.new_full(new_size, fill) + ret[inds, :] = data + return ret diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py new file mode 100644 index 000000000..2e9540644 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/anchor/guided_anchor_target.py @@ -0,0 +1,285 @@ +import torch + +from ..bbox import build_assigner, build_sampler, PseudoSampler +from ..utils import unmap, multi_apply + + +def calc_region(bbox, ratio, featmap_size=None): + """Calculate a proportional bbox region. + + The bbox center are fixed and the new h' and w' is h * ratio and w * ratio. + + Args: + bbox (Tensor): Bboxes to calculate regions, shape (n, 4) + ratio (float): Ratio of the output region. + featmap_size (tuple): Feature map size used for clipping the boundary. + + Returns: + tuple: x1, y1, x2, y2 + """ + x1 = torch.round((1 - ratio) * bbox[0] + ratio * bbox[2]).long() + y1 = torch.round((1 - ratio) * bbox[1] + ratio * bbox[3]).long() + x2 = torch.round(ratio * bbox[0] + (1 - ratio) * bbox[2]).long() + y2 = torch.round(ratio * bbox[1] + (1 - ratio) * bbox[3]).long() + if featmap_size is not None: + x1 = x1.clamp(min=0, max=featmap_size[1] - 1) + y1 = y1.clamp(min=0, max=featmap_size[0] - 1) + x2 = x2.clamp(min=0, max=featmap_size[1] - 1) + y2 = y2.clamp(min=0, max=featmap_size[0] - 1) + return (x1, y1, x2, y2) + + +def ga_loc_target(gt_bboxes_list, + featmap_sizes, + anchor_scale, + anchor_strides, + center_ratio=0.2, + ignore_ratio=0.5): + """Compute location targets for guided anchoring. + + Each feature map is divided into positive, negative and ignore regions. + - positive regions: target 1, weight 1 + - ignore regions: target 0, weight 0 + - negative regions: target 0, weight 0.1 + + Args: + gt_bboxes_list (list[Tensor]): Gt bboxes of each image. + featmap_sizes (list[tuple]): Multi level sizes of each feature maps. + anchor_scale (int): Anchor scale. + anchor_strides ([list[int]]): Multi level anchor strides. + center_ratio (float): Ratio of center region. + ignore_ratio (float): Ratio of ignore region. + + Returns: + tuple + """ + img_per_gpu = len(gt_bboxes_list) + num_lvls = len(featmap_sizes) + r1 = (1 - center_ratio) / 2 + r2 = (1 - ignore_ratio) / 2 + all_loc_targets = [] + all_loc_weights = [] + all_ignore_map = [] + for lvl_id in range(num_lvls): + h, w = featmap_sizes[lvl_id] + loc_targets = torch.zeros(img_per_gpu, + 1, + h, + w, + device=gt_bboxes_list[0].device, + dtype=torch.float32) + loc_weights = torch.full_like(loc_targets, -1) + ignore_map = torch.zeros_like(loc_targets) + all_loc_targets.append(loc_targets) + all_loc_weights.append(loc_weights) + all_ignore_map.append(ignore_map) + for img_id in range(img_per_gpu): + gt_bboxes = gt_bboxes_list[img_id] + scale = torch.sqrt((gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * + (gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1)) + min_anchor_size = scale.new_full( + (1, ), float(anchor_scale * anchor_strides[0])) + # assign gt bboxes to different feature levels w.r.t. their scales + target_lvls = torch.floor( + torch.log2(scale) - torch.log2(min_anchor_size) + 0.5) + target_lvls = target_lvls.clamp(min=0, max=num_lvls - 1).long() + for gt_id in range(gt_bboxes.size(0)): + lvl = target_lvls[gt_id].item() + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[lvl] + # calculate ignore regions + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[lvl]) + # calculate positive (center) regions + ctr_x1, ctr_y1, ctr_x2, ctr_y2 = calc_region( + gt_, r1, featmap_sizes[lvl]) + all_loc_targets[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, ctr_x1:ctr_x2 + + 1] = 1 + all_loc_weights[lvl][img_id, 0, ignore_y1:ignore_y2 + + 1, ignore_x1:ignore_x2 + 1] = 0 + all_loc_weights[lvl][img_id, 0, ctr_y1:ctr_y2 + 1, ctr_x1:ctr_x2 + + 1] = 1 + # calculate ignore map on nearby low level feature + if lvl > 0: + d_lvl = lvl - 1 + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[d_lvl] + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[d_lvl]) + all_ignore_map[d_lvl][img_id, 0, ignore_y1:ignore_y2 + + 1, ignore_x1:ignore_x2 + 1] = 1 + # calculate ignore map on nearby high level feature + if lvl < num_lvls - 1: + u_lvl = lvl + 1 + # rescaled to corresponding feature map + gt_ = gt_bboxes[gt_id, :4] / anchor_strides[u_lvl] + ignore_x1, ignore_y1, ignore_x2, ignore_y2 = calc_region( + gt_, r2, featmap_sizes[u_lvl]) + all_ignore_map[u_lvl][img_id, 0, ignore_y1:ignore_y2 + + 1, ignore_x1:ignore_x2 + 1] = 1 + for lvl_id in range(num_lvls): + # ignore negative regions w.r.t. ignore map + all_loc_weights[lvl_id][(all_loc_weights[lvl_id] < 0) + & (all_ignore_map[lvl_id] > 0)] = 0 + # set negative regions with weight 0.1 + all_loc_weights[lvl_id][all_loc_weights[lvl_id] < 0] = 0.1 + # loc average factor to balance loss + loc_avg_factor = sum( + [t.size(0) * t.size(-1) * t.size(-2) for t in all_loc_targets]) / 200 + return all_loc_targets, all_loc_weights, loc_avg_factor + + +def ga_shape_target(approx_list, + inside_flag_list, + square_list, + gt_bboxes_list, + img_metas, + approxs_per_octave, + cfg, + gt_bboxes_ignore_list=None, + sampling=True, + unmap_outputs=True): + """Compute guided anchoring targets. + + Args: + approx_list (list[list]): Multi level approxs of each image. + inside_flag_list (list[list]): Multi level inside flags of each image. + square_list (list[list]): Multi level squares of each image. + gt_bboxes_list (list[Tensor]): Ground truth bboxes of each image. + img_metas (list[dict]): Meta info of each image. + approxs_per_octave (int): number of approxs per octave + cfg (dict): RPN train configs. + gt_bboxes_ignore_list (list[Tensor]): ignore list of gt bboxes. + sampling (bool): sampling or not. + unmap_outputs (bool): unmap outputs or not. + + Returns: + tuple + """ + num_imgs = len(img_metas) + assert len(approx_list) == len(inside_flag_list) == len( + square_list) == num_imgs + # anchor number of multi levels + num_level_squares = [squares.size(0) for squares in square_list[0]] + # concat all level anchors and flags to a single tensor + inside_flag_flat_list = [] + approx_flat_list = [] + square_flat_list = [] + for i in range(num_imgs): + assert len(square_list[i]) == len(inside_flag_list[i]) + inside_flag_flat_list.append(torch.cat(inside_flag_list[i])) + approx_flat_list.append(torch.cat(approx_list[i])) + square_flat_list.append(torch.cat(square_list[i])) + + # compute targets for each image + if gt_bboxes_ignore_list is None: + gt_bboxes_ignore_list = [None for _ in range(num_imgs)] + (all_bbox_anchors, all_bbox_gts, all_bbox_weights, pos_inds_list, + neg_inds_list) = multi_apply(ga_shape_target_single, + approx_flat_list, + inside_flag_flat_list, + square_flat_list, + gt_bboxes_list, + gt_bboxes_ignore_list, + img_metas, + approxs_per_octave=approxs_per_octave, + cfg=cfg, + sampling=sampling, + unmap_outputs=unmap_outputs) + # no valid anchors + if any([bbox_anchors is None for bbox_anchors in all_bbox_anchors]): + return None + # sampled anchors of all images + num_total_pos = sum([max(inds.numel(), 1) for inds in pos_inds_list]) + num_total_neg = sum([max(inds.numel(), 1) for inds in neg_inds_list]) + # split targets to a list w.r.t. multiple levels + bbox_anchors_list = images_to_levels(all_bbox_anchors, num_level_squares) + bbox_gts_list = images_to_levels(all_bbox_gts, num_level_squares) + bbox_weights_list = images_to_levels(all_bbox_weights, num_level_squares) + return (bbox_anchors_list, bbox_gts_list, bbox_weights_list, num_total_pos, + num_total_neg) + + +def images_to_levels(target, num_level_anchors): + """Convert targets by image to targets by feature level. + + [target_img0, target_img1] -> [target_level0, target_level1, ...] + """ + target = torch.stack(target, 0) + level_targets = [] + start = 0 + for n in num_level_anchors: + end = start + n + level_targets.append(target[:, start:end].squeeze(0)) + start = end + return level_targets + + +def ga_shape_target_single(flat_approxs, + inside_flags, + flat_squares, + gt_bboxes, + gt_bboxes_ignore, + img_meta, + approxs_per_octave, + cfg, + sampling=True, + unmap_outputs=True): + """Compute guided anchoring targets. + + This function returns sampled anchors and gt bboxes directly + rather than calculates regression targets. + + Args: + flat_approxs (Tensor): flat approxs of a single image, + shape (n, 4) + inside_flags (Tensor): inside flags of a single image, + shape (n, ). + flat_squares (Tensor): flat squares of a single image, + shape (approxs_per_octave * n, 4) + gt_bboxes (Tensor): Ground truth bboxes of a single image. + img_meta (dict): Meta info of a single image. + approxs_per_octave (int): number of approxs per octave + cfg (dict): RPN train configs. + sampling (bool): sampling or not. + unmap_outputs (bool): unmap outputs or not. + + Returns: + tuple + """ + if not inside_flags.any(): + return (None, ) * 6 + # assign gt and sample anchors + expand_inside_flags = inside_flags[:, None].expand( + -1, approxs_per_octave).reshape(-1) + approxs = flat_approxs[expand_inside_flags, :] + squares = flat_squares[inside_flags, :] + + bbox_assigner = build_assigner(cfg.ga_assigner) + assign_result = bbox_assigner.assign(approxs, squares, approxs_per_octave, + gt_bboxes, gt_bboxes_ignore) + if sampling: + bbox_sampler = build_sampler(cfg.ga_sampler) + else: + bbox_sampler = PseudoSampler() + sampling_result = bbox_sampler.sample(assign_result, squares, gt_bboxes) + + bbox_anchors = torch.zeros_like(squares) + bbox_gts = torch.zeros_like(squares) + bbox_weights = torch.zeros_like(squares) + + pos_inds = sampling_result.pos_inds + neg_inds = sampling_result.neg_inds + if len(pos_inds) > 0: + bbox_anchors[pos_inds, :] = sampling_result.pos_bboxes + bbox_gts[pos_inds, :] = sampling_result.pos_gt_bboxes + bbox_weights[pos_inds, :] = 1.0 + + # map up to original set of anchors + if unmap_outputs: + num_total_anchors = flat_squares.size(0) + bbox_anchors = unmap(bbox_anchors, num_total_anchors, inside_flags) + bbox_gts = unmap(bbox_gts, num_total_anchors, inside_flags) + bbox_weights = unmap(bbox_weights, num_total_anchors, inside_flags) + + return (bbox_anchors, bbox_gts, bbox_weights, pos_inds, neg_inds) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/__init__.py new file mode 100644 index 000000000..bcf6efda4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/__init__.py @@ -0,0 +1,20 @@ +from .geometry import bbox_overlaps +from .assigners import BaseAssigner, MaxIoUAssigner, AssignResult +from .samplers import (BaseSampler, PseudoSampler, RandomSampler, + InstanceBalancedPosSampler, IoUBalancedNegSampler, + CombinedSampler, SamplingResult) +from .assign_sampling import build_assigner, build_sampler, assign_and_sample +from .transforms import (bbox2delta, delta2bbox, bbox_flip, bbox_mapping, + bbox_mapping_back, bbox2roi, roi2bbox, bbox2result, + distance2bbox) +from .bbox_target import bbox_target + +__all__ = [ + 'bbox_overlaps', 'BaseAssigner', 'MaxIoUAssigner', 'AssignResult', + 'BaseSampler', 'PseudoSampler', 'RandomSampler', + 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', + 'SamplingResult', 'build_assigner', 'build_sampler', 'assign_and_sample', + 'bbox2delta', 'delta2bbox', 'bbox_flip', 'bbox_mapping', + 'bbox_mapping_back', 'bbox2roi', 'roi2bbox', 'bbox2result', + 'distance2bbox', 'bbox_target' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assign_sampling.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assign_sampling.py new file mode 100644 index 000000000..4267174bb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assign_sampling.py @@ -0,0 +1,33 @@ +import mmcv + +from . import assigners, samplers + + +def build_assigner(cfg, **kwargs): + if isinstance(cfg, assigners.BaseAssigner): + return cfg + elif isinstance(cfg, dict): + return mmcv.runner.obj_from_dict(cfg, assigners, default_args=kwargs) + else: + raise TypeError('Invalid type {} for building a sampler'.format( + type(cfg))) + + +def build_sampler(cfg, **kwargs): + if isinstance(cfg, samplers.BaseSampler): + return cfg + elif isinstance(cfg, dict): + return mmcv.runner.obj_from_dict(cfg, samplers, default_args=kwargs) + else: + raise TypeError('Invalid type {} for building a sampler'.format( + type(cfg))) + + +def assign_and_sample(bboxes, gt_bboxes, gt_bboxes_ignore, gt_labels, cfg): + bbox_assigner = build_assigner(cfg.assigner) + bbox_sampler = build_sampler(cfg.sampler) + assign_result = bbox_assigner.assign(bboxes, gt_bboxes, gt_bboxes_ignore, + gt_labels) + sampling_result = bbox_sampler.sample(assign_result, bboxes, gt_bboxes, + gt_labels) + return assign_result, sampling_result diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/__init__.py new file mode 100644 index 000000000..fafa3fa08 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/__init__.py @@ -0,0 +1,8 @@ +from .base_assigner import BaseAssigner +from .max_iou_assigner import MaxIoUAssigner +from .approx_max_iou_assigner import ApproxMaxIoUAssigner +from .assign_result import AssignResult + +__all__ = [ + 'BaseAssigner', 'MaxIoUAssigner', 'ApproxMaxIoUAssigner', 'AssignResult' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/approx_max_iou_assigner.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/approx_max_iou_assigner.py new file mode 100644 index 000000000..1283f7f52 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/approx_max_iou_assigner.py @@ -0,0 +1,116 @@ +import torch + +from .max_iou_assigner import MaxIoUAssigner +from ..geometry import bbox_overlaps + + +class ApproxMaxIoUAssigner(MaxIoUAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + pos_iou_thr (float): IoU threshold for positive bboxes. + neg_iou_thr (float or tuple): IoU threshold for negative bboxes. + min_pos_iou (float): Minimum iou for a bbox to be considered as a + positive bbox. Positive samples can have smaller IoU than + pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + gt_max_assign_all (bool): Whether to assign all bboxes with the same + highest overlap with some gt to that gt. + ignore_iof_thr (float): IoF threshold for ignoring bboxes (if + `gt_bboxes_ignore` is specified). Negative values mean not + ignoring any bboxes. + ignore_wrt_candidates (bool): Whether to compute the iof between + `bboxes` and `gt_bboxes_ignore`, or the contrary. + """ + + def __init__(self, + pos_iou_thr, + neg_iou_thr, + min_pos_iou=.0, + gt_max_assign_all=True, + ignore_iof_thr=-1, + ignore_wrt_candidates=True): + self.pos_iou_thr = pos_iou_thr + self.neg_iou_thr = neg_iou_thr + self.min_pos_iou = min_pos_iou + self.gt_max_assign_all = gt_max_assign_all + self.ignore_iof_thr = ignore_iof_thr + self.ignore_wrt_candidates = ignore_wrt_candidates + + def assign(self, + approxs, + squares, + approxs_per_octave, + gt_bboxes, + gt_bboxes_ignore=None, + gt_labels=None): + """Assign gt to approxs. + + This method assign a gt bbox to each group of approxs (bboxes), + each group of approxs is represent by a base approx (bbox) and + will be assigned with -1, 0, or a positive number. + -1 means don't care, 0 means negative sample, + positive number is the index (1-based) of assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every bbox to -1 + 2. use the max IoU of each group of approxs to assign + 2. assign proposals whose iou with all gts < neg_iou_thr to 0 + 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, + assign it to that bbox + 4. for each gt bbox, assign its nearest proposals (may be more than + one) to itself + + Args: + approxs (Tensor): Bounding boxes to be assigned, + shape(approxs_per_octave*n, 4). + squares (Tensor): Base Bounding boxes to be assigned, + shape(n, 4). + approxs_per_octave (int): number of approxs per octave + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + + if squares.shape[0] == 0 or gt_bboxes.shape[0] == 0: + raise ValueError('No gt or approxs') + num_squares = squares.size(0) + num_gts = gt_bboxes.size(0) + # re-organize anchors by approxs_per_octave x num_squares + approxs = torch.transpose( + approxs.view(num_squares, approxs_per_octave, 4), 0, + 1).contiguous().view(-1, 4) + all_overlaps = bbox_overlaps(approxs, gt_bboxes) + + overlaps, _ = all_overlaps.view(approxs_per_octave, num_squares, + num_gts).max(dim=0) + overlaps = torch.transpose(overlaps, 0, 1) + + bboxes = squares[:, :4] + + if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( + gt_bboxes_ignore.numel() > 0): + if self.ignore_wrt_candidates: + ignore_overlaps = bbox_overlaps(bboxes, + gt_bboxes_ignore, + mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) + else: + ignore_overlaps = bbox_overlaps(gt_bboxes_ignore, + bboxes, + mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) + overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 + + assign_result = self.assign_wrt_overlaps(overlaps, gt_labels) + return assign_result diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/assign_result.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/assign_result.py new file mode 100644 index 000000000..33c761dde --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/assign_result.py @@ -0,0 +1,19 @@ +import torch + + +class AssignResult(object): + + def __init__(self, num_gts, gt_inds, max_overlaps, labels=None): + self.num_gts = num_gts + self.gt_inds = gt_inds + self.max_overlaps = max_overlaps + self.labels = labels + + def add_gt_(self, gt_labels): + self_inds = torch.arange( + 1, len(gt_labels) + 1, dtype=torch.long, device=gt_labels.device) + self.gt_inds = torch.cat([self_inds, self.gt_inds]) + self.max_overlaps = torch.cat( + [self.max_overlaps.new_ones(self.num_gts), self.max_overlaps]) + if self.labels is not None: + self.labels = torch.cat([gt_labels, self.labels]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/base_assigner.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/base_assigner.py new file mode 100644 index 000000000..7bd02dce1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/base_assigner.py @@ -0,0 +1,8 @@ +from abc import ABCMeta, abstractmethod + + +class BaseAssigner(metaclass=ABCMeta): + + @abstractmethod + def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + pass diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py new file mode 100644 index 000000000..57a1e7504 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/assigners/max_iou_assigner.py @@ -0,0 +1,152 @@ +import torch + +from .base_assigner import BaseAssigner +from .assign_result import AssignResult +from ..geometry import bbox_overlaps + + +class MaxIoUAssigner(BaseAssigner): + """Assign a corresponding gt bbox or background to each bbox. + + Each proposals will be assigned with `-1`, `0`, or a positive integer + indicating the ground truth index. + + - -1: don't care + - 0: negative sample, no assigned gt + - positive integer: positive sample, index (1-based) of assigned gt + + Args: + pos_iou_thr (float): IoU threshold for positive bboxes. + neg_iou_thr (float or tuple): IoU threshold for negative bboxes. + min_pos_iou (float): Minimum iou for a bbox to be considered as a + positive bbox. Positive samples can have smaller IoU than + pos_iou_thr due to the 4th step (assign max IoU sample to each gt). + gt_max_assign_all (bool): Whether to assign all bboxes with the same + highest overlap with some gt to that gt. + ignore_iof_thr (float): IoF threshold for ignoring bboxes (if + `gt_bboxes_ignore` is specified). Negative values mean not + ignoring any bboxes. + ignore_wrt_candidates (bool): Whether to compute the iof between + `bboxes` and `gt_bboxes_ignore`, or the contrary. + """ + + def __init__(self, + pos_iou_thr, + neg_iou_thr, + min_pos_iou=.0, + gt_max_assign_all=True, + ignore_iof_thr=-1, + ignore_wrt_candidates=True): + self.pos_iou_thr = pos_iou_thr + self.neg_iou_thr = neg_iou_thr + self.min_pos_iou = min_pos_iou + self.gt_max_assign_all = gt_max_assign_all + self.ignore_iof_thr = ignore_iof_thr + self.ignore_wrt_candidates = ignore_wrt_candidates + + def assign(self, bboxes, gt_bboxes, gt_bboxes_ignore=None, gt_labels=None): + """Assign gt to bboxes. + + This method assign a gt bbox to every bbox (proposal/anchor), each bbox + will be assigned with -1, 0, or a positive number. -1 means don't care, + 0 means negative sample, positive number is the index (1-based) of + assigned gt. + The assignment is done in following steps, the order matters. + + 1. assign every bbox to -1 + 2. assign proposals whose iou with all gts < neg_iou_thr to 0 + 3. for each bbox, if the iou with its nearest gt >= pos_iou_thr, + assign it to that bbox + 4. for each gt bbox, assign its nearest proposals (may be more than + one) to itself + + Args: + bboxes (Tensor): Bounding boxes to be assigned, shape(n, 4). + gt_bboxes (Tensor): Groundtruth boxes, shape (k, 4). + gt_bboxes_ignore (Tensor, optional): Ground truth bboxes that are + labelled as `ignored`, e.g., crowd boxes in COCO. + gt_labels (Tensor, optional): Label of gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + if bboxes.shape[0] == 0 or gt_bboxes.shape[0] == 0: + raise ValueError('No gt or bboxes') + bboxes = bboxes[:, :4] + overlaps = bbox_overlaps(gt_bboxes, bboxes) + + if (self.ignore_iof_thr > 0) and (gt_bboxes_ignore is not None) and ( + gt_bboxes_ignore.numel() > 0): + if self.ignore_wrt_candidates: + ignore_overlaps = bbox_overlaps( + bboxes, gt_bboxes_ignore, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=1) + else: + ignore_overlaps = bbox_overlaps( + gt_bboxes_ignore, bboxes, mode='iof') + ignore_max_overlaps, _ = ignore_overlaps.max(dim=0) + overlaps[:, ignore_max_overlaps > self.ignore_iof_thr] = -1 + + assign_result = self.assign_wrt_overlaps(overlaps, gt_labels) + return assign_result + + def assign_wrt_overlaps(self, overlaps, gt_labels=None): + """Assign w.r.t. the overlaps of bboxes with gts. + + Args: + overlaps (Tensor): Overlaps between k gt_bboxes and n bboxes, + shape(k, n). + gt_labels (Tensor, optional): Labels of k gt_bboxes, shape (k, ). + + Returns: + :obj:`AssignResult`: The assign result. + """ + if overlaps.numel() == 0: + raise ValueError('No gt or proposals') + + num_gts, num_bboxes = overlaps.size(0), overlaps.size(1) + + # 1. assign -1 by default + assigned_gt_inds = overlaps.new_full( + (num_bboxes, ), -1, dtype=torch.long) + + # for each anchor, which gt best overlaps with it + # for each anchor, the max iou of all gts + max_overlaps, argmax_overlaps = overlaps.max(dim=0) + # for each gt, which anchor best overlaps with it + # for each gt, the max iou of all proposals + gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1) + + # 2. assign negative: below + if isinstance(self.neg_iou_thr, float): + assigned_gt_inds[(max_overlaps >= 0) + & (max_overlaps < self.neg_iou_thr)] = 0 + elif isinstance(self.neg_iou_thr, tuple): + assert len(self.neg_iou_thr) == 2 + assigned_gt_inds[(max_overlaps >= self.neg_iou_thr[0]) + & (max_overlaps < self.neg_iou_thr[1])] = 0 + + # 3. assign positive: above positive IoU threshold + pos_inds = max_overlaps >= self.pos_iou_thr + assigned_gt_inds[pos_inds] = argmax_overlaps[pos_inds] + 1 + + # 4. assign fg: for each gt, proposals with highest IoU + for i in range(num_gts): + if gt_max_overlaps[i] >= self.min_pos_iou: + if self.gt_max_assign_all: + max_iou_inds = overlaps[i, :] == gt_max_overlaps[i] + assigned_gt_inds[max_iou_inds] = i + 1 + else: + assigned_gt_inds[gt_argmax_overlaps[i]] = i + 1 + + if gt_labels is not None: + assigned_labels = assigned_gt_inds.new_zeros((num_bboxes, )) + pos_inds = torch.nonzero(assigned_gt_inds > 0).squeeze() + if pos_inds.numel() > 0: + assigned_labels[pos_inds] = gt_labels[ + assigned_gt_inds[pos_inds] - 1] + else: + assigned_labels = None + + return AssignResult( + num_gts, assigned_gt_inds, max_overlaps, labels=assigned_labels) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/bbox_target.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/bbox_target.py new file mode 100644 index 000000000..aa1fbc674 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/bbox_target.py @@ -0,0 +1,73 @@ +import torch + +from .transforms import bbox2delta +from ..utils import multi_apply + + +def bbox_target(pos_bboxes_list, + neg_bboxes_list, + pos_gt_bboxes_list, + pos_gt_labels_list, + cfg, + reg_classes=1, + target_means=[.0, .0, .0, .0], + target_stds=[1.0, 1.0, 1.0, 1.0], + concat=True): + labels, label_weights, bbox_targets, bbox_weights = multi_apply( + bbox_target_single, + pos_bboxes_list, + neg_bboxes_list, + pos_gt_bboxes_list, + pos_gt_labels_list, + cfg=cfg, + reg_classes=reg_classes, + target_means=target_means, + target_stds=target_stds) + + if concat: + labels = torch.cat(labels, 0) + label_weights = torch.cat(label_weights, 0) + bbox_targets = torch.cat(bbox_targets, 0) + bbox_weights = torch.cat(bbox_weights, 0) + return labels, label_weights, bbox_targets, bbox_weights + + +def bbox_target_single(pos_bboxes, + neg_bboxes, + pos_gt_bboxes, + pos_gt_labels, + cfg, + reg_classes=1, + target_means=[.0, .0, .0, .0], + target_stds=[1.0, 1.0, 1.0, 1.0]): + num_pos = pos_bboxes.size(0) + num_neg = neg_bboxes.size(0) + num_samples = num_pos + num_neg + labels = pos_bboxes.new_zeros(num_samples, dtype=torch.long) + label_weights = pos_bboxes.new_zeros(num_samples) + bbox_targets = pos_bboxes.new_zeros(num_samples, 4) + bbox_weights = pos_bboxes.new_zeros(num_samples, 4) + if num_pos > 0: + labels[:num_pos] = pos_gt_labels + pos_weight = 1.0 if cfg.pos_weight <= 0 else cfg.pos_weight + label_weights[:num_pos] = pos_weight + pos_bbox_targets = bbox2delta(pos_bboxes, pos_gt_bboxes, target_means, + target_stds) + bbox_targets[:num_pos, :] = pos_bbox_targets + bbox_weights[:num_pos, :] = 1 + if num_neg > 0: + label_weights[-num_neg:] = 1.0 + + return labels, label_weights, bbox_targets, bbox_weights + + +def expand_target(bbox_targets, bbox_weights, labels, num_classes): + bbox_targets_expand = bbox_targets.new_zeros((bbox_targets.size(0), + 4 * num_classes)) + bbox_weights_expand = bbox_weights.new_zeros((bbox_weights.size(0), + 4 * num_classes)) + for i in torch.nonzero(labels > 0).squeeze(-1): + start, end = labels[i] * 4, (labels[i] + 1) * 4 + bbox_targets_expand[i, start:end] = bbox_targets[i, :] + bbox_weights_expand[i, start:end] = bbox_weights[i, :] + return bbox_targets_expand, bbox_weights_expand diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/geometry.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/geometry.py new file mode 100644 index 000000000..3bc8dae90 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/geometry.py @@ -0,0 +1,63 @@ +import torch + + +def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False): + """Calculate overlap between two set of bboxes. + + If ``is_aligned`` is ``False``, then calculate the ious between each bbox + of bboxes1 and bboxes2, otherwise the ious between each aligned pair of + bboxes1 and bboxes2. + + Args: + bboxes1 (Tensor): shape (m, 4) + bboxes2 (Tensor): shape (n, 4), if is_aligned is ``True``, then m and n + must be equal. + mode (str): "iou" (intersection over union) or iof (intersection over + foreground). + + Returns: + ious(Tensor): shape (m, n) if is_aligned == False else shape (m, 1) + """ + + assert mode in ['iou', 'iof'] + + rows = bboxes1.size(0) + cols = bboxes2.size(0) + if is_aligned: + assert rows == cols + + if rows * cols == 0: + return bboxes1.new(rows, 1) if is_aligned else bboxes1.new(rows, cols) + + if is_aligned: + lt = torch.max(bboxes1[:, :2], bboxes2[:, :2]) # [rows, 2] + rb = torch.min(bboxes1[:, 2:], bboxes2[:, 2:]) # [rows, 2] + + wh = (rb - lt + 1).clamp(min=0) # [rows, 2] + overlap = wh[:, 0] * wh[:, 1] + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + + if mode == 'iou': + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + ious = overlap / (area1 + area2 - overlap) + else: + ious = overlap / area1 + else: + lt = torch.max(bboxes1[:, None, :2], bboxes2[:, :2]) # [rows, cols, 2] + rb = torch.min(bboxes1[:, None, 2:], bboxes2[:, 2:]) # [rows, cols, 2] + + wh = (rb - lt + 1).clamp(min=0) # [rows, cols, 2] + overlap = wh[:, :, 0] * wh[:, :, 1] + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + + if mode == 'iou': + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + ious = overlap / (area1[:, None] + area2 - overlap) + else: + ious = overlap / (area1[:, None]) + + return ious diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/__init__.py new file mode 100644 index 000000000..167044f5b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/__init__.py @@ -0,0 +1,14 @@ +from .base_sampler import BaseSampler +from .pseudo_sampler import PseudoSampler +from .random_sampler import RandomSampler +from .instance_balanced_pos_sampler import InstanceBalancedPosSampler +from .iou_balanced_neg_sampler import IoUBalancedNegSampler +from .combined_sampler import CombinedSampler +from .ohem_sampler import OHEMSampler +from .sampling_result import SamplingResult + +__all__ = [ + 'BaseSampler', 'PseudoSampler', 'RandomSampler', + 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', + 'OHEMSampler', 'SamplingResult' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py new file mode 100644 index 000000000..12df01306 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/base_sampler.py @@ -0,0 +1,78 @@ +from abc import ABCMeta, abstractmethod + +import torch + +from .sampling_result import SamplingResult + + +class BaseSampler(metaclass=ABCMeta): + + def __init__(self, + num, + pos_fraction, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + self.num = num + self.pos_fraction = pos_fraction + self.neg_pos_ub = neg_pos_ub + self.add_gt_as_proposals = add_gt_as_proposals + self.pos_sampler = self + self.neg_sampler = self + + @abstractmethod + def _sample_pos(self, assign_result, num_expected, **kwargs): + pass + + @abstractmethod + def _sample_neg(self, assign_result, num_expected, **kwargs): + pass + + def sample(self, + assign_result, + bboxes, + gt_bboxes, + gt_labels=None, + **kwargs): + """Sample positive and negative bboxes. + + This is a simple implementation of bbox sampling given candidates, + assigning results and ground truth bboxes. + + Args: + assign_result (:obj:`AssignResult`): Bbox assigning results. + bboxes (Tensor): Boxes to be sampled from. + gt_bboxes (Tensor): Ground truth bboxes. + gt_labels (Tensor, optional): Class labels of ground truth bboxes. + + Returns: + :obj:`SamplingResult`: Sampling result. + """ + bboxes = bboxes[:, :4] + + gt_flags = bboxes.new_zeros((bboxes.shape[0], ), dtype=torch.uint8) + if self.add_gt_as_proposals: + bboxes = torch.cat([gt_bboxes, bboxes], dim=0) + assign_result.add_gt_(gt_labels) + gt_ones = bboxes.new_ones(gt_bboxes.shape[0], dtype=torch.uint8) + gt_flags = torch.cat([gt_ones, gt_flags]) + + num_expected_pos = int(self.num * self.pos_fraction) + pos_inds = self.pos_sampler._sample_pos( + assign_result, num_expected_pos, bboxes=bboxes, **kwargs) + # We found that sampled indices have duplicated items occasionally. + # (may be a bug of PyTorch) + pos_inds = pos_inds.unique() + num_sampled_pos = pos_inds.numel() + num_expected_neg = self.num - num_sampled_pos + if self.neg_pos_ub >= 0: + _pos = max(1, num_sampled_pos) + neg_upper_bound = int(self.neg_pos_ub * _pos) + if num_expected_neg > neg_upper_bound: + num_expected_neg = neg_upper_bound + neg_inds = self.neg_sampler._sample_neg( + assign_result, num_expected_neg, bboxes=bboxes, **kwargs) + neg_inds = neg_inds.unique() + + return SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, + assign_result, gt_flags) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py new file mode 100644 index 000000000..25e820be1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py @@ -0,0 +1,16 @@ +from .base_sampler import BaseSampler +from ..assign_sampling import build_sampler + + +class CombinedSampler(BaseSampler): + + def __init__(self, pos_sampler, neg_sampler, **kwargs): + super(CombinedSampler, self).__init__(**kwargs) + self.pos_sampler = build_sampler(pos_sampler, **kwargs) + self.neg_sampler = build_sampler(neg_sampler, **kwargs) + + def _sample_pos(self, **kwargs): + raise NotImplementedError + + def _sample_neg(self, **kwargs): + raise NotImplementedError diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py new file mode 100644 index 000000000..bc829a236 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/instance_balanced_pos_sampler.py @@ -0,0 +1,41 @@ +import numpy as np +import torch + +from .random_sampler import RandomSampler + + +class InstanceBalancedPosSampler(RandomSampler): + + def _sample_pos(self, assign_result, num_expected, **kwargs): + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + unique_gt_inds = assign_result.gt_inds[pos_inds].unique() + num_gts = len(unique_gt_inds) + num_per_gt = int(round(num_expected / float(num_gts)) + 1) + sampled_inds = [] + for i in unique_gt_inds: + inds = torch.nonzero(assign_result.gt_inds == i.item()) + if inds.numel() != 0: + inds = inds.squeeze(1) + else: + continue + if len(inds) > num_per_gt: + inds = self.random_choice(inds, num_per_gt) + sampled_inds.append(inds) + sampled_inds = torch.cat(sampled_inds) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array( + list(set(pos_inds.cpu()) - set(sampled_inds.cpu()))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + extra_inds = torch.from_numpy(extra_inds).to( + assign_result.gt_inds.device).long() + sampled_inds = torch.cat([sampled_inds, extra_inds]) + elif len(sampled_inds) > num_expected: + sampled_inds = self.random_choice(sampled_inds, num_expected) + return sampled_inds diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py new file mode 100644 index 000000000..62431d6a0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py @@ -0,0 +1,133 @@ +import numpy as np +import torch + +from .random_sampler import RandomSampler + + +class IoUBalancedNegSampler(RandomSampler): + """IoU Balanced Sampling + + arXiv: https://arxiv.org/pdf/1904.02701.pdf (CVPR 2019) + + Sampling proposals according to their IoU. `floor_fraction` of needed RoIs + are sampled from proposals whose IoU are lower than `floor_thr` randomly. + The others are sampled from proposals whose IoU are higher than + `floor_thr`. These proposals are sampled from some bins evenly, which are + split by `num_bins` via IoU evenly. + + Args: + num (int): number of proposals. + pos_fraction (float): fraction of positive proposals. + floor_thr (float): threshold (minimum) IoU for IoU balanced sampling, + set to -1 if all using IoU balanced sampling. + floor_fraction (float): sampling fraction of proposals under floor_thr. + num_bins (int): number of bins in IoU balanced sampling. + """ + + def __init__(self, + num, + pos_fraction, + floor_thr=-1, + floor_fraction=0, + num_bins=3, + **kwargs): + super(IoUBalancedNegSampler, self).__init__(num, pos_fraction, + **kwargs) + assert floor_thr >= 0 or floor_thr == -1 + assert 0 <= floor_fraction <= 1 + assert num_bins >= 1 + + self.floor_thr = floor_thr + self.floor_fraction = floor_fraction + self.num_bins = num_bins + + def sample_via_interval(self, max_overlaps, full_set, num_expected): + max_iou = max_overlaps.max() + iou_interval = (max_iou - self.floor_thr) / self.num_bins + per_num_expected = int(num_expected / self.num_bins) + + sampled_inds = [] + for i in range(self.num_bins): + start_iou = self.floor_thr + i * iou_interval + end_iou = self.floor_thr + (i + 1) * iou_interval + tmp_set = set( + np.where( + np.logical_and(max_overlaps >= start_iou, + max_overlaps < end_iou))[0]) + tmp_inds = list(tmp_set & full_set) + if len(tmp_inds) > per_num_expected: + tmp_sampled_set = self.random_choice(tmp_inds, + per_num_expected) + else: + tmp_sampled_set = np.array(tmp_inds, dtype=np.int) + sampled_inds.append(tmp_sampled_set) + + sampled_inds = np.concatenate(sampled_inds) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array(list(full_set - set(sampled_inds))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + sampled_inds = np.concatenate([sampled_inds, extra_inds]) + + return sampled_inds + + def _sample_neg(self, assign_result, num_expected, **kwargs): + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + max_overlaps = assign_result.max_overlaps.cpu().numpy() + # balance sampling for negative samples + neg_set = set(neg_inds.cpu().numpy()) + + if self.floor_thr > 0: + floor_set = set( + np.where( + np.logical_and(max_overlaps >= 0, + max_overlaps < self.floor_thr))[0]) + iou_sampling_set = set( + np.where(max_overlaps >= self.floor_thr)[0]) + elif self.floor_thr == 0: + floor_set = set(np.where(max_overlaps == 0)[0]) + iou_sampling_set = set( + np.where(max_overlaps > self.floor_thr)[0]) + else: + floor_set = set() + iou_sampling_set = set( + np.where(max_overlaps > self.floor_thr)[0]) + + floor_neg_inds = list(floor_set & neg_set) + iou_sampling_neg_inds = list(iou_sampling_set & neg_set) + num_expected_iou_sampling = int(num_expected * + (1 - self.floor_fraction)) + if len(iou_sampling_neg_inds) > num_expected_iou_sampling: + if self.num_bins >= 2: + iou_sampled_inds = self.sample_via_interval( + max_overlaps, set(iou_sampling_neg_inds), + num_expected_iou_sampling) + else: + iou_sampled_inds = self.random_choice( + iou_sampling_neg_inds, num_expected_iou_sampling) + else: + iou_sampled_inds = np.array( + iou_sampling_neg_inds, dtype=np.int) + num_expected_floor = num_expected - len(iou_sampled_inds) + if len(floor_neg_inds) > num_expected_floor: + sampled_floor_inds = self.random_choice( + floor_neg_inds, num_expected_floor) + else: + sampled_floor_inds = np.array(floor_neg_inds, dtype=np.int) + sampled_inds = np.concatenate( + (sampled_floor_inds, iou_sampled_inds)) + if len(sampled_inds) < num_expected: + num_extra = num_expected - len(sampled_inds) + extra_inds = np.array(list(neg_set - set(sampled_inds))) + if len(extra_inds) > num_extra: + extra_inds = self.random_choice(extra_inds, num_extra) + sampled_inds = np.concatenate((sampled_inds, extra_inds)) + sampled_inds = torch.from_numpy(sampled_inds).long().to( + assign_result.gt_inds.device) + return sampled_inds diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/ohem_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/ohem_sampler.py new file mode 100644 index 000000000..0711d976c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/ohem_sampler.py @@ -0,0 +1,73 @@ +import torch + +from .base_sampler import BaseSampler +from ..transforms import bbox2roi + + +class OHEMSampler(BaseSampler): + + def __init__(self, + num, + pos_fraction, + context, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + super(OHEMSampler, self).__init__(num, pos_fraction, neg_pos_ub, + add_gt_as_proposals) + if not hasattr(context, 'num_stages'): + self.bbox_roi_extractor = context.bbox_roi_extractor + self.bbox_head = context.bbox_head + else: + self.bbox_roi_extractor = context.bbox_roi_extractor[ + context.current_stage] + self.bbox_head = context.bbox_head[context.current_stage] + + def hard_mining(self, inds, num_expected, bboxes, labels, feats): + with torch.no_grad(): + rois = bbox2roi([bboxes]) + bbox_feats = self.bbox_roi_extractor( + feats[:self.bbox_roi_extractor.num_inputs], rois) + cls_score, _ = self.bbox_head(bbox_feats) + loss = self.bbox_head.loss( + cls_score=cls_score, + bbox_pred=None, + labels=labels, + label_weights=cls_score.new_ones(cls_score.size(0)), + bbox_targets=None, + bbox_weights=None, + reduction_override='none')['loss_cls'] + _, topk_loss_inds = loss.topk(num_expected) + return inds[topk_loss_inds] + + def _sample_pos(self, + assign_result, + num_expected, + bboxes=None, + feats=None, + **kwargs): + # Sample some hard positive samples + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + return self.hard_mining(pos_inds, num_expected, bboxes[pos_inds], + assign_result.labels[pos_inds], feats) + + def _sample_neg(self, + assign_result, + num_expected, + bboxes=None, + feats=None, + **kwargs): + # Sample some hard negative samples + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + return self.hard_mining(neg_inds, num_expected, bboxes[neg_inds], + assign_result.labels[neg_inds], feats) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py new file mode 100644 index 000000000..b4c2ea09b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/pseudo_sampler.py @@ -0,0 +1,26 @@ +import torch + +from .base_sampler import BaseSampler +from .sampling_result import SamplingResult + + +class PseudoSampler(BaseSampler): + + def __init__(self, **kwargs): + pass + + def _sample_pos(self, **kwargs): + raise NotImplementedError + + def _sample_neg(self, **kwargs): + raise NotImplementedError + + def sample(self, assign_result, bboxes, gt_bboxes, **kwargs): + pos_inds = torch.nonzero( + assign_result.gt_inds > 0).squeeze(-1).unique() + neg_inds = torch.nonzero( + assign_result.gt_inds == 0).squeeze(-1).unique() + gt_flags = bboxes.new_zeros(bboxes.shape[0], dtype=torch.uint8) + sampling_result = SamplingResult(pos_inds, neg_inds, bboxes, gt_bboxes, + assign_result, gt_flags) + return sampling_result diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/random_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/random_sampler.py new file mode 100644 index 000000000..0d02b2747 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/random_sampler.py @@ -0,0 +1,53 @@ +import numpy as np +import torch + +from .base_sampler import BaseSampler + + +class RandomSampler(BaseSampler): + + def __init__(self, + num, + pos_fraction, + neg_pos_ub=-1, + add_gt_as_proposals=True, + **kwargs): + super(RandomSampler, self).__init__(num, pos_fraction, neg_pos_ub, + add_gt_as_proposals) + + @staticmethod + def random_choice(gallery, num): + """Random select some elements from the gallery. + + It seems that Pytorch's implementation is slower than numpy so we use + numpy to randperm the indices. + """ + assert len(gallery) >= num + if isinstance(gallery, list): + gallery = np.array(gallery) + cands = np.arange(len(gallery)) + np.random.shuffle(cands) + rand_inds = cands[:num] + if not isinstance(gallery, np.ndarray): + rand_inds = torch.from_numpy(rand_inds).long().to(gallery.device) + return gallery[rand_inds] + + def _sample_pos(self, assign_result, num_expected, **kwargs): + """Randomly sample some positive samples.""" + pos_inds = torch.nonzero(assign_result.gt_inds > 0) + if pos_inds.numel() != 0: + pos_inds = pos_inds.squeeze(1) + if pos_inds.numel() <= num_expected: + return pos_inds + else: + return self.random_choice(pos_inds, num_expected) + + def _sample_neg(self, assign_result, num_expected, **kwargs): + """Randomly sample some negative samples.""" + neg_inds = torch.nonzero(assign_result.gt_inds == 0) + if neg_inds.numel() != 0: + neg_inds = neg_inds.squeeze(1) + if len(neg_inds) <= num_expected: + return neg_inds + else: + return self.random_choice(neg_inds, num_expected) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/sampling_result.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/sampling_result.py new file mode 100644 index 000000000..696e65097 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/sampling_result.py @@ -0,0 +1,24 @@ +import torch + + +class SamplingResult(object): + + def __init__(self, pos_inds, neg_inds, bboxes, gt_bboxes, assign_result, + gt_flags): + self.pos_inds = pos_inds + self.neg_inds = neg_inds + self.pos_bboxes = bboxes[pos_inds] + self.neg_bboxes = bboxes[neg_inds] + self.pos_is_gt = gt_flags[pos_inds] + + self.num_gts = gt_bboxes.shape[0] + self.pos_assigned_gt_inds = assign_result.gt_inds[pos_inds] - 1 + self.pos_gt_bboxes = gt_bboxes[self.pos_assigned_gt_inds, :] + if assign_result.labels is not None: + self.pos_gt_labels = assign_result.labels[pos_inds] + else: + self.pos_gt_labels = None + + @property + def bboxes(self): + return torch.cat([self.pos_bboxes, self.neg_bboxes]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/transforms.py new file mode 100644 index 000000000..580b9bdfb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/transforms.py @@ -0,0 +1,180 @@ +import mmcv +import numpy as np +import torch + + +def bbox2delta(proposals, gt, means=[0, 0, 0, 0], stds=[1, 1, 1, 1]): + assert proposals.size() == gt.size() + + proposals = proposals.float() + gt = gt.float() + px = (proposals[..., 0] + proposals[..., 2]) * 0.5 + py = (proposals[..., 1] + proposals[..., 3]) * 0.5 + pw = proposals[..., 2] - proposals[..., 0] + 1.0 + ph = proposals[..., 3] - proposals[..., 1] + 1.0 + + gx = (gt[..., 0] + gt[..., 2]) * 0.5 + gy = (gt[..., 1] + gt[..., 3]) * 0.5 + gw = gt[..., 2] - gt[..., 0] + 1.0 + gh = gt[..., 3] - gt[..., 1] + 1.0 + + dx = (gx - px) / pw + dy = (gy - py) / ph + dw = torch.log(gw / pw) + dh = torch.log(gh / ph) + deltas = torch.stack([dx, dy, dw, dh], dim=-1) + + means = deltas.new_tensor(means).unsqueeze(0) + stds = deltas.new_tensor(stds).unsqueeze(0) + deltas = deltas.sub_(means).div_(stds) + + return deltas + + +def delta2bbox(rois, + deltas, + means=[0, 0, 0, 0], + stds=[1, 1, 1, 1], + max_shape=None, + wh_ratio_clip=16 / 1000): + means = deltas.new_tensor(means).repeat(1, deltas.size(1) // 4) + stds = deltas.new_tensor(stds).repeat(1, deltas.size(1) // 4) + denorm_deltas = deltas * stds + means + dx = denorm_deltas[:, 0::4] + dy = denorm_deltas[:, 1::4] + dw = denorm_deltas[:, 2::4] + dh = denorm_deltas[:, 3::4] + max_ratio = np.abs(np.log(wh_ratio_clip)) + dw = dw.clamp(min=-max_ratio, max=max_ratio) + dh = dh.clamp(min=-max_ratio, max=max_ratio) + px = ((rois[:, 0] + rois[:, 2]) * 0.5).unsqueeze(1).expand_as(dx) + py = ((rois[:, 1] + rois[:, 3]) * 0.5).unsqueeze(1).expand_as(dy) + pw = (rois[:, 2] - rois[:, 0] + 1.0).unsqueeze(1).expand_as(dw) + ph = (rois[:, 3] - rois[:, 1] + 1.0).unsqueeze(1).expand_as(dh) + gw = pw * dw.exp() + gh = ph * dh.exp() + gx = torch.addcmul(px, 1, pw, dx) # gx = px + pw * dx + gy = torch.addcmul(py, 1, ph, dy) # gy = py + ph * dy + x1 = gx - gw * 0.5 + 0.5 + y1 = gy - gh * 0.5 + 0.5 + x2 = gx + gw * 0.5 - 0.5 + y2 = gy + gh * 0.5 - 0.5 + if max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + bboxes = torch.stack([x1, y1, x2, y2], dim=-1).view_as(deltas) + return bboxes + + +def bbox_flip(bboxes, img_shape): + """Flip bboxes horizontally. + + Args: + bboxes(Tensor or ndarray): Shape (..., 4*k) + img_shape(tuple): Image shape. + + Returns: + Same type as `bboxes`: Flipped bboxes. + """ + if isinstance(bboxes, torch.Tensor): + assert bboxes.shape[-1] % 4 == 0 + flipped = bboxes.clone() + flipped[:, 0::4] = img_shape[1] - bboxes[:, 2::4] - 1 + flipped[:, 2::4] = img_shape[1] - bboxes[:, 0::4] - 1 + return flipped + elif isinstance(bboxes, np.ndarray): + return mmcv.bbox_flip(bboxes, img_shape) + + +def bbox_mapping(bboxes, img_shape, scale_factor, flip): + """Map bboxes from the original image scale to testing scale""" + new_bboxes = bboxes * scale_factor + if flip: + new_bboxes = bbox_flip(new_bboxes, img_shape) + return new_bboxes + + +def bbox_mapping_back(bboxes, img_shape, scale_factor, flip): + """Map bboxes from testing scale to original image scale""" + new_bboxes = bbox_flip(bboxes, img_shape) if flip else bboxes + new_bboxes = new_bboxes / scale_factor + return new_bboxes + + +def bbox2roi(bbox_list): + """Convert a list of bboxes to roi format. + + Args: + bbox_list (list[Tensor]): a list of bboxes corresponding to a batch + of images. + + Returns: + Tensor: shape (n, 5), [batch_ind, x1, y1, x2, y2] + """ + rois_list = [] + for img_id, bboxes in enumerate(bbox_list): + if bboxes.size(0) > 0: + img_inds = bboxes.new_full((bboxes.size(0), 1), img_id) + rois = torch.cat([img_inds, bboxes[:, :4]], dim=-1) + else: + rois = bboxes.new_zeros((0, 5)) + rois_list.append(rois) + rois = torch.cat(rois_list, 0) + return rois + + +def roi2bbox(rois): + bbox_list = [] + img_ids = torch.unique(rois[:, 0].cpu(), sorted=True) + for img_id in img_ids: + inds = (rois[:, 0] == img_id.item()) + bbox = rois[inds, 1:] + bbox_list.append(bbox) + return bbox_list + + +def bbox2result(bboxes, labels, num_classes): + """Convert detection results to a list of numpy arrays. + + Args: + bboxes (Tensor): shape (n, 5) + labels (Tensor): shape (n, ) + num_classes (int): class number, including background class + + Returns: + list(ndarray): bbox results of each class + """ + if bboxes.shape[0] == 0: + return [ + np.zeros((0, 5), dtype=np.float32) for i in range(num_classes - 1) + ] + else: + bboxes = bboxes.cpu().numpy() + labels = labels.cpu().numpy() + return [bboxes[labels == i, :] for i in range(num_classes - 1)] + + +def distance2bbox(points, distance, max_shape=None): + """Decode distance prediction to bounding box. + + Args: + points (Tensor): Shape (n, 2), [x, y]. + distance (Tensor): Distance from the given point to 4 + boundaries (left, top, right, bottom). + max_shape (tuple): Shape of the image. + + Returns: + Tensor: Decoded bboxes. + """ + x1 = points[:, 0] - distance[:, 0] + y1 = points[:, 1] - distance[:, 1] + x2 = points[:, 0] + distance[:, 2] + y2 = points[:, 1] + distance[:, 3] + if max_shape is not None: + x1 = x1.clamp(min=0, max=max_shape[1] - 1) + y1 = y1.clamp(min=0, max=max_shape[0] - 1) + x2 = x2.clamp(min=0, max=max_shape[1] - 1) + y2 = y2.clamp(min=0, max=max_shape[0] - 1) + return torch.stack([x1, y1, x2, y2], -1) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/__init__.py new file mode 100644 index 000000000..b8177aad5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/__init__.py @@ -0,0 +1,14 @@ +from .class_names import (coco_classes, dataset_aliases, get_classes, + imagenet_det_classes, imagenet_vid_classes, + voc_classes) +from .eval_hooks import DistEvalHook +from .mean_ap import average_precision, eval_map, print_map_summary +from .recall import (eval_recalls, plot_iou_recall, plot_num_recall, + print_recall_summary) + +__all__ = [ + 'voc_classes', 'imagenet_det_classes', 'imagenet_vid_classes', + 'coco_classes', 'dataset_aliases', 'get_classes', 'DistEvalHook', + 'average_precision', 'eval_map', 'print_map_summary', 'eval_recalls', + 'print_recall_summary', 'plot_num_recall', 'plot_iou_recall' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/bbox_overlaps.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/bbox_overlaps.py new file mode 100644 index 000000000..ad4c70523 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/bbox_overlaps.py @@ -0,0 +1,49 @@ +import numpy as np + + +def bbox_overlaps(bboxes1, bboxes2, mode='iou'): + """Calculate the ious between each bbox of bboxes1 and bboxes2. + + Args: + bboxes1(ndarray): shape (n, 4) + bboxes2(ndarray): shape (k, 4) + mode(str): iou (intersection over union) or iof (intersection + over foreground) + + Returns: + ious(ndarray): shape (n, k) + """ + + assert mode in ['iou', 'iof'] + + bboxes1 = bboxes1.astype(np.float32) + bboxes2 = bboxes2.astype(np.float32) + rows = bboxes1.shape[0] + cols = bboxes2.shape[0] + ious = np.zeros((rows, cols), dtype=np.float32) + if rows * cols == 0: + return ious + exchange = False + if bboxes1.shape[0] > bboxes2.shape[0]: + bboxes1, bboxes2 = bboxes2, bboxes1 + ious = np.zeros((cols, rows), dtype=np.float32) + exchange = True + area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( + bboxes1[:, 3] - bboxes1[:, 1] + 1) + area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( + bboxes2[:, 3] - bboxes2[:, 1] + 1) + for i in range(bboxes1.shape[0]): + x_start = np.maximum(bboxes1[i, 0], bboxes2[:, 0]) + y_start = np.maximum(bboxes1[i, 1], bboxes2[:, 1]) + x_end = np.minimum(bboxes1[i, 2], bboxes2[:, 2]) + y_end = np.minimum(bboxes1[i, 3], bboxes2[:, 3]) + overlap = np.maximum(x_end - x_start + 1, 0) * np.maximum( + y_end - y_start + 1, 0) + if mode == 'iou': + union = area1[i] + area2 - overlap + else: + union = area1[i] if not exchange else area2 + ious[i, :] = overlap / union + if exchange: + ious = ious.T + return ious diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/class_names.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/class_names.py new file mode 100644 index 000000000..87fb2399b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/class_names.py @@ -0,0 +1,108 @@ +import mmcv + + +def wider_face_classes(): + return ['face'] + + +def voc_classes(): + return [ + 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', + 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', + 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' + ] + + +def imagenet_det_classes(): + return [ + 'accordion', 'airplane', 'ant', 'antelope', 'apple', 'armadillo', + 'artichoke', 'axe', 'baby_bed', 'backpack', 'bagel', 'balance_beam', + 'banana', 'band_aid', 'banjo', 'baseball', 'basketball', 'bathing_cap', + 'beaker', 'bear', 'bee', 'bell_pepper', 'bench', 'bicycle', 'binder', + 'bird', 'bookshelf', 'bow_tie', 'bow', 'bowl', 'brassiere', 'burrito', + 'bus', 'butterfly', 'camel', 'can_opener', 'car', 'cart', 'cattle', + 'cello', 'centipede', 'chain_saw', 'chair', 'chime', 'cocktail_shaker', + 'coffee_maker', 'computer_keyboard', 'computer_mouse', 'corkscrew', + 'cream', 'croquet_ball', 'crutch', 'cucumber', 'cup_or_mug', 'diaper', + 'digital_clock', 'dishwasher', 'dog', 'domestic_cat', 'dragonfly', + 'drum', 'dumbbell', 'electric_fan', 'elephant', 'face_powder', 'fig', + 'filing_cabinet', 'flower_pot', 'flute', 'fox', 'french_horn', 'frog', + 'frying_pan', 'giant_panda', 'goldfish', 'golf_ball', 'golfcart', + 'guacamole', 'guitar', 'hair_dryer', 'hair_spray', 'hamburger', + 'hammer', 'hamster', 'harmonica', 'harp', 'hat_with_a_wide_brim', + 'head_cabbage', 'helmet', 'hippopotamus', 'horizontal_bar', 'horse', + 'hotdog', 'iPod', 'isopod', 'jellyfish', 'koala_bear', 'ladle', + 'ladybug', 'lamp', 'laptop', 'lemon', 'lion', 'lipstick', 'lizard', + 'lobster', 'maillot', 'maraca', 'microphone', 'microwave', 'milk_can', + 'miniskirt', 'monkey', 'motorcycle', 'mushroom', 'nail', 'neck_brace', + 'oboe', 'orange', 'otter', 'pencil_box', 'pencil_sharpener', 'perfume', + 'person', 'piano', 'pineapple', 'ping-pong_ball', 'pitcher', 'pizza', + 'plastic_bag', 'plate_rack', 'pomegranate', 'popsicle', 'porcupine', + 'power_drill', 'pretzel', 'printer', 'puck', 'punching_bag', 'purse', + 'rabbit', 'racket', 'ray', 'red_panda', 'refrigerator', + 'remote_control', 'rubber_eraser', 'rugby_ball', 'ruler', + 'salt_or_pepper_shaker', 'saxophone', 'scorpion', 'screwdriver', + 'seal', 'sheep', 'ski', 'skunk', 'snail', 'snake', 'snowmobile', + 'snowplow', 'soap_dispenser', 'soccer_ball', 'sofa', 'spatula', + 'squirrel', 'starfish', 'stethoscope', 'stove', 'strainer', + 'strawberry', 'stretcher', 'sunglasses', 'swimming_trunks', 'swine', + 'syringe', 'table', 'tape_player', 'tennis_ball', 'tick', 'tie', + 'tiger', 'toaster', 'traffic_light', 'train', 'trombone', 'trumpet', + 'turtle', 'tv_or_monitor', 'unicycle', 'vacuum', 'violin', + 'volleyball', 'waffle_iron', 'washer', 'water_bottle', 'watercraft', + 'whale', 'wine_bottle', 'zebra' + ] + + +def imagenet_vid_classes(): + return [ + 'airplane', 'antelope', 'bear', 'bicycle', 'bird', 'bus', 'car', + 'cattle', 'dog', 'domestic_cat', 'elephant', 'fox', 'giant_panda', + 'hamster', 'horse', 'lion', 'lizard', 'monkey', 'motorcycle', 'rabbit', + 'red_panda', 'sheep', 'snake', 'squirrel', 'tiger', 'train', 'turtle', + 'watercraft', 'whale', 'zebra' + ] + + +def coco_classes(): + return [ + 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', + 'truck', 'boat', 'traffic_light', 'fire_hydrant', 'stop_sign', + 'parking_meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', + 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', + 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', + 'sports_ball', 'kite', 'baseball_bat', 'baseball_glove', 'skateboard', + 'surfboard', 'tennis_racket', 'bottle', 'wine_glass', 'cup', 'fork', + 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', + 'broccoli', 'carrot', 'hot_dog', 'pizza', 'donut', 'cake', 'chair', + 'couch', 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', + 'laptop', 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', + 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', + 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush' + ] + + +dataset_aliases = { + 'voc': ['voc', 'pascal_voc', 'voc07', 'voc12'], + 'imagenet_det': ['det', 'imagenet_det', 'ilsvrc_det'], + 'imagenet_vid': ['vid', 'imagenet_vid', 'ilsvrc_vid'], + 'coco': ['coco', 'mscoco', 'ms_coco'], + 'wider_face': ['WIDERFaceDataset', 'wider_face', 'WDIERFace'] +} + + +def get_classes(dataset): + """Get class names of a dataset.""" + alias2name = {} + for name, aliases in dataset_aliases.items(): + for alias in aliases: + alias2name[alias] = name + + if mmcv.is_str(dataset): + if dataset in alias2name: + labels = eval(alias2name[dataset] + '_classes()') + else: + raise ValueError('Unrecognized dataset: {}'.format(dataset)) + else: + raise TypeError('dataset must a str, but got {}'.format(type(dataset))) + return labels diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py new file mode 100644 index 000000000..3022ad014 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/coco_utils.py @@ -0,0 +1,177 @@ +import mmcv +import numpy as np +from pycocotools.coco import COCO +from pycocotools.cocoeval import COCOeval + +from .recall import eval_recalls + + +def coco_eval(result_files, result_types, coco, max_dets=(100, 300, 1000)): + for res_type in result_types: + assert res_type in [ + 'proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints' + ] + + if mmcv.is_str(coco): + coco = COCO(coco) + assert isinstance(coco, COCO) + + if result_types == ['proposal_fast']: + ar = fast_eval_recall(result_files, coco, np.array(max_dets)) + for i, num in enumerate(max_dets): + print('AR@{}\t= {:.4f}'.format(num, ar[i])) + return + + for res_type in result_types: + result_file = result_files[res_type] + assert result_file.endswith('.json') + + coco_dets = coco.loadRes(result_file) + img_ids = coco.getImgIds() + iou_type = 'bbox' if res_type == 'proposal' else res_type + cocoEval = COCOeval(coco, coco_dets, iou_type) + cocoEval.params.imgIds = img_ids + if res_type == 'proposal': + cocoEval.params.useCats = 0 + cocoEval.params.maxDets = list(max_dets) + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + + +def fast_eval_recall(results, + coco, + max_dets, + iou_thrs=np.arange(0.5, 0.96, 0.05)): + if mmcv.is_str(results): + assert results.endswith('.pkl') + results = mmcv.load(results) + elif not isinstance(results, list): + raise TypeError( + 'results must be a list of numpy arrays or a filename, not {}'. + format(type(results))) + + gt_bboxes = [] + img_ids = coco.getImgIds() + for i in range(len(img_ids)): + ann_ids = coco.getAnnIds(imgIds=img_ids[i]) + ann_info = coco.loadAnns(ann_ids) + if len(ann_info) == 0: + gt_bboxes.append(np.zeros((0, 4))) + continue + bboxes = [] + for ann in ann_info: + if ann.get('ignore', False) or ann['iscrowd']: + continue + x1, y1, w, h = ann['bbox'] + bboxes.append([x1, y1, x1 + w - 1, y1 + h - 1]) + bboxes = np.array(bboxes, dtype=np.float32) + if bboxes.shape[0] == 0: + bboxes = np.zeros((0, 4)) + gt_bboxes.append(bboxes) + + recalls = eval_recalls( + gt_bboxes, results, max_dets, iou_thrs, print_summary=False) + ar = recalls.mean(axis=1) + return ar + + +def xyxy2xywh(bbox): + _bbox = bbox.tolist() + return [ + _bbox[0], + _bbox[1], + _bbox[2] - _bbox[0] + 1, + _bbox[3] - _bbox[1] + 1, + ] + + +def proposal2json(dataset, results): + json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + bboxes = results[idx] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = 1 + json_results.append(data) + return json_results + + +def det2json(dataset, results): + json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + result = results[idx] + for label in range(len(result)): + bboxes = result[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = dataset.cat_ids[label] + json_results.append(data) + return json_results + + +def segm2json(dataset, results): + bbox_json_results = [] + segm_json_results = [] + for idx in range(len(dataset)): + img_id = dataset.img_ids[idx] + det, seg = results[idx] + for label in range(len(det)): + # bbox results + bboxes = det[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = dataset.cat_ids[label] + bbox_json_results.append(data) + + # segm results + # some detectors use different score for det and segm + if len(seg) == 2: + segms = seg[0][label] + mask_score = seg[1][label] + else: + segms = seg[label] + mask_score = [bbox[4] for bbox in bboxes] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['score'] = float(mask_score[i]) + data['category_id'] = dataset.cat_ids[label] + segms[i]['counts'] = segms[i]['counts'].decode() + data['segmentation'] = segms[i] + segm_json_results.append(data) + return bbox_json_results, segm_json_results + + +def results2json(dataset, results, out_file): + result_files = dict() + if isinstance(results[0], list): + json_results = det2json(dataset, results) + result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') + mmcv.dump(json_results, result_files['bbox']) + elif isinstance(results[0], tuple): + json_results = segm2json(dataset, results) + result_files['bbox'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['proposal'] = '{}.{}.json'.format(out_file, 'bbox') + result_files['segm'] = '{}.{}.json'.format(out_file, 'segm') + mmcv.dump(json_results[0], result_files['bbox']) + mmcv.dump(json_results[1], result_files['segm']) + elif isinstance(results[0], np.ndarray): + json_results = proposal2json(dataset, results) + result_files['proposal'] = '{}.{}.json'.format(out_file, 'proposal') + mmcv.dump(json_results, result_files['proposal']) + else: + raise TypeError('invalid type of results') + return result_files diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/eval_hooks.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/eval_hooks.py new file mode 100644 index 000000000..e75bffbf4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/eval_hooks.py @@ -0,0 +1,74 @@ +import os +import os.path as osp + +import mmcv +import torch +import torch.distributed as dist +from mmcv.parallel import collate, scatter +from mmcv.runner import Hook +from torch.utils.data import Dataset + + +class DistEvalHook(Hook): + + def __init__(self, dataset, interval=1, **eval_kwargs): + from mmdet import datasets + if isinstance(dataset, Dataset): + self.dataset = dataset + elif isinstance(dataset, dict): + self.dataset = datasets.build_dataset(dataset, {'test_mode': True}) + else: + raise TypeError( + 'dataset must be a Dataset object or a dict, not {}'.format( + type(dataset))) + self.interval = interval + self.eval_kwargs = eval_kwargs + + def after_train_epoch(self, runner): + if not self.every_n_epochs(runner, self.interval): + return + runner.model.eval() + results = [None for _ in range(len(self.dataset))] + if runner.rank == 0: + prog_bar = mmcv.ProgressBar(len(self.dataset)) + for idx in range(runner.rank, len(self.dataset), runner.world_size): + data = self.dataset[idx] + data_gpu = scatter( + collate([data], samples_per_gpu=1), + [torch.cuda.current_device()])[0] + + # compute output + with torch.no_grad(): + result = runner.model( + return_loss=False, rescale=True, **data_gpu) + results[idx] = result + + batch_size = runner.world_size + if idx % 200 == 0: + if runner.rank == 0: + for _ in range(0, batch_size, 10): + prog_bar.update() + + if runner.rank == 0: + print('\n') + dist.barrier() + for i in range(1, runner.world_size): + tmp_file = osp.join(runner.work_dir, 'temp_{}.pkl'.format(i)) + tmp_results = mmcv.load(tmp_file) + for idx in range(i, len(results), runner.world_size): + results[idx] = tmp_results[idx] + os.remove(tmp_file) + self.evaluate(runner, results) + else: + tmp_file = osp.join(runner.work_dir, + 'temp_{}.pkl'.format(runner.rank)) + mmcv.dump(results, tmp_file) + dist.barrier() + dist.barrier() + + def evaluate(self, runner, results): + eval_res = self.dataset.evaluate( + results, logger=runner.logger, **self.eval_kwargs) + for name, val in eval_res.items(): + runner.log_buffer.output[name] = val + runner.log_buffer.ready = True \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/mean_ap.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/mean_ap.py new file mode 100644 index 000000000..b60d1cbfb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/mean_ap.py @@ -0,0 +1,455 @@ +from multiprocessing import Pool + +import mmcv +import numpy as np +from terminaltables import AsciiTable + +from mmdet.utils import print_log +from .bbox_overlaps import bbox_overlaps +from .class_names import get_classes + + +def average_precision(recalls, precisions, mode='area'): + """Calculate average precision (for single or multiple scales). + + Args: + recalls (ndarray): shape (num_scales, num_dets) or (num_dets, ) + precisions (ndarray): shape (num_scales, num_dets) or (num_dets, ) + mode (str): 'area' or '11points', 'area' means calculating the area + under precision-recall curve, '11points' means calculating + the average precision of recalls at [0, 0.1, ..., 1] + + Returns: + float or ndarray: calculated average precision + """ + no_scale = False + if recalls.ndim == 1: + no_scale = True + recalls = recalls[np.newaxis, :] + precisions = precisions[np.newaxis, :] + assert recalls.shape == precisions.shape and recalls.ndim == 2 + num_scales = recalls.shape[0] + ap = np.zeros(num_scales, dtype=np.float32) + if mode == 'area': + zeros = np.zeros((num_scales, 1), dtype=recalls.dtype) + ones = np.ones((num_scales, 1), dtype=recalls.dtype) + mrec = np.hstack((zeros, recalls, ones)) + mpre = np.hstack((zeros, precisions, zeros)) + for i in range(mpre.shape[1] - 1, 0, -1): + mpre[:, i - 1] = np.maximum(mpre[:, i - 1], mpre[:, i]) + for i in range(num_scales): + ind = np.where(mrec[i, 1:] != mrec[i, :-1])[0] + ap[i] = np.sum( + (mrec[i, ind + 1] - mrec[i, ind]) * mpre[i, ind + 1]) + elif mode == '11points': + for i in range(num_scales): + for thr in np.arange(0, 1 + 1e-3, 0.1): + precs = precisions[i, recalls[i, :] >= thr] + prec = precs.max() if precs.size > 0 else 0 + ap[i] += prec + ap /= 11 + else: + raise ValueError( + 'Unrecognized mode, only "area" and "11points" are supported') + if no_scale: + ap = ap[0] + return ap + + +def tpfp_imagenet(det_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + default_iou_thr=0.5, + area_ranges=None): + """Check if detected bboxes are true positive or false positive. + + Args: + det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). + gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). + gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, + of shape (k, 4). Default: None + default_iou_thr (float): IoU threshold to be considered as matched for + medium and large bboxes (small ones have special rules). + Default: 0.5. + area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. Default: None. + + Returns: + tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of + each array is (num_scales, m). + """ + # an indicator of ignored gts + gt_ignore_inds = np.concatenate( + (np.zeros(gt_bboxes.shape[0], dtype=np.bool), + np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool))) + # stack gt_bboxes and gt_bboxes_ignore for convenience + gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore)) + + num_dets = det_bboxes.shape[0] + num_gts = gt_bboxes.shape[0] + if area_ranges is None: + area_ranges = [(None, None)] + num_scales = len(area_ranges) + # tp and fp are of shape (num_scales, num_gts), each row is tp or fp + # of a certain scale. + tp = np.zeros((num_scales, num_dets), dtype=np.float32) + fp = np.zeros((num_scales, num_dets), dtype=np.float32) + if gt_bboxes.shape[0] == 0: + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + return tp, fp + ious = bbox_overlaps(det_bboxes, gt_bboxes - 1) + gt_w = gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1 + gt_h = gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1 + iou_thrs = np.minimum((gt_w * gt_h) / ((gt_w + 10.0) * (gt_h + 10.0)), + default_iou_thr) + # sort all detections by scores in descending order + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + gt_covered = np.zeros(num_gts, dtype=bool) + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = gt_w * gt_h + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + max_iou = -1 + matched_gt = -1 + # find best overlapped available gt + for j in range(num_gts): + # different from PASCAL VOC: allow finding other gts if the + # best overlaped ones are already matched by other det bboxes + if gt_covered[j]: + continue + elif ious[i, j] >= iou_thrs[j] and ious[i, j] > max_iou: + max_iou = ious[i, j] + matched_gt = j + # there are 4 cases for a det bbox: + # 1. it matches a gt, tp = 1, fp = 0 + # 2. it matches an ignored gt, tp = 0, fp = 0 + # 3. it matches no gt and within area range, tp = 0, fp = 1 + # 4. it matches no gt but is beyond area range, tp = 0, fp = 0 + if matched_gt >= 0: + gt_covered[matched_gt] = 1 + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + tp[k, i] = 1 + elif min_area is None: + fp[k, i] = 1 + else: + bbox = det_bboxes[i, :4] + area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + if area >= min_area and area < max_area: + fp[k, i] = 1 + return tp, fp + + +def tpfp_default(det_bboxes, + gt_bboxes, + gt_bboxes_ignore=None, + iou_thr=0.5, + area_ranges=None): + """Check if detected bboxes are true positive or false positive. + + Args: + det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5). + gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4). + gt_bboxes_ignore (ndarray): Ignored gt bboxes of this image, + of shape (k, 4). Default: None + iou_thr (float): IoU threshold to be considered as matched. + Default: 0.5. + area_ranges (list[tuple] | None): Range of bbox areas to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. Default: None. + + Returns: + tuple[np.ndarray]: (tp, fp) whose elements are 0 and 1. The shape of + each array is (num_scales, m). + """ + # an indicator of ignored gts + gt_ignore_inds = np.concatenate( + (np.zeros(gt_bboxes.shape[0], dtype=np.bool), + np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool))) + # stack gt_bboxes and gt_bboxes_ignore for convenience + gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore)) + + num_dets = det_bboxes.shape[0] + num_gts = gt_bboxes.shape[0] + if area_ranges is None: + area_ranges = [(None, None)] + num_scales = len(area_ranges) + # tp and fp are of shape (num_scales, num_gts), each row is tp or fp of + # a certain scale + tp = np.zeros((num_scales, num_dets), dtype=np.float32) + fp = np.zeros((num_scales, num_dets), dtype=np.float32) + + # if there is no gt bboxes in this image, then all det bboxes + # within area range are false positives + if gt_bboxes.shape[0] == 0: + if area_ranges == [(None, None)]: + fp[...] = 1 + else: + det_areas = (det_bboxes[:, 2] - det_bboxes[:, 0] + 1) * ( + det_bboxes[:, 3] - det_bboxes[:, 1] + 1) + for i, (min_area, max_area) in enumerate(area_ranges): + fp[i, (det_areas >= min_area) & (det_areas < max_area)] = 1 + return tp, fp + + ious = bbox_overlaps(det_bboxes, gt_bboxes) + # for each det, the max iou with all gts + ious_max = ious.max(axis=1) + # for each det, which gt overlaps most with it + ious_argmax = ious.argmax(axis=1) + # sort all dets in descending order by scores + sort_inds = np.argsort(-det_bboxes[:, -1]) + for k, (min_area, max_area) in enumerate(area_ranges): + gt_covered = np.zeros(num_gts, dtype=bool) + # if no area range is specified, gt_area_ignore is all False + if min_area is None: + gt_area_ignore = np.zeros_like(gt_ignore_inds, dtype=bool) + else: + gt_areas = (gt_bboxes[:, 2] - gt_bboxes[:, 0] + 1) * ( + gt_bboxes[:, 3] - gt_bboxes[:, 1] + 1) + gt_area_ignore = (gt_areas < min_area) | (gt_areas >= max_area) + for i in sort_inds: + if ious_max[i] >= iou_thr: + matched_gt = ious_argmax[i] + if not (gt_ignore_inds[matched_gt] + or gt_area_ignore[matched_gt]): + if not gt_covered[matched_gt]: + gt_covered[matched_gt] = True + tp[k, i] = 1 + else: + fp[k, i] = 1 + # otherwise ignore this detected bbox, tp = 0, fp = 0 + elif min_area is None: + fp[k, i] = 1 + else: + bbox = det_bboxes[i, :4] + area = (bbox[2] - bbox[0] + 1) * (bbox[3] - bbox[1] + 1) + if area >= min_area and area < max_area: + fp[k, i] = 1 + return tp, fp + + +def get_cls_results(det_results, annotations, class_id): + """Get det results and gt information of a certain class. + + Args: + det_results (list[list]): Same as `eval_map()`. + annotations (list[dict]): Same as `eval_map()`. + + Returns: + tuple[list[np.ndarray]]: detected bboxes, gt bboxes, ignored gt bboxes + """ + cls_dets = [img_res[class_id] for img_res in det_results] + cls_gts = [] + cls_gts_ignore = [] + for ann in annotations: + gt_inds = ann['labels'] == (class_id + 1) + cls_gts.append(ann['bboxes'][gt_inds, :]) + + if ann.get('labels_ignore', None) is not None: + ignore_inds = ann['labels_ignore'] == (class_id + 1) + cls_gts_ignore.append(ann['bboxes_ignore'][ignore_inds, :]) + else: + cls_gts_ignore.append(np.array((0, 4), dtype=np.float32)) + + return cls_dets, cls_gts, cls_gts_ignore + + +def eval_map(det_results, + annotations, + scale_ranges=None, + iou_thr=0.5, + dataset=None, + logger=None, + nproc=4): + """Evaluate mAP of a dataset. + + Args: + det_results (list[list]): [[cls1_det, cls2_det, ...], ...]. + The outer list indicates images, and the inner list indicates + per-class detected bboxes. + annotations (list[dict]): Ground truth annotations where each item of + the list indicates an image. Keys of annotations are: + - "bboxes": numpy array of shape (n, 4) + - "labels": numpy array of shape (n, ) + - "bboxes_ignore" (optional): numpy array of shape (k, 4) + - "labels_ignore" (optional): numpy array of shape (k, ) + scale_ranges (list[tuple] | None): Range of scales to be evaluated, + in the format [(min1, max1), (min2, max2), ...]. A range of + (32, 64) means the area range between (32**2, 64**2). + Default: None. + iou_thr (float): IoU threshold to be considered as matched. + Default: 0.5. + dataset (list[str] | str | None): Dataset name or dataset classes, + there are minor differences in metrics for different datsets, e.g. + "voc07", "imagenet_det", etc. Default: None. + logger (logging.Logger | str | None): The way to print the mAP + summary. See `mmdet.utils.print_log()` for details. Default: None. + nproc (int): Processes used for computing TP and FP. + Default: 4. + + Returns: + tuple: (mAP, [dict, dict, ...]) + """ + assert len(det_results) == len(annotations) + + num_imgs = len(det_results) + num_scales = len(scale_ranges) if scale_ranges is not None else 1 + num_classes = len(det_results[0]) # positive class num + area_ranges = ([(rg[0]**2, rg[1]**2) for rg in scale_ranges] + if scale_ranges is not None else None) + + pool = Pool(nproc) + eval_results = [] + for i in range(num_classes): + # get gt and det bboxes of this class + cls_dets, cls_gts, cls_gts_ignore = get_cls_results( + det_results, annotations, i) + # choose proper function according to datasets to compute tp and fp + if dataset in ['det', 'vid']: + tpfp_func = tpfp_imagenet + else: + tpfp_func = tpfp_default + # compute tp and fp for each image with multiple processes + tpfp = pool.starmap( + tpfp_func, + zip(cls_dets, cls_gts, cls_gts_ignore, + [iou_thr for _ in range(num_imgs)], + [area_ranges for _ in range(num_imgs)])) + tp, fp = tuple(zip(*tpfp)) + # calculate gt number of each scale + # ignored gts or gts beyond the specific scale are not counted + num_gts = np.zeros(num_scales, dtype=int) + for j, bbox in enumerate(cls_gts): + if area_ranges is None: + num_gts[0] += bbox.shape[0] + else: + gt_areas = (bbox[:, 2] - bbox[:, 0] + 1) * ( + bbox[:, 3] - bbox[:, 1] + 1) + for k, (min_area, max_area) in enumerate(area_ranges): + num_gts[k] += np.sum((gt_areas >= min_area) + & (gt_areas < max_area)) + # sort all det bboxes by score, also sort tp and fp + cls_dets = np.vstack(cls_dets) + num_dets = cls_dets.shape[0] + sort_inds = np.argsort(-cls_dets[:, -1]) + tp = np.hstack(tp)[:, sort_inds] + fp = np.hstack(fp)[:, sort_inds] + # calculate recall and precision with tp and fp + tp = np.cumsum(tp, axis=1) + fp = np.cumsum(fp, axis=1) + eps = np.finfo(np.float32).eps + recalls = tp / np.maximum(num_gts[:, np.newaxis], eps) + precisions = tp / np.maximum((tp + fp), eps) + # calculate AP + if scale_ranges is None: + recalls = recalls[0, :] + precisions = precisions[0, :] + num_gts = num_gts.item() + mode = 'area' if dataset != 'voc07' else '11points' + ap = average_precision(recalls, precisions, mode) + eval_results.append({ + 'num_gts': num_gts, + 'num_dets': num_dets, + 'recall': recalls, + 'precision': precisions, + 'ap': ap + }) + if scale_ranges is not None: + # shape (num_classes, num_scales) + all_ap = np.vstack([cls_result['ap'] for cls_result in eval_results]) + all_num_gts = np.vstack( + [cls_result['num_gts'] for cls_result in eval_results]) + mean_ap = [] + for i in range(num_scales): + if np.any(all_num_gts[:, i] > 0): + mean_ap.append(all_ap[all_num_gts[:, i] > 0, i].mean()) + else: + mean_ap.append(0.0) + else: + aps = [] + for cls_result in eval_results: + if cls_result['num_gts'] > 0: + aps.append(cls_result['ap']) + mean_ap = np.array(aps).mean().item() if aps else 0.0 + + print_map_summary( + mean_ap, eval_results, dataset, area_ranges, logger=logger) + + return mean_ap, eval_results + + +def print_map_summary(mean_ap, + results, + dataset=None, + scale_ranges=None, + logger=None): + """Print mAP and results of each class. + + A table will be printed to show the gts/dets/recall/AP of each class and + the mAP. + + Args: + mean_ap (float): Calculated from `eval_map()`. + results (list[dict]): Calculated from `eval_map()`. + dataset (list[str] | str | None): Dataset name or dataset classes. + scale_ranges (list[tuple] | None): Range of scales to be evaluated. + logger (logging.Logger | str | None): The way to print the mAP + summary. See `mmdet.utils.print_log()` for details. Default: None. + """ + + if logger == 'silent': + return + + if isinstance(results[0]['ap'], np.ndarray): + num_scales = len(results[0]['ap']) + else: + num_scales = 1 + + if scale_ranges is not None: + assert len(scale_ranges) == num_scales + + num_classes = len(results) + + recalls = np.zeros((num_scales, num_classes), dtype=np.float32) + aps = np.zeros((num_scales, num_classes), dtype=np.float32) + num_gts = np.zeros((num_scales, num_classes), dtype=int) + for i, cls_result in enumerate(results): + if cls_result['recall'].size > 0: + recalls[:, i] = np.array(cls_result['recall'], ndmin=2)[:, -1] + aps[:, i] = cls_result['ap'] + num_gts[:, i] = cls_result['num_gts'] + + if dataset is None: + label_names = [str(i) for i in range(1, num_classes + 1)] + elif mmcv.is_str(dataset): + label_names = get_classes(dataset) + else: + label_names = dataset + + if not isinstance(mean_ap, list): + mean_ap = [mean_ap] + + header = ['class', 'gts', 'dets', 'recall', 'ap'] + for i in range(num_scales): + if scale_ranges is not None: + print_log('Scale range {}'.format(scale_ranges[i]), logger=logger) + table_data = [header] + for j in range(num_classes): + row_data = [ + label_names[j], num_gts[i, j], results[j]['num_dets'], + '{:.3f}'.format(recalls[i, j]), '{:.3f}'.format(aps[i, j]) + ] + table_data.append(row_data) + table_data.append(['mAP', '', '', '', '{:.3f}'.format(mean_ap[i])]) + table = AsciiTable(table_data) + table.inner_footing_row_border = True + print_log('\n' + table.table, logger=logger) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/recall.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/recall.py new file mode 100644 index 000000000..132c9ec1d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/evaluation/recall.py @@ -0,0 +1,193 @@ +from collections.abc import Sequence + +import numpy as np +from terminaltables import AsciiTable + +from mmdet.utils import print_log +from .bbox_overlaps import bbox_overlaps + + +def _recalls(all_ious, proposal_nums, thrs): + + img_num = all_ious.shape[0] + total_gt_num = sum([ious.shape[0] for ious in all_ious]) + + _ious = np.zeros((proposal_nums.size, total_gt_num), dtype=np.float32) + for k, proposal_num in enumerate(proposal_nums): + tmp_ious = np.zeros(0) + for i in range(img_num): + ious = all_ious[i][:, :proposal_num].copy() + gt_ious = np.zeros((ious.shape[0])) + if ious.size == 0: + tmp_ious = np.hstack((tmp_ious, gt_ious)) + continue + for j in range(ious.shape[0]): + gt_max_overlaps = ious.argmax(axis=1) + max_ious = ious[np.arange(0, ious.shape[0]), gt_max_overlaps] + gt_idx = max_ious.argmax() + gt_ious[j] = max_ious[gt_idx] + box_idx = gt_max_overlaps[gt_idx] + ious[gt_idx, :] = -1 + ious[:, box_idx] = -1 + tmp_ious = np.hstack((tmp_ious, gt_ious)) + _ious[k, :] = tmp_ious + + _ious = np.fliplr(np.sort(_ious, axis=1)) + recalls = np.zeros((proposal_nums.size, thrs.size)) + for i, thr in enumerate(thrs): + recalls[:, i] = (_ious >= thr).sum(axis=1) / float(total_gt_num) + + return recalls + + +def set_recall_param(proposal_nums, iou_thrs): + """Check proposal_nums and iou_thrs and set correct format. + """ + if isinstance(proposal_nums, Sequence): + _proposal_nums = np.array(proposal_nums) + elif isinstance(proposal_nums, int): + _proposal_nums = np.array([proposal_nums]) + else: + _proposal_nums = proposal_nums + + if iou_thrs is None: + _iou_thrs = np.array([0.5]) + elif isinstance(iou_thrs, Sequence): + _iou_thrs = np.array(iou_thrs) + elif isinstance(iou_thrs, float): + _iou_thrs = np.array([iou_thrs]) + else: + _iou_thrs = iou_thrs + + return _proposal_nums, _iou_thrs + + +def eval_recalls(gts, + proposals, + proposal_nums=None, + iou_thrs=0.5, + logger=None): + """Calculate recalls. + + Args: + gts (list[ndarray]): a list of arrays of shape (n, 4) + proposals (list[ndarray]): a list of arrays of shape (k, 4) or (k, 5) + proposal_nums (int | Sequence[int]): Top N proposals to be evaluated. + iou_thrs (float | Sequence[float]): IoU thresholds. Default: 0.5. + logger (logging.Logger | str | None): The way to print the recall + summary. See `mmdet.utils.print_log()` for details. Default: None. + + Returns: + ndarray: recalls of different ious and proposal nums + """ + + img_num = len(gts) + assert img_num == len(proposals) + + proposal_nums, iou_thrs = set_recall_param(proposal_nums, iou_thrs) + + all_ious = [] + for i in range(img_num): + if proposals[i].ndim == 2 and proposals[i].shape[1] == 5: + scores = proposals[i][:, 4] + sort_idx = np.argsort(scores)[::-1] + img_proposal = proposals[i][sort_idx, :] + else: + img_proposal = proposals[i] + prop_num = min(img_proposal.shape[0], proposal_nums[-1]) + if gts[i] is None or gts[i].shape[0] == 0: + ious = np.zeros((0, img_proposal.shape[0]), dtype=np.float32) + else: + ious = bbox_overlaps(gts[i], img_proposal[:prop_num, :4]) + all_ious.append(ious) + all_ious = np.array(all_ious) + recalls = _recalls(all_ious, proposal_nums, iou_thrs) + + print_recall_summary(recalls, proposal_nums, iou_thrs, logger=logger) + return recalls + + +def print_recall_summary(recalls, + proposal_nums, + iou_thrs, + row_idxs=None, + col_idxs=None, + logger=None): + """Print recalls in a table. + + Args: + recalls (ndarray): calculated from `bbox_recalls` + proposal_nums (ndarray or list): top N proposals + iou_thrs (ndarray or list): iou thresholds + row_idxs (ndarray): which rows(proposal nums) to print + col_idxs (ndarray): which cols(iou thresholds) to print + logger (logging.Logger | str | None): The way to print the recall + summary. See `mmdet.utils.print_log()` for details. Default: None. + """ + proposal_nums = np.array(proposal_nums, dtype=np.int32) + iou_thrs = np.array(iou_thrs) + if row_idxs is None: + row_idxs = np.arange(proposal_nums.size) + if col_idxs is None: + col_idxs = np.arange(iou_thrs.size) + row_header = [''] + iou_thrs[col_idxs].tolist() + table_data = [row_header] + for i, num in enumerate(proposal_nums[row_idxs]): + row = [ + '{:.3f}'.format(val) + for val in recalls[row_idxs[i], col_idxs].tolist() + ] + row.insert(0, num) + table_data.append(row) + table = AsciiTable(table_data) + print_log('\n' + table.table, logger=logger) + + +def plot_num_recall(recalls, proposal_nums): + """Plot Proposal_num-Recalls curve. + + Args: + recalls(ndarray or list): shape (k,) + proposal_nums(ndarray or list): same shape as `recalls` + """ + if isinstance(proposal_nums, np.ndarray): + _proposal_nums = proposal_nums.tolist() + else: + _proposal_nums = proposal_nums + if isinstance(recalls, np.ndarray): + _recalls = recalls.tolist() + else: + _recalls = recalls + + import matplotlib.pyplot as plt + f = plt.figure() + plt.plot([0] + _proposal_nums, [0] + _recalls) + plt.xlabel('Proposal num') + plt.ylabel('Recall') + plt.axis([0, proposal_nums.max(), 0, 1]) + f.show() + + +def plot_iou_recall(recalls, iou_thrs): + """Plot IoU-Recalls curve. + + Args: + recalls(ndarray or list): shape (k,) + iou_thrs(ndarray or list): same shape as `recalls` + """ + if isinstance(iou_thrs, np.ndarray): + _iou_thrs = iou_thrs.tolist() + else: + _iou_thrs = iou_thrs + if isinstance(recalls, np.ndarray): + _recalls = recalls.tolist() + else: + _recalls = recalls + + import matplotlib.pyplot as plt + f = plt.figure() + plt.plot(_iou_thrs + [1.0], _recalls + [0.]) + plt.xlabel('IoU') + plt.ylabel('Recall') + plt.axis([iou_thrs.min(), 1, 0, 1]) + f.show() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py new file mode 100644 index 000000000..cc655b7c3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/__init__.py @@ -0,0 +1,4 @@ +from .decorators import auto_fp16, force_fp32 +from .hooks import Fp16OptimizerHook, wrap_fp16_model + +__all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py new file mode 100644 index 000000000..10ffbf898 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py @@ -0,0 +1,160 @@ +import functools +from inspect import getfullargspec + +import torch + +from .utils import cast_tensor_type + + +def auto_fp16(apply_to=None, out_fp32=False): + """Decorator to enable fp16 training automatically. + + This decorator is useful when you write custom modules and want to support + mixed precision training. If inputs arguments are fp32 tensors, they will + be converted to fp16 automatically. Arguments other than fp32 tensors are + ignored. + + Args: + apply_to (Iterable, optional): The argument names to be converted. + `None` indicates all arguments. + out_fp32 (bool): Whether to convert the output back to fp32. + + :Example: + + class MyModule1(nn.Module) + + # Convert x and y to fp16 + @auto_fp16() + def forward(self, x, y): + pass + + class MyModule2(nn.Module): + + # convert pred to fp16 + @auto_fp16(apply_to=('pred', )) + def do_something(self, pred, others): + pass + """ + + def auto_fp16_wrapper(old_func): + + @functools.wraps(old_func) + def new_func(*args, **kwargs): + # check if the module has set the attribute `fp16_enabled`, if not, + # just fallback to the original method. + if not isinstance(args[0], torch.nn.Module): + raise TypeError('@auto_fp16 can only be used to decorate the ' + 'method of nn.Module') + if not (hasattr(args[0], 'fp16_enabled') and args[0].fp16_enabled): + return old_func(*args, **kwargs) + # get the arg spec of the decorated method + args_info = getfullargspec(old_func) + # get the argument names to be casted + args_to_cast = args_info.args if apply_to is None else apply_to + # convert the args that need to be processed + new_args = [] + # NOTE: default args are not taken into consideration + if args: + arg_names = args_info.args[:len(args)] + for i, arg_name in enumerate(arg_names): + if arg_name in args_to_cast: + new_args.append( + cast_tensor_type(args[i], torch.float, torch.half)) + else: + new_args.append(args[i]) + # convert the kwargs that need to be processed + new_kwargs = {} + if kwargs: + for arg_name, arg_value in kwargs.items(): + if arg_name in args_to_cast: + new_kwargs[arg_name] = cast_tensor_type( + arg_value, torch.float, torch.half) + else: + new_kwargs[arg_name] = arg_value + # apply converted arguments to the decorated method + output = old_func(*new_args, **new_kwargs) + # cast the results back to fp32 if necessary + if out_fp32: + output = cast_tensor_type(output, torch.half, torch.float) + return output + + return new_func + + return auto_fp16_wrapper + + +def force_fp32(apply_to=None, out_fp16=False): + """Decorator to convert input arguments to fp32 in force. + + This decorator is useful when you write custom modules and want to support + mixed precision training. If there are some inputs that must be processed + in fp32 mode, then this decorator can handle it. If inputs arguments are + fp16 tensors, they will be converted to fp32 automatically. Arguments other + than fp16 tensors are ignored. + + Args: + apply_to (Iterable, optional): The argument names to be converted. + `None` indicates all arguments. + out_fp16 (bool): Whether to convert the output back to fp16. + + :Example: + + class MyModule1(nn.Module) + + # Convert x and y to fp32 + @force_fp32() + def loss(self, x, y): + pass + + class MyModule2(nn.Module): + + # convert pred to fp32 + @force_fp32(apply_to=('pred', )) + def post_process(self, pred, others): + pass + """ + + def force_fp32_wrapper(old_func): + + @functools.wraps(old_func) + def new_func(*args, **kwargs): + # check if the module has set the attribute `fp16_enabled`, if not, + # just fallback to the original method. + if not isinstance(args[0], torch.nn.Module): + raise TypeError('@force_fp32 can only be used to decorate the ' + 'method of nn.Module') + if not (hasattr(args[0], 'fp16_enabled') and args[0].fp16_enabled): + return old_func(*args, **kwargs) + # get the arg spec of the decorated method + args_info = getfullargspec(old_func) + # get the argument names to be casted + args_to_cast = args_info.args if apply_to is None else apply_to + # convert the args that need to be processed + new_args = [] + if args: + arg_names = args_info.args[:len(args)] + for i, arg_name in enumerate(arg_names): + if arg_name in args_to_cast: + new_args.append( + cast_tensor_type(args[i], torch.half, torch.float)) + else: + new_args.append(args[i]) + # convert the kwargs that need to be processed + new_kwargs = dict() + if kwargs: + for arg_name, arg_value in kwargs.items(): + if arg_name in args_to_cast: + new_kwargs[arg_name] = cast_tensor_type( + arg_value, torch.half, torch.float) + else: + new_kwargs[arg_name] = arg_value + # apply converted arguments to the decorated method + output = old_func(*new_args, **new_kwargs) + # cast the results back to fp32 if necessary + if out_fp16: + output = cast_tensor_type(output, torch.float, torch.half) + return output + + return new_func + + return force_fp32_wrapper diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/hooks.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/hooks.py new file mode 100644 index 000000000..b1ab45ef5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/hooks.py @@ -0,0 +1,126 @@ +import copy +import torch +import torch.nn as nn +from mmcv.runner import OptimizerHook + +from .utils import cast_tensor_type +from ..utils.dist_utils import allreduce_grads + + +class Fp16OptimizerHook(OptimizerHook): + """FP16 optimizer hook. + + The steps of fp16 optimizer is as follows. + 1. Scale the loss value. + 2. BP in the fp16 model. + 2. Copy gradients from fp16 model to fp32 weights. + 3. Update fp32 weights. + 4. Copy updated parameters from fp32 weights to fp16 model. + + Refer to https://arxiv.org/abs/1710.03740 for more details. + + Args: + loss_scale (float): Scale factor multiplied with loss. + """ + + def __init__(self, + grad_clip=None, + coalesce=True, + bucket_size_mb=-1, + loss_scale=512., + distributed=True): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + self.loss_scale = loss_scale + self.distributed = distributed + + def before_run(self, runner): + # keep a copy of fp32 weights + runner.optimizer.param_groups = copy.deepcopy( + runner.optimizer.param_groups) + # convert model to fp16 + wrap_fp16_model(runner.model) + + def copy_grads_to_fp32(self, fp16_net, fp32_weights): + """Copy gradients from fp16 model to fp32 weight copy.""" + for fp32_param, fp16_param in zip(fp32_weights, fp16_net.parameters()): + if fp16_param.grad is not None: + if fp32_param.grad is None: + fp32_param.grad = fp32_param.data.new(fp32_param.size()) + fp32_param.grad.copy_(fp16_param.grad) + + def copy_params_to_fp16(self, fp16_net, fp32_weights): + """Copy updated params from fp32 weight copy to fp16 model.""" + for fp16_param, fp32_param in zip(fp16_net.parameters(), fp32_weights): + fp16_param.data.copy_(fp32_param.data) + + def after_train_iter(self, runner): + # clear grads of last iteration + runner.model.zero_grad() + runner.optimizer.zero_grad() + # scale the loss value + scaled_loss = runner.outputs['loss'] * self.loss_scale + scaled_loss.backward() + # copy fp16 grads in the model to fp32 params in the optimizer + fp32_weights = [] + for param_group in runner.optimizer.param_groups: + fp32_weights += param_group['params'] + self.copy_grads_to_fp32(runner.model, fp32_weights) + # allreduce grads + if self.distributed: + allreduce_grads(fp32_weights, self.coalesce, self.bucket_size_mb) + # scale the gradients back + for param in fp32_weights: + if param.grad is not None: + param.grad.div_(self.loss_scale) + if self.grad_clip is not None: + self.clip_grads(fp32_weights) + # update fp32 params + runner.optimizer.step() + # copy fp32 params to the fp16 model + self.copy_params_to_fp16(runner.model, fp32_weights) + + +def wrap_fp16_model(model): + # convert model to fp16 + model.half() + # patch the normalization layers to make it work in fp32 mode + patch_norm_fp32(model) + # set `fp16_enabled` flag + for m in model.modules(): + if hasattr(m, 'fp16_enabled'): + m.fp16_enabled = True + + +def patch_norm_fp32(module): + if isinstance(module, (nn.modules.batchnorm._BatchNorm, nn.GroupNorm)): + module.float() + module.forward = patch_forward_method(module.forward, torch.half, + torch.float) + for child in module.children(): + patch_norm_fp32(child) + return module + + +def patch_forward_method(func, src_type, dst_type, convert_output=True): + """Patch the forward method of a module. + + Args: + func (callable): The original forward method. + src_type (torch.dtype): Type of input arguments to be converted from. + dst_type (torch.dtype): Type of input arguments to be converted to. + convert_output (bool): Whether to convert the output back to src_type. + + Returns: + callable: The patched forward method. + """ + + def new_forward(*args, **kwargs): + output = func(*cast_tensor_type(args, src_type, dst_type), + **cast_tensor_type(kwargs, src_type, dst_type)) + if convert_output: + output = cast_tensor_type(output, dst_type, src_type) + return output + + return new_forward diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/utils.py new file mode 100644 index 000000000..ce691c799 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/utils.py @@ -0,0 +1,23 @@ +from collections import abc + +import numpy as np +import torch + + +def cast_tensor_type(inputs, src_type, dst_type): + if isinstance(inputs, torch.Tensor): + return inputs.to(dst_type) + elif isinstance(inputs, str): + return inputs + elif isinstance(inputs, np.ndarray): + return inputs + elif isinstance(inputs, abc.Mapping): + return type(inputs)({ + k: cast_tensor_type(v, src_type, dst_type) + for k, v in inputs.items() + }) + elif isinstance(inputs, abc.Iterable): + return type(inputs)( + cast_tensor_type(item, src_type, dst_type) for item in inputs) + else: + return inputs diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/__init__.py new file mode 100644 index 000000000..b703b55d3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/__init__.py @@ -0,0 +1,4 @@ +from .utils import split_combined_polys +from .mask_target import mask_target + +__all__ = ['split_combined_polys', 'mask_target'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py new file mode 100644 index 000000000..be93dfc28 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/mask_target.py @@ -0,0 +1,36 @@ +import torch +import numpy as np +import mmcv + + +def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, + cfg): + cfg_list = [cfg for _ in range(len(pos_proposals_list))] + mask_targets = map(mask_target_single, pos_proposals_list, + pos_assigned_gt_inds_list, gt_masks_list, cfg_list) + mask_targets = torch.cat(list(mask_targets)) + return mask_targets + + +def mask_target_single(pos_proposals, pos_assigned_gt_inds, gt_masks, cfg): + mask_size = cfg.mask_size + num_pos = pos_proposals.size(0) + mask_targets = [] + if num_pos > 0: + proposals_np = pos_proposals.cpu().numpy() + pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() + for i in range(num_pos): + gt_mask = gt_masks[pos_assigned_gt_inds[i]] + bbox = proposals_np[i, :].astype(np.int32) + x1, y1, x2, y2 = bbox + w = np.maximum(x2 - x1 + 1, 1) + h = np.maximum(y2 - y1 + 1, 1) + # mask is uint8 both before and after resizing + target = mmcv.imresize(gt_mask[y1:y1 + h, x1:x1 + w], + (mask_size, mask_size)) + mask_targets.append(target) + mask_targets = torch.from_numpy(np.stack(mask_targets)).float().to( + pos_proposals.device) + else: + mask_targets = pos_proposals.new_zeros((0, mask_size, mask_size)) + return mask_targets diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/utils.py new file mode 100644 index 000000000..a68312b17 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/mask/utils.py @@ -0,0 +1,30 @@ +import mmcv + + +def split_combined_polys(polys, poly_lens, polys_per_mask): + """Split the combined 1-D polys into masks. + + A mask is represented as a list of polys, and a poly is represented as + a 1-D array. In dataset, all masks are concatenated into a single 1-D + tensor. Here we need to split the tensor into original representations. + + Args: + polys (list): a list (length = image num) of 1-D tensors + poly_lens (list): a list (length = image num) of poly length + polys_per_mask (list): a list (length = image num) of poly number + of each mask + + Returns: + list: a list (length = image num) of list (length = mask num) of + list (length = poly num) of numpy array + """ + mask_polys_list = [] + for img_id in range(len(polys)): + polys_single = polys[img_id] + polys_lens_single = poly_lens[img_id].tolist() + polys_per_mask_single = polys_per_mask[img_id].tolist() + + split_polys = mmcv.slice_list(polys_single, polys_lens_single) + mask_polys = mmcv.slice_list(split_polys, polys_per_mask_single) + mask_polys_list.append(mask_polys) + return mask_polys_list diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/__init__.py new file mode 100644 index 000000000..1b24a3fc6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/__init__.py @@ -0,0 +1,8 @@ +from .bbox_nms import multiclass_nms +from .merge_augs import (merge_aug_proposals, merge_aug_bboxes, + merge_aug_scores, merge_aug_masks) + +__all__ = [ + 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', + 'merge_aug_scores', 'merge_aug_masks' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/bbox_nms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/bbox_nms.py new file mode 100644 index 000000000..cb3fe21e0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/bbox_nms.py @@ -0,0 +1,64 @@ +import torch + +from mmdet.ops.nms import nms_wrapper + + +def multiclass_nms(multi_bboxes, + multi_scores, + score_thr, + nms_cfg, + max_num=-1, + score_factors=None): + """NMS for multi-class bboxes. + + Args: + multi_bboxes (Tensor): shape (n, #class*4) or (n, 4) + multi_scores (Tensor): shape (n, #class) + score_thr (float): bbox threshold, bboxes with scores lower than it + will not be considered. + nms_thr (float): NMS IoU threshold + max_num (int): if there are more than max_num bboxes after NMS, + only top max_num will be kept. + score_factors (Tensor): The factors multiplied to scores before + applying NMS + + Returns: + tuple: (bboxes, labels), tensors of shape (k, 5) and (k, 1). Labels + are 0-based. + """ + num_classes = multi_scores.shape[1] + bboxes, labels = [], [] + nms_cfg_ = nms_cfg.copy() + nms_type = nms_cfg_.pop('type', 'nms') + nms_op = getattr(nms_wrapper, nms_type) + for i in range(1, num_classes): + cls_inds = multi_scores[:, i] > score_thr + if not cls_inds.any(): + continue + # get bboxes and scores of this class + if multi_bboxes.shape[1] == 4: + _bboxes = multi_bboxes[cls_inds, :] + else: + _bboxes = multi_bboxes[cls_inds, i * 4:(i + 1) * 4] + _scores = multi_scores[cls_inds, i] + if score_factors is not None: + _scores *= score_factors[cls_inds] + cls_dets = torch.cat([_bboxes, _scores[:, None]], dim=1) + cls_dets, _ = nms_op(cls_dets, **nms_cfg_) + cls_labels = multi_bboxes.new_full( + (cls_dets.shape[0], ), i - 1, dtype=torch.long) + bboxes.append(cls_dets) + labels.append(cls_labels) + if bboxes: + bboxes = torch.cat(bboxes) + labels = torch.cat(labels) + if bboxes.shape[0] > max_num: + _, inds = bboxes[:, -1].sort(descending=True) + inds = inds[:max_num] + bboxes = bboxes[inds] + labels = labels[inds] + else: + bboxes = multi_bboxes.new_zeros((0, 5)) + labels = multi_bboxes.new_zeros((0, ), dtype=torch.long) + + return bboxes, labels diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/merge_augs.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/merge_augs.py new file mode 100644 index 000000000..f97954b8a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/post_processing/merge_augs.py @@ -0,0 +1,96 @@ +import torch + +import numpy as np + +from mmdet.ops import nms +from ..bbox import bbox_mapping_back + + +def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): + """Merge augmented proposals (multiscale, flip, etc.) + + Args: + aug_proposals (list[Tensor]): proposals from different testing + schemes, shape (n, 5). Note that they are not rescaled to the + original image size. + img_metas (list[dict]): image info including "shape_scale" and "flip". + rpn_test_cfg (dict): rpn test config. + + Returns: + Tensor: shape (n, 4), proposals corresponding to original image scale. + """ + recovered_proposals = [] + for proposals, img_info in zip(aug_proposals, img_metas): + img_shape = img_info['img_shape'] + scale_factor = img_info['scale_factor'] + flip = img_info['flip'] + _proposals = proposals.clone() + _proposals[:, :4] = bbox_mapping_back(_proposals[:, :4], img_shape, + scale_factor, flip) + recovered_proposals.append(_proposals) + aug_proposals = torch.cat(recovered_proposals, dim=0) + merged_proposals, _ = nms(aug_proposals, rpn_test_cfg.nms_thr) + scores = merged_proposals[:, 4] + _, order = scores.sort(0, descending=True) + num = min(rpn_test_cfg.max_num, merged_proposals.shape[0]) + order = order[:num] + merged_proposals = merged_proposals[order, :] + return merged_proposals + + +def merge_aug_bboxes(aug_bboxes, aug_scores, img_metas, rcnn_test_cfg): + """Merge augmented detection bboxes and scores. + + Args: + aug_bboxes (list[Tensor]): shape (n, 4*#class) + aug_scores (list[Tensor] or None): shape (n, #class) + img_shapes (list[Tensor]): shape (3, ). + rcnn_test_cfg (dict): rcnn test config. + + Returns: + tuple: (bboxes, scores) + """ + recovered_bboxes = [] + for bboxes, img_info in zip(aug_bboxes, img_metas): + img_shape = img_info[0]['img_shape'] + scale_factor = img_info[0]['scale_factor'] + flip = img_info[0]['flip'] + bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) + recovered_bboxes.append(bboxes) + bboxes = torch.stack(recovered_bboxes).mean(dim=0) + if aug_scores is None: + return bboxes + else: + scores = torch.stack(aug_scores).mean(dim=0) + return bboxes, scores + + +def merge_aug_scores(aug_scores): + """Merge augmented bbox scores.""" + if isinstance(aug_scores[0], torch.Tensor): + return torch.mean(torch.stack(aug_scores), dim=0) + else: + return np.mean(aug_scores, axis=0) + + +def merge_aug_masks(aug_masks, img_metas, rcnn_test_cfg, weights=None): + """Merge augmented mask prediction. + + Args: + aug_masks (list[ndarray]): shape (n, #class, h, w) + img_shapes (list[ndarray]): shape (3, ). + rcnn_test_cfg (dict): rcnn test config. + + Returns: + tuple: (bboxes, scores) + """ + recovered_masks = [ + mask if not img_info[0]['flip'] else mask[..., ::-1] + for mask, img_info in zip(aug_masks, img_metas) + ] + if weights is None: + merged_masks = np.mean(recovered_masks, axis=0) + else: + merged_masks = np.average( + np.array(recovered_masks), axis=0, weights=np.array(weights)) + return merged_masks diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/__init__.py new file mode 100644 index 000000000..c1a24a64e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/__init__.py @@ -0,0 +1,7 @@ +from .dist_utils import allreduce_grads, DistOptimizerHook, DistOptimizerArchHook +from .misc import tensor2imgs, unmap, multi_apply + +__all__ = [ + 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', + 'multi_apply', 'DistOptimizerArchHook' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/dist_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/dist_utils.py new file mode 100644 index 000000000..b29236c06 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/dist_utils.py @@ -0,0 +1,89 @@ +from collections import OrderedDict + +import os +import torch.distributed as dist +from torch._utils import (_flatten_dense_tensors, _unflatten_dense_tensors, + _take_tensors) +from mmcv.runner import OptimizerHook, OptimizerArchHook + + +def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): + if bucket_size_mb > 0: + bucket_size_bytes = bucket_size_mb * 1024 * 1024 + buckets = _take_tensors(tensors, bucket_size_bytes) + else: + buckets = OrderedDict() + for tensor in tensors: + tp = tensor.type() + if tp not in buckets: + buckets[tp] = [] + buckets[tp].append(tensor) + buckets = buckets.values() + + for bucket in buckets: + flat_tensors = _flatten_dense_tensors(bucket) + dist.all_reduce(flat_tensors) + flat_tensors.div_(world_size) + for tensor, synced in zip( + bucket, _unflatten_dense_tensors(flat_tensors, bucket)): + tensor.copy_(synced) + + +def allreduce_grads(params, coalesce=True, bucket_size_mb=-1): + grads = [ + param.grad.data for param in params + if param.requires_grad and param.grad is not None + ] + world_size = dist.get_world_size() + if coalesce: + _allreduce_coalesced(grads, world_size, bucket_size_mb) + else: + for tensor in grads: + dist.all_reduce(tensor.div_(world_size)) + + +class DistOptimizerHook(OptimizerHook): + def __init__(self, grad_clip=None, coalesce=True, bucket_size_mb=-1): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + + def after_train_iter(self, runner): + #if runner.rank == 0: + # os.system('df -h /dev/shm/') + runner.optimizer.zero_grad() + runner.outputs['loss'].backward() + allreduce_grads(runner.model.parameters(), self.coalesce, + self.bucket_size_mb) + if self.grad_clip is not None: + self.clip_grads(runner.model.parameters()) + runner.optimizer.step() + + +class DistOptimizerArchHook(OptimizerArchHook): + def __init__(self, grad_clip=None, coalesce=True, bucket_size_mb=-1): + self.grad_clip = grad_clip + self.coalesce = coalesce + self.bucket_size_mb = bucket_size_mb + + def arch_after_train_iter(self, runner): + if runner.optimizer_arch is not None: + runner.optimizer_arch.zero_grad() + #runner.optimizer.zero_grad() + runner.outputs_arch['loss'].backward() + #allreduce_grads(runner.model.parameters(), self.coalesce, + # self.bucket_size_mb) + params = [] + if 'backbone' in runner.arch_name: + raise NotImplementedError + if 'neck' in runner.arch_name: + raise NotImplementedError + if 'head' in runner.arch_name: + raise NotImplementedError + allreduce_grads(params, self.coalesce, self.bucket_size_mb) + #if self.grad_clip is not None: + # self.clip_grads(runner.model.parameters()) + #runner.optimizer.step() + if runner.optimizer_arch is not None: + runner.optimizer_arch.step() + \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py new file mode 100644 index 000000000..262f168e6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/core/utils/misc.py @@ -0,0 +1,37 @@ +from functools import partial + +import mmcv +import numpy as np +from six.moves import map, zip + + +def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): + num_imgs = tensor.size(0) + mean = np.array(mean, dtype=np.float32) + std = np.array(std, dtype=np.float32) + imgs = [] + for img_id in range(num_imgs): + img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) + img = mmcv.imdenormalize( + img, mean, std, to_bgr=to_rgb).astype(np.uint8) + imgs.append(np.ascontiguousarray(img)) + return imgs + + +def multi_apply(func, *args, **kwargs): + pfunc = partial(func, **kwargs) if kwargs else func + map_results = map(pfunc, *args) + return tuple(map(list, zip(*map_results))) + + +def unmap(data, count, inds, fill=0): + """ Unmap a subset of item (data) back to the original set of items (of + size count) """ + if data.dim() == 1: + ret = data.new_full((count, ), fill) + ret[inds] = data + else: + new_size = (count, ) + data.size()[1:] + ret = data.new_full(new_size, fill) + ret[inds, :] = data + return ret diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/__init__.py new file mode 100644 index 000000000..361090ed0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/__init__.py @@ -0,0 +1,17 @@ +from .custom import CustomDataset +from .cityscapes import CityscapesDataset +from .xml_style import XMLDataset +from .coco import CocoDataset +from .voc import VOCDataset +from .wider_face import WIDERFaceDataset +from .loader import GroupSampler, DistributedGroupSampler, build_dataloader, build_dataloader_arch +from .dataset_wrappers import ConcatDataset, RepeatDataset +from .registry import DATASETS +from .builder import build_dataset + +__all__ = [ + 'CustomDataset', 'XMLDataset', 'CocoDataset', 'VOCDataset', + 'CityscapesDataset', 'GroupSampler', 'DistributedGroupSampler', + 'build_dataloader', 'ConcatDataset', 'RepeatDataset', 'WIDERFaceDataset', + 'DATASETS', 'build_dataset', 'build_dataloader_arch' +] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/builder.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/builder.py new file mode 100644 index 000000000..6e707b190 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/builder.py @@ -0,0 +1,41 @@ +import copy + +from mmdet.utils import build_from_cfg +from .dataset_wrappers import ConcatDataset, RepeatDataset +from .registry import DATASETS + + +def _concat_dataset(cfg, default_args=None): + ann_files = cfg['ann_file'] + img_prefixes = cfg.get('img_prefix', None) + seg_prefixes = cfg.get('seg_prefix', None) + proposal_files = cfg.get('proposal_file', None) + + datasets = [] + num_dset = len(ann_files) + for i in range(num_dset): + data_cfg = copy.deepcopy(cfg) + data_cfg['ann_file'] = ann_files[i] + if isinstance(img_prefixes, (list, tuple)): + data_cfg['img_prefix'] = img_prefixes[i] + if isinstance(seg_prefixes, (list, tuple)): + data_cfg['seg_prefix'] = seg_prefixes[i] + if isinstance(proposal_files, (list, tuple)): + data_cfg['proposal_file'] = proposal_files[i] + datasets.append(build_dataset(data_cfg, default_args)) + + return ConcatDataset(datasets) + + +def build_dataset(cfg, default_args=None): + if isinstance(cfg, (list, tuple)): + dataset = ConcatDataset([build_dataset(c, default_args) for c in cfg]) + elif cfg['type'] == 'RepeatDataset': + dataset = RepeatDataset( + build_dataset(cfg['dataset'], default_args), cfg['times']) + elif isinstance(cfg['ann_file'], (list, tuple)): + dataset = _concat_dataset(cfg, default_args) + else: + dataset = build_from_cfg(cfg, DATASETS, default_args) + + return dataset diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/cityscapes.py new file mode 100644 index 000000000..51ca04987 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/cityscapes.py @@ -0,0 +1,9 @@ +from .coco import CocoDataset +from .registry import DATASETS + + +@DATASETS.register_module +class CityscapesDataset(CocoDataset): + + CLASSES = ('person', 'rider', 'car', 'truck', 'bus', 'train', 'motorcycle', + 'bicycle') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py new file mode 100644 index 000000000..45b1df909 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/coco.py @@ -0,0 +1,372 @@ +import logging +import os.path as osp +import tempfile + +import mmcv +import numpy as np +from pycocotools.coco import COCO +from pycocotools.cocoeval import COCOeval + +from mmdet.core import eval_recalls +from mmdet.utils import print_log +from .custom import CustomDataset +from .registry import DATASETS + + +@DATASETS.register_module +class CocoDataset(CustomDataset): + + CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', + 'train', 'truck', 'boat', 'traffic_light', 'fire_hydrant', + 'stop_sign', 'parking_meter', 'bench', 'bird', 'cat', 'dog', + 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', + 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', + 'skis', 'snowboard', 'sports_ball', 'kite', 'baseball_bat', + 'baseball_glove', 'skateboard', 'surfboard', 'tennis_racket', + 'bottle', 'wine_glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', + 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', + 'hot_dog', 'pizza', 'donut', 'cake', 'chair', 'couch', + 'potted_plant', 'bed', 'dining_table', 'toilet', 'tv', 'laptop', + 'mouse', 'remote', 'keyboard', 'cell_phone', 'microwave', + 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', + 'vase', 'scissors', 'teddy_bear', 'hair_drier', 'toothbrush') + + def load_annotations(self, ann_file): + self.coco = COCO(ann_file) + self.cat_ids = self.coco.getCatIds() + self.cat2label = { + cat_id: i + 1 + for i, cat_id in enumerate(self.cat_ids) + } + self.img_ids = self.coco.getImgIds() + img_infos = [] + for i in self.img_ids: + info = self.coco.loadImgs([i])[0] + info['filename'] = info['file_name'] + img_infos.append(info) + return img_infos + + def get_ann_info(self, idx): + img_id = self.img_infos[idx]['id'] + ann_ids = self.coco.getAnnIds(imgIds=[img_id]) + ann_info = self.coco.loadAnns(ann_ids) + return self._parse_ann_info(self.img_infos[idx], ann_info) + + def _filter_imgs(self, min_size=32): + """Filter images too small or without ground truths.""" + valid_inds = [] + ids_with_ann = set(_['image_id'] for _ in self.coco.anns.values()) + for i, img_info in enumerate(self.img_infos): + if self.filter_empty_gt and self.img_ids[i] not in ids_with_ann: + continue + if min(img_info['width'], img_info['height']) >= min_size: + valid_inds.append(i) + return valid_inds + + def _parse_ann_info(self, img_info, ann_info): + """Parse bbox and mask annotation. + + Args: + ann_info (list[dict]): Annotation info of an image. + with_mask (bool): Whether to parse mask annotations. + + Returns: + dict: A dict containing the following keys: bboxes, bboxes_ignore, + labels, masks, seg_map. "masks" are raw annotations and not + decoded into binary masks. + """ + gt_bboxes = [] + gt_labels = [] + gt_bboxes_ignore = [] + gt_masks_ann = [] + + for i, ann in enumerate(ann_info): + if ann.get('ignore', False): + continue + x1, y1, w, h = ann['bbox'] + if ann['area'] <= 0 or w < 1 or h < 1: + continue + bbox = [x1, y1, x1 + w - 1, y1 + h - 1] + if ann.get('iscrowd', False): + gt_bboxes_ignore.append(bbox) + else: + gt_bboxes.append(bbox) + gt_labels.append(self.cat2label[ann['category_id']]) + gt_masks_ann.append(ann['segmentation']) + + if gt_bboxes: + gt_bboxes = np.array(gt_bboxes, dtype=np.float32) + gt_labels = np.array(gt_labels, dtype=np.int64) + else: + gt_bboxes = np.zeros((0, 4), dtype=np.float32) + gt_labels = np.array([], dtype=np.int64) + + if gt_bboxes_ignore: + gt_bboxes_ignore = np.array(gt_bboxes_ignore, dtype=np.float32) + else: + gt_bboxes_ignore = np.zeros((0, 4), dtype=np.float32) + + seg_map = img_info['filename'].replace('jpg', 'png') + + ann = dict( + bboxes=gt_bboxes, + labels=gt_labels, + bboxes_ignore=gt_bboxes_ignore, + masks=gt_masks_ann, + seg_map=seg_map) + + return ann + + def xyxy2xywh(self, bbox): + _bbox = bbox.tolist() + return [ + _bbox[0], + _bbox[1], + _bbox[2] - _bbox[0] + 1, + _bbox[3] - _bbox[1] + 1, + ] + + def _proposal2json(self, results): + json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + bboxes = results[idx] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = 1 + json_results.append(data) + return json_results + + def _det2json(self, results): + json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + result = results[idx] + for label in range(len(result)): + bboxes = result[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = self.cat_ids[label] + json_results.append(data) + return json_results + + def _segm2json(self, results): + bbox_json_results = [] + segm_json_results = [] + for idx in range(len(self)): + img_id = self.img_ids[idx] + det, seg = results[idx] + for label in range(len(det)): + # bbox results + bboxes = det[label] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(bboxes[i][4]) + data['category_id'] = self.cat_ids[label] + bbox_json_results.append(data) + + # segm results + # some detectors use different scores for bbox and mask + if isinstance(seg, tuple): + segms = seg[0][label] + mask_score = seg[1][label] + else: + segms = seg[label] + mask_score = [bbox[4] for bbox in bboxes] + for i in range(bboxes.shape[0]): + data = dict() + data['image_id'] = img_id + data['bbox'] = self.xyxy2xywh(bboxes[i]) + data['score'] = float(mask_score[i]) + data['category_id'] = self.cat_ids[label] + if isinstance(segms[i]['counts'], bytes): + segms[i]['counts'] = segms[i]['counts'].decode() + data['segmentation'] = segms[i] + segm_json_results.append(data) + return bbox_json_results, segm_json_results + + def results2json(self, results, outfile_prefix): + """Dump the detection results to a json file. + + There are 3 types of results: proposals, bbox predictions, mask + predictions, and they have different data types. This method will + automatically recognize the type, and dump them to json files. + + Args: + results (list[list | tuple | ndarray]): Testing results of the + dataset. + outfile_prefix (str): The filename prefix of the json files. If the + prefix is "somepath/xxx", the json files will be named + "somepath/xxx.bbox.json", "somepath/xxx.segm.json", + "somepath/xxx.proposal.json". + + Returns: + dict[str: str]: Possible keys are "bbox", "segm", "proposal", and + values are corresponding filenames. + """ + result_files = dict() + if isinstance(results[0], list): + json_results = self._det2json(results) + result_files['bbox'] = '{}.{}.json'.format(outfile_prefix, 'bbox') + result_files['proposal'] = '{}.{}.json'.format( + outfile_prefix, 'bbox') + mmcv.dump(json_results, result_files['bbox']) + elif isinstance(results[0], tuple): + json_results = self._segm2json(results) + result_files['bbox'] = '{}.{}.json'.format(outfile_prefix, 'bbox') + result_files['proposal'] = '{}.{}.json'.format( + outfile_prefix, 'bbox') + result_files['segm'] = '{}.{}.json'.format(outfile_prefix, 'segm') + mmcv.dump(json_results[0], result_files['bbox']) + mmcv.dump(json_results[1], result_files['segm']) + elif isinstance(results[0], np.ndarray): + json_results = self._proposal2json(results) + result_files['proposal'] = '{}.{}.json'.format( + outfile_prefix, 'proposal') + mmcv.dump(json_results, result_files['proposal']) + else: + raise TypeError('invalid type of results') + return result_files + + def fast_eval_recall(self, results, proposal_nums, iou_thrs, logger=None): + gt_bboxes = [] + for i in range(len(self.img_ids)): + ann_ids = self.coco.getAnnIds(imgIds=self.img_ids[i]) + ann_info = self.coco.loadAnns(ann_ids) + if len(ann_info) == 0: + gt_bboxes.append(np.zeros((0, 4))) + continue + bboxes = [] + for ann in ann_info: + if ann.get('ignore', False) or ann['iscrowd']: + continue + x1, y1, w, h = ann['bbox'] + bboxes.append([x1, y1, x1 + w - 1, y1 + h - 1]) + bboxes = np.array(bboxes, dtype=np.float32) + if bboxes.shape[0] == 0: + bboxes = np.zeros((0, 4)) + gt_bboxes.append(bboxes) + + recalls = eval_recalls( + gt_bboxes, results, proposal_nums, iou_thrs, logger=logger) + ar = recalls.mean(axis=1) + return ar + + def evaluate(self, + results, + metric='bbox', + logger=None, + jsonfile_prefix=None, + classwise=False, + proposal_nums=(100, 300, 1000), + iou_thrs=np.arange(0.5, 0.96, 0.05)): + """Evaluation in COCO protocol. + + Args: + results (list): Testing results of the dataset. + metric (str | list[str]): Metrics to be evaluated. + logger (logging.Logger | str | None): Logger used for printing + related information during evaluation. Default: None. + jsonfile_prefix (str | None): + classwise (bool): Whether to evaluating the AP for each class. + proposal_nums (Sequence[int]): Proposal number used for evaluating + recalls, such as recall@100, recall@1000. + Default: (100, 300, 1000). + iou_thrs (Sequence[float]): IoU threshold used for evaluating + recalls. If set to a list, the average recall of all IoUs will + also be computed. Default: 0.5. + + Returns: + dict[str: float] + """ + assert isinstance(results, list), 'results must be a list' + assert len(results) == len(self), ( + 'The length of results is not equal to the dataset len: {} != {}'. + format(len(results), len(self))) + + metrics = metric if isinstance(metric, list) else [metric] + allowed_metrics = ['bbox', 'segm', 'proposal', 'proposal_fast'] + for metric in metrics: + if metric not in allowed_metrics: + raise KeyError('metric {} is not supported'.format(metric)) + + if jsonfile_prefix is None: + tmp_dir = tempfile.TemporaryDirectory() + jsonfile_prefix = osp.join(tmp_dir.name, 'results') + else: + tmp_dir = None + result_files = self.results2json(results, jsonfile_prefix) + + eval_results = {} + cocoGt = self.coco + for metric in metrics: + msg = 'Evaluating {}...'.format(metric) + if logger is None: + msg = '\n' + msg + print_log(msg, logger=logger) + + if metric == 'proposal_fast': + ar = self.fast_eval_recall( + results, proposal_nums, iou_thrs, logger='silent') + log_msg = [] + for i, num in enumerate(proposal_nums): + eval_results['AR@{}'.format(num)] = ar[i] + log_msg.append('\nAR@{}\t{:.4f}'.format(num, ar[i])) + log_msg = ''.join(log_msg) + print_log(log_msg, logger=logger) + continue + + if metric not in result_files: + raise KeyError('{} is not in results'.format(metric)) + try: + cocoDt = cocoGt.loadRes(result_files[metric]) + except IndexError: + print_log( + 'The testing results of the whole dataset is empty.', + logger=logger, + level=logging.ERROR) + break + + iou_type = 'bbox' if metric == 'proposal' else metric + cocoEval = COCOeval(cocoGt, cocoDt, iou_type) + cocoEval.params.imgIds = self.img_ids + if metric == 'proposal': + cocoEval.params.useCats = 0 + cocoEval.params.maxDets = list(proposal_nums) + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + metric_items = [ + 'AR@100', 'AR@300', 'AR@1000', 'AR_s@1000', 'AR_m@1000', + 'AR_l@1000' + ] + for i, item in enumerate(metric_items): + val = float('{:.3f}'.format(cocoEval.stats[i + 6])) + eval_results[item] = val + else: + cocoEval.evaluate() + cocoEval.accumulate() + cocoEval.summarize() + if classwise: # Compute per-category AP + pass # TODO + metric_items = [ + 'mAP', 'mAP_50', 'mAP_75', 'mAP_s', 'mAP_m', 'mAP_l' + ] + for i in range(len(metric_items)): + key = '{}_{}'.format(metric, metric_items[i]) + val = float('{:.3f}'.format(cocoEval.stats[i])) + eval_results[key] = val + eval_results['{}_mAP_copypaste'.format(metric)] = ( + '{ap[0]:.3f} {ap[1]:.3f} {ap[2]:.3f} {ap[3]:.3f} ' + '{ap[4]:.3f} {ap[5]:.3f}').format(ap=cocoEval.stats[:6]) + if tmp_dir is not None: + tmp_dir.cleanup() + return eval_results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py new file mode 100644 index 000000000..aea338a5c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py @@ -0,0 +1,211 @@ +import os.path as osp + +import mmcv +import numpy as np +from torch.utils.data import Dataset + +from mmdet.core import eval_map, eval_recalls +from .pipelines import Compose +from .registry import DATASETS + + +@DATASETS.register_module +class CustomDataset(Dataset): + """Custom dataset for detection. + + Annotation format: + [ + { + 'filename': 'a.jpg', + 'width': 1280, + 'height': 720, + 'ann': { + 'bboxes': (n, 4), + 'labels': (n, ), + 'bboxes_ignore': (k, 4), (optional field) + 'labels_ignore': (k, 4) (optional field) + } + }, + ... + ] + + The `ann` field is optional for testing. + """ + + CLASSES = None + + def __init__(self, + ann_file, + pipeline, + data_root=None, + img_prefix='', + seg_prefix=None, + proposal_file=None, + test_mode=False, + filter_empty_gt=True): + self.ann_file = ann_file + self.data_root = data_root + self.img_prefix = img_prefix + self.seg_prefix = seg_prefix + self.proposal_file = proposal_file + self.test_mode = test_mode + self.filter_empty_gt = filter_empty_gt + + # join paths if data_root is specified + if self.data_root is not None: + if not osp.isabs(self.ann_file): + self.ann_file = osp.join(self.data_root, self.ann_file) + if not (self.img_prefix is None or osp.isabs(self.img_prefix)): + self.img_prefix = osp.join(self.data_root, self.img_prefix) + if not (self.seg_prefix is None or osp.isabs(self.seg_prefix)): + self.seg_prefix = osp.join(self.data_root, self.seg_prefix) + if not (self.proposal_file is None + or osp.isabs(self.proposal_file)): + self.proposal_file = osp.join(self.data_root, + self.proposal_file) + # load annotations (and proposals) + self.img_infos = self.load_annotations(self.ann_file) + if self.proposal_file is not None: + self.proposals = self.load_proposals(self.proposal_file) + else: + self.proposals = None + # filter images too small + if not test_mode: + valid_inds = self._filter_imgs() + self.img_infos = [self.img_infos[i] for i in valid_inds] + if self.proposals is not None: + self.proposals = [self.proposals[i] for i in valid_inds] + # set group flag for the sampler + if not self.test_mode: + self._set_group_flag() + # processing pipeline + self.pipeline = Compose(pipeline) + + def __len__(self): + return len(self.img_infos) + + def load_annotations(self, ann_file): + return mmcv.load(ann_file) + + def load_proposals(self, proposal_file): + return mmcv.load(proposal_file) + + def get_ann_info(self, idx): + return self.img_infos[idx]['ann'] + + def pre_pipeline(self, results): + results['img_prefix'] = self.img_prefix + results['seg_prefix'] = self.seg_prefix + results['proposal_file'] = self.proposal_file + results['bbox_fields'] = [] + results['mask_fields'] = [] + results['seg_fields'] = [] + + def _filter_imgs(self, min_size=32): + """Filter images too small.""" + valid_inds = [] + for i, img_info in enumerate(self.img_infos): + if min(img_info['width'], img_info['height']) >= min_size: + valid_inds.append(i) + return valid_inds + + def _set_group_flag(self): + """Set flag according to image aspect ratio. + + Images with aspect ratio greater than 1 will be set as group 1, + otherwise group 0. + """ + self.flag = np.zeros(len(self), dtype=np.uint8) + for i in range(len(self)): + img_info = self.img_infos[i] + if img_info['width'] / img_info['height'] > 1: + self.flag[i] = 1 + + def _rand_another(self, idx): + pool = np.where(self.flag == self.flag[idx])[0] + return np.random.choice(pool) + + def __getitem__(self, idx): + if self.test_mode: + return self.prepare_test_img(idx) + while True: + data = self.prepare_train_img(idx) + if data is None: + idx = self._rand_another(idx) + continue + return data + + def prepare_train_img(self, idx): + img_info = self.img_infos[idx] + ann_info = self.get_ann_info(idx) + results = dict(img_info=img_info, ann_info=ann_info) + if self.proposals is not None: + results['proposals'] = self.proposals[idx] + self.pre_pipeline(results) + return self.pipeline(results) + + def prepare_test_img(self, idx): + img_info = self.img_infos[idx] + results = dict(img_info=img_info) + if self.proposals is not None: + results['proposals'] = self.proposals[idx] + self.pre_pipeline(results) + return self.pipeline(results) + + def evaluate(self, + results, + metric='mAP', + logger=None, + proposal_nums=(100, 300, 1000), + iou_thr=0.5, + scale_ranges=None): + """Evaluate the dataset. + + Args: + results (list): Testing results of the dataset. + metric (str | list[str]): Metrics to be evaluated. + logger (logging.Logger | None | str): Logger used for printing + related information during evaluation. Default: None. + proposal_nums (Sequence[int]): Proposal number used for evaluating + recalls, such as recall@100, recall@1000. + Default: (100, 300, 1000). + iou_thr (float | list[float]): IoU threshold. It must be a float + when evaluating mAP, and can be a list when evaluating recall. + Default: 0.5. + scale_ranges (list[tuple] | None): Scale ranges for evaluating mAP. + Default: None. + """ + allowed_metrics = ['mAP', 'recall'] + if metric not in allowed_metrics: + raise KeyError('metric {} is not supported'.format(metric)) + annotations = [self.get_ann_info(i) for i in range(len(self))] + eval_results = {} + if metric == 'mAP': + assert isinstance(iou_thr, float) + mean_ap, _ = eval_map( + results, + annotations, + scale_ranges=scale_ranges, + iou_thr=iou_thr, + dataset=self.CLASSES, + logger=logger) + eval_results['mAP'] = mean_ap + elif metric == 'recall': + gt_bboxes = [ann['bboxes'] for ann in annotations] + if isinstance(iou_thr, float): + iou_thr = [iou_thr] + recalls = eval_recalls( + gt_bboxes, + results, + proposal_nums, + iou_thr, + print_summary=False) + for i, num in enumerate(proposal_nums): + for j, iou in enumerate(iou_thr): + eval_results['recall@{}@{}'.format(num, iou)] = recalls[i, + j] + if recalls.shape[1] > 1: + ar = recalls.mean(axis=1) + for i, num in enumerate(proposal_nums): + eval_results['AR@{}'.format(num)] = ar[i] + return eval_results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/dataset_wrappers.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/dataset_wrappers.py new file mode 100644 index 000000000..e749cb076 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/dataset_wrappers.py @@ -0,0 +1,55 @@ +import numpy as np +from torch.utils.data.dataset import ConcatDataset as _ConcatDataset + +from .registry import DATASETS + + +@DATASETS.register_module +class ConcatDataset(_ConcatDataset): + """A wrapper of concatenated dataset. + + Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but + concat the group flag for image aspect ratio. + + Args: + datasets (list[:obj:`Dataset`]): A list of datasets. + """ + + def __init__(self, datasets): + super(ConcatDataset, self).__init__(datasets) + self.CLASSES = datasets[0].CLASSES + if hasattr(datasets[0], 'flag'): + flags = [] + for i in range(0, len(datasets)): + flags.append(datasets[i].flag) + self.flag = np.concatenate(flags) + + +@DATASETS.register_module +class RepeatDataset(object): + """A wrapper of repeated dataset. + + The length of repeated dataset will be `times` larger than the original + dataset. This is useful when the data loading time is long but the dataset + is small. Using RepeatDataset can reduce the data loading time between + epochs. + + Args: + dataset (:obj:`Dataset`): The dataset to be repeated. + times (int): Repeat times. + """ + + def __init__(self, dataset, times): + self.dataset = dataset + self.times = times + self.CLASSES = dataset.CLASSES + if hasattr(self.dataset, 'flag'): + self.flag = np.tile(self.dataset.flag, times) + + self._ori_len = len(self.dataset) + + def __getitem__(self, idx): + return self.dataset[idx % self._ori_len] + + def __len__(self): + return self.times * self._ori_len diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/__init__.py new file mode 100644 index 000000000..87f88d6a1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/__init__.py @@ -0,0 +1,4 @@ +from .build_loader import build_dataloader, build_dataloader_arch +from .sampler import DistributedGroupSampler, GroupSampler + +__all__ = ['GroupSampler', 'DistributedGroupSampler', 'build_dataloader', 'build_dataloader_arch'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/build_loader.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/build_loader.py new file mode 100644 index 000000000..48425d093 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/build_loader.py @@ -0,0 +1,101 @@ +from functools import partial +import numpy as np +import torch.utils.data.sampler as _sampler +from mmcv.runner import get_dist_info +from mmcv.parallel import collate +from torch.utils.data import DataLoader + +from .sampler import GroupSampler, DistributedGroupSampler, DistributedSampler + +# https://github.com/pytorch/pytorch/issues/973 +import resource +rlimit = resource.getrlimit(resource.RLIMIT_NOFILE) +resource.setrlimit(resource.RLIMIT_NOFILE, (4096, rlimit[1])) + + +def build_dataloader(dataset, + imgs_per_gpu, + workers_per_gpu, + num_gpus=1, + dist=True, + **kwargs): + shuffle = kwargs.get('shuffle', True) + if dist: + rank, world_size = get_dist_info() + if shuffle: + sampler = DistributedGroupSampler(dataset, imgs_per_gpu, + world_size, rank) + else: + sampler = DistributedSampler( + dataset, world_size, rank, shuffle=False) + batch_size = imgs_per_gpu + num_workers = workers_per_gpu + else: + sampler = GroupSampler(dataset, imgs_per_gpu) if shuffle else None + batch_size = num_gpus * imgs_per_gpu + num_workers = num_gpus * workers_per_gpu + + data_loader = DataLoader( + dataset, + batch_size=batch_size, + sampler=sampler, + num_workers=num_workers, + collate_fn=partial(collate, samples_per_gpu=imgs_per_gpu), + pin_memory=False, + **kwargs) + + return data_loader + + +def build_dataloader_arch(dataset, + imgs_per_gpu, + workers_per_gpu, + num_gpus=1, + dist=True, + split_ratio=0.5, + **kwargs): + + shuffle = kwargs.get('shuffle', True) + + num_train = len(dataset) + indices = np.array(range(num_train)) + split = int(np.floor(split_ratio * num_train)) + + if dist: + rank, world_size = get_dist_info() + if shuffle: + sampler = DistributedGroupSampler(dataset, imgs_per_gpu, world_size, rank) + sampler_train = DistributedGroupSampler(dataset, imgs_per_gpu, world_size, rank, split=split, mode='train') + sampler_val = DistributedGroupSampler(dataset, imgs_per_gpu, world_size, rank, split=split, mode='val') + else: + sampler = DistributedSampler( + dataset, world_size, rank, shuffle=False) + batch_size = imgs_per_gpu + num_workers = workers_per_gpu + else: + sampler_train = GroupSampler(dataset, imgs_per_gpu, split, 'train') if shuffle else None + sampler_val = GroupSampler(dataset, imgs_per_gpu, split, 'val') if shuffle else None + batch_size = num_gpus * imgs_per_gpu + num_workers = num_gpus * workers_per_gpu + + data_loader_train = DataLoader( + dataset, + batch_size=batch_size, + sampler=sampler_train, + #sampler=_sampler.SubsetRandomSampler(indices[split:]), + num_workers=num_workers, + collate_fn=partial(collate, samples_per_gpu=imgs_per_gpu), + pin_memory=False, + **kwargs) + + data_loader_val = DataLoader( + dataset, + batch_size=batch_size, + sampler=sampler_val, + #sampler=_sampler.SubsetRandomSampler(indices[:split]), + num_workers=num_workers, + collate_fn=partial(collate, samples_per_gpu=imgs_per_gpu), + pin_memory=False, + **kwargs) + + return data_loader_train, data_loader_val \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py new file mode 100644 index 000000000..64f085e11 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/loader/sampler.py @@ -0,0 +1,201 @@ +from __future__ import division +import math + +import numpy as np +import torch +from mmcv.runner.utils import get_dist_info +from torch.utils.data import DistributedSampler as _DistributedSampler +from torch.utils.data import Sampler + + +class DistributedSampler(_DistributedSampler): + + def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): + super().__init__(dataset, num_replicas=num_replicas, rank=rank) + self.shuffle = shuffle + + def __iter__(self): + # deterministically shuffle based on epoch + if self.shuffle: + g = torch.Generator() + g.manual_seed(self.epoch) + indices = torch.randperm(len(self.dataset), generator=g).tolist() + else: + indices = torch.arange(len(self.dataset)).tolist() + + # add extra samples to make it evenly divisible + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + assert len(indices) == self.num_samples + + return iter(indices) + + +class GroupSampler(Sampler): + + def __init__(self, dataset, samples_per_gpu=1, split=1000, mode=None): + assert hasattr(dataset, 'flag') + self.dataset = dataset + self.split = int(np.floor(split / samples_per_gpu)) * samples_per_gpu + self.mode = mode + self.samples_per_gpu = samples_per_gpu + self.flag = dataset.flag.astype(np.int64) + self.group_sizes = np.bincount(self.flag) + self.num_samples = 0 + for i, size in enumerate(self.group_sizes): + self.num_samples += int(np.ceil( + size / self.samples_per_gpu)) * self.samples_per_gpu + if mode == 'train': + self.num_samples = self.split + elif mode == 'val': + self.num_samples = self.num_samples - self.split + + def __iter__(self): + #indices = [] + indices = np.array([], dtype='int64') + size_flag = 0 + for i, size in enumerate(self.group_sizes): + if size == 0: + continue + indice = np.where(self.flag == i)[0] + assert len(indice) == size + + num_extra = int(np.ceil(size / self.samples_per_gpu) + ) * self.samples_per_gpu - len(indice) + indice = np.concatenate([indice, indice[:num_extra]]) + + if self.mode == 'train': + if (size * self.split) % sum(self.group_sizes) != 0: + size_flag += 1 + split = int(size/sum(self.group_sizes)*self.split) + if i == len(self.group_sizes) - 1 and size_flag != 0: + split += 1 + indice = indice[:split] + elif self.mode == 'val': + if (size * self.split) % sum(self.group_sizes) != 0: + size_flag += 1 + split = int(size/sum(self.group_sizes)*self.split) + if i == len(self.group_sizes) - 1 and size_flag != 0: + split += 1 + indice = indice[split:] + + np.random.shuffle(indice) + # indices.append(indice) + indices = np.concatenate([indices, indice]) + _indices = np.array([], dtype='int64') + for i in np.random.permutation(range(len(indices) // self.samples_per_gpu)): + _indices = np.append(_indices, indices[i * self.samples_per_gpu:(i + 1) * self.samples_per_gpu]) + indices = _indices + + indices = torch.from_numpy(indices).long() + + assert len(indices) == self.num_samples + return iter(indices) + + def __len__(self): + return self.num_samples + + +class DistributedGroupSampler(Sampler): + """Sampler that restricts data loading to a subset of the dataset. + It is especially useful in conjunction with + :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each + process can pass a DistributedSampler instance as a DataLoader sampler, + and load a subset of the original dataset that is exclusive to it. + .. note:: + Dataset is assumed to be of constant size. + Arguments: + dataset: Dataset used for sampling. + num_replicas (optional): Number of processes participating in + distributed training. + rank (optional): Rank of the current process within num_replicas. + """ + + def __init__(self, dataset, samples_per_gpu=1, num_replicas=None, rank=None, split=1000, mode=None): + _rank, _num_replicas = get_dist_info() + if num_replicas is None: + num_replicas = _num_replicas + if rank is None: + rank = _rank + self.dataset = dataset + self.samples_per_gpu = samples_per_gpu + self.num_replicas = num_replicas + self.rank = rank + self.epoch = 0 + self.split = int(np.floor(split / samples_per_gpu / self.num_replicas)) * samples_per_gpu + self.mode = mode + + assert hasattr(self.dataset, 'flag') + self.flag = self.dataset.flag + self.group_sizes = np.bincount(self.flag) + + self.num_samples = 0 + for i, j in enumerate(self.group_sizes): + self.num_samples += int( + math.ceil(self.group_sizes[i] * 1.0 / self.samples_per_gpu / + self.num_replicas)) * self.samples_per_gpu + if self.mode == 'train': + self.num_samples = self.split + elif self.mode == 'val': + self.num_samples = self.num_samples - self.split + self.total_size = self.num_samples * self.num_replicas + self.split *= self.num_replicas + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch) + + #indices = np.array([]) + indices = [] + size_flag = 0 + for i, size in enumerate(self.group_sizes): + if size > 0: + indice = np.where(self.flag == i)[0] + assert len(indice) == size + extra = int( + math.ceil( + size * 1.0 / self.samples_per_gpu / self.num_replicas) + ) * self.samples_per_gpu * self.num_replicas - len(indice) + indice = np.concatenate([indice, indice[:extra]]) + + if self.mode == 'train': + split = int(size/sum(self.group_sizes)*self.split) + if (size * self.split) % sum(self.group_sizes) != 0: + size_flag += 1 + if i == len(self.group_sizes) - 1 and size_flag != 0: + split += 1 + indice = indice[:split] + elif self.mode == 'val': + split = int(size/sum(self.group_sizes)*self.split) + if (size * self.split) % sum(self.group_sizes) != 0: + size_flag += 1 + if i == len(self.group_sizes) - 1 and size_flag != 0: + split += 1 + indice = indice[split:] + indice = indice[list(torch.randperm(int(len(indice)), generator=g))].tolist() + indices += indice + assert len(indices) == self.total_size + + indices = [ + indices[j] for i in list( + torch.randperm( + len(indices) // self.samples_per_gpu, generator=g)) + for j in range(i * self.samples_per_gpu, (i + 1) * + self.samples_per_gpu) + ] + # subsample + offset = self.num_samples * self.rank + indices = indices[offset:offset + self.num_samples] + assert len(indices) == self.num_samples + + return iter(indices) + + def __len__(self): + return self.num_samples + + def set_epoch(self, epoch): + self.epoch = epoch diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/__init__.py new file mode 100644 index 000000000..ae55b2563 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/__init__.py @@ -0,0 +1,16 @@ +from .compose import Compose +from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, + Transpose, to_tensor) +from .loading import LoadAnnotations, LoadImageFromFile, LoadProposals +from .test_aug import MultiScaleFlipAug +from .transforms import (Albu, Expand, MinIoURandomCrop, Normalize, Pad, + PhotoMetricDistortion, RandomCrop, RandomFlip, Resize, + SegResizeFlipPadRescale) + +__all__ = [ + 'Compose', 'to_tensor', 'ToTensor', 'ImageToTensor', 'ToDataContainer', + 'Transpose', 'Collect', 'LoadAnnotations', 'LoadImageFromFile', + 'LoadProposals', 'MultiScaleFlipAug', 'Resize', 'RandomFlip', 'Pad', + 'RandomCrop', 'Normalize', 'SegResizeFlipPadRescale', 'MinIoURandomCrop', + 'Expand', 'PhotoMetricDistortion', 'Albu' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/compose.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/compose.py new file mode 100644 index 000000000..f160eed97 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/compose.py @@ -0,0 +1,35 @@ +import collections + +from mmdet.utils import build_from_cfg +from ..registry import PIPELINES + + +@PIPELINES.register_module +class Compose(object): + + def __init__(self, transforms): + assert isinstance(transforms, collections.abc.Sequence) + self.transforms = [] + for transform in transforms: + if isinstance(transform, dict): + transform = build_from_cfg(transform, PIPELINES) + self.transforms.append(transform) + elif callable(transform): + self.transforms.append(transform) + else: + raise TypeError('transform must be callable or a dict') + + def __call__(self, data): + for t in self.transforms: + data = t(data) + if data is None: + return None + return data + + def __repr__(self): + format_string = self.__class__.__name__ + '(' + for t in self.transforms: + format_string += '\n' + format_string += ' {0}'.format(t) + format_string += '\n)' + return format_string diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/formating.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/formating.py new file mode 100644 index 000000000..83385ab94 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/formating.py @@ -0,0 +1,186 @@ +from collections.abc import Sequence + +import mmcv +import numpy as np +import torch +from mmcv.parallel import DataContainer as DC + +from ..registry import PIPELINES + + +def to_tensor(data): + """Convert objects of various python types to :obj:`torch.Tensor`. + + Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`, + :class:`Sequence`, :class:`int` and :class:`float`. + """ + if isinstance(data, torch.Tensor): + return data + elif isinstance(data, np.ndarray): + return torch.from_numpy(data) + elif isinstance(data, Sequence) and not mmcv.is_str(data): + return torch.tensor(data) + elif isinstance(data, int): + return torch.LongTensor([data]) + elif isinstance(data, float): + return torch.FloatTensor([data]) + else: + raise TypeError('type {} cannot be converted to tensor.'.format( + type(data))) + + +@PIPELINES.register_module +class ToTensor(object): + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + for key in self.keys: + results[key] = to_tensor(results[key]) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={})'.format(self.keys) + + +@PIPELINES.register_module +class ImageToTensor(object): + + def __init__(self, keys): + self.keys = keys + + def __call__(self, results): + for key in self.keys: + results[key] = to_tensor(results[key].transpose(2, 0, 1)) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={})'.format(self.keys) + + +@PIPELINES.register_module +class Transpose(object): + + def __init__(self, keys, order): + self.keys = keys + self.order = order + + def __call__(self, results): + for key in self.keys: + results[key] = results[key].transpose(self.order) + return results + + def __repr__(self): + return self.__class__.__name__ + '(keys={}, order={})'.format( + self.keys, self.order) + + +@PIPELINES.register_module +class ToDataContainer(object): + + def __init__(self, + fields=(dict(key='img', stack=True), dict(key='gt_bboxes'), + dict(key='gt_labels'))): + self.fields = fields + + def __call__(self, results): + for field in self.fields: + field = field.copy() + key = field.pop('key') + results[key] = DC(results[key], **field) + return results + + def __repr__(self): + return self.__class__.__name__ + '(fields={})'.format(self.fields) + + +@PIPELINES.register_module +class DefaultFormatBundle(object): + """Default formatting bundle. + + It simplifies the pipeline of formatting common fields, including "img", + "proposals", "gt_bboxes", "gt_labels", "gt_masks" and "gt_semantic_seg". + These fields are formatted as follows. + + - img: (1)transpose, (2)to tensor, (3)to DataContainer (stack=True) + - proposals: (1)to tensor, (2)to DataContainer + - gt_bboxes: (1)to tensor, (2)to DataContainer + - gt_bboxes_ignore: (1)to tensor, (2)to DataContainer + - gt_labels: (1)to tensor, (2)to DataContainer + - gt_masks: (1)to tensor, (2)to DataContainer (cpu_only=True) + - gt_semantic_seg: (1)unsqueeze dim-0 (2)to tensor, + (3)to DataContainer (stack=True) + """ + + def __call__(self, results): + if 'img' in results: + img = np.ascontiguousarray(results['img'].transpose(2, 0, 1)) + results['img'] = DC(to_tensor(img), stack=True) + for key in ['proposals', 'gt_bboxes', 'gt_bboxes_ignore', 'gt_labels']: + if key not in results: + continue + results[key] = DC(to_tensor(results[key])) + if 'gt_masks' in results: + results['gt_masks'] = DC(results['gt_masks'], cpu_only=True) + if 'gt_semantic_seg' in results: + results['gt_semantic_seg'] = DC( + to_tensor(results['gt_semantic_seg'][None, ...]), stack=True) + return results + + def __repr__(self): + return self.__class__.__name__ + + +@PIPELINES.register_module +class Collect(object): + """ + Collect data from the loader relevant to the specific task. + + This is usually the last stage of the data loader pipeline. Typically keys + is set to some subset of "img", "proposals", "gt_bboxes", + "gt_bboxes_ignore", "gt_labels", and/or "gt_masks". + + The "img_meta" item is always populated. The contents of the "img_meta" + dictionary depends on "meta_keys". By default this includes: + + - "img_shape": shape of the image input to the network as a tuple + (h, w, c). Note that images may be zero padded on the bottom/right + if the batch tensor is larger than this shape. + + - "scale_factor": a float indicating the preprocessing scale + + - "flip": a boolean indicating if image flip transform was used + + - "filename": path to the image file + + - "ori_shape": original shape of the image as a tuple (h, w, c) + + - "pad_shape": image shape after padding + + - "img_norm_cfg": a dict of normalization information: + - mean - per channel mean subtraction + - std - per channel std divisor + - to_rgb - bool indicating if bgr was converted to rgb + """ + + def __init__(self, + keys, + meta_keys=('filename', 'ori_shape', 'img_shape', 'pad_shape', + 'scale_factor', 'flip', 'img_norm_cfg')): + self.keys = keys + self.meta_keys = meta_keys + + def __call__(self, results): + data = {} + img_meta = {} + for key in self.meta_keys: + img_meta[key] = results[key] + data['img_meta'] = DC(img_meta, cpu_only=True) + for key in self.keys: + data[key] = results[key] + return data + + def __repr__(self): + return self.__class__.__name__ + '(keys={}, meta_keys={})'.format( + self.keys, self.meta_keys) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/loading.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/loading.py new file mode 100644 index 000000000..f3aee9fb3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/loading.py @@ -0,0 +1,155 @@ +import os.path as osp +import warnings + +import mmcv +import numpy as np +import pycocotools.mask as maskUtils + +from ..registry import PIPELINES + + +@PIPELINES.register_module +class LoadImageFromFile(object): + + def __init__(self, to_float32=False): + self.to_float32 = to_float32 + + def __call__(self, results): + if results['img_prefix'] is not None: + filename = osp.join(results['img_prefix'], + results['img_info']['filename']) + else: + filename = results['img_info']['filename'] + img = mmcv.imread(filename) + if self.to_float32: + img = img.astype(np.float32) + results['filename'] = filename + results['img'] = img + results['img_shape'] = img.shape + results['ori_shape'] = img.shape + return results + + def __repr__(self): + return self.__class__.__name__ + '(to_float32={})'.format( + self.to_float32) + + +@PIPELINES.register_module +class LoadAnnotations(object): + + def __init__(self, + with_bbox=True, + with_label=True, + with_mask=False, + with_seg=False, + poly2mask=True, + skip_img_without_anno=True): + self.with_bbox = with_bbox + self.with_label = with_label + self.with_mask = with_mask + self.with_seg = with_seg + self.poly2mask = poly2mask + self.skip_img_without_anno = skip_img_without_anno + + def _load_bboxes(self, results): + ann_info = results['ann_info'] + results['gt_bboxes'] = ann_info['bboxes'] + if len(results['gt_bboxes']) == 0 and self.skip_img_without_anno: + if results['img_prefix'] is not None: + file_path = osp.join(results['img_prefix'], + results['img_info']['filename']) + else: + file_path = results['img_info']['filename'] + warnings.warn( + 'Skip the image "{}" that has no valid gt bbox'.format( + file_path)) + return None + + gt_bboxes_ignore = ann_info.get('bboxes_ignore', None) + if gt_bboxes_ignore is not None: + results['gt_bboxes_ignore'] = gt_bboxes_ignore + results['bbox_fields'].append('gt_bboxes_ignore') + results['bbox_fields'].append('gt_bboxes') + return results + + def _load_labels(self, results): + results['gt_labels'] = results['ann_info']['labels'] + return results + + def _poly2mask(self, mask_ann, img_h, img_w): + if isinstance(mask_ann, list): + # polygon -- a single object might consist of multiple parts + # we merge all parts into one mask rle code + rles = maskUtils.frPyObjects(mask_ann, img_h, img_w) + rle = maskUtils.merge(rles) + elif isinstance(mask_ann['counts'], list): + # uncompressed RLE + rle = maskUtils.frPyObjects(mask_ann, img_h, img_w) + else: + # rle + rle = mask_ann + mask = maskUtils.decode(rle) + return mask + + def _load_masks(self, results): + h, w = results['img_info']['height'], results['img_info']['width'] + gt_masks = results['ann_info']['masks'] + if self.poly2mask: + gt_masks = [self._poly2mask(mask, h, w) for mask in gt_masks] + results['gt_masks'] = gt_masks + results['mask_fields'].append('gt_masks') + return results + + def _load_semantic_seg(self, results): + results['gt_semantic_seg'] = mmcv.imread( + osp.join(results['seg_prefix'], results['ann_info']['seg_map']), + flag='unchanged').squeeze() + return results + + def __call__(self, results): + if self.with_bbox: + results = self._load_bboxes(results) + if results is None: + return None + if self.with_label: + results = self._load_labels(results) + if self.with_mask: + results = self._load_masks(results) + if self.with_seg: + results = self._load_semantic_seg(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(with_bbox={}, with_label={}, with_mask={},' + ' with_seg={})').format(self.with_bbox, self.with_label, + self.with_mask, self.with_seg) + return repr_str + + +@PIPELINES.register_module +class LoadProposals(object): + + def __init__(self, num_max_proposals=None): + self.num_max_proposals = num_max_proposals + + def __call__(self, results): + proposals = results['proposals'] + if proposals.shape[1] not in (4, 5): + raise AssertionError( + 'proposals should have shapes (n, 4) or (n, 5), ' + 'but found {}'.format(proposals.shape)) + proposals = proposals[:, :4] + + if self.num_max_proposals is not None: + proposals = proposals[:self.num_max_proposals] + + if len(proposals) == 0: + proposals = np.array([0, 0, 0, 0], dtype=np.float32) + results['proposals'] = proposals + results['bbox_fields'].append('proposals') + return results + + def __repr__(self): + return self.__class__.__name__ + '(num_max_proposals={})'.format( + self.num_max_proposals) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/test_aug.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/test_aug.py new file mode 100644 index 000000000..bffe0f7bd --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/test_aug.py @@ -0,0 +1,37 @@ +import mmcv + +from ..registry import PIPELINES +from .compose import Compose + + +@PIPELINES.register_module +class MultiScaleFlipAug(object): + + def __init__(self, transforms, img_scale, flip=False): + self.transforms = Compose(transforms) + self.img_scale = img_scale if isinstance(img_scale, list) else [img_scale] + assert mmcv.is_list_of(self.img_scale, tuple) + self.flip = flip + + def __call__(self, results): + aug_data = [] + flip_aug = [False, True] if self.flip else [False] + for scale in self.img_scale: + for flip in flip_aug: + _results = results.copy() + _results['scale'] = scale + _results['flip'] = flip + data = self.transforms(_results) + aug_data.append(data) + # list of dict to dict of list + aug_data_dict = {key: [] for key in aug_data[0]} + for data in aug_data: + for key, val in data.items(): + aug_data_dict[key].append(val) + return aug_data_dict + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(transforms={}, img_scale={}, flip={})'.format( + self.transforms, self.img_scale, self.flip) + return repr_str diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/transforms.py new file mode 100644 index 000000000..760b3b1d1 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/pipelines/transforms.py @@ -0,0 +1,853 @@ +import inspect + +import albumentations +import mmcv +import numpy as np +from albumentations import Compose +from imagecorruptions import corrupt +from numpy import random + +from mmdet.core.evaluation.bbox_overlaps import bbox_overlaps +from ..registry import PIPELINES + + +@PIPELINES.register_module +class Resize(object): + """Resize images & bbox & mask. + + This transform resizes the input image to some scale. Bboxes and masks are + then resized with the same scale factor. If the input dict contains the key + "scale", then the scale in the input dict is used, otherwise the specified + scale in the init method is used. + + `img_scale` can either be a tuple (single-scale) or a list of tuple + (multi-scale). There are 3 multiscale modes: + - `ratio_range` is not None: randomly sample a ratio from the ratio range + and multiply it with the image scale. + - `ratio_range` is None and `multiscale_mode` == "range": randomly sample a + scale from the a range. + - `ratio_range` is None and `multiscale_mode` == "value": randomly sample a + scale from multiple scales. + + Args: + img_scale (tuple or list[tuple]): Images scales for resizing. + multiscale_mode (str): Either "range" or "value". + ratio_range (tuple[float]): (min_ratio, max_ratio) + keep_ratio (bool): Whether to keep the aspect ratio when resizing the + image. + """ + + def __init__(self, + img_scale=None, + multiscale_mode='range', + ratio_range=None, + keep_ratio=True): + if img_scale is None: + self.img_scale = None + else: + if isinstance(img_scale, list): + self.img_scale = img_scale + else: + self.img_scale = [img_scale] + assert mmcv.is_list_of(self.img_scale, tuple) + + if ratio_range is not None: + # mode 1: given a scale and a range of image ratio + assert len(self.img_scale) == 1 + else: + # mode 2: given multiple scales or a range of scales + assert multiscale_mode in ['value', 'range'] + + self.multiscale_mode = multiscale_mode + self.ratio_range = ratio_range + self.keep_ratio = keep_ratio + + @staticmethod + def random_select(img_scales): + assert mmcv.is_list_of(img_scales, tuple) + scale_idx = np.random.randint(len(img_scales)) + img_scale = img_scales[scale_idx] + return img_scale, scale_idx + + @staticmethod + def random_sample(img_scales): + assert mmcv.is_list_of(img_scales, tuple) and len(img_scales) == 2 + img_scale_long = [max(s) for s in img_scales] + img_scale_short = [min(s) for s in img_scales] + long_edge = np.random.randint( + min(img_scale_long), + max(img_scale_long) + 1) + short_edge = np.random.randint( + min(img_scale_short), + max(img_scale_short) + 1) + img_scale = (long_edge, short_edge) + return img_scale, None + + @staticmethod + def random_sample_ratio(img_scale, ratio_range): + assert isinstance(img_scale, tuple) and len(img_scale) == 2 + min_ratio, max_ratio = ratio_range + assert min_ratio <= max_ratio + ratio = np.random.random_sample() * (max_ratio - min_ratio) + min_ratio + scale = int(img_scale[0] * ratio), int(img_scale[1] * ratio) + return scale, None + + def _random_scale(self, results): + if self.ratio_range is not None: + scale, scale_idx = self.random_sample_ratio( + self.img_scale[0], self.ratio_range) + elif len(self.img_scale) == 1: + scale, scale_idx = self.img_scale[0], 0 + elif self.multiscale_mode == 'range': + scale, scale_idx = self.random_sample(self.img_scale) + elif self.multiscale_mode == 'value': + scale, scale_idx = self.random_select(self.img_scale) + else: + raise NotImplementedError + + results['scale'] = scale + results['scale_idx'] = scale_idx + + def _resize_img(self, results): + if self.keep_ratio: + img, scale_factor = mmcv.imrescale( + results['img'], results['scale'], return_scale=True) + else: + img, w_scale, h_scale = mmcv.imresize( + results['img'], results['scale'], return_scale=True) + scale_factor = np.array([w_scale, h_scale, w_scale, h_scale], + dtype=np.float32) + results['img'] = img + results['img_shape'] = img.shape + results['pad_shape'] = img.shape # in case that there is no padding + results['scale_factor'] = scale_factor + results['keep_ratio'] = self.keep_ratio + + def _resize_bboxes(self, results): + img_shape = results['img_shape'] + for key in results.get('bbox_fields', []): + bboxes = results[key] * results['scale_factor'] + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) + results[key] = bboxes + + def _resize_masks(self, results): + for key in results.get('mask_fields', []): + if results[key] is None: + continue + if self.keep_ratio: + masks = [ + mmcv.imrescale( + mask, results['scale_factor'], interpolation='nearest') + for mask in results[key] + ] + else: + mask_size = (results['img_shape'][1], results['img_shape'][0]) + masks = [ + mmcv.imresize(mask, mask_size, interpolation='nearest') + for mask in results[key] + ] + results[key] = masks + + def __call__(self, results): + if 'scale' not in results: + self._random_scale(results) + self._resize_img(results) + self._resize_bboxes(results) + self._resize_masks(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(img_scale={}, multiscale_mode={}, ratio_range={}, ' + 'keep_ratio={})').format(self.img_scale, + self.multiscale_mode, + self.ratio_range, + self.keep_ratio) + return repr_str + + +@PIPELINES.register_module +class RandomFlip(object): + """Flip the image & bbox & mask. + + If the input dict contains the key "flip", then the flag will be used, + otherwise it will be randomly decided by a ratio specified in the init + method. + + Args: + flip_ratio (float, optional): The flipping probability. + """ + + def __init__(self, flip_ratio=None, direction='horizontal'): + self.flip_ratio = flip_ratio + self.direction = direction + if flip_ratio is not None: + assert flip_ratio >= 0 and flip_ratio <= 1 + assert direction in ['horizontal', 'vertical'] + + def bbox_flip(self, bboxes, img_shape, direction): + """Flip bboxes horizontally. + + Args: + bboxes(ndarray): shape (..., 4*k) + img_shape(tuple): (height, width) + """ + assert bboxes.shape[-1] % 4 == 0 + flipped = bboxes.copy() + if direction == 'horizontal': + w = img_shape[1] + flipped[..., 0::4] = w - bboxes[..., 2::4] - 1 + flipped[..., 2::4] = w - bboxes[..., 0::4] - 1 + elif direction == 'vertical': + h = img_shape[0] + flipped[..., 1::4] = h - bboxes[..., 3::4] - 1 + flipped[..., 3::4] = h - bboxes[..., 1::4] - 1 + else: + raise ValueError( + 'Invalid flipping direction "{}"'.format(direction)) + return flipped + + def __call__(self, results): + if 'flip' not in results: + flip = True if np.random.rand() < self.flip_ratio else False + results['flip'] = flip + if 'flip_direction' not in results: + results['flip_direction'] = self.direction + if results['flip']: + # flip image + results['img'] = mmcv.imflip( + results['img'], direction=results['flip_direction']) + # flip bboxes + for key in results.get('bbox_fields', []): + results[key] = self.bbox_flip(results[key], + results['img_shape'], + results['flip_direction']) + # flip masks + for key in results.get('mask_fields', []): + results[key] = [ + mmcv.imflip(mask, direction=results['flip_direction']) + for mask in results[key] + ] + return results + + def __repr__(self): + return self.__class__.__name__ + '(flip_ratio={})'.format( + self.flip_ratio) + + +@PIPELINES.register_module +class Pad(object): + """Pad the image & mask. + + There are two padding modes: (1) pad to a fixed size and (2) pad to the + minimum size that is divisible by some number. + + Args: + size (tuple, optional): Fixed padding size. + size_divisor (int, optional): The divisor of padded size. + pad_val (float, optional): Padding value, 0 by default. + """ + + def __init__(self, size=None, size_divisor=None, pad_val=0): + self.size = size + self.size_divisor = size_divisor + self.pad_val = pad_val + # only one of size and size_divisor should be valid + assert size is not None or size_divisor is not None + assert size is None or size_divisor is None + + def _pad_img(self, results): + if self.size is not None: + padded_img = mmcv.impad(results['img'], self.size) + elif self.size_divisor is not None: + padded_img = mmcv.impad_to_multiple( + results['img'], self.size_divisor, pad_val=self.pad_val) + results['img'] = padded_img + results['pad_shape'] = padded_img.shape + results['pad_fixed_size'] = self.size + results['pad_size_divisor'] = self.size_divisor + + def _pad_masks(self, results): + pad_shape = results['pad_shape'][:2] + for key in results.get('mask_fields', []): + padded_masks = [ + mmcv.impad(mask, pad_shape, pad_val=self.pad_val) + for mask in results[key] + ] + results[key] = np.stack(padded_masks, axis=0) + + def __call__(self, results): + self._pad_img(results) + self._pad_masks(results) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(size={}, size_divisor={}, pad_val={})'.format( + self.size, self.size_divisor, self.pad_val) + return repr_str + + +@PIPELINES.register_module +class Normalize(object): + """Normalize the image. + + Args: + mean (sequence): Mean values of 3 channels. + std (sequence): Std values of 3 channels. + to_rgb (bool): Whether to convert the image from BGR to RGB, + default is true. + """ + + def __init__(self, mean, std, to_rgb=True): + self.mean = np.array(mean, dtype=np.float32) + self.std = np.array(std, dtype=np.float32) + self.to_rgb = to_rgb + + def __call__(self, results): + results['img'] = mmcv.imnormalize(results['img'], self.mean, self.std, + self.to_rgb) + results['img_norm_cfg'] = dict( + mean=self.mean, std=self.std, to_rgb=self.to_rgb) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(mean={}, std={}, to_rgb={})'.format( + self.mean, self.std, self.to_rgb) + return repr_str + + +@PIPELINES.register_module +class RandomCrop(object): + """Random crop the image & bboxes & masks. + + Args: + crop_size (tuple): Expected size after cropping, (h, w). + """ + + def __init__(self, crop_size): + self.crop_size = crop_size + + def __call__(self, results): + img = results['img'] + margin_h = max(img.shape[0] - self.crop_size[0], 0) + margin_w = max(img.shape[1] - self.crop_size[1], 0) + offset_h = np.random.randint(0, margin_h + 1) + offset_w = np.random.randint(0, margin_w + 1) + crop_y1, crop_y2 = offset_h, offset_h + self.crop_size[0] + crop_x1, crop_x2 = offset_w, offset_w + self.crop_size[1] + + # crop the image + img = img[crop_y1:crop_y2, crop_x1:crop_x2, :] + img_shape = img.shape + results['img'] = img + results['img_shape'] = img_shape + + # crop bboxes accordingly and clip to the image boundary + for key in results.get('bbox_fields', []): + bbox_offset = np.array([offset_w, offset_h, offset_w, offset_h], + dtype=np.float32) + bboxes = results[key] - bbox_offset + bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1] - 1) + bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0] - 1) + results[key] = bboxes + + # filter out the gt bboxes that are completely cropped + if 'gt_bboxes' in results: + gt_bboxes = results['gt_bboxes'] + valid_inds = (gt_bboxes[:, 2] > gt_bboxes[:, 0]) & ( + gt_bboxes[:, 3] > gt_bboxes[:, 1]) + # if no gt bbox remains after cropping, just skip this image + if not np.any(valid_inds): + return None + results['gt_bboxes'] = gt_bboxes[valid_inds, :] + if 'gt_labels' in results: + results['gt_labels'] = results['gt_labels'][valid_inds] + + # filter and crop the masks + if 'gt_masks' in results: + valid_gt_masks = [] + for i in np.where(valid_inds)[0]: + gt_mask = results['gt_masks'][i][crop_y1:crop_y2, + crop_x1:crop_x2] + valid_gt_masks.append(gt_mask) + results['gt_masks'] = valid_gt_masks + + return results + + def __repr__(self): + return self.__class__.__name__ + '(crop_size={})'.format( + self.crop_size) + + +@PIPELINES.register_module +class SegResizeFlipPadRescale(object): + """A sequential transforms to semantic segmentation maps. + + The same pipeline as input images is applied to the semantic segmentation + map, and finally rescale it by some scale factor. The transforms include: + 1. resize + 2. flip + 3. pad + 4. rescale (so that the final size can be different from the image size) + + Args: + scale_factor (float): The scale factor of the final output. + """ + + def __init__(self, scale_factor=1): + self.scale_factor = scale_factor + + def __call__(self, results): + if results['keep_ratio']: + gt_seg = mmcv.imrescale( + results['gt_semantic_seg'], + results['scale'], + interpolation='nearest') + else: + gt_seg = mmcv.imresize( + results['gt_semantic_seg'], + results['scale'], + interpolation='nearest') + if results['flip']: + gt_seg = mmcv.imflip(gt_seg) + if gt_seg.shape != results['pad_shape']: + gt_seg = mmcv.impad(gt_seg, results['pad_shape'][:2]) + if self.scale_factor != 1: + gt_seg = mmcv.imrescale( + gt_seg, self.scale_factor, interpolation='nearest') + results['gt_semantic_seg'] = gt_seg + return results + + def __repr__(self): + return self.__class__.__name__ + '(scale_factor={})'.format( + self.scale_factor) + + +@PIPELINES.register_module +class PhotoMetricDistortion(object): + """Apply photometric distortion to image sequentially, every transformation + is applied with a probability of 0.5. The position of random contrast is in + second or second to last. + + 1. random brightness + 2. random contrast (mode 0) + 3. convert color from BGR to HSV + 4. random saturation + 5. random hue + 6. convert color from HSV to BGR + 7. random contrast (mode 1) + 8. randomly swap channels + + Args: + brightness_delta (int): delta of brightness. + contrast_range (tuple): range of contrast. + saturation_range (tuple): range of saturation. + hue_delta (int): delta of hue. + """ + + def __init__(self, + brightness_delta=32, + contrast_range=(0.5, 1.5), + saturation_range=(0.5, 1.5), + hue_delta=18): + self.brightness_delta = brightness_delta + self.contrast_lower, self.contrast_upper = contrast_range + self.saturation_lower, self.saturation_upper = saturation_range + self.hue_delta = hue_delta + + def __call__(self, results): + img = results['img'] + # random brightness + if random.randint(2): + delta = random.uniform(-self.brightness_delta, + self.brightness_delta) + img += delta + + # mode == 0 --> do random contrast first + # mode == 1 --> do random contrast last + mode = random.randint(2) + if mode == 1: + if random.randint(2): + alpha = random.uniform(self.contrast_lower, + self.contrast_upper) + img *= alpha + + # convert color from BGR to HSV + img = mmcv.bgr2hsv(img) + + # random saturation + if random.randint(2): + img[..., 1] *= random.uniform(self.saturation_lower, + self.saturation_upper) + + # random hue + if random.randint(2): + img[..., 0] += random.uniform(-self.hue_delta, self.hue_delta) + img[..., 0][img[..., 0] > 360] -= 360 + img[..., 0][img[..., 0] < 0] += 360 + + # convert color from HSV to BGR + img = mmcv.hsv2bgr(img) + + # random contrast + if mode == 0: + if random.randint(2): + alpha = random.uniform(self.contrast_lower, + self.contrast_upper) + img *= alpha + + # randomly swap channels + if random.randint(2): + img = img[..., random.permutation(3)] + + results['img'] = img + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += ('(brightness_delta={}, contrast_range={}, ' + 'saturation_range={}, hue_delta={})').format( + self.brightness_delta, self.contrast_range, + self.saturation_range, self.hue_delta) + return repr_str + + +@PIPELINES.register_module +class Expand(object): + """Random expand the image & bboxes. + + Randomly place the original image on a canvas of 'ratio' x original image + size filled with mean values. The ratio is in the range of ratio_range. + + Args: + mean (tuple): mean value of dataset. + to_rgb (bool): if need to convert the order of mean to align with RGB. + ratio_range (tuple): range of expand ratio. + prob (float): probability of applying this transformation + """ + + def __init__(self, + mean=(0, 0, 0), + to_rgb=True, + ratio_range=(1, 4), + seg_ignore_label=None, + prob=0.5): + self.to_rgb = to_rgb + self.ratio_range = ratio_range + if to_rgb: + self.mean = mean[::-1] + else: + self.mean = mean + self.min_ratio, self.max_ratio = ratio_range + self.seg_ignore_label = seg_ignore_label + self.prob = prob + + def __call__(self, results): + if random.uniform(0, 1) > self.prob: + return results + + img, boxes = [results[k] for k in ('img', 'gt_bboxes')] + + h, w, c = img.shape + ratio = random.uniform(self.min_ratio, self.max_ratio) + expand_img = np.full((int(h * ratio), int(w * ratio), c), + self.mean).astype(img.dtype) + left = int(random.uniform(0, w * ratio - w)) + top = int(random.uniform(0, h * ratio - h)) + expand_img[top:top + h, left:left + w] = img + boxes = boxes + np.tile((left, top), 2).astype(boxes.dtype) + + results['img'] = expand_img + results['gt_bboxes'] = boxes + + if 'gt_masks' in results: + expand_gt_masks = [] + for mask in results['gt_masks']: + expand_mask = np.full((int(h * ratio), int(w * ratio)), + 0).astype(mask.dtype) + expand_mask[top:top + h, left:left + w] = mask + expand_gt_masks.append(expand_mask) + results['gt_masks'] = expand_gt_masks + + # not tested + if 'gt_semantic_seg' in results: + assert self.seg_ignore_label is not None + gt_seg = results['gt_semantic_seg'] + expand_gt_seg = np.full((int(h * ratio), int(w * ratio)), + self.seg_ignore_label).astype(gt_seg.dtype) + expand_gt_seg[top:top + h, left:left + w] = gt_seg + results['gt_semantic_seg'] = expand_gt_seg + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(mean={}, to_rgb={}, ratio_range={}, ' \ + 'seg_ignore_label={})'.format( + self.mean, self.to_rgb, self.ratio_range, + self.seg_ignore_label) + return repr_str + + +@PIPELINES.register_module +class MinIoURandomCrop(object): + """Random crop the image & bboxes, the cropped patches have minimum IoU + requirement with original image & bboxes, the IoU threshold is randomly + selected from min_ious. + + Args: + min_ious (tuple): minimum IoU threshold for all intersections with + bounding boxes + min_crop_size (float): minimum crop's size (i.e. h,w := a*h, a*w, + where a >= min_crop_size). + """ + + def __init__(self, min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3): + # 1: return ori img + self.sample_mode = (1, *min_ious, 0) + self.min_crop_size = min_crop_size + + def __call__(self, results): + img, boxes, labels = [ + results[k] for k in ('img', 'gt_bboxes', 'gt_labels') + ] + h, w, c = img.shape + while True: + mode = random.choice(self.sample_mode) + if mode == 1: + return results + + min_iou = mode + for i in range(50): + new_w = random.uniform(self.min_crop_size * w, w) + new_h = random.uniform(self.min_crop_size * h, h) + + # h / w in [0.5, 2] + if new_h / new_w < 0.5 or new_h / new_w > 2: + continue + + left = random.uniform(w - new_w) + top = random.uniform(h - new_h) + + patch = np.array( + (int(left), int(top), int(left + new_w), int(top + new_h))) + overlaps = bbox_overlaps( + patch.reshape(-1, 4), boxes.reshape(-1, 4)).reshape(-1) + if overlaps.min() < min_iou: + continue + + # center of boxes should inside the crop img + center = (boxes[:, :2] + boxes[:, 2:]) / 2 + mask = ((center[:, 0] > patch[0]) * (center[:, 1] > patch[1]) * + (center[:, 0] < patch[2]) * (center[:, 1] < patch[3])) + if not mask.any(): + continue + boxes = boxes[mask] + labels = labels[mask] + + # adjust boxes + img = img[patch[1]:patch[3], patch[0]:patch[2]] + boxes[:, 2:] = boxes[:, 2:].clip(max=patch[2:]) + boxes[:, :2] = boxes[:, :2].clip(min=patch[:2]) + boxes -= np.tile(patch[:2], 2) + + results['img'] = img + results['gt_bboxes'] = boxes + results['gt_labels'] = labels + + if 'gt_masks' in results: + valid_masks = [ + results['gt_masks'][i] for i in range(len(mask)) + if mask[i] + ] + results['gt_masks'] = [ + gt_mask[patch[1]:patch[3], patch[0]:patch[2]] + for gt_mask in valid_masks + ] + + # not tested + if 'gt_semantic_seg' in results: + results['gt_semantic_seg'] = results['gt_semantic_seg'][ + patch[1]:patch[3], patch[0]:patch[2]] + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(min_ious={}, min_crop_size={})'.format( + self.min_ious, self.min_crop_size) + return repr_str + + +@PIPELINES.register_module +class Corrupt(object): + + def __init__(self, corruption, severity=1): + self.corruption = corruption + self.severity = severity + + def __call__(self, results): + results['img'] = corrupt( + results['img'].astype(np.uint8), + corruption_name=self.corruption, + severity=self.severity) + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(corruption={}, severity={})'.format( + self.corruption, self.severity) + return repr_str + + +@PIPELINES.register_module +class Albu(object): + + def __init__(self, + transforms, + bbox_params=None, + keymap=None, + update_pad_shape=False, + skip_img_without_anno=False): + """ + Adds custom transformations from Albumentations lib. + Please, visit `https://albumentations.readthedocs.io` + to get more information. + + transforms (list): list of albu transformations + bbox_params (dict): bbox_params for albumentation `Compose` + keymap (dict): contains {'input key':'albumentation-style key'} + skip_img_without_anno (bool): whether to skip the image + if no ann left after aug + """ + + self.transforms = transforms + self.filter_lost_elements = False + self.update_pad_shape = update_pad_shape + self.skip_img_without_anno = skip_img_without_anno + + # A simple workaround to remove masks without boxes + if (isinstance(bbox_params, dict) and 'label_fields' in bbox_params + and 'filter_lost_elements' in bbox_params): + self.filter_lost_elements = True + self.origin_label_fields = bbox_params['label_fields'] + bbox_params['label_fields'] = ['idx_mapper'] + del bbox_params['filter_lost_elements'] + + self.bbox_params = ( + self.albu_builder(bbox_params) if bbox_params else None) + self.aug = Compose([self.albu_builder(t) for t in self.transforms], + bbox_params=self.bbox_params) + + if not keymap: + self.keymap_to_albu = { + 'img': 'image', + 'gt_masks': 'masks', + 'gt_bboxes': 'bboxes' + } + else: + self.keymap_to_albu = keymap + self.keymap_back = {v: k for k, v in self.keymap_to_albu.items()} + + def albu_builder(self, cfg): + """Import a module from albumentations. + Inherits some of `build_from_cfg` logic. + + Args: + cfg (dict): Config dict. It should at least contain the key "type". + Returns: + obj: The constructed object. + """ + assert isinstance(cfg, dict) and "type" in cfg + args = cfg.copy() + + obj_type = args.pop("type") + if mmcv.is_str(obj_type): + obj_cls = getattr(albumentations, obj_type) + elif inspect.isclass(obj_type): + obj_cls = obj_type + else: + raise TypeError( + 'type must be a str or valid type, but got {}'.format( + type(obj_type))) + + if 'transforms' in args: + args['transforms'] = [ + self.albu_builder(transform) + for transform in args['transforms'] + ] + + return obj_cls(**args) + + @staticmethod + def mapper(d, keymap): + """ + Dictionary mapper. + Renames keys according to keymap provided. + + Args: + d (dict): old dict + keymap (dict): {'old_key':'new_key'} + Returns: + dict: new dict. + """ + updated_dict = {} + for k, v in zip(d.keys(), d.values()): + new_k = keymap.get(k, k) + updated_dict[new_k] = d[k] + return updated_dict + + def __call__(self, results): + # dict to albumentations format + results = self.mapper(results, self.keymap_to_albu) + + if 'bboxes' in results: + # to list of boxes + if isinstance(results['bboxes'], np.ndarray): + results['bboxes'] = [x for x in results['bboxes']] + # add pseudo-field for filtration + if self.filter_lost_elements: + results['idx_mapper'] = np.arange(len(results['bboxes'])) + + results = self.aug(**results) + + if 'bboxes' in results: + if isinstance(results['bboxes'], list): + results['bboxes'] = np.array( + results['bboxes'], dtype=np.float32) + + # filter label_fields + if self.filter_lost_elements: + + results['idx_mapper'] = np.arange(len(results['bboxes'])) + + for label in self.origin_label_fields: + results[label] = np.array( + [results[label][i] for i in results['idx_mapper']]) + if 'masks' in results: + results['masks'] = [ + results['masks'][i] for i in results['idx_mapper'] + ] + + if (not len(results['idx_mapper']) + and self.skip_img_without_anno): + return None + + if 'gt_labels' in results: + if isinstance(results['gt_labels'], list): + results['gt_labels'] = np.array(results['gt_labels']) + + # back to the original format + results = self.mapper(results, self.keymap_back) + + # update final shape + if self.update_pad_shape: + results['pad_shape'] = results['img'].shape + + return results + + def __repr__(self): + repr_str = self.__class__.__name__ + repr_str += '(transformations={})'.format(self.transformations) + return repr_str diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py new file mode 100644 index 000000000..974a4fbb7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/registry.py @@ -0,0 +1,4 @@ +from mmdet.utils import Registry + +DATASETS = Registry('dataset') +PIPELINES = Registry('pipeline') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/transforms.py new file mode 100644 index 000000000..ff575dba3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/transforms.py @@ -0,0 +1,147 @@ +import mmcv +import numpy as np +import torch + +__all__ = [ + 'ImageTransform', 'BboxTransform', 'MaskTransform', 'SegMapTransform', + 'Numpy2Tensor' +] + + +class ImageTransform(object): + """Preprocess an image. + + 1. rescale the image to expected size + 2. normalize the image + 3. flip the image (if needed) + 4. pad the image (if needed) + 5. transpose to (c, h, w) + """ + + def __init__(self, + mean=(0, 0, 0), + std=(1, 1, 1), + to_rgb=True, + size_divisor=None): + self.mean = np.array(mean, dtype=np.float32) + self.std = np.array(std, dtype=np.float32) + self.to_rgb = to_rgb + self.size_divisor = size_divisor + + def __call__(self, img, scale, flip=False, keep_ratio=True): + if keep_ratio: + img, scale_factor = mmcv.imrescale(img, scale, return_scale=True) + else: + img, w_scale, h_scale = mmcv.imresize( + img, scale, return_scale=True) + scale_factor = np.array( + [w_scale, h_scale, w_scale, h_scale], dtype=np.float32) + img_shape = img.shape + img = mmcv.imnormalize(img, self.mean, self.std, self.to_rgb) + if flip: + img = mmcv.imflip(img) + if self.size_divisor is not None: + img = mmcv.impad_to_multiple(img, self.size_divisor) + pad_shape = img.shape + else: + pad_shape = img_shape + img = img.transpose(2, 0, 1) + return img, img_shape, pad_shape, scale_factor + + +def bbox_flip(bboxes, img_shape): + """Flip bboxes horizontally. + + Args: + bboxes(ndarray): shape (..., 4*k) + img_shape(tuple): (height, width) + """ + assert bboxes.shape[-1] % 4 == 0 + w = img_shape[1] + flipped = bboxes.copy() + flipped[..., 0::4] = w - bboxes[..., 2::4] - 1 + flipped[..., 2::4] = w - bboxes[..., 0::4] - 1 + return flipped + + +class BboxTransform(object): + """Preprocess gt bboxes. + + 1. rescale bboxes according to image size + 2. flip bboxes (if needed) + 3. pad the first dimension to `max_num_gts` + """ + + def __init__(self, max_num_gts=None): + self.max_num_gts = max_num_gts + + def __call__(self, bboxes, img_shape, scale_factor, flip=False): + gt_bboxes = bboxes * scale_factor + if flip: + gt_bboxes = bbox_flip(gt_bboxes, img_shape) + gt_bboxes[:, 0::2] = np.clip(gt_bboxes[:, 0::2], 0, img_shape[1] - 1) + gt_bboxes[:, 1::2] = np.clip(gt_bboxes[:, 1::2], 0, img_shape[0] - 1) + if self.max_num_gts is None: + return gt_bboxes + else: + num_gts = gt_bboxes.shape[0] + padded_bboxes = np.zeros((self.max_num_gts, 4), dtype=np.float32) + padded_bboxes[:num_gts, :] = gt_bboxes + return padded_bboxes + + +class MaskTransform(object): + """Preprocess masks. + + 1. resize masks to expected size and stack to a single array + 2. flip the masks (if needed) + 3. pad the masks (if needed) + """ + + def __call__(self, masks, pad_shape, scale_factor, flip=False): + masks = [ + mmcv.imrescale(mask, scale_factor, interpolation='nearest') + for mask in masks + ] + if flip: + masks = [mask[:, ::-1] for mask in masks] + padded_masks = [ + mmcv.impad(mask, pad_shape[:2], pad_val=0) for mask in masks + ] + padded_masks = np.stack(padded_masks, axis=0) + return padded_masks + + +class SegMapTransform(object): + """Preprocess semantic segmentation maps. + + 1. rescale the segmentation map to expected size + 3. flip the image (if needed) + 4. pad the image (if needed) + """ + + def __init__(self, size_divisor=None): + self.size_divisor = size_divisor + + def __call__(self, img, scale, flip=False, keep_ratio=True): + if keep_ratio: + img = mmcv.imrescale(img, scale, interpolation='nearest') + else: + img = mmcv.imresize(img, scale, interpolation='nearest') + if flip: + img = mmcv.imflip(img) + if self.size_divisor is not None: + img = mmcv.impad_to_multiple(img, self.size_divisor) + return img + + +class Numpy2Tensor(object): + + def __init__(self): + pass + + def __call__(self, *args): + if len(args) == 1: + return torch.from_numpy(args[0]) + else: + return tuple([torch.from_numpy(np.array(array)) for array in args]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/utils.py new file mode 100644 index 000000000..9f4f46cae --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/utils.py @@ -0,0 +1,68 @@ +from collections import Sequence + +import matplotlib.pyplot as plt +import mmcv +import numpy as np +import torch + + +def to_tensor(data): + """Convert objects of various python types to :obj:`torch.Tensor`. + + Supported types are: :class:`numpy.ndarray`, :class:`torch.Tensor`, + :class:`Sequence`, :class:`int` and :class:`float`. + """ + if isinstance(data, torch.Tensor): + return data + elif isinstance(data, np.ndarray): + return torch.from_numpy(data) + elif isinstance(data, Sequence) and not mmcv.is_str(data): + return torch.tensor(data) + elif isinstance(data, int): + return torch.LongTensor([data]) + elif isinstance(data, float): + return torch.FloatTensor([data]) + else: + raise TypeError('type {} cannot be converted to tensor.'.format( + type(data))) + + +def random_scale(img_scales, mode='range'): + """Randomly select a scale from a list of scales or scale ranges. + + Args: + img_scales (list[tuple]): Image scale or scale range. + mode (str): "range" or "value". + + Returns: + tuple: Sampled image scale. + """ + num_scales = len(img_scales) + if num_scales == 1: # fixed scale is specified + img_scale = img_scales[0] + elif num_scales == 2: # randomly sample a scale + if mode == 'range': + img_scale_long = [max(s) for s in img_scales] + img_scale_short = [min(s) for s in img_scales] + long_edge = np.random.randint( + min(img_scale_long), + max(img_scale_long) + 1) + short_edge = np.random.randint( + min(img_scale_short), + max(img_scale_short) + 1) + img_scale = (long_edge, short_edge) + elif mode == 'value': + img_scale = img_scales[np.random.randint(num_scales)] + else: + if mode != 'value': + raise ValueError( + 'Only "value" mode supports more than 2 image scales') + img_scale = img_scales[np.random.randint(num_scales)] + return img_scale + + +def show_ann(coco, img, ann_info): + plt.imshow(mmcv.bgr2rgb(img)) + plt.axis('off') + coco.showAnns(ann_info) + plt.show() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/voc.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/voc.py new file mode 100644 index 000000000..0e3162f3f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/voc.py @@ -0,0 +1,66 @@ +from mmdet.core import eval_map, eval_recalls +from .registry import DATASETS +from .xml_style import XMLDataset + + +@DATASETS.register_module +class VOCDataset(XMLDataset): + + CLASSES = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', + 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', + 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', + 'tvmonitor') + + def __init__(self, **kwargs): + super(VOCDataset, self).__init__(**kwargs) + if 'VOC2007' in self.img_prefix: + self.year = 2007 + elif 'VOC2012' in self.img_prefix: + self.year = 2012 + else: + raise ValueError('Cannot infer dataset year from img_prefix') + + def evaluate(self, + results, + metric='mAP', + logger=None, + proposal_nums=(100, 300, 1000), + iou_thr=0.5, + scale_ranges=None): + if not isinstance(metric, str): + assert len(metric) == 1 + metric = metric[0] + allowed_metrics = ['mAP', 'recall'] + if metric not in allowed_metrics: + raise KeyError('metric {} is not supported'.format(metric)) + annotations = [self.get_ann_info(i) for i in range(len(self))] + eval_results = {} + if metric == 'mAP': + assert isinstance(iou_thr, float) + if self.year == 2007: + ds_name = 'voc07' + else: + ds_name = self.dataset.CLASSES + mean_ap, _ = eval_map( + results, + annotations, + scale_ranges=None, + iou_thr=iou_thr, + dataset=ds_name, + logger=logger) + eval_results['mAP'] = mean_ap + elif metric == 'recall': + gt_bboxes = [ann['bboxes'] for ann in annotations] + if isinstance(iou_thr, float): + iou_thr = [iou_thr] + recalls = eval_recalls( + gt_bboxes, results, proposal_nums, iou_thr, logger=logger) + for i, num in enumerate(proposal_nums): + for j, iou in enumerate(iou_thr): + eval_results['recall@{}@{}'.format(num, iou)] = recalls[i, + j] + if recalls.shape[1] > 1: + ar = recalls.mean(axis=1) + for i, num in enumerate(proposal_nums): + eval_results['AR@{}'.format(num)] = ar[i] + return eval_results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py new file mode 100644 index 000000000..b83e3d664 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/wider_face.py @@ -0,0 +1,42 @@ +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv + +from .registry import DATASETS +from .xml_style import XMLDataset + + +@DATASETS.register_module +class WIDERFaceDataset(XMLDataset): + """ + Reader for the WIDER Face dataset in PASCAL VOC format. + Conversion scripts can be found in + https://github.com/sovrasov/wider-face-pascal-voc-annotations + """ + CLASSES = ('face', ) + + def __init__(self, **kwargs): + super(WIDERFaceDataset, self).__init__(**kwargs) + + def load_annotations(self, ann_file): + img_infos = [] + img_ids = mmcv.list_from_file(ann_file) + for img_id in img_ids: + filename = '{}.jpg'.format(img_id) + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + width = int(size.find('width').text) + height = int(size.find('height').text) + folder = root.find('folder').text + img_infos.append( + dict( + id=img_id, + filename=osp.join(folder, filename), + width=width, + height=height)) + + return img_infos diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py new file mode 100644 index 000000000..39d57042e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py @@ -0,0 +1,86 @@ +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv +import numpy as np + +from .custom import CustomDataset +from .registry import DATASETS + + +@DATASETS.register_module +class XMLDataset(CustomDataset): + + def __init__(self, min_size=None, **kwargs): + super(XMLDataset, self).__init__(**kwargs) + self.cat2label = {cat: i + 1 for i, cat in enumerate(self.CLASSES)} + self.min_size = min_size + + def load_annotations(self, ann_file): + img_infos = [] + img_ids = mmcv.list_from_file(ann_file) + for img_id in img_ids: + filename = 'JPEGImages/{}.jpg'.format(img_id) + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + width = int(size.find('width').text) + height = int(size.find('height').text) + img_infos.append( + dict(id=img_id, filename=filename, width=width, height=height)) + return img_infos + + def get_ann_info(self, idx): + img_id = self.img_infos[idx]['id'] + xml_path = osp.join(self.img_prefix, 'Annotations', + '{}.xml'.format(img_id)) + tree = ET.parse(xml_path) + root = tree.getroot() + bboxes = [] + labels = [] + bboxes_ignore = [] + labels_ignore = [] + for obj in root.findall('object'): + name = obj.find('name').text + label = self.cat2label[name] + difficult = int(obj.find('difficult').text) + bnd_box = obj.find('bndbox') + bbox = [ + int(bnd_box.find('xmin').text), + int(bnd_box.find('ymin').text), + int(bnd_box.find('xmax').text), + int(bnd_box.find('ymax').text) + ] + ignore = False + if self.min_size: + assert not self.test_mode + w = bbox[2] - bbox[0] + h = bbox[3] - bbox[1] + if w < self.min_size or h < self.min_size: + ignore = True + if difficult or ignore: + bboxes_ignore.append(bbox) + labels_ignore.append(label) + else: + bboxes.append(bbox) + labels.append(label) + if not bboxes: + bboxes = np.zeros((0, 4)) + labels = np.zeros((0, )) + else: + bboxes = np.array(bboxes, ndmin=2) - 1 + labels = np.array(labels) + if not bboxes_ignore: + bboxes_ignore = np.zeros((0, 4)) + labels_ignore = np.zeros((0, )) + else: + bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 + labels_ignore = np.array(labels_ignore) + ann = dict( + bboxes=bboxes.astype(np.float32), + labels=labels.astype(np.int64), + bboxes_ignore=bboxes_ignore.astype(np.float32), + labels_ignore=labels_ignore.astype(np.int64)) + return ann diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py new file mode 100644 index 000000000..5f6ad0930 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py @@ -0,0 +1,19 @@ +from .dcn import (DeformConv, DeformConvPack, ModulatedDeformConv, + ModulatedDeformConvPack, DeformRoIPooling, + DeformRoIPoolingPack, ModulatedDeformRoIPoolingPack, + deform_conv, modulated_deform_conv, deform_roi_pooling) +from .gcb import ContextBlock +from .nms import nms, soft_nms +from .roi_align import RoIAlign, roi_align +from .roi_pool import RoIPool, roi_pool +from .sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss +from .masked_conv import MaskedConv2d + +__all__ = [ + 'nms', 'soft_nms', 'RoIAlign', 'roi_align', 'RoIPool', 'roi_pool', + 'DeformConv', 'DeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', + 'ModulatedDeformRoIPoolingPack', 'ModulatedDeformConv', + 'ModulatedDeformConvPack', 'deform_conv', 'modulated_deform_conv', + 'deform_roi_pooling', 'SigmoidFocalLoss', 'sigmoid_focal_loss', + 'MaskedConv2d', 'ContextBlock' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/__init__.py new file mode 100644 index 000000000..165e63725 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/__init__.py @@ -0,0 +1,13 @@ +from .functions.deform_conv import deform_conv, modulated_deform_conv +from .functions.deform_pool import deform_roi_pooling +from .modules.deform_conv import (DeformConv, ModulatedDeformConv, + DeformConvPack, ModulatedDeformConvPack) +from .modules.deform_pool import (DeformRoIPooling, DeformRoIPoolingPack, + ModulatedDeformRoIPoolingPack) + +__all__ = [ + 'DeformConv', 'DeformConvPack', 'ModulatedDeformConv', + 'ModulatedDeformConvPack', 'DeformRoIPooling', 'DeformRoIPoolingPack', + 'ModulatedDeformRoIPoolingPack', 'deform_conv', 'modulated_deform_conv', + 'deform_roi_pooling' +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_conv.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_conv.py new file mode 100644 index 000000000..6af75a758 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_conv.py @@ -0,0 +1,181 @@ +import torch +from torch.autograd import Function +from torch.nn.modules.utils import _pair + +from .. import deform_conv_cuda + + +class DeformConvFunction(Function): + + @staticmethod + def forward(ctx, + input, + offset, + weight, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + im2col_step=64): + if input is not None and input.dim() != 4: + raise ValueError( + "Expected 4D tensor as input, got {}D tensor instead.".format( + input.dim())) + ctx.stride = _pair(stride) + ctx.padding = _pair(padding) + ctx.dilation = _pair(dilation) + ctx.groups = groups + ctx.deformable_groups = deformable_groups + ctx.im2col_step = im2col_step + + ctx.save_for_backward(input, offset, weight) + + output = input.new_empty( + DeformConvFunction._output_size(input, weight, ctx.padding, + ctx.dilation, ctx.stride)) + + ctx.bufs_ = [input.new_empty(0), input.new_empty(0)] # columns, ones + + if not input.is_cuda: + raise NotImplementedError + else: + cur_im2col_step = min(ctx.im2col_step, input.shape[0]) + assert (input.shape[0] % + cur_im2col_step) == 0, 'im2col step must divide batchsize' + deform_conv_cuda.deform_conv_forward_cuda( + input, weight, offset, output, ctx.bufs_[0], ctx.bufs_[1], + weight.size(3), weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, + cur_im2col_step) + return output + + @staticmethod + def backward(ctx, grad_output): + input, offset, weight = ctx.saved_tensors + + grad_input = grad_offset = grad_weight = None + + if not grad_output.is_cuda: + raise NotImplementedError + else: + cur_im2col_step = min(ctx.im2col_step, input.shape[0]) + assert (input.shape[0] % + cur_im2col_step) == 0, 'im2col step must divide batchsize' + + if ctx.needs_input_grad[0] or ctx.needs_input_grad[1]: + grad_input = torch.zeros_like(input) + grad_offset = torch.zeros_like(offset) + deform_conv_cuda.deform_conv_backward_input_cuda( + input, offset, grad_output, grad_input, + grad_offset, weight, ctx.bufs_[0], weight.size(3), + weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, + cur_im2col_step) + + if ctx.needs_input_grad[2]: + grad_weight = torch.zeros_like(weight) + deform_conv_cuda.deform_conv_backward_parameters_cuda( + input, offset, grad_output, + grad_weight, ctx.bufs_[0], ctx.bufs_[1], weight.size(3), + weight.size(2), ctx.stride[1], ctx.stride[0], + ctx.padding[1], ctx.padding[0], ctx.dilation[1], + ctx.dilation[0], ctx.groups, ctx.deformable_groups, 1, + cur_im2col_step) + + return (grad_input, grad_offset, grad_weight, None, None, None, None, + None) + + @staticmethod + def _output_size(input, weight, padding, dilation, stride): + channels = weight.size(0) + output_size = (input.size(0), channels) + for d in range(input.dim() - 2): + in_size = input.size(d + 2) + pad = padding[d] + kernel = dilation[d] * (weight.size(d + 2) - 1) + 1 + stride_ = stride[d] + output_size += ((in_size + (2 * pad) - kernel) // stride_ + 1, ) + if not all(map(lambda s: s > 0, output_size)): + raise ValueError( + "convolution input is too small (output would be {})".format( + 'x'.join(map(str, output_size)))) + return output_size + + +class ModulatedDeformConvFunction(Function): + + @staticmethod + def forward(ctx, + input, + offset, + mask, + weight, + bias=None, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1): + ctx.stride = stride + ctx.padding = padding + ctx.dilation = dilation + ctx.groups = groups + ctx.deformable_groups = deformable_groups + ctx.with_bias = bias is not None + if not ctx.with_bias: + bias = input.new_empty(1) # fake tensor + if not input.is_cuda: + raise NotImplementedError + if weight.requires_grad or mask.requires_grad or offset.requires_grad \ + or input.requires_grad: + ctx.save_for_backward(input, offset, mask, weight, bias) + output = input.new_empty( + ModulatedDeformConvFunction._infer_shape(ctx, input, weight)) + ctx._bufs = [input.new_empty(0), input.new_empty(0)] + deform_conv_cuda.modulated_deform_conv_cuda_forward( + input, weight, bias, ctx._bufs[0], offset, mask, output, + ctx._bufs[1], weight.shape[2], weight.shape[3], ctx.stride, + ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, + ctx.groups, ctx.deformable_groups, ctx.with_bias) + return output + + @staticmethod + def backward(ctx, grad_output): + if not grad_output.is_cuda: + raise NotImplementedError + input, offset, mask, weight, bias = ctx.saved_tensors + grad_input = torch.zeros_like(input) + grad_offset = torch.zeros_like(offset) + grad_mask = torch.zeros_like(mask) + grad_weight = torch.zeros_like(weight) + grad_bias = torch.zeros_like(bias) + deform_conv_cuda.modulated_deform_conv_cuda_backward( + input, weight, bias, ctx._bufs[0], offset, mask, ctx._bufs[1], + grad_input, grad_weight, grad_bias, grad_offset, grad_mask, + grad_output, weight.shape[2], weight.shape[3], ctx.stride, + ctx.stride, ctx.padding, ctx.padding, ctx.dilation, ctx.dilation, + ctx.groups, ctx.deformable_groups, ctx.with_bias) + if not ctx.with_bias: + grad_bias = None + + return (grad_input, grad_offset, grad_mask, grad_weight, grad_bias, + None, None, None, None, None) + + @staticmethod + def _infer_shape(ctx, input, weight): + n = input.size(0) + channels_out = weight.size(0) + height, width = input.shape[2:4] + kernel_h, kernel_w = weight.shape[2:4] + height_out = (height + 2 * ctx.padding - + (ctx.dilation * (kernel_h - 1) + 1)) // ctx.stride + 1 + width_out = (width + 2 * ctx.padding - + (ctx.dilation * (kernel_w - 1) + 1)) // ctx.stride + 1 + return n, channels_out, height_out, width_out + + +deform_conv = DeformConvFunction.apply +modulated_deform_conv = ModulatedDeformConvFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py new file mode 100644 index 000000000..65ff0efb5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/functions/deform_pool.py @@ -0,0 +1,69 @@ +import torch +from torch.autograd import Function + +from .. import deform_pool_cuda + + +class DeformRoIPoolingFunction(Function): + + @staticmethod + def forward(ctx, + data, + rois, + offset, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0): + ctx.spatial_scale = spatial_scale + ctx.out_size = out_size + ctx.out_channels = out_channels + ctx.no_trans = no_trans + ctx.group_size = group_size + ctx.part_size = out_size if part_size is None else part_size + ctx.sample_per_part = sample_per_part + ctx.trans_std = trans_std + + assert 0.0 <= ctx.trans_std <= 1.0 + if not data.is_cuda: + raise NotImplementedError + + n = rois.shape[0] + output = data.new_empty(n, out_channels, out_size, out_size) + output_count = data.new_empty(n, out_channels, out_size, out_size) + deform_pool_cuda.deform_psroi_pooling_cuda_forward( + data, rois, offset, output, output_count, ctx.no_trans, + ctx.spatial_scale, ctx.out_channels, ctx.group_size, ctx.out_size, + ctx.part_size, ctx.sample_per_part, ctx.trans_std) + + if data.requires_grad or rois.requires_grad or offset.requires_grad: + ctx.save_for_backward(data, rois, offset) + ctx.output_count = output_count + + return output + + @staticmethod + def backward(ctx, grad_output): + if not grad_output.is_cuda: + raise NotImplementedError + + data, rois, offset = ctx.saved_tensors + output_count = ctx.output_count + grad_input = torch.zeros_like(data) + grad_rois = None + grad_offset = torch.zeros_like(offset) + + deform_pool_cuda.deform_psroi_pooling_cuda_backward( + grad_output, data, rois, offset, output_count, grad_input, + grad_offset, ctx.no_trans, ctx.spatial_scale, ctx.out_channels, + ctx.group_size, ctx.out_size, ctx.part_size, ctx.sample_per_part, + ctx.trans_std) + return (grad_input, grad_rois, grad_offset, None, None, None, None, + None, None, None, None) + + +deform_roi_pooling = DeformRoIPoolingFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_conv.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_conv.py new file mode 100644 index 000000000..50d15d151 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_conv.py @@ -0,0 +1,157 @@ +import math + +import torch +import torch.nn as nn +from torch.nn.modules.utils import _pair + +from ..functions.deform_conv import deform_conv, modulated_deform_conv + + +class DeformConv(nn.Module): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + bias=False): + super(DeformConv, self).__init__() + + assert not bias + assert in_channels % groups == 0, \ + 'in_channels {} cannot be divisible by groups {}'.format( + in_channels, groups) + assert out_channels % groups == 0, \ + 'out_channels {} cannot be divisible by groups {}'.format( + out_channels, groups) + + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = _pair(kernel_size) + self.stride = _pair(stride) + self.padding = _pair(padding) + self.dilation = _pair(dilation) + self.groups = groups + self.deformable_groups = deformable_groups + + self.weight = nn.Parameter( + torch.Tensor(out_channels, in_channels // self.groups, + *self.kernel_size)) + + self.reset_parameters() + + def reset_parameters(self): + n = self.in_channels + for k in self.kernel_size: + n *= k + stdv = 1. / math.sqrt(n) + self.weight.data.uniform_(-stdv, stdv) + + def forward(self, x, offset): + return deform_conv(x, offset, self.weight, self.stride, self.padding, + self.dilation, self.groups, self.deformable_groups) + + +class DeformConvPack(DeformConv): + + def __init__(self, *args, **kwargs): + super(DeformConvPack, self).__init__(*args, **kwargs) + + self.conv_offset = nn.Conv2d( + self.in_channels, + self.deformable_groups * 2 * self.kernel_size[0] * + self.kernel_size[1], + kernel_size=self.kernel_size, + stride=_pair(self.stride), + padding=_pair(self.padding), + bias=True) + self.init_offset() + + def init_offset(self): + self.conv_offset.weight.data.zero_() + self.conv_offset.bias.data.zero_() + + def forward(self, x): + offset = self.conv_offset(x) + return deform_conv(x, offset, self.weight, self.stride, self.padding, + self.dilation, self.groups, self.deformable_groups) + + +class ModulatedDeformConv(nn.Module): + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + deformable_groups=1, + bias=True): + super(ModulatedDeformConv, self).__init__() + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = _pair(kernel_size) + self.stride = stride + self.padding = padding + self.dilation = dilation + self.groups = groups + self.deformable_groups = deformable_groups + self.with_bias = bias + + self.weight = nn.Parameter( + torch.Tensor(out_channels, in_channels // groups, + *self.kernel_size)) + if bias: + self.bias = nn.Parameter(torch.Tensor(out_channels)) + else: + self.register_parameter('bias', None) + self.reset_parameters() + + def reset_parameters(self): + n = self.in_channels + for k in self.kernel_size: + n *= k + stdv = 1. / math.sqrt(n) + self.weight.data.uniform_(-stdv, stdv) + if self.bias is not None: + self.bias.data.zero_() + + def forward(self, x, offset, mask): + return modulated_deform_conv(x, offset, mask, self.weight, self.bias, + self.stride, self.padding, self.dilation, + self.groups, self.deformable_groups) + + +class ModulatedDeformConvPack(ModulatedDeformConv): + + def __init__(self, *args, **kwargs): + super(ModulatedDeformConvPack, self).__init__(*args, **kwargs) + + self.conv_offset_mask = nn.Conv2d( + self.in_channels, + self.deformable_groups * 3 * self.kernel_size[0] * + self.kernel_size[1], + kernel_size=self.kernel_size, + stride=_pair(self.stride), + padding=_pair(self.padding), + bias=True) + self.init_offset() + + def init_offset(self): + self.conv_offset_mask.weight.data.zero_() + self.conv_offset_mask.bias.data.zero_() + + def forward(self, x): + out = self.conv_offset_mask(x) + o1, o2, mask = torch.chunk(out, 3, dim=1) + offset = torch.cat((o1, o2), dim=1) + mask = torch.sigmoid(mask) + return modulated_deform_conv(x, offset, mask, self.weight, self.bias, + self.stride, self.padding, self.dilation, + self.groups, self.deformable_groups) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_pool.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_pool.py new file mode 100644 index 000000000..5e0196753 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/modules/deform_pool.py @@ -0,0 +1,172 @@ +from torch import nn + +from ..functions.deform_pool import deform_roi_pooling + + +class DeformRoIPooling(nn.Module): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0): + super(DeformRoIPooling, self).__init__() + self.spatial_scale = spatial_scale + self.out_size = out_size + self.out_channels = out_channels + self.no_trans = no_trans + self.group_size = group_size + self.part_size = out_size if part_size is None else part_size + self.sample_per_part = sample_per_part + self.trans_std = trans_std + + def forward(self, data, rois, offset): + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, self.part_size, + self.sample_per_part, self.trans_std) + + +class DeformRoIPoolingPack(DeformRoIPooling): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0, + num_offset_fcs=3, + deform_fc_channels=1024): + super(DeformRoIPoolingPack, + self).__init__(spatial_scale, out_size, out_channels, no_trans, + group_size, part_size, sample_per_part, trans_std) + + self.num_offset_fcs = num_offset_fcs + self.deform_fc_channels = deform_fc_channels + + if not no_trans: + seq = [] + ic = self.out_size * self.out_size * self.out_channels + for i in range(self.num_offset_fcs): + if i < self.num_offset_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size * self.out_size * 2 + seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_offset_fcs - 1: + seq.append(nn.ReLU(inplace=True)) + self.offset_fc = nn.Sequential(*seq) + self.offset_fc[-1].weight.data.zero_() + self.offset_fc[-1].bias.data.zero_() + + def forward(self, data, rois): + assert data.size(1) == self.out_channels + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, + self.part_size, self.sample_per_part, self.trans_std) + else: + n = rois.shape[0] + offset = data.new_empty(0) + x = deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, True, + self.group_size, self.part_size, + self.sample_per_part, self.trans_std) + offset = self.offset_fc(x.view(n, -1)) + offset = offset.view(n, 2, self.out_size, self.out_size) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, + self.part_size, self.sample_per_part, self.trans_std) + + +class ModulatedDeformRoIPoolingPack(DeformRoIPooling): + + def __init__(self, + spatial_scale, + out_size, + out_channels, + no_trans, + group_size=1, + part_size=None, + sample_per_part=4, + trans_std=.0, + num_offset_fcs=3, + num_mask_fcs=2, + deform_fc_channels=1024): + super(ModulatedDeformRoIPoolingPack, self).__init__( + spatial_scale, out_size, out_channels, no_trans, group_size, + part_size, sample_per_part, trans_std) + + self.num_offset_fcs = num_offset_fcs + self.num_mask_fcs = num_mask_fcs + self.deform_fc_channels = deform_fc_channels + + if not no_trans: + offset_fc_seq = [] + ic = self.out_size * self.out_size * self.out_channels + for i in range(self.num_offset_fcs): + if i < self.num_offset_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size * self.out_size * 2 + offset_fc_seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_offset_fcs - 1: + offset_fc_seq.append(nn.ReLU(inplace=True)) + self.offset_fc = nn.Sequential(*offset_fc_seq) + self.offset_fc[-1].weight.data.zero_() + self.offset_fc[-1].bias.data.zero_() + + mask_fc_seq = [] + ic = self.out_size * self.out_size * self.out_channels + for i in range(self.num_mask_fcs): + if i < self.num_mask_fcs - 1: + oc = self.deform_fc_channels + else: + oc = self.out_size * self.out_size + mask_fc_seq.append(nn.Linear(ic, oc)) + ic = oc + if i < self.num_mask_fcs - 1: + mask_fc_seq.append(nn.ReLU(inplace=True)) + else: + mask_fc_seq.append(nn.Sigmoid()) + self.mask_fc = nn.Sequential(*mask_fc_seq) + self.mask_fc[-2].weight.data.zero_() + self.mask_fc[-2].bias.data.zero_() + + def forward(self, data, rois): + assert data.size(1) == self.out_channels + if self.no_trans: + offset = data.new_empty(0) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, + self.part_size, self.sample_per_part, self.trans_std) + else: + n = rois.shape[0] + offset = data.new_empty(0) + x = deform_roi_pooling(data, rois, offset, self.spatial_scale, + self.out_size, self.out_channels, True, + self.group_size, self.part_size, + self.sample_per_part, self.trans_std) + offset = self.offset_fc(x.view(n, -1)) + offset = offset.view(n, 2, self.out_size, self.out_size) + mask = self.mask_fc(x.view(n, -1)) + mask = mask.view(n, 1, self.out_size, self.out_size) + return deform_roi_pooling( + data, rois, offset, self.spatial_scale, self.out_size, + self.out_channels, self.no_trans, self.group_size, + self.part_size, self.sample_per_part, self.trans_std) * mask diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/setup.py new file mode 100644 index 000000000..96380181d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/setup.py @@ -0,0 +1,15 @@ +from setuptools import setup +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +setup( + name='deform_conv', + ext_modules=[ + CUDAExtension('deform_conv_cuda', [ + 'src/deform_conv_cuda.cpp', + 'src/deform_conv_cuda_kernel.cu', + ]), + CUDAExtension( + 'deform_pool_cuda', + ['src/deform_pool_cuda.cpp', 'src/deform_pool_cuda_kernel.cu']), + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda.cpp new file mode 100644 index 000000000..e45155b94 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda.cpp @@ -0,0 +1,695 @@ +// modify from +// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda.c + +#include + +#include +#include + +void deformable_im2col(const at::Tensor data_im, const at::Tensor data_offset, + const int channels, const int height, const int width, + const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor data_col); + +void deformable_col2im(const at::Tensor data_col, const at::Tensor data_offset, + const int channels, const int height, const int width, + const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor grad_im); + +void deformable_col2im_coord( + const at::Tensor data_col, const at::Tensor data_im, + const at::Tensor data_offset, const int channels, const int height, + const int width, const int ksize_h, const int ksize_w, const int pad_h, + const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int parallel_imgs, + const int deformable_group, at::Tensor grad_offset); + +void modulated_deformable_im2col_cuda( + const at::Tensor data_im, const at::Tensor data_offset, + const at::Tensor data_mask, const int batch_size, const int channels, + const int height_im, const int width_im, const int height_col, + const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int deformable_group, + at::Tensor data_col); + +void modulated_deformable_col2im_cuda( + const at::Tensor data_col, const at::Tensor data_offset, + const at::Tensor data_mask, const int batch_size, const int channels, + const int height_im, const int width_im, const int height_col, + const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int deformable_group, + at::Tensor grad_im); + +void modulated_deformable_col2im_coord_cuda( + const at::Tensor data_col, const at::Tensor data_im, + const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, + const int width_im, const int height_col, const int width_col, + const int kernel_h, const int kenerl_w, const int pad_h, const int pad_w, + const int stride_h, const int stride_w, const int dilation_h, + const int dilation_w, const int deformable_group, at::Tensor grad_offset, + at::Tensor grad_mask); + +void shape_check(at::Tensor input, at::Tensor offset, at::Tensor *gradOutput, + at::Tensor weight, int kH, int kW, int dH, int dW, int padH, + int padW, int dilationH, int dilationW, int group, + int deformable_group) { + TORCH_CHECK(weight.ndimension() == 4, + "4D weight tensor (nOutputPlane,nInputPlane,kH,kW) expected, " + "but got: %s", + weight.ndimension()); + + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + + TORCH_CHECK(kW > 0 && kH > 0, + "kernel size should be greater than zero, but got kH: %d kW: %d", kH, + kW); + + TORCH_CHECK((weight.size(2) == kH && weight.size(3) == kW), + "kernel size should be consistent with weight, ", + "but got kH: %d kW: %d weight.size(2): %d, weight.size(3): %d", kH, + kW, weight.size(2), weight.size(3)); + + TORCH_CHECK(dW > 0 && dH > 0, + "stride should be greater than zero, but got dH: %d dW: %d", dH, dW); + + TORCH_CHECK( + dilationW > 0 && dilationH > 0, + "dilation should be greater than 0, but got dilationH: %d dilationW: %d", + dilationH, dilationW); + + int ndim = input.ndimension(); + int dimf = 0; + int dimh = 1; + int dimw = 2; + + if (ndim == 4) { + dimf++; + dimh++; + dimw++; + } + + TORCH_CHECK(ndim == 3 || ndim == 4, "3D or 4D input tensor expected but got: %s", + ndim); + + long nInputPlane = weight.size(1) * group; + long inputHeight = input.size(dimh); + long inputWidth = input.size(dimw); + long nOutputPlane = weight.size(0); + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + + TORCH_CHECK(nInputPlane % deformable_group == 0, + "input channels must divide deformable group size"); + + if (outputWidth < 1 || outputHeight < 1) + AT_ERROR( + "Given input size: (%ld x %ld x %ld). " + "Calculated output size: (%ld x %ld x %ld). Output size is too small", + nInputPlane, inputHeight, inputWidth, nOutputPlane, outputHeight, + outputWidth); + + TORCH_CHECK(input.size(1) == nInputPlane, + "invalid number of input planes, expected: %d, but got: %d", + nInputPlane, input.size(1)); + + TORCH_CHECK((inputHeight >= kH && inputWidth >= kW), + "input image is smaller than kernel"); + + TORCH_CHECK((offset.size(2) == outputHeight && offset.size(3) == outputWidth), + "invalid spatial size of offset, expected height: %d width: %d, but " + "got height: %d width: %d", + outputHeight, outputWidth, offset.size(2), offset.size(3)); + + TORCH_CHECK((offset.size(1) == deformable_group * 2 * kH * kW), + "invalid number of channels of offset"); + + if (gradOutput != NULL) { + TORCH_CHECK(gradOutput->size(dimf) == nOutputPlane, + "invalid number of gradOutput planes, expected: %d, but got: %d", + nOutputPlane, gradOutput->size(dimf)); + + TORCH_CHECK((gradOutput->size(dimh) == outputHeight && + gradOutput->size(dimw) == outputWidth), + "invalid size of gradOutput, expected height: %d width: %d , but " + "got height: %d width: %d", + outputHeight, outputWidth, gradOutput->size(dimh), + gradOutput->size(dimw)); + } +} + +int deform_conv_forward_cuda(at::Tensor input, at::Tensor weight, + at::Tensor offset, at::Tensor output, + at::Tensor columns, at::Tensor ones, int kW, + int kH, int dW, int dH, int padW, int padH, + int dilationW, int dilationH, int group, + int deformable_group, int im2col_step) { + // todo: resize columns to include im2col: done + // todo: add im2col_step as input + // todo: add new output buffer and transpose it to output (or directly + // transpose output) todo: possibly change data indexing because of + // parallel_imgs + + shape_check(input, offset, NULL, weight, kH, kW, dH, dW, padH, padW, + dilationH, dilationW, group, deformable_group); + + input = input.contiguous(); + offset = offset.contiguous(); + weight = weight.contiguous(); + + int batch = 1; + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input.unsqueeze_(0); + offset.unsqueeze_(0); + } + + // todo: assert batchsize dividable by im2col_step + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = weight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); + + output = output.view({batchSize / im2col_step, im2col_step, nOutputPlane, + outputHeight, outputWidth}); + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < outputHeight * outputWidth) { + ones = at::ones({outputHeight, outputWidth}, input.options()); + } + + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + at::Tensor output_buffer = + at::zeros({batchSize / im2col_step, nOutputPlane, + im2col_step * outputHeight, outputWidth}, + output.options()); + + output_buffer = output_buffer.view( + {output_buffer.size(0), group, output_buffer.size(1) / group, + output_buffer.size(2), output_buffer.size(3)}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, columns); + + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + + for (int g = 0; g < group; g++) { + output_buffer[elt][g] = output_buffer[elt][g] + .flatten(1) + .addmm_(weight[g].flatten(1), columns[g]) + .view_as(output_buffer[elt][g]); + } + } + + output_buffer = output_buffer.view( + {output_buffer.size(0), output_buffer.size(1) * output_buffer.size(2), + output_buffer.size(3), output_buffer.size(4)}); + + output_buffer = output_buffer.view({batchSize / im2col_step, nOutputPlane, + im2col_step, outputHeight, outputWidth}); + output_buffer.transpose_(1, 2); + output.copy_(output_buffer); + output = output.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + output = output.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); + } + + return 1; +} + +int deform_conv_backward_input_cuda(at::Tensor input, at::Tensor offset, + at::Tensor gradOutput, at::Tensor gradInput, + at::Tensor gradOffset, at::Tensor weight, + at::Tensor columns, int kW, int kH, int dW, + int dH, int padW, int padH, int dilationW, + int dilationH, int group, + int deformable_group, int im2col_step) { + shape_check(input, offset, &gradOutput, weight, kH, kW, dH, dW, padH, padW, + dilationH, dilationW, group, deformable_group); + + input = input.contiguous(); + offset = offset.contiguous(); + gradOutput = gradOutput.contiguous(); + weight = weight.contiguous(); + + int batch = 1; + + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input = input.view({1, input.size(0), input.size(1), input.size(2)}); + offset = offset.view({1, offset.size(0), offset.size(1), offset.size(2)}); + gradOutput = gradOutput.view( + {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); + } + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = weight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), 3, "invalid batch size of offset"); + gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + // change order of grad output + gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, + nOutputPlane, outputHeight, outputWidth}); + gradOutput.transpose_(1, 2); + + gradInput = gradInput.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + gradOffset = gradOffset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, + outputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + // divide into groups + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + gradOutput = gradOutput.view( + {gradOutput.size(0), group, gradOutput.size(1) / group, + gradOutput.size(2), gradOutput.size(3), gradOutput.size(4)}); + + for (int g = 0; g < group; g++) { + columns[g] = columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), + gradOutput[elt][g].flatten(1), 0.0f, 1.0f); + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + gradOutput = gradOutput.view( + {gradOutput.size(0), gradOutput.size(1) * gradOutput.size(2), + gradOutput.size(3), gradOutput.size(4), gradOutput.size(5)}); + + deformable_col2im_coord(columns, input[elt], offset[elt], nInputPlane, + inputHeight, inputWidth, kH, kW, padH, padW, dH, dW, + dilationH, dilationW, im2col_step, deformable_group, + gradOffset[elt]); + + deformable_col2im(columns, offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, gradInput[elt]); + } + + gradOutput.transpose_(1, 2); + gradOutput = + gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + gradInput = gradInput.view({batchSize, nInputPlane, inputHeight, inputWidth}); + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + gradOffset = gradOffset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + gradInput = gradInput.view({nInputPlane, inputHeight, inputWidth}); + offset = offset.view({offset.size(1), offset.size(2), offset.size(3)}); + gradOffset = + gradOffset.view({offset.size(1), offset.size(2), offset.size(3)}); + } + + return 1; +} + +int deform_conv_backward_parameters_cuda( + at::Tensor input, at::Tensor offset, at::Tensor gradOutput, + at::Tensor gradWeight, // at::Tensor gradBias, + at::Tensor columns, at::Tensor ones, int kW, int kH, int dW, int dH, + int padW, int padH, int dilationW, int dilationH, int group, + int deformable_group, float scale, int im2col_step) { + // todo: transpose and reshape outGrad + // todo: reshape columns + // todo: add im2col_step as input + + shape_check(input, offset, &gradOutput, gradWeight, kH, kW, dH, dW, padH, + padW, dilationH, dilationW, group, deformable_group); + + input = input.contiguous(); + offset = offset.contiguous(); + gradOutput = gradOutput.contiguous(); + + int batch = 1; + + if (input.ndimension() == 3) { + // Force batch + batch = 0; + input = input.view( + at::IntList({1, input.size(0), input.size(1), input.size(2)})); + gradOutput = gradOutput.view( + {1, gradOutput.size(0), gradOutput.size(1), gradOutput.size(2)}); + } + + long batchSize = input.size(0); + long nInputPlane = input.size(1); + long inputHeight = input.size(2); + long inputWidth = input.size(3); + + long nOutputPlane = gradWeight.size(0); + + long outputWidth = + (inputWidth + 2 * padW - (dilationW * (kW - 1) + 1)) / dW + 1; + long outputHeight = + (inputHeight + 2 * padH - (dilationH * (kH - 1) + 1)) / dH + 1; + + TORCH_CHECK((offset.size(0) == batchSize), "invalid batch size of offset"); + + columns = at::zeros( + {nInputPlane * kW * kH, im2col_step * outputHeight * outputWidth}, + input.options()); + + gradOutput = gradOutput.view({batchSize / im2col_step, im2col_step, + nOutputPlane, outputHeight, outputWidth}); + gradOutput.transpose_(1, 2); + + at::Tensor gradOutputBuffer = at::zeros_like(gradOutput); + gradOutputBuffer = + gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, im2col_step, + outputHeight, outputWidth}); + gradOutputBuffer.copy_(gradOutput); + gradOutputBuffer = + gradOutputBuffer.view({batchSize / im2col_step, nOutputPlane, + im2col_step * outputHeight, outputWidth}); + + gradOutput.transpose_(1, 2); + gradOutput = + gradOutput.view({batchSize, nOutputPlane, outputHeight, outputWidth}); + + input = input.view({batchSize / im2col_step, im2col_step, nInputPlane, + inputHeight, inputWidth}); + offset = + offset.view({batchSize / im2col_step, im2col_step, + deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + for (int elt = 0; elt < batchSize / im2col_step; elt++) { + deformable_im2col(input[elt], offset[elt], nInputPlane, inputHeight, + inputWidth, kH, kW, padH, padW, dH, dW, dilationH, + dilationW, im2col_step, deformable_group, columns); + + // divide into group + gradOutputBuffer = gradOutputBuffer.view( + {gradOutputBuffer.size(0), group, gradOutputBuffer.size(1) / group, + gradOutputBuffer.size(2), gradOutputBuffer.size(3)}); + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + gradWeight = + gradWeight.view({group, gradWeight.size(0) / group, gradWeight.size(1), + gradWeight.size(2), gradWeight.size(3)}); + + for (int g = 0; g < group; g++) { + gradWeight[g] = gradWeight[g] + .flatten(1) + .addmm_(gradOutputBuffer[elt][g].flatten(1), + columns[g].transpose(1, 0), 1.0, scale) + .view_as(gradWeight[g]); + } + gradOutputBuffer = gradOutputBuffer.view( + {gradOutputBuffer.size(0), + gradOutputBuffer.size(1) * gradOutputBuffer.size(2), + gradOutputBuffer.size(3), gradOutputBuffer.size(4)}); + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + gradWeight = gradWeight.view({gradWeight.size(0) * gradWeight.size(1), + gradWeight.size(2), gradWeight.size(3), + gradWeight.size(4)}); + } + + input = input.view({batchSize, nInputPlane, inputHeight, inputWidth}); + offset = offset.view( + {batchSize, deformable_group * 2 * kH * kW, outputHeight, outputWidth}); + + if (batch == 0) { + gradOutput = gradOutput.view({nOutputPlane, outputHeight, outputWidth}); + input = input.view({nInputPlane, inputHeight, inputWidth}); + } + + return 1; +} + +void modulated_deform_conv_cuda_forward( + at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, + at::Tensor offset, at::Tensor mask, at::Tensor output, at::Tensor columns, + int kernel_h, int kernel_w, const int stride_h, const int stride_w, + const int pad_h, const int pad_w, const int dilation_h, + const int dilation_w, const int group, const int deformable_group, + const bool with_bias) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + + const int channels_out = weight.size(0); + const int channels_kernel = weight.size(1); + const int kernel_h_ = weight.size(2); + const int kernel_w_ = weight.size(3); + + if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) + AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", + kernel_h_, kernel_w, kernel_h_, kernel_w_); + if (channels != channels_kernel * group) + AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", + channels, channels_kernel * group); + + const int height_out = + (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; + const int width_out = + (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < height_out * width_out) { + // Resize plane and fill with ones... + ones = at::ones({height_out, width_out}, input.options()); + } + + // resize output + output = output.view({batch, channels_out, height_out, width_out}).zero_(); + // resize temporary columns + columns = + at::zeros({channels * kernel_h * kernel_w, 1 * height_out * width_out}, + input.options()); + + output = output.view({output.size(0), group, output.size(1) / group, + output.size(2), output.size(3)}); + + for (int b = 0; b < batch; b++) { + modulated_deformable_im2col_cuda( + input[b], offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, columns); + + // divide into group + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + + for (int g = 0; g < group; g++) { + output[b][g] = output[b][g] + .flatten(1) + .addmm_(weight[g].flatten(1), columns[g]) + .view_as(output[b][g]); + } + + weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), + weight.size(3), weight.size(4)}); + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + } + + output = output.view({output.size(0), output.size(1) * output.size(2), + output.size(3), output.size(4)}); + + if (with_bias) { + output += bias.view({1, bias.size(0), 1, 1}); + } +} + +void modulated_deform_conv_cuda_backward( + at::Tensor input, at::Tensor weight, at::Tensor bias, at::Tensor ones, + at::Tensor offset, at::Tensor mask, at::Tensor columns, + at::Tensor grad_input, at::Tensor grad_weight, at::Tensor grad_bias, + at::Tensor grad_offset, at::Tensor grad_mask, at::Tensor grad_output, + int kernel_h, int kernel_w, int stride_h, int stride_w, int pad_h, + int pad_w, int dilation_h, int dilation_w, int group, int deformable_group, + const bool with_bias) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + TORCH_CHECK(weight.is_contiguous(), "weight tensor has to be contiguous"); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + + const int channels_kernel = weight.size(1); + const int kernel_h_ = weight.size(2); + const int kernel_w_ = weight.size(3); + if (kernel_h_ != kernel_h || kernel_w_ != kernel_w) + AT_ERROR("Input shape and kernel shape wont match: (%d x %d vs %d x %d).", + kernel_h_, kernel_w, kernel_h_, kernel_w_); + if (channels != channels_kernel * group) + AT_ERROR("Input shape and kernel channels wont match: (%d vs %d).", + channels, channels_kernel * group); + + const int height_out = + (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1; + const int width_out = + (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1; + + if (ones.ndimension() != 2 || + ones.size(0) * ones.size(1) < height_out * width_out) { + // Resize plane and fill with ones... + ones = at::ones({height_out, width_out}, input.options()); + } + + grad_input = grad_input.view({batch, channels, height, width}); + columns = at::zeros({channels * kernel_h * kernel_w, height_out * width_out}, + input.options()); + + grad_output = + grad_output.view({grad_output.size(0), group, grad_output.size(1) / group, + grad_output.size(2), grad_output.size(3)}); + + for (int b = 0; b < batch; b++) { + // divide int group + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + weight = weight.view({group, weight.size(0) / group, weight.size(1), + weight.size(2), weight.size(3)}); + + for (int g = 0; g < group; g++) { + columns[g].addmm_(weight[g].flatten(1).transpose(0, 1), + grad_output[b][g].flatten(1), 0.0f, 1.0f); + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + weight = weight.view({weight.size(0) * weight.size(1), weight.size(2), + weight.size(3), weight.size(4)}); + + // gradient w.r.t. input coordinate data + modulated_deformable_col2im_coord_cuda( + columns, input[b], offset[b], mask[b], 1, channels, height, width, + height_out, width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, + stride_w, dilation_h, dilation_w, deformable_group, grad_offset[b], + grad_mask[b]); + // gradient w.r.t. input data + modulated_deformable_col2im_cuda( + columns, offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, grad_input[b]); + + // gradient w.r.t. weight, dWeight should accumulate across the batch and + // group + modulated_deformable_im2col_cuda( + input[b], offset[b], mask[b], 1, channels, height, width, height_out, + width_out, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, deformable_group, columns); + + columns = columns.view({group, columns.size(0) / group, columns.size(1)}); + grad_weight = grad_weight.view({group, grad_weight.size(0) / group, + grad_weight.size(1), grad_weight.size(2), + grad_weight.size(3)}); + if (with_bias) + grad_bias = grad_bias.view({group, grad_bias.size(0) / group}); + + for (int g = 0; g < group; g++) { + grad_weight[g] = + grad_weight[g] + .flatten(1) + .addmm_(grad_output[b][g].flatten(1), columns[g].transpose(0, 1)) + .view_as(grad_weight[g]); + if (with_bias) { + grad_bias[g] = + grad_bias[g] + .view({-1, 1}) + .addmm_(grad_output[b][g].flatten(1), ones.view({-1, 1})) + .view(-1); + } + } + + columns = + columns.view({columns.size(0) * columns.size(1), columns.size(2)}); + grad_weight = grad_weight.view({grad_weight.size(0) * grad_weight.size(1), + grad_weight.size(2), grad_weight.size(3), + grad_weight.size(4)}); + if (with_bias) + grad_bias = grad_bias.view({grad_bias.size(0) * grad_bias.size(1)}); + } + grad_output = grad_output.view({grad_output.size(0) * grad_output.size(1), + grad_output.size(2), grad_output.size(3), + grad_output.size(4)}); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("deform_conv_forward_cuda", &deform_conv_forward_cuda, + "deform forward (CUDA)"); + m.def("deform_conv_backward_input_cuda", &deform_conv_backward_input_cuda, + "deform_conv_backward_input (CUDA)"); + m.def("deform_conv_backward_parameters_cuda", + &deform_conv_backward_parameters_cuda, + "deform_conv_backward_parameters (CUDA)"); + m.def("modulated_deform_conv_cuda_forward", + &modulated_deform_conv_cuda_forward, + "modulated deform conv forward (CUDA)"); + m.def("modulated_deform_conv_cuda_backward", + &modulated_deform_conv_cuda_backward, + "modulated deform conv backward (CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu new file mode 100644 index 000000000..fd5601630 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu @@ -0,0 +1,866 @@ +/*! + ******************* BEGIN Caffe Copyright Notice and Disclaimer **************** + * + * COPYRIGHT + * + * All contributions by the University of California: + * Copyright (c) 2014-2017 The Regents of the University of California (Regents) + * All rights reserved. + * + * All other contributions: + * Copyright (c) 2014-2017, the respective contributors + * All rights reserved. + * + * Caffe uses a shared copyright model: each contributor holds copyright over + * their contributions to Caffe. The project versioning records all such + * contribution and copyright details. If a contributor wants to further mark + * their specific copyright on a particular contribution, they should indicate + * their copyright solely in the commit message of the change when it is + * committed. + * + * LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * CONTRIBUTION AGREEMENT + * + * By contributing to the BVLC/caffe repository through pull-request, comment, + * or otherwise, the contributor releases their content to the + * license and copyright terms herein. + * + ***************** END Caffe Copyright Notice and Disclaimer ******************** + * + * Copyright (c) 2018 Microsoft + * Licensed under The MIT License [see LICENSE for details] + * \file modulated_deformable_im2col.cuh + * \brief Function definitions of converting an image to + * column matrix based on kernel, padding, dilation, and offset. + * These functions are mainly used in deformable convolution operators. + * \ref: https://arxiv.org/abs/1703.06211 + * \author Yuwen Xiong, Haozhi Qi, Jifeng Dai, Xizhou Zhu, Han Hu, Dazhi Cheng + */ + +// modify from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/deform_conv_cuda_kernel.cu + +#include +#include +#include +#include +#include + +using namespace at; + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); \ + i += blockDim.x * gridDim.x) + +const int CUDA_NUM_THREADS = 1024; +const int kMaxGridNum = 65535; + +inline int GET_BLOCKS(const int N) +{ + return std::min(kMaxGridNum, (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS); +} + +template +__device__ scalar_t deformable_im2col_bilinear(const scalar_t *bottom_data, const int data_width, + const int height, const int width, scalar_t h, scalar_t w) +{ + + int h_low = floor(h); + int w_low = floor(w); + int h_high = h_low + 1; + int w_high = w_low + 1; + + scalar_t lh = h - h_low; + scalar_t lw = w - w_low; + scalar_t hh = 1 - lh, hw = 1 - lw; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + v1 = bottom_data[h_low * data_width + w_low]; + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + v2 = bottom_data[h_low * data_width + w_high]; + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + v3 = bottom_data[h_high * data_width + w_low]; + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + v4 = bottom_data[h_high * data_width + w_high]; + + scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + +template +__device__ scalar_t get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, + const int h, const int w, const int height, const int width) +{ + + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + if (h == argmax_h_low && w == argmax_w_low) + weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); + if (h == argmax_h_low && w == argmax_w_high) + weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); + if (h == argmax_h_high && w == argmax_w_low) + weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); + if (h == argmax_h_high && w == argmax_w_high) + weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); + return weight; +} + +template +__device__ scalar_t get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, + const int height, const int width, const scalar_t *im_data, + const int data_width, const int bp_dir) +{ + + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + + if (bp_dir == 0) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + else if (bp_dir == 1) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + + return weight; +} + +template +__global__ void deformable_im2col_gpu_kernel(const int n, const scalar_t *data_im, const scalar_t *data_offset, + const int height, const int width, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int channel_per_deformable_group, + const int batch_size, const int num_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + // index index of output matrix + const int w_col = index % width_col; + const int h_col = (index / width_col) % height_col; + const int b_col = (index / width_col / height_col) % batch_size; + const int c_im = (index / width_col / height_col) / batch_size; + const int c_col = c_im * kernel_h * kernel_w; + + // compute deformable group index + const int deformable_group_index = c_im / channel_per_deformable_group; + + const int h_in = h_col * stride_h - pad_h; + const int w_in = w_col * stride_w - pad_w; + scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; + //const scalar_t* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; + const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; + const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + + for (int i = 0; i < kernel_h; ++i) + { + for (int j = 0; j < kernel_w; ++j) + { + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + scalar_t val = static_cast(0); + const scalar_t h_im = h_in + i * dilation_h + offset_h; + const scalar_t w_im = w_in + j * dilation_w + offset_w; + if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) + { + //const scalar_t map_h = i * dilation_h + offset_h; + //const scalar_t map_w = j * dilation_w + offset_w; + //const int cur_height = height - h_in; + //const int cur_width = width - w_in; + //val = deformable_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); + val = deformable_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); + } + *data_col_ptr = val; + data_col_ptr += batch_size * height_col * width_col; + } + } + } +} + +void deformable_im2col( + const at::Tensor data_im, const at::Tensor data_offset, const int channels, + const int height, const int width, const int ksize_h, const int ksize_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, const int parallel_imgs, + const int deformable_group, at::Tensor data_col) +{ + // num_axes should be smaller than block size + // todo: check parallel_imgs is correctly passed in + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = channels * height_col * width_col * parallel_imgs; + int channel_per_deformable_group = channels / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_im.type(), "deformable_im2col_gpu", ([&] { + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *data_col_ = data_col.data(); + + deformable_im2col_gpu_kernel<<>>( + num_kernels, data_im_, data_offset_, height, width, ksize_h, ksize_w, + pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, + channel_per_deformable_group, parallel_imgs, channels, deformable_group, + height_col, width_col, data_col_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in deformable_im2col: %s\n", cudaGetErrorString(err)); + } +} + +template +__global__ void deformable_col2im_gpu_kernel( + const int n, const scalar_t *data_col, const scalar_t *data_offset, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_im) +{ + CUDA_KERNEL_LOOP(index, n) + { + const int j = (index / width_col / height_col / batch_size) % kernel_w; + const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; + const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; + // compute the start and end of the output + + const int deformable_group_index = c / channel_per_deformable_group; + + int w_out = index % width_col; + int h_out = (index / width_col) % height_col; + int b = (index / width_col / height_col) % batch_size; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * + 2 * kernel_h * kernel_w * height_col * width_col; + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; + const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; + + const scalar_t cur_top_grad = data_col[index]; + const int cur_h = (int)cur_inv_h_data; + const int cur_w = (int)cur_inv_w_data; + for (int dy = -2; dy <= 2; dy++) + { + for (int dx = -2; dx <= 2; dx++) + { + if (cur_h + dy >= 0 && cur_h + dy < height && + cur_w + dx >= 0 && cur_w + dx < width && + abs(cur_inv_h_data - (cur_h + dy)) < 1 && + abs(cur_inv_w_data - (cur_w + dx)) < 1) + { + int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; + scalar_t weight = get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); + atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); + } + } + } + } +} + +void deformable_col2im( + const at::Tensor data_col, const at::Tensor data_offset, const int channels, + const int height, const int width, const int ksize_h, + const int ksize_w, const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, + at::Tensor grad_im) +{ + + // todo: make sure parallel_imgs is passed in correctly + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = channels * ksize_h * ksize_w * height_col * width_col * parallel_imgs; + int channel_per_deformable_group = channels / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.type(), "deformable_col2im_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *grad_im_ = grad_im.data(); + + deformable_col2im_gpu_kernel<<>>( + num_kernels, data_col_, data_offset_, channels, height, width, ksize_h, + ksize_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + parallel_imgs, deformable_group, height_col, width_col, grad_im_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in deformable_col2im: %s\n", cudaGetErrorString(err)); + } +} + +template +__global__ void deformable_col2im_coord_gpu_kernel(const int n, const scalar_t *data_col, + const scalar_t *data_im, const scalar_t *data_offset, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int offset_channels, const int deformable_group, + const int height_col, const int width_col, scalar_t *grad_offset) +{ + CUDA_KERNEL_LOOP(index, n) + { + scalar_t val = 0; + int w = index % width_col; + int h = (index / width_col) % height_col; + int c = (index / width_col / height_col) % offset_channels; + int b = (index / width_col / height_col) / offset_channels; + // compute the start and end of the output + + const int deformable_group_index = c / (2 * kernel_h * kernel_w); + const int col_step = kernel_h * kernel_w; + int cnt = 0; + const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * + batch_size * width_col * height_col; + const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * + channel_per_deformable_group / kernel_h / kernel_w * height * width; + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; + + const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; + + for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) + { + const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; + const int bp_dir = offset_c % 2; + + int j = (col_pos / width_col / height_col / batch_size) % kernel_w; + int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; + int w_out = col_pos % width_col; + int h_out = (col_pos / width_col) % height_col; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); + const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + scalar_t inv_h = h_in + i * dilation_h + offset_h; + scalar_t inv_w = w_in + j * dilation_w + offset_w; + if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) + { + inv_h = inv_w = -2; + } + const scalar_t weight = get_coordinate_weight( + inv_h, inv_w, + height, width, data_im_ptr + cnt * height * width, width, bp_dir); + val += weight * data_col_ptr[col_pos]; + cnt += 1; + } + + grad_offset[index] = val; + } +} + +void deformable_col2im_coord( + const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, + const int channels, const int height, const int width, const int ksize_h, + const int ksize_w, const int pad_h, const int pad_w, const int stride_h, + const int stride_w, const int dilation_h, const int dilation_w, + const int parallel_imgs, const int deformable_group, at::Tensor grad_offset) +{ + + int height_col = (height + 2 * pad_h - (dilation_h * (ksize_h - 1) + 1)) / stride_h + 1; + int width_col = (width + 2 * pad_w - (dilation_w * (ksize_w - 1) + 1)) / stride_w + 1; + int num_kernels = height_col * width_col * 2 * ksize_h * ksize_w * deformable_group * parallel_imgs; + int channel_per_deformable_group = channels * ksize_h * ksize_w / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.type(), "deformable_col2im_coord_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + scalar_t *grad_offset_ = grad_offset.data(); + + deformable_col2im_coord_gpu_kernel<<>>( + num_kernels, data_col_, data_im_, data_offset_, channels, height, width, + ksize_h, ksize_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + parallel_imgs, 2 * ksize_h * ksize_w * deformable_group, deformable_group, + height_col, width_col, grad_offset_); + })); +} + +template +__device__ scalar_t dmcn_im2col_bilinear(const scalar_t *bottom_data, const int data_width, + const int height, const int width, scalar_t h, scalar_t w) +{ + int h_low = floor(h); + int w_low = floor(w); + int h_high = h_low + 1; + int w_high = w_low + 1; + + scalar_t lh = h - h_low; + scalar_t lw = w - w_low; + scalar_t hh = 1 - lh, hw = 1 - lw; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + v1 = bottom_data[h_low * data_width + w_low]; + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + v2 = bottom_data[h_low * data_width + w_high]; + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + v3 = bottom_data[h_high * data_width + w_low]; + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + v4 = bottom_data[h_high * data_width + w_high]; + + scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + +template +__device__ scalar_t dmcn_get_gradient_weight(scalar_t argmax_h, scalar_t argmax_w, + const int h, const int w, const int height, const int width) +{ + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + if (h == argmax_h_low && w == argmax_w_low) + weight = (h + 1 - argmax_h) * (w + 1 - argmax_w); + if (h == argmax_h_low && w == argmax_w_high) + weight = (h + 1 - argmax_h) * (argmax_w + 1 - w); + if (h == argmax_h_high && w == argmax_w_low) + weight = (argmax_h + 1 - h) * (w + 1 - argmax_w); + if (h == argmax_h_high && w == argmax_w_high) + weight = (argmax_h + 1 - h) * (argmax_w + 1 - w); + return weight; +} + +template +__device__ scalar_t dmcn_get_coordinate_weight(scalar_t argmax_h, scalar_t argmax_w, + const int height, const int width, const scalar_t *im_data, + const int data_width, const int bp_dir) +{ + if (argmax_h <= -1 || argmax_h >= height || argmax_w <= -1 || argmax_w >= width) + { + //empty + return 0; + } + + int argmax_h_low = floor(argmax_h); + int argmax_w_low = floor(argmax_w); + int argmax_h_high = argmax_h_low + 1; + int argmax_w_high = argmax_w_low + 1; + + scalar_t weight = 0; + + if (bp_dir == 0) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += -1 * (argmax_w - argmax_w_low) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += (argmax_w_low + 1 - argmax_w) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_w - argmax_w_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + else if (bp_dir == 1) + { + if (argmax_h_low >= 0 && argmax_w_low >= 0) + weight += -1 * (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_low]; + if (argmax_h_low >= 0 && argmax_w_high <= width - 1) + weight += (argmax_h_low + 1 - argmax_h) * im_data[argmax_h_low * data_width + argmax_w_high]; + if (argmax_h_high <= height - 1 && argmax_w_low >= 0) + weight += -1 * (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_low]; + if (argmax_h_high <= height - 1 && argmax_w_high <= width - 1) + weight += (argmax_h - argmax_h_low) * im_data[argmax_h_high * data_width + argmax_w_high]; + } + + return weight; +} + +template +__global__ void modulated_deformable_im2col_gpu_kernel(const int n, + const scalar_t *data_im, const scalar_t *data_offset, const scalar_t *data_mask, + const int height, const int width, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int num_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + // index index of output matrix + const int w_col = index % width_col; + const int h_col = (index / width_col) % height_col; + const int b_col = (index / width_col / height_col) % batch_size; + const int c_im = (index / width_col / height_col) / batch_size; + const int c_col = c_im * kernel_h * kernel_w; + + // compute deformable group index + const int deformable_group_index = c_im / channel_per_deformable_group; + + const int h_in = h_col * stride_h - pad_h; + const int w_in = w_col * stride_w - pad_w; + + scalar_t *data_col_ptr = data_col + ((c_col * batch_size + b_col) * height_col + h_col) * width_col + w_col; + //const float* data_im_ptr = data_im + ((b_col * num_channels + c_im) * height + h_in) * width + w_in; + const scalar_t *data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; + const scalar_t *data_offset_ptr = data_offset + (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + + const scalar_t *data_mask_ptr = data_mask + (b_col * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + + for (int i = 0; i < kernel_h; ++i) + { + for (int j = 0; j < kernel_w; ++j) + { + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_col) * width_col + w_col; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_col) * width_col + w_col; + const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_col) * width_col + w_col; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + scalar_t val = static_cast(0); + const scalar_t h_im = h_in + i * dilation_h + offset_h; + const scalar_t w_im = w_in + j * dilation_w + offset_w; + //if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { + if (h_im > -1 && w_im > -1 && h_im < height && w_im < width) + { + //const float map_h = i * dilation_h + offset_h; + //const float map_w = j * dilation_w + offset_w; + //const int cur_height = height - h_in; + //const int cur_width = width - w_in; + //val = dmcn_im2col_bilinear(data_im_ptr, width, cur_height, cur_width, map_h, map_w); + val = dmcn_im2col_bilinear(data_im_ptr, width, height, width, h_im, w_im); + } + *data_col_ptr = val * mask; + data_col_ptr += batch_size * height_col * width_col; + //data_col_ptr += height_col * width_col; + } + } + } +} + +template +__global__ void modulated_deformable_col2im_gpu_kernel(const int n, + const scalar_t *data_col, const scalar_t *data_offset, const scalar_t *data_mask, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_im) +{ + CUDA_KERNEL_LOOP(index, n) + { + const int j = (index / width_col / height_col / batch_size) % kernel_w; + const int i = (index / width_col / height_col / batch_size / kernel_w) % kernel_h; + const int c = index / width_col / height_col / batch_size / kernel_w / kernel_h; + // compute the start and end of the output + + const int deformable_group_index = c / channel_per_deformable_group; + + int w_out = index % width_col; + int h_out = (index / width_col) % height_col; + int b = (index / width_col / height_col) % batch_size; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; + const int data_offset_w_ptr = ((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out; + const int data_mask_hw_ptr = ((i * kernel_w + j) * height_col + h_out) * width_col + w_out; + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + const scalar_t cur_inv_h_data = h_in + i * dilation_h + offset_h; + const scalar_t cur_inv_w_data = w_in + j * dilation_w + offset_w; + + const scalar_t cur_top_grad = data_col[index] * mask; + const int cur_h = (int)cur_inv_h_data; + const int cur_w = (int)cur_inv_w_data; + for (int dy = -2; dy <= 2; dy++) + { + for (int dx = -2; dx <= 2; dx++) + { + if (cur_h + dy >= 0 && cur_h + dy < height && + cur_w + dx >= 0 && cur_w + dx < width && + abs(cur_inv_h_data - (cur_h + dy)) < 1 && + abs(cur_inv_w_data - (cur_w + dx)) < 1) + { + int cur_bottom_grad_pos = ((b * channels + c) * height + cur_h + dy) * width + cur_w + dx; + scalar_t weight = dmcn_get_gradient_weight(cur_inv_h_data, cur_inv_w_data, cur_h + dy, cur_w + dx, height, width); + atomicAdd(grad_im + cur_bottom_grad_pos, weight * cur_top_grad); + } + } + } + } +} + +template +__global__ void modulated_deformable_col2im_coord_gpu_kernel(const int n, + const scalar_t *data_col, const scalar_t *data_im, + const scalar_t *data_offset, const scalar_t *data_mask, + const int channels, const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int channel_per_deformable_group, + const int batch_size, const int offset_channels, const int deformable_group, + const int height_col, const int width_col, + scalar_t *grad_offset, scalar_t *grad_mask) +{ + CUDA_KERNEL_LOOP(index, n) + { + scalar_t val = 0, mval = 0; + int w = index % width_col; + int h = (index / width_col) % height_col; + int c = (index / width_col / height_col) % offset_channels; + int b = (index / width_col / height_col) / offset_channels; + // compute the start and end of the output + + const int deformable_group_index = c / (2 * kernel_h * kernel_w); + const int col_step = kernel_h * kernel_w; + int cnt = 0; + const scalar_t *data_col_ptr = data_col + deformable_group_index * channel_per_deformable_group * batch_size * width_col * height_col; + const scalar_t *data_im_ptr = data_im + (b * deformable_group + deformable_group_index) * channel_per_deformable_group / kernel_h / kernel_w * height * width; + const scalar_t *data_offset_ptr = data_offset + (b * deformable_group + deformable_group_index) * 2 * kernel_h * kernel_w * height_col * width_col; + const scalar_t *data_mask_ptr = data_mask + (b * deformable_group + deformable_group_index) * kernel_h * kernel_w * height_col * width_col; + + const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; + + for (int col_c = (offset_c / 2); col_c < channel_per_deformable_group; col_c += col_step) + { + const int col_pos = (((col_c * batch_size + b) * height_col) + h) * width_col + w; + const int bp_dir = offset_c % 2; + + int j = (col_pos / width_col / height_col / batch_size) % kernel_w; + int i = (col_pos / width_col / height_col / batch_size / kernel_w) % kernel_h; + int w_out = col_pos % width_col; + int h_out = (col_pos / width_col) % height_col; + int w_in = w_out * stride_w - pad_w; + int h_in = h_out * stride_h - pad_h; + const int data_offset_h_ptr = (((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out); + const int data_offset_w_ptr = (((2 * (i * kernel_w + j) + 1) * height_col + h_out) * width_col + w_out); + const int data_mask_hw_ptr = (((i * kernel_w + j) * height_col + h_out) * width_col + w_out); + const scalar_t offset_h = data_offset_ptr[data_offset_h_ptr]; + const scalar_t offset_w = data_offset_ptr[data_offset_w_ptr]; + const scalar_t mask = data_mask_ptr[data_mask_hw_ptr]; + scalar_t inv_h = h_in + i * dilation_h + offset_h; + scalar_t inv_w = w_in + j * dilation_w + offset_w; + if (inv_h <= -1 || inv_w <= -1 || inv_h >= height || inv_w >= width) + { + inv_h = inv_w = -2; + } + else + { + mval += data_col_ptr[col_pos] * dmcn_im2col_bilinear(data_im_ptr + cnt * height * width, width, height, width, inv_h, inv_w); + } + const scalar_t weight = dmcn_get_coordinate_weight( + inv_h, inv_w, + height, width, data_im_ptr + cnt * height * width, width, bp_dir); + val += weight * data_col_ptr[col_pos] * mask; + cnt += 1; + } + // KERNEL_ASSIGN(grad_offset[index], offset_req, val); + grad_offset[index] = val; + if (offset_c % 2 == 0) + // KERNEL_ASSIGN(grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w], mask_req, mval); + grad_mask[(((b * deformable_group + deformable_group_index) * kernel_h * kernel_w + offset_c / 2) * height_col + h) * width_col + w] = mval; + } +} + +void modulated_deformable_im2col_cuda( + const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kenerl_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, at::Tensor data_col) +{ + // num_axes should be smaller than block size + const int channel_per_deformable_group = channels / deformable_group; + const int num_kernels = channels * batch_size * height_col * width_col; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_im.type(), "modulated_deformable_im2col_gpu", ([&] { + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *data_col_ = data_col.data(); + + modulated_deformable_im2col_gpu_kernel<<>>( + num_kernels, data_im_, data_offset_, data_mask_, height_im, width_im, kernel_h, kenerl_w, + pad_h, pad_w, stride_h, stride_w, dilation_h, dilation_w, channel_per_deformable_group, + batch_size, channels, deformable_group, height_col, width_col, data_col_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_im2col_cuda: %s\n", cudaGetErrorString(err)); + } +} + +void modulated_deformable_col2im_cuda( + const at::Tensor data_col, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, at::Tensor grad_im) +{ + + const int channel_per_deformable_group = channels / deformable_group; + const int num_kernels = channels * kernel_h * kernel_w * batch_size * height_col * width_col; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.type(), "modulated_deformable_col2im_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *grad_im_ = grad_im.data(); + + modulated_deformable_col2im_gpu_kernel<<>>( + num_kernels, data_col_, data_offset_, data_mask_, channels, height_im, width_im, + kernel_h, kernel_w, pad_h, pad_h, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + batch_size, deformable_group, height_col, width_col, grad_im_); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_col2im_cuda: %s\n", cudaGetErrorString(err)); + } +} + +void modulated_deformable_col2im_coord_cuda( + const at::Tensor data_col, const at::Tensor data_im, const at::Tensor data_offset, const at::Tensor data_mask, + const int batch_size, const int channels, const int height_im, const int width_im, + const int height_col, const int width_col, const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, const int stride_h, const int stride_w, + const int dilation_h, const int dilation_w, + const int deformable_group, + at::Tensor grad_offset, at::Tensor grad_mask) +{ + const int num_kernels = batch_size * height_col * width_col * 2 * kernel_h * kernel_w * deformable_group; + const int channel_per_deformable_group = channels * kernel_h * kernel_w / deformable_group; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data_col.type(), "modulated_deformable_col2im_coord_gpu", ([&] { + const scalar_t *data_col_ = data_col.data(); + const scalar_t *data_im_ = data_im.data(); + const scalar_t *data_offset_ = data_offset.data(); + const scalar_t *data_mask_ = data_mask.data(); + scalar_t *grad_offset_ = grad_offset.data(); + scalar_t *grad_mask_ = grad_mask.data(); + + modulated_deformable_col2im_coord_gpu_kernel<<>>( + num_kernels, data_col_, data_im_, data_offset_, data_mask_, channels, height_im, width_im, + kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, + dilation_h, dilation_w, channel_per_deformable_group, + batch_size, 2 * kernel_h * kernel_w * deformable_group, deformable_group, height_col, width_col, + grad_offset_, grad_mask_); + })); + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in modulated_deformable_col2im_coord_cuda: %s\n", cudaGetErrorString(err)); + } +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp new file mode 100644 index 000000000..e19cf42ae --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda.cpp @@ -0,0 +1,87 @@ +// modify from +// https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/modulated_dcn_cuda.c + +// based on +// author: Charles Shang +// https://github.com/torch/cunn/blob/master/lib/THCUNN/generic/SpatialConvolutionMM.cu + +#include + +#include +#include + +void DeformablePSROIPoolForward( + const at::Tensor data, const at::Tensor bbox, const at::Tensor trans, + at::Tensor out, at::Tensor top_count, const int batch, const int channels, + const int height, const int width, const int num_bbox, + const int channels_trans, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std); + +void DeformablePSROIPoolBackwardAcc( + const at::Tensor out_grad, const at::Tensor data, const at::Tensor bbox, + const at::Tensor trans, const at::Tensor top_count, at::Tensor in_grad, + at::Tensor trans_grad, const int batch, const int channels, + const int height, const int width, const int num_bbox, + const int channels_trans, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std); + +void deform_psroi_pooling_cuda_forward( + at::Tensor input, at::Tensor bbox, at::Tensor trans, at::Tensor out, + at::Tensor top_count, const int no_trans, const float spatial_scale, + const int output_dim, const int group_size, const int pooled_size, + const int part_size, const int sample_per_part, const float trans_std) { + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + const int channels_trans = no_trans ? 2 : trans.size(1); + + const int num_bbox = bbox.size(0); + if (num_bbox != out.size(0)) + AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", + out.size(0), num_bbox); + + DeformablePSROIPoolForward( + input, bbox, trans, out, top_count, batch, channels, height, width, + num_bbox, channels_trans, no_trans, spatial_scale, output_dim, group_size, + pooled_size, part_size, sample_per_part, trans_std); +} + +void deform_psroi_pooling_cuda_backward( + at::Tensor out_grad, at::Tensor input, at::Tensor bbox, at::Tensor trans, + at::Tensor top_count, at::Tensor input_grad, at::Tensor trans_grad, + const int no_trans, const float spatial_scale, const int output_dim, + const int group_size, const int pooled_size, const int part_size, + const int sample_per_part, const float trans_std) { + TORCH_CHECK(out_grad.is_contiguous(), "out_grad tensor has to be contiguous"); + TORCH_CHECK(input.is_contiguous(), "input tensor has to be contiguous"); + + const int batch = input.size(0); + const int channels = input.size(1); + const int height = input.size(2); + const int width = input.size(3); + const int channels_trans = no_trans ? 2 : trans.size(1); + + const int num_bbox = bbox.size(0); + if (num_bbox != out_grad.size(0)) + AT_ERROR("Output shape and bbox number wont match: (%d vs %d).", + out_grad.size(0), num_bbox); + + DeformablePSROIPoolBackwardAcc( + out_grad, input, bbox, trans, top_count, input_grad, trans_grad, batch, + channels, height, width, num_bbox, channels_trans, no_trans, + spatial_scale, output_dim, group_size, pooled_size, part_size, + sample_per_part, trans_std); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("deform_psroi_pooling_cuda_forward", &deform_psroi_pooling_cuda_forward, + "deform psroi pooling forward(CUDA)"); + m.def("deform_psroi_pooling_cuda_backward", + &deform_psroi_pooling_cuda_backward, + "deform psroi pooling backward(CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu new file mode 100644 index 000000000..e49446005 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/dcn/src/deform_pool_cuda_kernel.cu @@ -0,0 +1,364 @@ +/*! + * Copyright (c) 2017 Microsoft + * Licensed under The MIT License [see LICENSE for details] + * \file deformable_psroi_pooling.cu + * \brief + * \author Yi Li, Guodong Zhang, Jifeng Dai +*/ +/***************** Adapted by Charles Shang *********************/ +// modify from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/blob/mmdetection/mmdet/ops/dcn/src/cuda/deform_psroi_pooling_cuda.cu + +#include +#include +#include +#include +#include + +using namespace at; + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ + i < (n); \ + i += blockDim.x * gridDim.x) + +const int CUDA_NUM_THREADS = 1024; +inline int GET_BLOCKS(const int N) +{ + return (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS; +} + +template +__device__ scalar_t bilinear_interp( + const scalar_t *data, + const scalar_t x, + const scalar_t y, + const int width, + const int height) +{ + int x1 = floor(x); + int x2 = ceil(x); + int y1 = floor(y); + int y2 = ceil(y); + scalar_t dist_x = (scalar_t)(x - x1); + scalar_t dist_y = (scalar_t)(y - y1); + scalar_t value11 = data[y1 * width + x1]; + scalar_t value12 = data[y2 * width + x1]; + scalar_t value21 = data[y1 * width + x2]; + scalar_t value22 = data[y2 * width + x2]; + scalar_t value = (1 - dist_x) * (1 - dist_y) * value11 + (1 - dist_x) * dist_y * value12 + dist_x * (1 - dist_y) * value21 + dist_x * dist_y * value22; + return value; +} + +template +__global__ void DeformablePSROIPoolForwardKernel( + const int count, + const scalar_t *bottom_data, + const scalar_t spatial_scale, + const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + const scalar_t *bottom_rois, const scalar_t *bottom_trans, + const int no_trans, + const scalar_t trans_std, + const int sample_per_part, + const int output_dim, + const int group_size, + const int part_size, + const int num_classes, + const int channels_each_class, + scalar_t *top_data, + scalar_t *top_count) +{ + CUDA_KERNEL_LOOP(index, count) + { + // The output is in order (n, ctop, ph, pw) + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int ctop = (index / pooled_width / pooled_height) % output_dim; + int n = index / pooled_width / pooled_height / output_dim; + + // [start, end) interval for spatial sampling + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; + scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; + scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; + scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; + + // Force too small ROIs to be 1x1 + scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 + scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); + + // Compute w and h at bottom + scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); + scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); + + scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); + scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); + + int part_h = floor((scalar_t)(ph) / pooled_height * part_size); + int part_w = floor((scalar_t)(pw) / pooled_width * part_size); + int class_id = ctop / channels_each_class; + scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + + scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; + wstart += trans_x * roi_width; + scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; + hstart += trans_y * roi_height; + + scalar_t sum = 0; + int count = 0; + int gw = floor((scalar_t)(pw)*group_size / pooled_width); + int gh = floor((scalar_t)(ph)*group_size / pooled_height); + gw = min(max(gw, 0), group_size - 1); + gh = min(max(gh, 0), group_size - 1); + + const scalar_t *offset_bottom_data = bottom_data + (roi_batch_ind * channels) * height * width; + for (int ih = 0; ih < sample_per_part; ih++) + { + for (int iw = 0; iw < sample_per_part; iw++) + { + scalar_t w = wstart + iw * sub_bin_size_w; + scalar_t h = hstart + ih * sub_bin_size_h; + // bilinear interpolation + if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) + { + continue; + } + w = min(max(w, 0.), width - 1.); + h = min(max(h, 0.), height - 1.); + int c = (ctop * group_size + gh) * group_size + gw; + scalar_t val = bilinear_interp(offset_bottom_data + c * height * width, w, h, width, height); + sum += val; + count++; + } + } + top_data[index] = count == 0 ? (scalar_t)(0) : sum / count; + top_count[index] = count; + } +} + +template +__global__ void DeformablePSROIPoolBackwardAccKernel( + const int count, + const scalar_t *top_diff, + const scalar_t *top_count, + const int num_rois, + const scalar_t spatial_scale, + const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + const int output_dim, + scalar_t *bottom_data_diff, scalar_t *bottom_trans_diff, + const scalar_t *bottom_data, + const scalar_t *bottom_rois, + const scalar_t *bottom_trans, + const int no_trans, + const scalar_t trans_std, + const int sample_per_part, + const int group_size, + const int part_size, + const int num_classes, + const int channels_each_class) +{ + CUDA_KERNEL_LOOP(index, count) + { + // The output is in order (n, ctop, ph, pw) + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int ctop = (index / pooled_width / pooled_height) % output_dim; + int n = index / pooled_width / pooled_height / output_dim; + + // [start, end) interval for spatial sampling + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = (scalar_t)(round(offset_bottom_rois[1])) * spatial_scale - 0.5; + scalar_t roi_start_h = (scalar_t)(round(offset_bottom_rois[2])) * spatial_scale - 0.5; + scalar_t roi_end_w = (scalar_t)(round(offset_bottom_rois[3]) + 1.) * spatial_scale - 0.5; + scalar_t roi_end_h = (scalar_t)(round(offset_bottom_rois[4]) + 1.) * spatial_scale - 0.5; + + // Force too small ROIs to be 1x1 + scalar_t roi_width = max(roi_end_w - roi_start_w, 0.1); //avoid 0 + scalar_t roi_height = max(roi_end_h - roi_start_h, 0.1); + + // Compute w and h at bottom + scalar_t bin_size_h = roi_height / (scalar_t)(pooled_height); + scalar_t bin_size_w = roi_width / (scalar_t)(pooled_width); + + scalar_t sub_bin_size_h = bin_size_h / (scalar_t)(sample_per_part); + scalar_t sub_bin_size_w = bin_size_w / (scalar_t)(sample_per_part); + + int part_h = floor((scalar_t)(ph) / pooled_height * part_size); + int part_w = floor((scalar_t)(pw) / pooled_width * part_size); + int class_id = ctop / channels_each_class; + scalar_t trans_x = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + scalar_t trans_y = no_trans ? (scalar_t)(0) : bottom_trans[(((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w] * (scalar_t)trans_std; + + scalar_t wstart = (scalar_t)(pw)*bin_size_w + roi_start_w; + wstart += trans_x * roi_width; + scalar_t hstart = (scalar_t)(ph)*bin_size_h + roi_start_h; + hstart += trans_y * roi_height; + + if (top_count[index] <= 0) + { + continue; + } + scalar_t diff_val = top_diff[index] / top_count[index]; + const scalar_t *offset_bottom_data = bottom_data + roi_batch_ind * channels * height * width; + scalar_t *offset_bottom_data_diff = bottom_data_diff + roi_batch_ind * channels * height * width; + int gw = floor((scalar_t)(pw)*group_size / pooled_width); + int gh = floor((scalar_t)(ph)*group_size / pooled_height); + gw = min(max(gw, 0), group_size - 1); + gh = min(max(gh, 0), group_size - 1); + + for (int ih = 0; ih < sample_per_part; ih++) + { + for (int iw = 0; iw < sample_per_part; iw++) + { + scalar_t w = wstart + iw * sub_bin_size_w; + scalar_t h = hstart + ih * sub_bin_size_h; + // bilinear interpolation + if (w < -0.5 || w > width - 0.5 || h < -0.5 || h > height - 0.5) + { + continue; + } + w = min(max(w, 0.), width - 1.); + h = min(max(h, 0.), height - 1.); + int c = (ctop * group_size + gh) * group_size + gw; + // backward on feature + int x0 = floor(w); + int x1 = ceil(w); + int y0 = floor(h); + int y1 = ceil(h); + scalar_t dist_x = w - x0, dist_y = h - y0; + scalar_t q00 = (1 - dist_x) * (1 - dist_y); + scalar_t q01 = (1 - dist_x) * dist_y; + scalar_t q10 = dist_x * (1 - dist_y); + scalar_t q11 = dist_x * dist_y; + int bottom_index_base = c * height * width; + atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x0, q00 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x0, q01 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y0 * width + x1, q10 * diff_val); + atomicAdd(offset_bottom_data_diff + bottom_index_base + y1 * width + x1, q11 * diff_val); + + if (no_trans) + { + continue; + } + scalar_t U00 = offset_bottom_data[bottom_index_base + y0 * width + x0]; + scalar_t U01 = offset_bottom_data[bottom_index_base + y1 * width + x0]; + scalar_t U10 = offset_bottom_data[bottom_index_base + y0 * width + x1]; + scalar_t U11 = offset_bottom_data[bottom_index_base + y1 * width + x1]; + scalar_t diff_x = (U11 * dist_y + U10 * (1 - dist_y) - U01 * dist_y - U00 * (1 - dist_y)) * trans_std * diff_val; + diff_x *= roi_width; + scalar_t diff_y = (U11 * dist_x + U01 * (1 - dist_x) - U10 * dist_x - U00 * (1 - dist_x)) * trans_std * diff_val; + diff_y *= roi_height; + + atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2) * part_size + part_h) * part_size + part_w, diff_x); + atomicAdd(bottom_trans_diff + (((n * num_classes + class_id) * 2 + 1) * part_size + part_h) * part_size + part_w, diff_y); + } + } + } +} + +void DeformablePSROIPoolForward(const at::Tensor data, + const at::Tensor bbox, + const at::Tensor trans, + at::Tensor out, + at::Tensor top_count, + const int batch, + const int channels, + const int height, + const int width, + const int num_bbox, + const int channels_trans, + const int no_trans, + const float spatial_scale, + const int output_dim, + const int group_size, + const int pooled_size, + const int part_size, + const int sample_per_part, + const float trans_std) +{ + const int pooled_height = pooled_size; + const int pooled_width = pooled_size; + const int count = num_bbox * output_dim * pooled_height * pooled_width; + const int num_classes = no_trans ? 1 : channels_trans / 2; + const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + data.type(), "deformable_psroi_pool_forward", ([&] { + const scalar_t *bottom_data = data.data(); + const scalar_t *bottom_rois = bbox.data(); + const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); + scalar_t *top_data = out.data(); + scalar_t *top_count_data = top_count.data(); + + DeformablePSROIPoolForwardKernel<<>>( + count, bottom_data, (scalar_t)spatial_scale, channels, height, width, pooled_height, pooled_width, + bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, output_dim, + group_size, part_size, num_classes, channels_each_class, top_data, top_count_data); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); + } +} + +void DeformablePSROIPoolBackwardAcc(const at::Tensor out_grad, + const at::Tensor data, + const at::Tensor bbox, + const at::Tensor trans, + const at::Tensor top_count, + at::Tensor in_grad, + at::Tensor trans_grad, + const int batch, + const int channels, + const int height, + const int width, + const int num_bbox, + const int channels_trans, + const int no_trans, + const float spatial_scale, + const int output_dim, + const int group_size, + const int pooled_size, + const int part_size, + const int sample_per_part, + const float trans_std) +{ + // LOG(INFO) << "DeformablePSROIPoolBackward"; + const int num_rois = num_bbox; + const int pooled_height = pooled_size; + const int pooled_width = pooled_size; + const int count = num_bbox * output_dim * pooled_height * pooled_width; + const int num_classes = no_trans ? 1 : channels_trans / 2; + const int channels_each_class = no_trans ? output_dim : output_dim / num_classes; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + out_grad.type(), "deformable_psroi_pool_backward_acc", ([&] { + const scalar_t *top_diff = out_grad.data(); + const scalar_t *bottom_data = data.data(); + const scalar_t *bottom_rois = bbox.data(); + const scalar_t *bottom_trans = no_trans ? NULL : trans.data(); + scalar_t *bottom_data_diff = in_grad.data(); + scalar_t *bottom_trans_diff = no_trans ? NULL : trans_grad.data(); + const scalar_t *top_count_data = top_count.data(); + + DeformablePSROIPoolBackwardAccKernel<<>>( + count, top_diff, top_count_data, num_rois, (scalar_t)spatial_scale, channels, height, width, + pooled_height, pooled_width, output_dim, bottom_data_diff, bottom_trans_diff, + bottom_data, bottom_rois, bottom_trans, no_trans, (scalar_t)trans_std, sample_per_part, + group_size, part_size, num_classes, channels_each_class); + })); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in DeformablePSROIPoolForward: %s\n", cudaGetErrorString(err)); + } +} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/__init__.py new file mode 100644 index 000000000..05dd6251e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/__init__.py @@ -0,0 +1,5 @@ +from .context_block import ContextBlock + +__all__ = [ + 'ContextBlock', +] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/context_block.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/context_block.py new file mode 100644 index 000000000..be9092c48 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/gcb/context_block.py @@ -0,0 +1,104 @@ +import torch +from mmcv.cnn import constant_init, kaiming_init +from torch import nn + + +def last_zero_init(m): + if isinstance(m, nn.Sequential): + constant_init(m[-1], val=0) + else: + constant_init(m, val=0) + + +class ContextBlock(nn.Module): + + def __init__(self, + inplanes, + ratio, + pooling_type='att', + fusion_types=('channel_add', )): + super(ContextBlock, self).__init__() + assert pooling_type in ['avg', 'att'] + assert isinstance(fusion_types, (list, tuple)) + valid_fusion_types = ['channel_add', 'channel_mul'] + assert all([f in valid_fusion_types for f in fusion_types]) + assert len(fusion_types) > 0, 'at least one fusion should be used' + self.inplanes = inplanes + self.ratio = ratio + self.planes = int(inplanes * ratio) + self.pooling_type = pooling_type + self.fusion_types = fusion_types + if pooling_type == 'att': + self.conv_mask = nn.Conv2d(inplanes, 1, kernel_size=1) + self.softmax = nn.Softmax(dim=2) + else: + self.avg_pool = nn.AdaptiveAvgPool2d(1) + if 'channel_add' in fusion_types: + self.channel_add_conv = nn.Sequential( + nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.LayerNorm([self.planes, 1, 1]), + nn.ReLU(inplace=True), # yapf: disable + nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + else: + self.channel_add_conv = None + if 'channel_mul' in fusion_types: + self.channel_mul_conv = nn.Sequential( + nn.Conv2d(self.inplanes, self.planes, kernel_size=1), + nn.LayerNorm([self.planes, 1, 1]), + nn.ReLU(inplace=True), # yapf: disable + nn.Conv2d(self.planes, self.inplanes, kernel_size=1)) + else: + self.channel_mul_conv = None + self.reset_parameters() + + def reset_parameters(self): + if self.pooling_type == 'att': + kaiming_init(self.conv_mask, mode='fan_in') + self.conv_mask.inited = True + + if self.channel_add_conv is not None: + last_zero_init(self.channel_add_conv) + if self.channel_mul_conv is not None: + last_zero_init(self.channel_mul_conv) + + def spatial_pool(self, x): + batch, channel, height, width = x.size() + if self.pooling_type == 'att': + input_x = x + # [N, C, H * W] + input_x = input_x.view(batch, channel, height * width) + # [N, 1, C, H * W] + input_x = input_x.unsqueeze(1) + # [N, 1, H, W] + context_mask = self.conv_mask(x) + # [N, 1, H * W] + context_mask = context_mask.view(batch, 1, height * width) + # [N, 1, H * W] + context_mask = self.softmax(context_mask) + # [N, 1, H * W, 1] + context_mask = context_mask.unsqueeze(-1) + # [N, 1, C, 1] + context = torch.matmul(input_x, context_mask) + # [N, C, 1, 1] + context = context.view(batch, channel, 1, 1) + else: + # [N, C, 1, 1] + context = self.avg_pool(x) + + return context + + def forward(self, x): + # [N, C, 1, 1] + context = self.spatial_pool(x) + + out = x + if self.channel_mul_conv is not None: + # [N, C, 1, 1] + channel_mul_term = torch.sigmoid(self.channel_mul_conv(context)) + out = out * channel_mul_term + if self.channel_add_conv is not None: + # [N, C, 1, 1] + channel_add_term = self.channel_add_conv(context) + out = out + channel_add_term + + return out diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py new file mode 100644 index 000000000..feab95316 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/__init__.py @@ -0,0 +1,4 @@ +from .functions.masked_conv import masked_conv2d +from .modules.masked_conv import MaskedConv2d + +__all__ = ['masked_conv2d', 'MaskedConv2d'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/masked_conv.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/masked_conv.py new file mode 100644 index 000000000..eed32b737 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/functions/masked_conv.py @@ -0,0 +1,56 @@ +import math +import torch +from torch.autograd import Function +from torch.nn.modules.utils import _pair +from .. import masked_conv2d_cuda + + +class MaskedConv2dFunction(Function): + + @staticmethod + def forward(ctx, features, mask, weight, bias, padding=0, stride=1): + assert mask.dim() == 3 and mask.size(0) == 1 + assert features.dim() == 4 and features.size(0) == 1 + assert features.size()[2:] == mask.size()[1:] + pad_h, pad_w = _pair(padding) + stride_h, stride_w = _pair(stride) + if stride_h != 1 or stride_w != 1: + raise ValueError( + 'Stride could not only be 1 in masked_conv2d currently.') + if not features.is_cuda: + raise NotImplementedError + + out_channel, in_channel, kernel_h, kernel_w = weight.size() + + batch_size = features.size(0) + out_h = int( + math.floor((features.size(2) + 2 * pad_h - + (kernel_h - 1) - 1) / stride_h + 1)) + out_w = int( + math.floor((features.size(3) + 2 * pad_w - + (kernel_h - 1) - 1) / stride_w + 1)) + mask_inds = torch.nonzero(mask[0] > 0) + output = features.new_zeros(batch_size, out_channel, out_h, out_w) + if mask_inds.numel() > 0: + mask_h_idx = mask_inds[:, 0].contiguous() + mask_w_idx = mask_inds[:, 1].contiguous() + data_col = features.new_zeros(in_channel * kernel_h * kernel_w, + mask_inds.size(0)) + masked_conv2d_cuda.masked_im2col_forward(features, mask_h_idx, + mask_w_idx, kernel_h, + kernel_w, pad_h, pad_w, + data_col) + + masked_output = torch.addmm(1, bias[:, None], 1, + weight.view(out_channel, -1), data_col) + masked_conv2d_cuda.masked_col2im_forward(masked_output, mask_h_idx, + mask_w_idx, out_h, out_w, + out_channel, output) + return output + + @staticmethod + def backward(ctx, grad_output): + return (None, ) * 5 + + +masked_conv2d = MaskedConv2dFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/masked_conv.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/masked_conv.py new file mode 100644 index 000000000..1b8c434a3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/modules/masked_conv.py @@ -0,0 +1,30 @@ +import torch.nn as nn +from ..functions.masked_conv import masked_conv2d + + +class MaskedConv2d(nn.Conv2d): + """A MaskedConv2d which inherits the official Conv2d. + + The masked forward doesn't implement the backward function and only + supports the stride parameter to be 1 currently. + """ + + def __init__(self, + in_channels, + out_channels, + kernel_size, + stride=1, + padding=0, + dilation=1, + groups=1, + bias=True): + super(MaskedConv2d, + self).__init__(in_channels, out_channels, kernel_size, stride, + padding, dilation, groups, bias) + + def forward(self, input, mask=None): + if mask is None: # fallback to the normal Conv2d + return super(MaskedConv2d, self).forward(input) + else: + return masked_conv2d(input, mask, self.weight, self.bias, + self.padding) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py new file mode 100644 index 000000000..fdff5f20f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +setup( + name='masked_conv2d_cuda', + ext_modules=[ + CUDAExtension('masked_conv2d_cuda', [ + 'src/masked_conv2d_cuda.cpp', + 'src/masked_conv2d_kernel.cu', + ]), + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp new file mode 100644 index 000000000..5c26ccccf --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_cuda.cpp @@ -0,0 +1,74 @@ +#include + +#include +#include + +int MaskedIm2colForwardLaucher(const at::Tensor im, const int height, + const int width, const int channels, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor col); + +int MaskedCol2imForwardLaucher(const at::Tensor col, const int height, + const int width, const int channels, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor im); + +#define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int masked_im2col_forward_cuda(const at::Tensor im, const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int kernel_h, + const int kernel_w, const int pad_h, + const int pad_w, at::Tensor col) { + CHECK_INPUT(im); + CHECK_INPUT(mask_h_idx); + CHECK_INPUT(mask_w_idx); + CHECK_INPUT(col); + // im: (n, ic, h, w), kernel size (kh, kw) + // kernel: (oc, ic * kh * kw), col: (kh * kw * ic, ow * oh) + + int channels = im.size(1); + int height = im.size(2); + int width = im.size(3); + int mask_cnt = mask_h_idx.size(0); + + MaskedIm2colForwardLaucher(im, height, width, channels, kernel_h, kernel_w, + pad_h, pad_w, mask_h_idx, mask_w_idx, mask_cnt, + col); + + return 1; +} + +int masked_col2im_forward_cuda(const at::Tensor col, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, int height, + int width, int channels, at::Tensor im) { + CHECK_INPUT(col); + CHECK_INPUT(mask_h_idx); + CHECK_INPUT(mask_w_idx); + CHECK_INPUT(im); + // im: (n, ic, h, w), kernel size (kh, kw) + // kernel: (oc, ic * kh * kh), col: (kh * kw * ic, ow * oh) + + int mask_cnt = mask_h_idx.size(0); + + MaskedCol2imForwardLaucher(col, height, width, channels, mask_h_idx, + mask_w_idx, mask_cnt, im); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("masked_im2col_forward", &masked_im2col_forward_cuda, + "masked_im2col forward (CUDA)"); + m.def("masked_col2im_forward", &masked_col2im_forward_cuda, + "masked_col2im forward (CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu new file mode 100644 index 000000000..394af13e3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/masked_conv/src/masked_conv2d_kernel.cu @@ -0,0 +1,113 @@ +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return min(optimal_block_num, max_block_num); +} + +template +__global__ void MaskedIm2colForward(const int n, const scalar_t *data_im, + const int height, const int width, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const long *mask_h_idx, + const long *mask_w_idx, const int mask_cnt, + scalar_t *data_col) { + // mask_cnt * channels + CUDA_1D_KERNEL_LOOP(index, n) { + const int m_index = index % mask_cnt; + const int h_col = mask_h_idx[m_index]; + const int w_col = mask_w_idx[m_index]; + const int c_im = index / mask_cnt; + const int c_col = c_im * kernel_h * kernel_w; + const int h_offset = h_col - pad_h; + const int w_offset = w_col - pad_w; + scalar_t *data_col_ptr = data_col + c_col * mask_cnt + m_index; + for (int i = 0; i < kernel_h; ++i) { + int h_im = h_offset + i; + for (int j = 0; j < kernel_w; ++j) { + int w_im = w_offset + j; + if (h_im >= 0 && w_im >= 0 && h_im < height && w_im < width) { + *data_col_ptr = + (scalar_t)data_im[(c_im * height + h_im) * width + w_im]; + } else { + *data_col_ptr = 0.0; + } + data_col_ptr += mask_cnt; + } + } + } +} + +int MaskedIm2colForwardLaucher(const at::Tensor bottom_data, const int height, + const int width, const int channels, + const int kernel_h, const int kernel_w, + const int pad_h, const int pad_w, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor top_data) { + const int output_size = mask_cnt * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + bottom_data.type(), "MaskedIm2colLaucherForward", ([&] { + const scalar_t *bottom_data_ = bottom_data.data(); + const long *mask_h_idx_ = mask_h_idx.data(); + const long *mask_w_idx_ = mask_w_idx.data(); + scalar_t *top_data_ = top_data.data(); + MaskedIm2colForward + <<>>( + output_size, bottom_data_, height, width, kernel_h, kernel_w, + pad_h, pad_w, mask_h_idx_, mask_w_idx_, mask_cnt, top_data_); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__global__ void MaskedCol2imForward(const int n, const scalar_t *data_col, + const int height, const int width, + const int channels, const long *mask_h_idx, + const long *mask_w_idx, const int mask_cnt, + scalar_t *data_im) { + CUDA_1D_KERNEL_LOOP(index, n) { + const int m_index = index % mask_cnt; + const int h_im = mask_h_idx[m_index]; + const int w_im = mask_w_idx[m_index]; + const int c_im = index / mask_cnt; + // int kernel_extent_w = (kernel_w - 1) + 1; + // int kernel_extent_h = (kernel_h - 1) + 1; + // compute the start and end of the output + data_im[(c_im * height + h_im) * width + w_im] = data_col[index]; + } +} + +int MaskedCol2imForwardLaucher(const at::Tensor bottom_data, const int height, + const int width, const int channels, + const at::Tensor mask_h_idx, + const at::Tensor mask_w_idx, const int mask_cnt, + at::Tensor top_data) { + const int output_size = mask_cnt * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + bottom_data.type(), "MaskedCol2imLaucherForward", ([&] { + const scalar_t *bottom_data_ = bottom_data.data(); + const long *mask_h_idx_ = mask_h_idx.data(); + const long *mask_w_idx_ = mask_w_idx.data(); + scalar_t *top_data_ = top_data.data(); + + MaskedCol2imForward + <<>>( + output_size, bottom_data_, height, width, channels, mask_h_idx_, + mask_w_idx_, mask_cnt, top_data_); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/__init__.py new file mode 100644 index 000000000..c4407041a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/__init__.py @@ -0,0 +1,3 @@ +from .nms_wrapper import nms, soft_nms + +__all__ = ['nms', 'soft_nms'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/nms_wrapper.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/nms_wrapper.py new file mode 100644 index 000000000..8ce5bc443 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/nms_wrapper.py @@ -0,0 +1,78 @@ +import numpy as np +import torch + +from . import nms_cuda, nms_cpu +from .soft_nms_cpu import soft_nms_cpu + + +def nms(dets, iou_thr, device_id=None): + """Dispatch to either CPU or GPU NMS implementations. + + The input can be either a torch tensor or numpy array. GPU NMS will be used + if the input is a gpu tensor or device_id is specified, otherwise CPU NMS + will be used. The returned type will always be the same as inputs. + + Arguments: + dets (torch.Tensor or np.ndarray): bboxes with scores. + iou_thr (float): IoU threshold for NMS. + device_id (int, optional): when `dets` is a numpy array, if `device_id` + is None, then cpu nms is used, otherwise gpu_nms will be used. + + Returns: + tuple: kept bboxes and indice, which is always the same data type as + the input. + """ + # convert dets (tensor or numpy array) to tensor + if isinstance(dets, torch.Tensor): + is_numpy = False + dets_th = dets + elif isinstance(dets, np.ndarray): + is_numpy = True + device = 'cpu' if device_id is None else 'cuda:{}'.format(device_id) + dets_th = torch.from_numpy(dets).to(device) + else: + raise TypeError( + 'dets must be either a Tensor or numpy array, but got {}'.format( + type(dets))) + + # execute cpu or cuda nms + if dets_th.shape[0] == 0: + inds = dets_th.new_zeros(0, dtype=torch.long) + else: + if dets_th.is_cuda: + inds = nms_cuda.nms(dets_th, iou_thr) + else: + inds = nms_cpu.nms(dets_th, iou_thr) + + if is_numpy: + inds = inds.cpu().numpy() + return dets[inds, :], inds + + +def soft_nms(dets, iou_thr, method='linear', sigma=0.5, min_score=1e-3): + if isinstance(dets, torch.Tensor): + is_tensor = True + dets_np = dets.detach().cpu().numpy() + elif isinstance(dets, np.ndarray): + is_tensor = False + dets_np = dets + else: + raise TypeError( + 'dets must be either a Tensor or numpy array, but got {}'.format( + type(dets))) + + method_codes = {'linear': 1, 'gaussian': 2} + if method not in method_codes: + raise ValueError('Invalid method for SoftNMS: {}'.format(method)) + new_dets, inds = soft_nms_cpu( + dets_np, + iou_thr, + method=method_codes[method], + sigma=sigma, + min_score=min_score) + + if is_tensor: + return dets.new_tensor(new_dets), dets.new_tensor( + inds, dtype=torch.long) + else: + return new_dets.astype(np.float32), inds.astype(np.int64) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/setup.py new file mode 100644 index 000000000..28f3b4e9b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/setup.py @@ -0,0 +1,84 @@ +import os.path as osp +from setuptools import setup, Extension + +import numpy as np +from Cython.Build import cythonize +from Cython.Distutils import build_ext +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +ext_args = dict( + include_dirs=[np.get_include()], + language='c++', + extra_compile_args={ + 'cc': ['-Wno-unused-function', '-Wno-write-strings'], + 'nvcc': ['-c', '--compiler-options', '-fPIC'], + }, +) + +extensions = [ + Extension('soft_nms_cpu', ['src/soft_nms_cpu.pyx'], **ext_args), +] + + +def customize_compiler_for_nvcc(self): + """inject deep into distutils to customize how the dispatch + to cc/nvcc works. + If you subclass UnixCCompiler, it's not trivial to get your subclass + injected in, and still have the right customizations (i.e. + distutils.sysconfig.customize_compiler) run on it. So instead of going + the OO route, I have this. Note, it's kindof like a wierd functional + subclassing going on.""" + + # tell the compiler it can processes .cu + self.src_extensions.append('.cu') + + # save references to the default compiler_so and _comple methods + default_compiler_so = self.compiler_so + super = self._compile + + # now redefine the _compile method. This gets executed for each + # object but distutils doesn't have the ability to change compilers + # based on source extension: we add it. + def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): + if osp.splitext(src)[1] == '.cu': + # use the cuda for .cu files + self.set_executable('compiler_so', 'nvcc') + # use only a subset of the extra_postargs, which are 1-1 translated + # from the extra_compile_args in the Extension class + postargs = extra_postargs['nvcc'] + else: + postargs = extra_postargs['cc'] + + super(obj, src, ext, cc_args, postargs, pp_opts) + # reset the default compiler_so, which we might have changed for cuda + self.compiler_so = default_compiler_so + + # inject our redefined _compile method into the class + self._compile = _compile + + +class custom_build_ext(build_ext): + + def build_extensions(self): + customize_compiler_for_nvcc(self.compiler) + build_ext.build_extensions(self) + + +setup( + name='soft_nms', + cmdclass={'build_ext': custom_build_ext}, + ext_modules=cythonize(extensions), +) + +setup( + name='nms_cuda', + ext_modules=[ + CUDAExtension('nms_cuda', [ + 'src/nms_cuda.cpp', + 'src/nms_kernel.cu', + ]), + CUDAExtension('nms_cpu', [ + 'src/nms_cpu.cpp', + ]), + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cpu.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cpu.cpp new file mode 100644 index 000000000..65546ef49 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cpu.cpp @@ -0,0 +1,71 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include + +template +at::Tensor nms_cpu_kernel(const at::Tensor& dets, const float threshold) { + AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor"); + + if (dets.numel() == 0) { + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + } + + auto x1_t = dets.select(1, 0).contiguous(); + auto y1_t = dets.select(1, 1).contiguous(); + auto x2_t = dets.select(1, 2).contiguous(); + auto y2_t = dets.select(1, 3).contiguous(); + auto scores = dets.select(1, 4).contiguous(); + + at::Tensor areas_t = (x2_t - x1_t + 1) * (y2_t - y1_t + 1); + + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + + auto ndets = dets.size(0); + at::Tensor suppressed_t = + at::zeros({ndets}, dets.options().dtype(at::kByte).device(at::kCPU)); + + auto suppressed = suppressed_t.data(); + auto order = order_t.data(); + auto x1 = x1_t.data(); + auto y1 = y1_t.data(); + auto x2 = x2_t.data(); + auto y2 = y2_t.data(); + auto areas = areas_t.data(); + + for (int64_t _i = 0; _i < ndets; _i++) { + auto i = order[_i]; + if (suppressed[i] == 1) continue; + auto ix1 = x1[i]; + auto iy1 = y1[i]; + auto ix2 = x2[i]; + auto iy2 = y2[i]; + auto iarea = areas[i]; + + for (int64_t _j = _i + 1; _j < ndets; _j++) { + auto j = order[_j]; + if (suppressed[j] == 1) continue; + auto xx1 = std::max(ix1, x1[j]); + auto yy1 = std::max(iy1, y1[j]); + auto xx2 = std::min(ix2, x2[j]); + auto yy2 = std::min(iy2, y2[j]); + + auto w = std::max(static_cast(0), xx2 - xx1 + 1); + auto h = std::max(static_cast(0), yy2 - yy1 + 1); + auto inter = w * h; + auto ovr = inter / (iarea + areas[j] - inter); + if (ovr >= threshold) suppressed[j] = 1; + } + } + return at::nonzero(suppressed_t == 0).squeeze(1); +} + +at::Tensor nms(const at::Tensor& dets, const float threshold) { + at::Tensor result; + AT_DISPATCH_FLOATING_TYPES(dets.type(), "nms", [&] { + result = nms_cpu_kernel(dets, threshold); + }); + return result; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("nms", &nms, "non-maximum suppression"); +} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp new file mode 100644 index 000000000..f53359de2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_cuda.cpp @@ -0,0 +1,17 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include + +#define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") + +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh); + +at::Tensor nms(const at::Tensor& dets, const float threshold) { + CHECK_CUDA(dets); + if (dets.numel() == 0) + return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU)); + return nms_cuda(dets, threshold); +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("nms", &nms, "non-maximum suppression"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_kernel.cu new file mode 100644 index 000000000..9254f2ad4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/nms_kernel.cu @@ -0,0 +1,131 @@ +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +#include +#include + +#include +#include + +#include +#include + +int const threadsPerBlock = sizeof(unsigned long long) * 8; + +__device__ inline float devIoU(float const * const a, float const * const b) { + float left = max(a[0], b[0]), right = min(a[2], b[2]); + float top = max(a[1], b[1]), bottom = min(a[3], b[3]); + float width = max(right - left + 1, 0.f), height = max(bottom - top + 1, 0.f); + float interS = width * height; + float Sa = (a[2] - a[0] + 1) * (a[3] - a[1] + 1); + float Sb = (b[2] - b[0] + 1) * (b[3] - b[1] + 1); + return interS / (Sa + Sb - interS); +} + +__global__ void nms_kernel(const int n_boxes, const float nms_overlap_thresh, + const float *dev_boxes, unsigned long long *dev_mask) { + const int row_start = blockIdx.y; + const int col_start = blockIdx.x; + + // if (row_start > col_start) return; + + const int row_size = + min(n_boxes - row_start * threadsPerBlock, threadsPerBlock); + const int col_size = + min(n_boxes - col_start * threadsPerBlock, threadsPerBlock); + + __shared__ float block_boxes[threadsPerBlock * 5]; + if (threadIdx.x < col_size) { + block_boxes[threadIdx.x * 5 + 0] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 0]; + block_boxes[threadIdx.x * 5 + 1] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 1]; + block_boxes[threadIdx.x * 5 + 2] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 2]; + block_boxes[threadIdx.x * 5 + 3] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 3]; + block_boxes[threadIdx.x * 5 + 4] = + dev_boxes[(threadsPerBlock * col_start + threadIdx.x) * 5 + 4]; + } + __syncthreads(); + + if (threadIdx.x < row_size) { + const int cur_box_idx = threadsPerBlock * row_start + threadIdx.x; + const float *cur_box = dev_boxes + cur_box_idx * 5; + int i = 0; + unsigned long long t = 0; + int start = 0; + if (row_start == col_start) { + start = threadIdx.x + 1; + } + for (i = start; i < col_size; i++) { + if (devIoU(cur_box, block_boxes + i * 5) > nms_overlap_thresh) { + t |= 1ULL << i; + } + } + const int col_blocks = THCCeilDiv(n_boxes, threadsPerBlock); + dev_mask[cur_box_idx * col_blocks + col_start] = t; + } +} + +// boxes is a N x 5 tensor +at::Tensor nms_cuda(const at::Tensor boxes, float nms_overlap_thresh) { + using scalar_t = float; + AT_ASSERTM(boxes.type().is_cuda(), "boxes must be a CUDA tensor"); + auto scores = boxes.select(1, 4); + auto order_t = std::get<1>(scores.sort(0, /* descending=*/true)); + auto boxes_sorted = boxes.index_select(0, order_t); + + int boxes_num = boxes.size(0); + + const int col_blocks = THCCeilDiv(boxes_num, threadsPerBlock); + + scalar_t* boxes_dev = boxes_sorted.data(); + + THCState *state = at::globalContext().lazyInitCUDA(); // TODO replace with getTHCState + + unsigned long long* mask_dev = NULL; + //THCudaCheck(THCudaMalloc(state, (void**) &mask_dev, + // boxes_num * col_blocks * sizeof(unsigned long long))); + + mask_dev = (unsigned long long*) THCudaMalloc(state, boxes_num * col_blocks * sizeof(unsigned long long)); + + dim3 blocks(THCCeilDiv(boxes_num, threadsPerBlock), + THCCeilDiv(boxes_num, threadsPerBlock)); + dim3 threads(threadsPerBlock); + nms_kernel<<>>(boxes_num, + nms_overlap_thresh, + boxes_dev, + mask_dev); + + std::vector mask_host(boxes_num * col_blocks); + THCudaCheck(cudaMemcpy(&mask_host[0], + mask_dev, + sizeof(unsigned long long) * boxes_num * col_blocks, + cudaMemcpyDeviceToHost)); + + std::vector remv(col_blocks); + memset(&remv[0], 0, sizeof(unsigned long long) * col_blocks); + + at::Tensor keep = at::empty({boxes_num}, boxes.options().dtype(at::kLong).device(at::kCPU)); + int64_t* keep_out = keep.data(); + + int num_to_keep = 0; + for (int i = 0; i < boxes_num; i++) { + int nblock = i / threadsPerBlock; + int inblock = i % threadsPerBlock; + + if (!(remv[nblock] & (1ULL << inblock))) { + keep_out[num_to_keep++] = i; + unsigned long long *p = &mask_host[0] + i * col_blocks; + for (int j = nblock; j < col_blocks; j++) { + remv[j] |= p[j]; + } + } + } + + THCudaFree(state, mask_dev); + // TODO improve this part + return std::get<0>(order_t.index({ + keep.narrow(/*dim=*/0, /*start=*/0, /*length=*/num_to_keep).to( + order_t.device(), keep.scalar_type()) + }).sort(0, false)); +} \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.cpp new file mode 100644 index 000000000..763ee4c46 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.cpp @@ -0,0 +1,10246 @@ +/* Generated by Cython 0.28.3 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [ + "/home/work/anaconda3/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h", + "/home/work/anaconda3/lib/python3.6/site-packages/numpy/core/include/numpy/ufuncobject.h" + ], + "extra_compile_args": { + "cc": [ + "-Wno-unused-function", + "-Wno-write-strings" + ], + "nvcc": [ + "-c", + "--compiler-options", + "-fPIC" + ] + }, + "include_dirs": [ + "/home/work/anaconda3/lib/python3.6/site-packages/numpy/core/include" + ], + "language": "c++", + "name": "soft_nms_cpu", + "sources": [ + "src/soft_nms_cpu.pyx" + ] + }, + "module_name": "soft_nms_cpu" +} +END: Cython Metadata */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. +#else +#define CYTHON_ABI "0_28_3" +#define CYTHON_FUTURE_DIVISION 1 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; // PyThread_create_key reports success always +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif // TSS (Thread Specific Storage) API +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__soft_nms_cpu +#define __PYX_HAVE_API__soft_nms_cpu +/* Early includes */ +#include +#include +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +static PyObject *__pyx_m = NULL; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime = NULL; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +/* Header.proto */ +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "src/soft_nms_cpu.pyx", + "__init__.pxd", + "type.pxd", +}; +/* BufferFormatStructs.proto */ +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; + struct __Pyx_StructField_* fields; + size_t size; + size_t arraysize[8]; + int ndim; + char typegroup; + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":730 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":731 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":732 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":733 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":737 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":738 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":739 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":740 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":744 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":745 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":754 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":755 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":756 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":758 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":759 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":760 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":762 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":763 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":765 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":766 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":767 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + + +/*--- Type declarations ---*/ + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":769 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":770 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":771 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":773 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* ArgTypeTest.proto */ +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); + +/* IsLittleEndian.proto */ +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void); + +/* BufferFormatCheck.proto */ +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts); +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type); + +/* BufferGetAndValidate.proto */ +#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\ + ((obj == Py_None || obj == NULL) ?\ + (__Pyx_ZeroBuffer(buf), 0) :\ + __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)) +static int __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static void __Pyx_ZeroBuffer(Py_buffer* buf); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); +static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 }; +static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* GetModuleGlobalName.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +/* ObjectGetItem.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + +/* SetItemInt.proto */ +#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ + __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) +static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, + int is_list, int wraparound, int boundscheck); + +/* SliceObject.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( + PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** py_start, PyObject** py_stop, PyObject** py_slice, + int has_cstart, int has_cstop, int wraparound); + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) +#else +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) +#endif + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* BufferStructDeclare.proto */ +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* RealImag.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(__cplusplus) && CYTHON_CCOMPLEX\ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_float(a, b) ((a)==(b)) + #define __Pyx_c_sum_float(a, b) ((a)+(b)) + #define __Pyx_c_diff_float(a, b) ((a)-(b)) + #define __Pyx_c_prod_float(a, b) ((a)*(b)) + #define __Pyx_c_quot_float(a, b) ((a)/(b)) + #define __Pyx_c_neg_float(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_float(z) ((z)==(float)0) + #define __Pyx_c_conj_float(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_float(z) (::std::abs(z)) + #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_float(z) ((z)==0) + #define __Pyx_c_conj_float(z) (conjf(z)) + #if 1 + #define __Pyx_c_abs_float(z) (cabsf(z)) + #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_double(a, b) ((a)==(b)) + #define __Pyx_c_sum_double(a, b) ((a)+(b)) + #define __Pyx_c_diff_double(a, b) ((a)-(b)) + #define __Pyx_c_prod_double(a, b) ((a)*(b)) + #define __Pyx_c_quot_double(a, b) ((a)/(b)) + #define __Pyx_c_neg_double(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_double(z) ((z)==(double)0) + #define __Pyx_c_conj_double(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (::std::abs(z)) + #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_double(z) ((z)==0) + #define __Pyx_c_conj_double(z) (conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (cabs(z)) + #define __Pyx_c_pow_double(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* PyIdentifierFromString.proto */ +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +/* ModuleImport.proto */ +static PyObject *__Pyx_ImportModule(const char *name); + +/* TypeImport.proto */ +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'cpython' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'cpython.mem' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'soft_nms_cpu' */ +static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_12soft_nms_cpu_max(__pyx_t_5numpy_float32_t, __pyx_t_5numpy_float32_t); /*proto*/ +static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_12soft_nms_cpu_min(__pyx_t_5numpy_float32_t, __pyx_t_5numpy_float32_t); /*proto*/ +static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 }; +#define __Pyx_MODULE_NAME "soft_nms_cpu" +extern int __pyx_module_is_main_soft_nms_cpu; +int __pyx_module_is_main_soft_nms_cpu = 0; + +/* Implementation of 'soft_nms_cpu' */ +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_ImportError; +static const char __pyx_k_N[] = "N"; +static const char __pyx_k_i[] = "i"; +static const char __pyx_k_s[] = "s"; +static const char __pyx_k_ih[] = "ih"; +static const char __pyx_k_iw[] = "iw"; +static const char __pyx_k_np[] = "np"; +static const char __pyx_k_ov[] = "ov"; +static const char __pyx_k_ti[] = "ti"; +static const char __pyx_k_ts[] = "ts"; +static const char __pyx_k_ua[] = "ua"; +static const char __pyx_k_x1[] = "x1"; +static const char __pyx_k_x2[] = "x2"; +static const char __pyx_k_y1[] = "y1"; +static const char __pyx_k_y2[] = "y2"; +static const char __pyx_k_exp[] = "exp"; +static const char __pyx_k_pos[] = "pos"; +static const char __pyx_k_tx1[] = "tx1"; +static const char __pyx_k_tx2[] = "tx2"; +static const char __pyx_k_ty1[] = "ty1"; +static const char __pyx_k_ty2[] = "ty2"; +static const char __pyx_k_area[] = "area"; +static const char __pyx_k_copy[] = "copy"; +static const char __pyx_k_inds[] = "inds"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_boxes[] = "boxes"; +static const char __pyx_k_numpy[] = "numpy"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_shape[] = "shape"; +static const char __pyx_k_sigma[] = "sigma"; +static const char __pyx_k_arange[] = "arange"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_maxpos[] = "maxpos"; +static const char __pyx_k_method[] = "method"; +static const char __pyx_k_weight[] = "weight"; +static const char __pyx_k_iou_thr[] = "iou_thr"; +static const char __pyx_k_box_area[] = "box_area"; +static const char __pyx_k_boxes_in[] = "boxes_in"; +static const char __pyx_k_maxscore[] = "maxscore"; +static const char __pyx_k_min_score[] = "min_score"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_ImportError[] = "ImportError"; +static const char __pyx_k_RuntimeError[] = "RuntimeError"; +static const char __pyx_k_soft_nms_cpu[] = "soft_nms_cpu"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_src_soft_nms_cpu_pyx[] = "src/soft_nms_cpu.pyx"; +static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; +static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; +static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; +static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; +static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_ImportError; +static PyObject *__pyx_n_s_N; +static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_arange; +static PyObject *__pyx_n_s_area; +static PyObject *__pyx_n_s_box_area; +static PyObject *__pyx_n_s_boxes; +static PyObject *__pyx_n_s_boxes_in; +static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_copy; +static PyObject *__pyx_n_s_exp; +static PyObject *__pyx_n_s_i; +static PyObject *__pyx_n_s_ih; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_inds; +static PyObject *__pyx_n_s_iou_thr; +static PyObject *__pyx_n_s_iw; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_maxpos; +static PyObject *__pyx_n_s_maxscore; +static PyObject *__pyx_n_s_method; +static PyObject *__pyx_n_s_min_score; +static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; +static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to; +static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor; +static PyObject *__pyx_n_s_ov; +static PyObject *__pyx_n_s_pos; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_s; +static PyObject *__pyx_n_s_shape; +static PyObject *__pyx_n_s_sigma; +static PyObject *__pyx_n_s_soft_nms_cpu; +static PyObject *__pyx_kp_s_src_soft_nms_cpu_pyx; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_ti; +static PyObject *__pyx_n_s_ts; +static PyObject *__pyx_n_s_tx1; +static PyObject *__pyx_n_s_tx2; +static PyObject *__pyx_n_s_ty1; +static PyObject *__pyx_n_s_ty2; +static PyObject *__pyx_n_s_ua; +static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; +static PyObject *__pyx_n_s_weight; +static PyObject *__pyx_n_s_x1; +static PyObject *__pyx_n_s_x2; +static PyObject *__pyx_n_s_y1; +static PyObject *__pyx_n_s_y2; +static PyObject *__pyx_pf_12soft_nms_cpu_soft_nms_cpu(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_boxes_in, float __pyx_v_iou_thr, unsigned int __pyx_v_method, float __pyx_v_sigma, float __pyx_v_min_score); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_4; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_codeobj__11; +/* Late includes */ + +/* "soft_nms_cpu.pyx":15 + * + * + * cdef inline np.float32_t max(np.float32_t a, np.float32_t b): # <<<<<<<<<<<<<< + * return a if a >= b else b + * + */ + +static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_12soft_nms_cpu_max(__pyx_t_5numpy_float32_t __pyx_v_a, __pyx_t_5numpy_float32_t __pyx_v_b) { + __pyx_t_5numpy_float32_t __pyx_r; + __Pyx_RefNannyDeclarations + __pyx_t_5numpy_float32_t __pyx_t_1; + __Pyx_RefNannySetupContext("max", 0); + + /* "soft_nms_cpu.pyx":16 + * + * cdef inline np.float32_t max(np.float32_t a, np.float32_t b): + * return a if a >= b else b # <<<<<<<<<<<<<< + * + * cdef inline np.float32_t min(np.float32_t a, np.float32_t b): + */ + if (((__pyx_v_a >= __pyx_v_b) != 0)) { + __pyx_t_1 = __pyx_v_a; + } else { + __pyx_t_1 = __pyx_v_b; + } + __pyx_r = __pyx_t_1; + goto __pyx_L0; + + /* "soft_nms_cpu.pyx":15 + * + * + * cdef inline np.float32_t max(np.float32_t a, np.float32_t b): # <<<<<<<<<<<<<< + * return a if a >= b else b + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "soft_nms_cpu.pyx":18 + * return a if a >= b else b + * + * cdef inline np.float32_t min(np.float32_t a, np.float32_t b): # <<<<<<<<<<<<<< + * return a if a <= b else b + * + */ + +static CYTHON_INLINE __pyx_t_5numpy_float32_t __pyx_f_12soft_nms_cpu_min(__pyx_t_5numpy_float32_t __pyx_v_a, __pyx_t_5numpy_float32_t __pyx_v_b) { + __pyx_t_5numpy_float32_t __pyx_r; + __Pyx_RefNannyDeclarations + __pyx_t_5numpy_float32_t __pyx_t_1; + __Pyx_RefNannySetupContext("min", 0); + + /* "soft_nms_cpu.pyx":19 + * + * cdef inline np.float32_t min(np.float32_t a, np.float32_t b): + * return a if a <= b else b # <<<<<<<<<<<<<< + * + * + */ + if (((__pyx_v_a <= __pyx_v_b) != 0)) { + __pyx_t_1 = __pyx_v_a; + } else { + __pyx_t_1 = __pyx_v_b; + } + __pyx_r = __pyx_t_1; + goto __pyx_L0; + + /* "soft_nms_cpu.pyx":18 + * return a if a >= b else b + * + * cdef inline np.float32_t min(np.float32_t a, np.float32_t b): # <<<<<<<<<<<<<< + * return a if a <= b else b + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "soft_nms_cpu.pyx":22 + * + * + * def soft_nms_cpu( # <<<<<<<<<<<<<< + * np.ndarray[float, ndim=2] boxes_in, + * float iou_thr, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_12soft_nms_cpu_1soft_nms_cpu(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_12soft_nms_cpu_1soft_nms_cpu = {"soft_nms_cpu", (PyCFunction)__pyx_pw_12soft_nms_cpu_1soft_nms_cpu, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_12soft_nms_cpu_1soft_nms_cpu(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_boxes_in = 0; + float __pyx_v_iou_thr; + unsigned int __pyx_v_method; + float __pyx_v_sigma; + float __pyx_v_min_score; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("soft_nms_cpu (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_boxes_in,&__pyx_n_s_iou_thr,&__pyx_n_s_method,&__pyx_n_s_sigma,&__pyx_n_s_min_score,0}; + PyObject* values[5] = {0,0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_boxes_in)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_iou_thr)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("soft_nms_cpu", 0, 2, 5, 1); __PYX_ERR(0, 22, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method); + if (value) { values[2] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 3: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma); + if (value) { values[3] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 4: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_min_score); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "soft_nms_cpu") < 0)) __PYX_ERR(0, 22, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_boxes_in = ((PyArrayObject *)values[0]); + __pyx_v_iou_thr = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_iou_thr == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 24, __pyx_L3_error) + if (values[2]) { + __pyx_v_method = __Pyx_PyInt_As_unsigned_int(values[2]); if (unlikely((__pyx_v_method == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error) + } else { + __pyx_v_method = ((unsigned int)1); + } + if (values[3]) { + __pyx_v_sigma = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_sigma == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 26, __pyx_L3_error) + } else { + __pyx_v_sigma = ((float)0.5); + } + if (values[4]) { + __pyx_v_min_score = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_min_score == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 27, __pyx_L3_error) + } else { + __pyx_v_min_score = ((float)0.001); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("soft_nms_cpu", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 22, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("soft_nms_cpu.soft_nms_cpu", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_boxes_in), __pyx_ptype_5numpy_ndarray, 1, "boxes_in", 0))) __PYX_ERR(0, 23, __pyx_L1_error) + __pyx_r = __pyx_pf_12soft_nms_cpu_soft_nms_cpu(__pyx_self, __pyx_v_boxes_in, __pyx_v_iou_thr, __pyx_v_method, __pyx_v_sigma, __pyx_v_min_score); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_12soft_nms_cpu_soft_nms_cpu(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_boxes_in, float __pyx_v_iou_thr, unsigned int __pyx_v_method, float __pyx_v_sigma, float __pyx_v_min_score) { + PyObject *__pyx_v_boxes = NULL; + unsigned int __pyx_v_N; + float __pyx_v_iw; + float __pyx_v_ih; + float __pyx_v_ua; + int __pyx_v_pos; + float __pyx_v_maxscore; + int __pyx_v_maxpos; + float __pyx_v_x1; + float __pyx_v_x2; + float __pyx_v_y1; + float __pyx_v_y2; + float __pyx_v_tx1; + float __pyx_v_tx2; + float __pyx_v_ty1; + float __pyx_v_ty2; + float __pyx_v_ts; + float __pyx_v_area; + float __pyx_v_weight; + float __pyx_v_ov; + PyObject *__pyx_v_inds = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_ti = NULL; + CYTHON_UNUSED PyObject *__pyx_v_s = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_boxes_in; + __Pyx_Buffer __pyx_pybuffer_boxes_in; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + unsigned int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + float __pyx_t_9; + int __pyx_t_10; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + long __pyx_t_13; + __Pyx_RefNannySetupContext("soft_nms_cpu", 0); + __pyx_pybuffer_boxes_in.pybuffer.buf = NULL; + __pyx_pybuffer_boxes_in.refcount = 0; + __pyx_pybuffernd_boxes_in.data = NULL; + __pyx_pybuffernd_boxes_in.rcbuffer = &__pyx_pybuffer_boxes_in; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_boxes_in.rcbuffer->pybuffer, (PyObject*)__pyx_v_boxes_in, &__Pyx_TypeInfo_float, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 22, __pyx_L1_error) + } + __pyx_pybuffernd_boxes_in.diminfo[0].strides = __pyx_pybuffernd_boxes_in.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_boxes_in.diminfo[0].shape = __pyx_pybuffernd_boxes_in.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_boxes_in.diminfo[1].strides = __pyx_pybuffernd_boxes_in.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_boxes_in.diminfo[1].shape = __pyx_pybuffernd_boxes_in.rcbuffer->pybuffer.shape[1]; + + /* "soft_nms_cpu.pyx":29 + * float min_score=0.001, + * ): + * boxes = boxes_in.copy() # <<<<<<<<<<<<<< + * cdef unsigned int N = boxes.shape[0] + * cdef float iw, ih, box_area + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_boxes_in), __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_boxes = __pyx_t_1; + __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":30 + * ): + * boxes = boxes_in.copy() + * cdef unsigned int N = boxes.shape[0] # <<<<<<<<<<<<<< + * cdef float iw, ih, box_area + * cdef float ua + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_boxes, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(0, 30, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_N = __pyx_t_4; + + /* "soft_nms_cpu.pyx":33 + * cdef float iw, ih, box_area + * cdef float ua + * cdef int pos = 0 # <<<<<<<<<<<<<< + * cdef float maxscore = 0 + * cdef int maxpos = 0 + */ + __pyx_v_pos = 0; + + /* "soft_nms_cpu.pyx":34 + * cdef float ua + * cdef int pos = 0 + * cdef float maxscore = 0 # <<<<<<<<<<<<<< + * cdef int maxpos = 0 + * cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov + */ + __pyx_v_maxscore = 0.0; + + /* "soft_nms_cpu.pyx":35 + * cdef int pos = 0 + * cdef float maxscore = 0 + * cdef int maxpos = 0 # <<<<<<<<<<<<<< + * cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov + * inds = np.arange(N) + */ + __pyx_v_maxpos = 0; + + /* "soft_nms_cpu.pyx":37 + * cdef int maxpos = 0 + * cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov + * inds = np.arange(N) # <<<<<<<<<<<<<< + * + * for i in range(N): + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_inds = __pyx_t_2; + __pyx_t_2 = 0; + + /* "soft_nms_cpu.pyx":39 + * inds = np.arange(N) + * + * for i in range(N): # <<<<<<<<<<<<<< + * maxscore = boxes[i, 4] + * maxpos = i + */ + __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 39, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 39, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + } else { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 39, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + } + } else { + __pyx_t_3 = __pyx_t_8(__pyx_t_2); + if (unlikely(!__pyx_t_3)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 39, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3); + __pyx_t_3 = 0; + + /* "soft_nms_cpu.pyx":40 + * + * for i in range(N): + * maxscore = boxes[i, 4] # <<<<<<<<<<<<<< + * maxpos = i + * + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 40, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_v_maxscore = __pyx_t_9; + + /* "soft_nms_cpu.pyx":41 + * for i in range(N): + * maxscore = boxes[i, 4] + * maxpos = i # <<<<<<<<<<<<<< + * + * tx1 = boxes[i, 0] + */ + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_i); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L1_error) + __pyx_v_maxpos = __pyx_t_10; + + /* "soft_nms_cpu.pyx":43 + * maxpos = i + * + * tx1 = boxes[i, 0] # <<<<<<<<<<<<<< + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] + */ + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 43, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":44 + * + * tx1 = boxes[i, 0] + * ty1 = boxes[i, 1] # <<<<<<<<<<<<<< + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 44, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_v_ty1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":45 + * tx1 = boxes[i, 0] + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] # <<<<<<<<<<<<<< + * ty2 = boxes[i, 3] + * ts = boxes[i, 4] + */ + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 45, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":46 + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] # <<<<<<<<<<<<<< + * ts = boxes[i, 4] + * ti = inds[i] + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_v_ty2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":47 + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] + * ts = boxes[i, 4] # <<<<<<<<<<<<<< + * ti = inds[i] + * + */ + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_ts = __pyx_t_9; + + /* "soft_nms_cpu.pyx":48 + * ty2 = boxes[i, 3] + * ts = boxes[i, 4] + * ti = inds[i] # <<<<<<<<<<<<<< + * + * pos = i + 1 + */ + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_inds, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_ti, __pyx_t_3); + __pyx_t_3 = 0; + + /* "soft_nms_cpu.pyx":50 + * ti = inds[i] + * + * pos = i + 1 # <<<<<<<<<<<<<< + * # get max box + * while pos < N: + */ + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_pos = __pyx_t_10; + + /* "soft_nms_cpu.pyx":52 + * pos = i + 1 + * # get max box + * while pos < N: # <<<<<<<<<<<<<< + * if maxscore < boxes[pos, 4]: + * maxscore = boxes[pos, 4] + */ + while (1) { + __pyx_t_11 = ((__pyx_v_pos < __pyx_v_N) != 0); + if (!__pyx_t_11) break; + + /* "soft_nms_cpu.pyx":53 + * # get max box + * while pos < N: + * if maxscore < boxes[pos, 4]: # <<<<<<<<<<<<<< + * maxscore = boxes[pos, 4] + * maxpos = pos + */ + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_maxscore); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 53, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":54 + * while pos < N: + * if maxscore < boxes[pos, 4]: + * maxscore = boxes[pos, 4] # <<<<<<<<<<<<<< + * maxpos = pos + * pos = pos + 1 + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_maxscore = __pyx_t_9; + + /* "soft_nms_cpu.pyx":55 + * if maxscore < boxes[pos, 4]: + * maxscore = boxes[pos, 4] + * maxpos = pos # <<<<<<<<<<<<<< + * pos = pos + 1 + * + */ + __pyx_v_maxpos = __pyx_v_pos; + + /* "soft_nms_cpu.pyx":53 + * # get max box + * while pos < N: + * if maxscore < boxes[pos, 4]: # <<<<<<<<<<<<<< + * maxscore = boxes[pos, 4] + * maxpos = pos + */ + } + + /* "soft_nms_cpu.pyx":56 + * maxscore = boxes[pos, 4] + * maxpos = pos + * pos = pos + 1 # <<<<<<<<<<<<<< + * + * # add max box as a detection + */ + __pyx_v_pos = (__pyx_v_pos + 1); + } + + /* "soft_nms_cpu.pyx":59 + * + * # add max box as a detection + * boxes[i, 0] = boxes[maxpos, 0] # <<<<<<<<<<<<<< + * boxes[i, 1] = boxes[maxpos, 1] + * boxes[i, 2] = boxes[maxpos, 2] + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 59, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":60 + * # add max box as a detection + * boxes[i, 0] = boxes[maxpos, 0] + * boxes[i, 1] = boxes[maxpos, 1] # <<<<<<<<<<<<<< + * boxes[i, 2] = boxes[maxpos, 2] + * boxes[i, 3] = boxes[maxpos, 3] + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 60, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":61 + * boxes[i, 0] = boxes[maxpos, 0] + * boxes[i, 1] = boxes[maxpos, 1] + * boxes[i, 2] = boxes[maxpos, 2] # <<<<<<<<<<<<<< + * boxes[i, 3] = boxes[maxpos, 3] + * boxes[i, 4] = boxes[maxpos, 4] + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_2); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 61, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":62 + * boxes[i, 1] = boxes[maxpos, 1] + * boxes[i, 2] = boxes[maxpos, 2] + * boxes[i, 3] = boxes[maxpos, 3] # <<<<<<<<<<<<<< + * boxes[i, 4] = boxes[maxpos, 4] + * inds[i] = inds[maxpos] + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 62, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":63 + * boxes[i, 2] = boxes[maxpos, 2] + * boxes[i, 3] = boxes[maxpos, 3] + * boxes[i, 4] = boxes[maxpos, 4] # <<<<<<<<<<<<<< + * inds[i] = inds[maxpos] + * + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 63, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":64 + * boxes[i, 3] = boxes[maxpos, 3] + * boxes[i, 4] = boxes[maxpos, 4] + * inds[i] = inds[maxpos] # <<<<<<<<<<<<<< + * + * # swap ith box with position of max box + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_v_maxpos, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(PyObject_SetItem(__pyx_v_inds, __pyx_v_i, __pyx_t_1) < 0)) __PYX_ERR(0, 64, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":67 + * + * # swap ith box with position of max box + * boxes[maxpos, 0] = tx1 # <<<<<<<<<<<<<< + * boxes[maxpos, 1] = ty1 + * boxes[maxpos, 2] = tx2 + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_tx1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __pyx_t_6 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 67, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":68 + * # swap ith box with position of max box + * boxes[maxpos, 0] = tx1 + * boxes[maxpos, 1] = ty1 # <<<<<<<<<<<<<< + * boxes[maxpos, 2] = tx2 + * boxes[maxpos, 3] = ty2 + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ty1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":69 + * boxes[maxpos, 0] = tx1 + * boxes[maxpos, 1] = ty1 + * boxes[maxpos, 2] = tx2 # <<<<<<<<<<<<<< + * boxes[maxpos, 3] = ty2 + * boxes[maxpos, 4] = ts + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_tx2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); + __pyx_t_6 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 69, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":70 + * boxes[maxpos, 1] = ty1 + * boxes[maxpos, 2] = tx2 + * boxes[maxpos, 3] = ty2 # <<<<<<<<<<<<<< + * boxes[maxpos, 4] = ts + * inds[maxpos] = ti + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ty2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_6, __pyx_t_1) < 0)) __PYX_ERR(0, 70, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":71 + * boxes[maxpos, 2] = tx2 + * boxes[maxpos, 3] = ty2 + * boxes[maxpos, 4] = ts # <<<<<<<<<<<<<< + * inds[maxpos] = ti + * + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_maxpos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_6 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 71, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":72 + * boxes[maxpos, 3] = ty2 + * boxes[maxpos, 4] = ts + * inds[maxpos] = ti # <<<<<<<<<<<<<< + * + * tx1 = boxes[i, 0] + */ + if (unlikely(__Pyx_SetItemInt(__pyx_v_inds, __pyx_v_maxpos, __pyx_v_ti, int, 1, __Pyx_PyInt_From_int, 0, 1, 0) < 0)) __PYX_ERR(0, 72, __pyx_L1_error) + + /* "soft_nms_cpu.pyx":74 + * inds[maxpos] = ti + * + * tx1 = boxes[i, 0] # <<<<<<<<<<<<<< + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":75 + * + * tx1 = boxes[i, 0] + * ty1 = boxes[i, 1] # <<<<<<<<<<<<<< + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ty1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":76 + * tx1 = boxes[i, 0] + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] # <<<<<<<<<<<<<< + * ty2 = boxes[i, 3] + * ts = boxes[i, 4] + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_tx2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":77 + * ty1 = boxes[i, 1] + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] # <<<<<<<<<<<<<< + * ts = boxes[i, 4] + * + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_ty2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":78 + * tx2 = boxes[i, 2] + * ty2 = boxes[i, 3] + * ts = boxes[i, 4] # <<<<<<<<<<<<<< + * + * pos = i + 1 + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_i); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 78, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_ts = __pyx_t_9; + + /* "soft_nms_cpu.pyx":80 + * ts = boxes[i, 4] + * + * pos = i + 1 # <<<<<<<<<<<<<< + * # NMS iterations, note that N changes if detection boxes fall below + * # threshold + */ + __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_pos = __pyx_t_10; + + /* "soft_nms_cpu.pyx":83 + * # NMS iterations, note that N changes if detection boxes fall below + * # threshold + * while pos < N: # <<<<<<<<<<<<<< + * x1 = boxes[pos, 0] + * y1 = boxes[pos, 1] + */ + while (1) { + __pyx_t_11 = ((__pyx_v_pos < __pyx_v_N) != 0); + if (!__pyx_t_11) break; + + /* "soft_nms_cpu.pyx":84 + * # threshold + * while pos < N: + * x1 = boxes[pos, 0] # <<<<<<<<<<<<<< + * y1 = boxes[pos, 1] + * x2 = boxes[pos, 2] + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_x1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":85 + * while pos < N: + * x1 = boxes[pos, 0] + * y1 = boxes[pos, 1] # <<<<<<<<<<<<<< + * x2 = boxes[pos, 2] + * y2 = boxes[pos, 3] + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_y1 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":86 + * x1 = boxes[pos, 0] + * y1 = boxes[pos, 1] + * x2 = boxes[pos, 2] # <<<<<<<<<<<<<< + * y2 = boxes[pos, 3] + * s = boxes[pos, 4] + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_x2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":87 + * y1 = boxes[pos, 1] + * x2 = boxes[pos, 2] + * y2 = boxes[pos, 3] # <<<<<<<<<<<<<< + * s = boxes[pos, 4] + * + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_y2 = __pyx_t_9; + + /* "soft_nms_cpu.pyx":88 + * x2 = boxes[pos, 2] + * y2 = boxes[pos, 3] + * s = boxes[pos, 4] # <<<<<<<<<<<<<< + * + * area = (x2 - x1 + 1) * (y2 - y1 + 1) + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3); + __pyx_t_3 = 0; + + /* "soft_nms_cpu.pyx":90 + * s = boxes[pos, 4] + * + * area = (x2 - x1 + 1) * (y2 - y1 + 1) # <<<<<<<<<<<<<< + * iw = (min(tx2, x2) - max(tx1, x1) + 1) + * if iw > 0: + */ + __pyx_v_area = (((__pyx_v_x2 - __pyx_v_x1) + 1.0) * ((__pyx_v_y2 - __pyx_v_y1) + 1.0)); + + /* "soft_nms_cpu.pyx":91 + * + * area = (x2 - x1 + 1) * (y2 - y1 + 1) + * iw = (min(tx2, x2) - max(tx1, x1) + 1) # <<<<<<<<<<<<<< + * if iw > 0: + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + */ + __pyx_v_iw = ((__pyx_f_12soft_nms_cpu_min(__pyx_v_tx2, __pyx_v_x2) - __pyx_f_12soft_nms_cpu_max(__pyx_v_tx1, __pyx_v_x1)) + 1.0); + + /* "soft_nms_cpu.pyx":92 + * area = (x2 - x1 + 1) * (y2 - y1 + 1) + * iw = (min(tx2, x2) - max(tx1, x1) + 1) + * if iw > 0: # <<<<<<<<<<<<<< + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + * if ih > 0: + */ + __pyx_t_11 = ((__pyx_v_iw > 0.0) != 0); + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":93 + * iw = (min(tx2, x2) - max(tx1, x1) + 1) + * if iw > 0: + * ih = (min(ty2, y2) - max(ty1, y1) + 1) # <<<<<<<<<<<<<< + * if ih > 0: + * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + */ + __pyx_v_ih = ((__pyx_f_12soft_nms_cpu_min(__pyx_v_ty2, __pyx_v_y2) - __pyx_f_12soft_nms_cpu_max(__pyx_v_ty1, __pyx_v_y1)) + 1.0); + + /* "soft_nms_cpu.pyx":94 + * if iw > 0: + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + * if ih > 0: # <<<<<<<<<<<<<< + * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + * ov = iw * ih / ua # iou between max box and detection box + */ + __pyx_t_11 = ((__pyx_v_ih > 0.0) != 0); + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":95 + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + * if ih > 0: + * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) # <<<<<<<<<<<<<< + * ov = iw * ih / ua # iou between max box and detection box + * + */ + __pyx_v_ua = ((double)(((((__pyx_v_tx2 - __pyx_v_tx1) + 1.0) * ((__pyx_v_ty2 - __pyx_v_ty1) + 1.0)) + __pyx_v_area) - (__pyx_v_iw * __pyx_v_ih))); + + /* "soft_nms_cpu.pyx":96 + * if ih > 0: + * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + * ov = iw * ih / ua # iou between max box and detection box # <<<<<<<<<<<<<< + * + * if method == 1: # linear + */ + __pyx_t_9 = (__pyx_v_iw * __pyx_v_ih); + if (unlikely(__pyx_v_ua == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 96, __pyx_L1_error) + } + __pyx_v_ov = (__pyx_t_9 / __pyx_v_ua); + + /* "soft_nms_cpu.pyx":98 + * ov = iw * ih / ua # iou between max box and detection box + * + * if method == 1: # linear # <<<<<<<<<<<<<< + * if ov > iou_thr: + * weight = 1 - ov + */ + switch (__pyx_v_method) { + case 1: + + /* "soft_nms_cpu.pyx":99 + * + * if method == 1: # linear + * if ov > iou_thr: # <<<<<<<<<<<<<< + * weight = 1 - ov + * else: + */ + __pyx_t_11 = ((__pyx_v_ov > __pyx_v_iou_thr) != 0); + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":100 + * if method == 1: # linear + * if ov > iou_thr: + * weight = 1 - ov # <<<<<<<<<<<<<< + * else: + * weight = 1 + */ + __pyx_v_weight = (1.0 - __pyx_v_ov); + + /* "soft_nms_cpu.pyx":99 + * + * if method == 1: # linear + * if ov > iou_thr: # <<<<<<<<<<<<<< + * weight = 1 - ov + * else: + */ + goto __pyx_L12; + } + + /* "soft_nms_cpu.pyx":102 + * weight = 1 - ov + * else: + * weight = 1 # <<<<<<<<<<<<<< + * elif method == 2: # gaussian + * weight = np.exp(-(ov * ov) / sigma) + */ + /*else*/ { + __pyx_v_weight = 1.0; + } + __pyx_L12:; + + /* "soft_nms_cpu.pyx":98 + * ov = iw * ih / ua # iou between max box and detection box + * + * if method == 1: # linear # <<<<<<<<<<<<<< + * if ov > iou_thr: + * weight = 1 - ov + */ + break; + + /* "soft_nms_cpu.pyx":103 + * else: + * weight = 1 + * elif method == 2: # gaussian # <<<<<<<<<<<<<< + * weight = np.exp(-(ov * ov) / sigma) + * else: # original NMS + */ + case 2: + + /* "soft_nms_cpu.pyx":104 + * weight = 1 + * elif method == 2: # gaussian + * weight = np.exp(-(ov * ov) / sigma) # <<<<<<<<<<<<<< + * else: # original NMS + * if ov > iou_thr: + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_exp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = (-(__pyx_v_ov * __pyx_v_ov)); + if (unlikely(__pyx_v_sigma == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "float division"); + __PYX_ERR(0, 104, __pyx_L1_error) + } + __pyx_t_1 = PyFloat_FromDouble((__pyx_t_9 / __pyx_v_sigma)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + if (!__pyx_t_5) { + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_3); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; + __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_1}; + __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL; + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_weight = __pyx_t_9; + + /* "soft_nms_cpu.pyx":103 + * else: + * weight = 1 + * elif method == 2: # gaussian # <<<<<<<<<<<<<< + * weight = np.exp(-(ov * ov) / sigma) + * else: # original NMS + */ + break; + default: + + /* "soft_nms_cpu.pyx":106 + * weight = np.exp(-(ov * ov) / sigma) + * else: # original NMS + * if ov > iou_thr: # <<<<<<<<<<<<<< + * weight = 0 + * else: + */ + __pyx_t_11 = ((__pyx_v_ov > __pyx_v_iou_thr) != 0); + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":107 + * else: # original NMS + * if ov > iou_thr: + * weight = 0 # <<<<<<<<<<<<<< + * else: + * weight = 1 + */ + __pyx_v_weight = 0.0; + + /* "soft_nms_cpu.pyx":106 + * weight = np.exp(-(ov * ov) / sigma) + * else: # original NMS + * if ov > iou_thr: # <<<<<<<<<<<<<< + * weight = 0 + * else: + */ + goto __pyx_L13; + } + + /* "soft_nms_cpu.pyx":109 + * weight = 0 + * else: + * weight = 1 # <<<<<<<<<<<<<< + * + * boxes[pos, 4] = weight * boxes[pos, 4] + */ + /*else*/ { + __pyx_v_weight = 1.0; + } + __pyx_L13:; + break; + } + + /* "soft_nms_cpu.pyx":111 + * weight = 1 + * + * boxes[pos, 4] = weight * boxes[pos, 4] # <<<<<<<<<<<<<< + * + * # if box score falls below threshold, discard the box by + */ + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_weight); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_4); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_Multiply(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_6 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_12) < 0)) __PYX_ERR(0, 111, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + + /* "soft_nms_cpu.pyx":115 + * # if box score falls below threshold, discard the box by + * # swapping with last box update N + * if boxes[pos, 4] < min_score: # <<<<<<<<<<<<<< + * boxes[pos, 0] = boxes[N-1, 0] + * boxes[pos, 1] = boxes[N-1, 1] + */ + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyFloat_FromDouble(__pyx_v_min_score); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_RichCompare(__pyx_t_12, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_11) { + + /* "soft_nms_cpu.pyx":116 + * # swapping with last box update N + * if boxes[pos, 4] < min_score: + * boxes[pos, 0] = boxes[N-1, 0] # <<<<<<<<<<<<<< + * boxes[pos, 1] = boxes[N-1, 1] + * boxes[pos, 2] = boxes[N-1, 2] + */ + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_0); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":117 + * if boxes[pos, 4] < min_score: + * boxes[pos, 0] = boxes[N-1, 0] + * boxes[pos, 1] = boxes[N-1, 1] # <<<<<<<<<<<<<< + * boxes[pos, 2] = boxes[N-1, 2] + * boxes[pos, 3] = boxes[N-1, 3] + */ + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_1); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1); + __pyx_t_12 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 117, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":118 + * boxes[pos, 0] = boxes[N-1, 0] + * boxes[pos, 1] = boxes[N-1, 1] + * boxes[pos, 2] = boxes[N-1, 2] # <<<<<<<<<<<<<< + * boxes[pos, 3] = boxes[N-1, 3] + * boxes[pos, 4] = boxes[N-1, 4] + */ + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_2); + __Pyx_GIVEREF(__pyx_int_2); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_2); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 118, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":119 + * boxes[pos, 1] = boxes[N-1, 1] + * boxes[pos, 2] = boxes[N-1, 2] + * boxes[pos, 3] = boxes[N-1, 3] # <<<<<<<<<<<<<< + * boxes[pos, 4] = boxes[N-1, 4] + * inds[pos] = inds[N - 1] + */ + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_3); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); + __Pyx_INCREF(__pyx_int_3); + __Pyx_GIVEREF(__pyx_int_3); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3); + __pyx_t_12 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(0, 119, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":120 + * boxes[pos, 2] = boxes[N-1, 2] + * boxes[pos, 3] = boxes[N-1, 3] + * boxes[pos, 4] = boxes[N-1, 4] # <<<<<<<<<<<<<< + * inds[pos] = inds[N - 1] + * N = N - 1 + */ + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_N - 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_boxes, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); + __Pyx_INCREF(__pyx_int_4); + __Pyx_GIVEREF(__pyx_int_4); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_int_4); + __pyx_t_3 = 0; + if (unlikely(PyObject_SetItem(__pyx_v_boxes, __pyx_t_12, __pyx_t_6) < 0)) __PYX_ERR(0, 120, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":121 + * boxes[pos, 3] = boxes[N-1, 3] + * boxes[pos, 4] = boxes[N-1, 4] + * inds[pos] = inds[N - 1] # <<<<<<<<<<<<<< + * N = N - 1 + * pos = pos - 1 + */ + __pyx_t_13 = (__pyx_v_N - 1); + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_inds, __pyx_t_13, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (unlikely(__Pyx_SetItemInt(__pyx_v_inds, __pyx_v_pos, __pyx_t_6, int, 1, __Pyx_PyInt_From_int, 0, 1, 0) < 0)) __PYX_ERR(0, 121, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "soft_nms_cpu.pyx":122 + * boxes[pos, 4] = boxes[N-1, 4] + * inds[pos] = inds[N - 1] + * N = N - 1 # <<<<<<<<<<<<<< + * pos = pos - 1 + * + */ + __pyx_v_N = (__pyx_v_N - 1); + + /* "soft_nms_cpu.pyx":123 + * inds[pos] = inds[N - 1] + * N = N - 1 + * pos = pos - 1 # <<<<<<<<<<<<<< + * + * pos = pos + 1 + */ + __pyx_v_pos = (__pyx_v_pos - 1); + + /* "soft_nms_cpu.pyx":115 + * # if box score falls below threshold, discard the box by + * # swapping with last box update N + * if boxes[pos, 4] < min_score: # <<<<<<<<<<<<<< + * boxes[pos, 0] = boxes[N-1, 0] + * boxes[pos, 1] = boxes[N-1, 1] + */ + } + + /* "soft_nms_cpu.pyx":94 + * if iw > 0: + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + * if ih > 0: # <<<<<<<<<<<<<< + * ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + * ov = iw * ih / ua # iou between max box and detection box + */ + } + + /* "soft_nms_cpu.pyx":92 + * area = (x2 - x1 + 1) * (y2 - y1 + 1) + * iw = (min(tx2, x2) - max(tx1, x1) + 1) + * if iw > 0: # <<<<<<<<<<<<<< + * ih = (min(ty2, y2) - max(ty1, y1) + 1) + * if ih > 0: + */ + } + + /* "soft_nms_cpu.pyx":125 + * pos = pos - 1 + * + * pos = pos + 1 # <<<<<<<<<<<<<< + * + * return boxes[:N], inds[:N] + */ + __pyx_v_pos = (__pyx_v_pos + 1); + } + + /* "soft_nms_cpu.pyx":39 + * inds = np.arange(N) + * + * for i in range(N): # <<<<<<<<<<<<<< + * maxscore = boxes[i, 4] + * maxpos = i + */ + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "soft_nms_cpu.pyx":127 + * pos = pos + 1 + * + * return boxes[:N], inds[:N] # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_boxes, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_inds, 0, __pyx_v_N, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 127, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_6); + __pyx_t_2 = 0; + __pyx_t_6 = 0; + __pyx_r = __pyx_t_12; + __pyx_t_12 = 0; + goto __pyx_L0; + + /* "soft_nms_cpu.pyx":22 + * + * + * def soft_nms_cpu( # <<<<<<<<<<<<<< + * np.ndarray[float, ndim=2] boxes_in, + * float iou_thr, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_12); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_boxes_in.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("soft_nms_cpu.soft_nms_cpu", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_boxes_in.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF(__pyx_v_boxes); + __Pyx_XDECREF(__pyx_v_inds); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_ti); + __Pyx_XDECREF(__pyx_v_s); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":215 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fulfill the PEP. + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + char *__pyx_t_8; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; + } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * + * cdef int i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":223 + * cdef int i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":225 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":227 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":228 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":227 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 229, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 229, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":227 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L7_bool_binop_done; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":232 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L7_bool_binop_done:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 233, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":236 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":240 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":241 + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":242 + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_4 = __pyx_v_ndim; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":244 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + goto __pyx_L9; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":246 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + /*else*/ { + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":247 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L9:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":248 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":249 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":250 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":253 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef int offset + */ + __pyx_v_f = NULL; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":254 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef int offset + * + */ + __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * cdef int offset + * + * info.obj = self # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(descr): + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * info.obj = self + * + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L15_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L14_bool_binop_done; + } + __pyx_L15_next_or:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":262 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L14_bool_binop_done:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 263, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":264 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = ((char *)"b"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = ((char *)"B"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = ((char *)"h"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":267 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = ((char *)"H"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = ((char *)"i"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":269 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = ((char *)"I"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = ((char *)"l"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":271 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = ((char *)"L"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = ((char *)"q"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":273 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = ((char *)"Q"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = ((char *)"f"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = ((char *)"d"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = ((char *)"g"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":277 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = ((char *)"Zf"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":278 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = ((char *)"Zd"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = ((char *)"Zg"); + break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = ((char *)"O"); + break; + default: + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":282 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 282, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 282, __pyx_L1_error) + break; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * info.obj = self + * + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":286 + * return + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + /*else*/ { + __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":287 + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":288 + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":289 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) + */ + __pyx_t_8 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_8 == ((char *)NULL))) __PYX_ERR(1, 289, __pyx_L1_error) + __pyx_v_f = __pyx_t_8; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":215 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fulfill the PEP. + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":294 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":295 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":296 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) + */ + PyObject_Free(__pyx_v_info->format); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":295 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":297 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":298 + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + PyObject_Free(__pyx_v_info->strides); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":297 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":294 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":775 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 776, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":775 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":778 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 779, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":778 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":781 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":782 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 782, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":781 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":784 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 785, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":784 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":787 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":788 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 788, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":787 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":790 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":792 + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape # <<<<<<<<<<<<<< + * else: + * return () + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); + __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * return d.subarray.shape + * else: + * return () # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_empty_tuple); + __pyx_r = __pyx_empty_tuple; + goto __pyx_L0; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":790 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":796 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * + * cdef dtype child + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":802 + * cdef dtype child + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":805 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(1, 805, __pyx_L1_error) + } + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 805, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 805, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":806 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 806, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 806, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(1, 806, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":807 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 807, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 807, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 807, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 807, __pyx_L1_error) + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(1, 807, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":809 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 809, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 809, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 809, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (unlikely(__pyx_t_6)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":810 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 810, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 810, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":809 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":812 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":813 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":812 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (unlikely(__pyx_t_6)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":814 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 814, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 814, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":812 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":824 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 824, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 824, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 824, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 0x78; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":826 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":829 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":832 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (unlikely(__pyx_t_6)) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 834, __pyx_L1_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 837, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 838, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":839 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 839, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x68; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 840, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":841 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 841, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x69; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 842, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":843 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 843, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 843, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x6C; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 844, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":845 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 845, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 845, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 845, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x71; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":846 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 846, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 846, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":847 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 847, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 847, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x66; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":848 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 848, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 848, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 848, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x64; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":849 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 849, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 849, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 849, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x67; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":850 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 850, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x66; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":851 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 851, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x64; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":852 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 852, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x67; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":853 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(1, 853, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (likely(__pyx_t_6)) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":855 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + /*else*/ { + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 855, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 855, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 855, __pyx_L1_error) + } + __pyx_L15:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":856 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + goto __pyx_L13; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":860 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + /*else*/ { + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(1, 860, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":805 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":861 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":796 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":979 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":980 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":979 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + goto __pyx_L3; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":982 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + /*else*/ { + Py_INCREF(__pyx_v_base); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":983 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":984 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":985 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":987 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":988 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":989 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":988 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":991 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":987 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":996 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_array", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":998 + * cdef inline int import_array() except -1: + * try: + * _import_array() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") + */ + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 998, __pyx_L3_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":999 + * try: + * _import_array() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.multiarray failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 999, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1000, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1000, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":997 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":996 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1002 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_umath", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1003 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1004 + * cdef inline int import_umath() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1004, __pyx_L3_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1003 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1005 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1005, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1006 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1006, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1006, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1003 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1002 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1008 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_ufunc", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1009 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1010 + * cdef inline int import_ufunc() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1010, __pyx_L3_error) + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1009 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1011 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(1, 1011, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1012 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1012, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(1, 1012, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1009 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1008 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_soft_nms_cpu(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_soft_nms_cpu}, + {0, NULL} +}; +#endif + +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + "soft_nms_cpu", + 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1}, + {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1}, + {&__pyx_n_s_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 1, 1}, + {&__pyx_n_s_box_area, __pyx_k_box_area, sizeof(__pyx_k_box_area), 0, 0, 1, 1}, + {&__pyx_n_s_boxes, __pyx_k_boxes, sizeof(__pyx_k_boxes), 0, 0, 1, 1}, + {&__pyx_n_s_boxes_in, __pyx_k_boxes_in, sizeof(__pyx_k_boxes_in), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, + {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1}, + {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, + {&__pyx_n_s_ih, __pyx_k_ih, sizeof(__pyx_k_ih), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_inds, __pyx_k_inds, sizeof(__pyx_k_inds), 0, 0, 1, 1}, + {&__pyx_n_s_iou_thr, __pyx_k_iou_thr, sizeof(__pyx_k_iou_thr), 0, 0, 1, 1}, + {&__pyx_n_s_iw, __pyx_k_iw, sizeof(__pyx_k_iw), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_maxpos, __pyx_k_maxpos, sizeof(__pyx_k_maxpos), 0, 0, 1, 1}, + {&__pyx_n_s_maxscore, __pyx_k_maxscore, sizeof(__pyx_k_maxscore), 0, 0, 1, 1}, + {&__pyx_n_s_method, __pyx_k_method, sizeof(__pyx_k_method), 0, 0, 1, 1}, + {&__pyx_n_s_min_score, __pyx_k_min_score, sizeof(__pyx_k_min_score), 0, 0, 1, 1}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_kp_u_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 1, 0, 0}, + {&__pyx_kp_u_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 1, 0, 0}, + {&__pyx_n_s_ov, __pyx_k_ov, sizeof(__pyx_k_ov), 0, 0, 1, 1}, + {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_sigma, __pyx_k_sigma, sizeof(__pyx_k_sigma), 0, 0, 1, 1}, + {&__pyx_n_s_soft_nms_cpu, __pyx_k_soft_nms_cpu, sizeof(__pyx_k_soft_nms_cpu), 0, 0, 1, 1}, + {&__pyx_kp_s_src_soft_nms_cpu_pyx, __pyx_k_src_soft_nms_cpu_pyx, sizeof(__pyx_k_src_soft_nms_cpu_pyx), 0, 0, 1, 0}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_ti, __pyx_k_ti, sizeof(__pyx_k_ti), 0, 0, 1, 1}, + {&__pyx_n_s_ts, __pyx_k_ts, sizeof(__pyx_k_ts), 0, 0, 1, 1}, + {&__pyx_n_s_tx1, __pyx_k_tx1, sizeof(__pyx_k_tx1), 0, 0, 1, 1}, + {&__pyx_n_s_tx2, __pyx_k_tx2, sizeof(__pyx_k_tx2), 0, 0, 1, 1}, + {&__pyx_n_s_ty1, __pyx_k_ty1, sizeof(__pyx_k_ty1), 0, 0, 1, 1}, + {&__pyx_n_s_ty2, __pyx_k_ty2, sizeof(__pyx_k_ty2), 0, 0, 1, 1}, + {&__pyx_n_s_ua, __pyx_k_ua, sizeof(__pyx_k_ua), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_n_s_weight, __pyx_k_weight, sizeof(__pyx_k_weight), 0, 0, 1, 1}, + {&__pyx_n_s_x1, __pyx_k_x1, sizeof(__pyx_k_x1), 0, 0, 1, 1}, + {&__pyx_n_s_x2, __pyx_k_x2, sizeof(__pyx_k_x2), 0, 0, 1, 1}, + {&__pyx_n_s_y1, __pyx_k_y1, sizeof(__pyx_k_y1), 0, 0, 1, 1}, + {&__pyx_n_s_y2, __pyx_k_y2, sizeof(__pyx_k_y2), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 39, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(1, 810, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(1, 1000, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 229, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 233, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":810 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 810, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":814 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 814, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 834, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1000 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 1000, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1006 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 1006, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1012 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 1012, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "soft_nms_cpu.pyx":22 + * + * + * def soft_nms_cpu( # <<<<<<<<<<<<<< + * np.ndarray[float, ndim=2] boxes_in, + * float iou_thr, + */ + __pyx_tuple__10 = PyTuple_Pack(30, __pyx_n_s_boxes_in, __pyx_n_s_iou_thr, __pyx_n_s_method, __pyx_n_s_sigma, __pyx_n_s_min_score, __pyx_n_s_boxes, __pyx_n_s_N, __pyx_n_s_iw, __pyx_n_s_ih, __pyx_n_s_box_area, __pyx_n_s_ua, __pyx_n_s_pos, __pyx_n_s_maxscore, __pyx_n_s_maxpos, __pyx_n_s_x1, __pyx_n_s_x2, __pyx_n_s_y1, __pyx_n_s_y2, __pyx_n_s_tx1, __pyx_n_s_tx2, __pyx_n_s_ty1, __pyx_n_s_ty2, __pyx_n_s_ts, __pyx_n_s_area, __pyx_n_s_weight, __pyx_n_s_ov, __pyx_n_s_inds, __pyx_n_s_i, __pyx_n_s_ti, __pyx_n_s_s); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(5, 0, 30, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_soft_nms_cpu_pyx, __pyx_n_s_soft_nms_cpu, 22, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_modinit_global_init_code(void); /*proto*/ +static int __Pyx_modinit_variable_export_code(void); /*proto*/ +static int __Pyx_modinit_function_export_code(void); /*proto*/ +static int __Pyx_modinit_type_init_code(void); /*proto*/ +static int __Pyx_modinit_type_import_code(void); /*proto*/ +static int __Pyx_modinit_variable_import_code(void); /*proto*/ +static int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(2, 9, __pyx_L1_error) + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) __PYX_ERR(1, 164, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) __PYX_ERR(1, 186, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) __PYX_ERR(1, 190, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) __PYX_ERR(1, 199, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) __PYX_ERR(1, 872, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#if PY_MAJOR_VERSION < 3 +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#else +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) + #define CYTHON_SMALL_CODE __attribute__((optimize("Os"))) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initsoft_nms_cpu(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initsoft_nms_cpu(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_soft_nms_cpu(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_soft_nms_cpu(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_soft_nms_cpu(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_soft_nms_cpu(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("soft_nms_cpu", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_soft_nms_cpu) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "soft_nms_cpu")) { + if (unlikely(PyDict_SetItemString(modules, "soft_nms_cpu", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + (void)__Pyx_modinit_type_init_code(); + if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error; + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "soft_nms_cpu.pyx":11 + * # cython: language_level=3, boundscheck=False + * + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":22 + * + * + * def soft_nms_cpu( # <<<<<<<<<<<<<< + * np.ndarray[float, ndim=2] boxes_in, + * float iou_thr, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_12soft_nms_cpu_1soft_nms_cpu, NULL, __pyx_n_s_soft_nms_cpu); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_soft_nms_cpu, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "soft_nms_cpu.pyx":1 + * # ---------------------------------------------------------- # <<<<<<<<<<<<<< + * # Soft-NMS: Improving Object Detection With One Line of Code + * # Copyright (c) University of Maryland, College Park + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../../../anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/__init__.pxd":1008 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init soft_nms_cpu", 0, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init soft_nms_cpu"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* ArgTypeTest */ +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(__Pyx_TypeCheck(obj, type))) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +/* IsLittleEndian */ +static CYTHON_INLINE int __Pyx_Is_Little_Endian(void) +{ + union { + uint32_t u32; + uint8_t u8[4]; + } S; + S.u32 = 0x01020304; + return S.u8[0] == 4; +} + +/* BufferFormatCheck */ +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; + } + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_Is_Little_Endian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } + CYTHON_FALLTHROUGH; + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; + } + CYTHON_FALLTHROUGH; + case 's': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} + +/* BufferGetAndValidate */ + static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (unlikely(info->buf == NULL)) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} +static void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static int __Pyx__GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + buf->buf = NULL; + if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) { + __Pyx_ZeroBuffer(buf); + return -1; + } + if (unlikely(buf->ndim != nd)) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if (unlikely((unsigned)buf->itemsize != dtype->size)) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_SafeReleaseBuffer(buf); + return -1; +} + +/* PyCFunctionFastCall */ + #if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); + } +} +#endif + +/* PyFunctionFastCall */ + #if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCall */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* PyObjectCallNoArg */ + #if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* GetItemInt */ + static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* GetModuleGlobalName */ + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + if (likely(result)) { + Py_INCREF(result); + } else if (unlikely(PyErr_Occurred())) { + result = NULL; + } else { +#else + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#endif +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +/* ObjectGetItem */ + #if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + +/* PyIntBinop */ + #if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* SetItemInt */ + static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { + int r; + if (!j) return -1; + r = PyObject_SetItem(o, j, v); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, + CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); + if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { + PyObject* old = PyList_GET_ITEM(o, n); + Py_INCREF(v); + PyList_SET_ITEM(o, n, v); + Py_DECREF(old); + return 1; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_ass_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return -1; + PyErr_Clear(); + } + } + return m->sq_ass_item(o, i, v); + } + } +#else +#if CYTHON_COMPILING_IN_PYPY + if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { +#else + if (is_list || PySequence_Check(o)) { +#endif + return PySequence_SetItem(o, i, v); + } +#endif + return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); +} + +/* SliceObject */ + static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, + Py_ssize_t cstart, Py_ssize_t cstop, + PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, + int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { +#if CYTHON_USE_TYPE_SLOTS + PyMappingMethods* mp; +#if PY_MAJOR_VERSION < 3 + PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; + if (likely(ms && ms->sq_slice)) { + if (!has_cstart) { + if (_py_start && (*_py_start != Py_None)) { + cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); + if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstart = 0; + } + if (!has_cstop) { + if (_py_stop && (*_py_stop != Py_None)) { + cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); + if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; + } else + cstop = PY_SSIZE_T_MAX; + } + if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { + Py_ssize_t l = ms->sq_length(obj); + if (likely(l >= 0)) { + if (cstop < 0) { + cstop += l; + if (cstop < 0) cstop = 0; + } + if (cstart < 0) { + cstart += l; + if (cstart < 0) cstart = 0; + } + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + goto bad; + PyErr_Clear(); + } + } + return ms->sq_slice(obj, cstart, cstop); + } +#endif + mp = Py_TYPE(obj)->tp_as_mapping; + if (likely(mp && mp->mp_subscript)) +#endif + { + PyObject* result; + PyObject *py_slice, *py_start, *py_stop; + if (_py_slice) { + py_slice = *_py_slice; + } else { + PyObject* owned_start = NULL; + PyObject* owned_stop = NULL; + if (_py_start) { + py_start = *_py_start; + } else { + if (has_cstart) { + owned_start = py_start = PyInt_FromSsize_t(cstart); + if (unlikely(!py_start)) goto bad; + } else + py_start = Py_None; + } + if (_py_stop) { + py_stop = *_py_stop; + } else { + if (has_cstop) { + owned_stop = py_stop = PyInt_FromSsize_t(cstop); + if (unlikely(!py_stop)) { + Py_XDECREF(owned_start); + goto bad; + } + } else + py_stop = Py_None; + } + py_slice = PySlice_New(py_start, py_stop, Py_None); + Py_XDECREF(owned_start); + Py_XDECREF(owned_stop); + if (unlikely(!py_slice)) goto bad; + } +#if CYTHON_USE_TYPE_SLOTS + result = mp->mp_subscript(obj, py_slice); +#else + result = PyObject_GetItem(obj, py_slice); +#endif + if (!_py_slice) { + Py_DECREF(py_slice); + } + return result; + } + PyErr_Format(PyExc_TypeError, + "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); +bad: + return NULL; +} + +/* PyErrFetchRestore */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ + #if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* DictGetItem */ + #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseNoneIterError */ + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if PY_VERSION_HEX >= 0x030700A2 + *type = tstate->exc_state.exc_type; + *value = tstate->exc_state.exc_value; + *tb = tstate->exc_state.exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if PY_VERSION_HEX >= 0x030700A2 + tmp_type = tstate->exc_state.exc_type; + tmp_value = tstate->exc_state.exc_value; + tmp_tb = tstate->exc_state.exc_traceback; + tstate->exc_state.exc_type = type; + tstate->exc_state.exc_value = value; + tstate->exc_state.exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { +#endif + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if PY_VERSION_HEX >= 0x030700A2 + tmp_type = tstate->exc_state.exc_type; + tmp_value = tstate->exc_state.exc_value; + tmp_tb = tstate->exc_state.exc_traceback; + tstate->exc_state.exc_type = local_type; + tstate->exc_state.exc_value = local_value; + tstate->exc_state.exc_traceback = local_tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* Import */ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* CLineInTraceback */ + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (PyObject_Not(use_cline) != 0) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + if ((0)) {} + else if (__Pyx_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); + view->obj = NULL; + Py_DECREF(obj); +} +#endif + + + /* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(unsigned int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(unsigned int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(unsigned int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(unsigned int), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabsf(b.real) >= fabsf(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + float r = b.imag / b.real; + float s = 1.0 / (b.real + b.imag * r); + return __pyx_t_float_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + float r = b.real / b.imag; + float s = 1.0 / (b.imag + b.real * r); + return __pyx_t_float_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + float denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_float_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(a, a); + case 3: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, a); + case 4: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = powf(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2f(0, -1); + } + } else { + r = __Pyx_c_abs_float(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs(b.real) >= fabs(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + double r = b.imag / b.real; + double s = 1.0 / (b.real + b.imag * r); + return __pyx_t_double_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + double r = b.real / b.imag; + double s = 1.0 / (b.imag + b.real * r); + return __pyx_t_double_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + double denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_double_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(a, a); + case 3: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, a); + case 4: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = pow(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2(0, -1); + } + } else { + r = __Pyx_c_abs_double(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) -1, const_zero = (enum NPY_TYPES) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(enum NPY_TYPES) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(enum NPY_TYPES) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE unsigned int __Pyx_PyInt_As_unsigned_int(PyObject *x) { + const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(unsigned int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (unsigned int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, digits[0]) + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 2 * PyLong_SHIFT) { + return (unsigned int) (((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 3 * PyLong_SHIFT) { + return (unsigned int) (((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) >= 4 * PyLong_SHIFT) { + return (unsigned int) (((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (unsigned int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(unsigned int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (unsigned int) 0; + case -1: __PYX_VERIFY_RETURN_INT(unsigned int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(unsigned int, digit, +digits[0]) + case -2: + if (8 * sizeof(unsigned int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(unsigned int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + return (unsigned int) ((((((unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(unsigned int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(unsigned int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + return (unsigned int) ((((((((unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(unsigned int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) (((unsigned int)-1)*(((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(unsigned int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(unsigned int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(unsigned int) - 1 > 4 * PyLong_SHIFT) { + return (unsigned int) ((((((((((unsigned int)digits[3]) << PyLong_SHIFT) | (unsigned int)digits[2]) << PyLong_SHIFT) | (unsigned int)digits[1]) << PyLong_SHIFT) | (unsigned int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(unsigned int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(unsigned int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + unsigned int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (unsigned int) -1; + } + } else { + unsigned int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (unsigned int) -1; + val = __Pyx_PyInt_As_unsigned_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to unsigned int"); + return (unsigned int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned int"); + return (unsigned int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + +/* CheckBinaryVersion */ + static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* ModuleImport */ + #ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd", + module_name, class_name, basicsize, size); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +/* InitStrings */ + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(x); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.pyx b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.pyx new file mode 100644 index 000000000..c35f8f102 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/nms/src/soft_nms_cpu.pyx @@ -0,0 +1,127 @@ +# ---------------------------------------------------------- +# Soft-NMS: Improving Object Detection With One Line of Code +# Copyright (c) University of Maryland, College Park +# Licensed under The MIT License [see LICENSE for details] +# Written by Navaneeth Bodla and Bharat Singh +# Modified by Kai Chen +# ---------------------------------------------------------- + +# cython: language_level=3, boundscheck=False + +import numpy as np +cimport numpy as np + + +cdef inline np.float32_t max(np.float32_t a, np.float32_t b): + return a if a >= b else b + +cdef inline np.float32_t min(np.float32_t a, np.float32_t b): + return a if a <= b else b + + +def soft_nms_cpu( + np.ndarray[float, ndim=2] boxes_in, + float iou_thr, + unsigned int method=1, + float sigma=0.5, + float min_score=0.001, +): + boxes = boxes_in.copy() + cdef unsigned int N = boxes.shape[0] + cdef float iw, ih, box_area + cdef float ua + cdef int pos = 0 + cdef float maxscore = 0 + cdef int maxpos = 0 + cdef float x1, x2, y1, y2, tx1, tx2, ty1, ty2, ts, area, weight, ov + inds = np.arange(N) + + for i in range(N): + maxscore = boxes[i, 4] + maxpos = i + + tx1 = boxes[i, 0] + ty1 = boxes[i, 1] + tx2 = boxes[i, 2] + ty2 = boxes[i, 3] + ts = boxes[i, 4] + ti = inds[i] + + pos = i + 1 + # get max box + while pos < N: + if maxscore < boxes[pos, 4]: + maxscore = boxes[pos, 4] + maxpos = pos + pos = pos + 1 + + # add max box as a detection + boxes[i, 0] = boxes[maxpos, 0] + boxes[i, 1] = boxes[maxpos, 1] + boxes[i, 2] = boxes[maxpos, 2] + boxes[i, 3] = boxes[maxpos, 3] + boxes[i, 4] = boxes[maxpos, 4] + inds[i] = inds[maxpos] + + # swap ith box with position of max box + boxes[maxpos, 0] = tx1 + boxes[maxpos, 1] = ty1 + boxes[maxpos, 2] = tx2 + boxes[maxpos, 3] = ty2 + boxes[maxpos, 4] = ts + inds[maxpos] = ti + + tx1 = boxes[i, 0] + ty1 = boxes[i, 1] + tx2 = boxes[i, 2] + ty2 = boxes[i, 3] + ts = boxes[i, 4] + + pos = i + 1 + # NMS iterations, note that N changes if detection boxes fall below + # threshold + while pos < N: + x1 = boxes[pos, 0] + y1 = boxes[pos, 1] + x2 = boxes[pos, 2] + y2 = boxes[pos, 3] + s = boxes[pos, 4] + + area = (x2 - x1 + 1) * (y2 - y1 + 1) + iw = (min(tx2, x2) - max(tx1, x1) + 1) + if iw > 0: + ih = (min(ty2, y2) - max(ty1, y1) + 1) + if ih > 0: + ua = float((tx2 - tx1 + 1) * (ty2 - ty1 + 1) + area - iw * ih) + ov = iw * ih / ua # iou between max box and detection box + + if method == 1: # linear + if ov > iou_thr: + weight = 1 - ov + else: + weight = 1 + elif method == 2: # gaussian + weight = np.exp(-(ov * ov) / sigma) + else: # original NMS + if ov > iou_thr: + weight = 0 + else: + weight = 1 + + boxes[pos, 4] = weight * boxes[pos, 4] + + # if box score falls below threshold, discard the box by + # swapping with last box update N + if boxes[pos, 4] < min_score: + boxes[pos, 0] = boxes[N-1, 0] + boxes[pos, 1] = boxes[N-1, 1] + boxes[pos, 2] = boxes[N-1, 2] + boxes[pos, 3] = boxes[N-1, 3] + boxes[pos, 4] = boxes[N-1, 4] + inds[pos] = inds[N - 1] + N = N - 1 + pos = pos - 1 + + pos = pos + 1 + + return boxes[:N], inds[:N] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py new file mode 100644 index 000000000..6da98298f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/__init__.py @@ -0,0 +1,3 @@ +from .roi_align import RoIAlign, roi_align + +__all__ = ['roi_align', 'RoIAlign'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/roi_align.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/roi_align.py new file mode 100644 index 000000000..096badd25 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/functions/roi_align.py @@ -0,0 +1,61 @@ +from torch.autograd import Function + +from .. import roi_align_cuda + + +class RoIAlignFunction(Function): + + @staticmethod + def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0): + if isinstance(out_size, int): + out_h = out_size + out_w = out_size + elif isinstance(out_size, tuple): + assert len(out_size) == 2 + assert isinstance(out_size[0], int) + assert isinstance(out_size[1], int) + out_h, out_w = out_size + else: + raise TypeError( + '"out_size" must be an integer or tuple of integers') + ctx.spatial_scale = spatial_scale + ctx.sample_num = sample_num + ctx.save_for_backward(rois) + ctx.feature_size = features.size() + + batch_size, num_channels, data_height, data_width = features.size() + num_rois = rois.size(0) + + output = features.new_zeros(num_rois, num_channels, out_h, out_w) + if features.is_cuda: + roi_align_cuda.forward(features, rois, out_h, out_w, spatial_scale, + sample_num, output) + else: + raise NotImplementedError + + return output + + @staticmethod + def backward(ctx, grad_output): + feature_size = ctx.feature_size + spatial_scale = ctx.spatial_scale + sample_num = ctx.sample_num + rois = ctx.saved_tensors[0] + assert (feature_size is not None and grad_output.is_cuda) + + batch_size, num_channels, data_height, data_width = feature_size + out_w = grad_output.size(3) + out_h = grad_output.size(2) + + grad_input = grad_rois = None + if ctx.needs_input_grad[0]: + grad_input = rois.new_zeros(batch_size, num_channels, data_height, + data_width) + roi_align_cuda.backward(grad_output.contiguous(), rois, out_h, + out_w, spatial_scale, sample_num, + grad_input) + + return grad_input, grad_rois, None, None, None + + +roi_align = RoIAlignFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/gradcheck.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/gradcheck.py new file mode 100644 index 000000000..136456b39 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/gradcheck.py @@ -0,0 +1,30 @@ +import os.path as osp +import sys + +import numpy as np +import torch +from torch.autograd import gradcheck + +sys.path.append(osp.abspath(osp.join(__file__, '../../'))) +from roi_align import RoIAlign # noqa: E402, isort:skip + +feat_size = 15 +spatial_scale = 1.0 / 8 +img_size = feat_size / spatial_scale +num_imgs = 2 +num_rois = 20 + +batch_ind = np.random.randint(num_imgs, size=(num_rois, 1)) +rois = np.random.rand(num_rois, 4) * img_size * 0.5 +rois[:, 2:] += img_size * 0.5 +rois = np.hstack((batch_ind, rois)) + +feat = torch.randn( + num_imgs, 16, feat_size, feat_size, requires_grad=True, device='cuda:0') +rois = torch.from_numpy(rois).float().cuda() +inputs = (feat, rois) +print('Gradcheck for roi align...') +test = gradcheck(RoIAlign(3, spatial_scale), inputs, atol=1e-3, eps=1e-3) +print(test) +test = gradcheck(RoIAlign(3, spatial_scale, 2), inputs, atol=1e-3, eps=1e-3) +print(test) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py new file mode 100644 index 000000000..b83b74e6b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/modules/roi_align.py @@ -0,0 +1,16 @@ +from torch.nn.modules.module import Module +from ..functions.roi_align import RoIAlignFunction + + +class RoIAlign(Module): + + def __init__(self, out_size, spatial_scale, sample_num=0): + super(RoIAlign, self).__init__() + + self.out_size = out_size + self.spatial_scale = float(spatial_scale) + self.sample_num = int(sample_num) + + def forward(self, features, rois): + return RoIAlignFunction.apply(features, rois, self.out_size, + self.spatial_scale, self.sample_num) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/roi_align.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/roi_align.py new file mode 100644 index 000000000..a4cf24459 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/roi_align.py @@ -0,0 +1,87 @@ +import torch.nn as nn +from torch.autograd import Function +from torch.autograd.function import once_differentiable +from torch.nn.modules.utils import _pair + +from . import roi_align_cuda + + +class RoIAlignFunction(Function): + + @staticmethod + def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0): + out_h, out_w = _pair(out_size) + assert isinstance(out_h, int) and isinstance(out_w, int) + ctx.spatial_scale = spatial_scale + ctx.sample_num = sample_num + ctx.save_for_backward(rois) + ctx.feature_size = features.size() + + batch_size, num_channels, data_height, data_width = features.size() + num_rois = rois.size(0) + + output = features.new_zeros(num_rois, num_channels, out_h, out_w) + if features.is_cuda: + roi_align_cuda.forward(features, rois, out_h, out_w, spatial_scale, + sample_num, output) + else: + raise NotImplementedError + + return output + + @staticmethod + @once_differentiable + def backward(ctx, grad_output): + feature_size = ctx.feature_size + spatial_scale = ctx.spatial_scale + sample_num = ctx.sample_num + rois = ctx.saved_tensors[0] + assert (feature_size is not None and grad_output.is_cuda) + + batch_size, num_channels, data_height, data_width = feature_size + out_w = grad_output.size(3) + out_h = grad_output.size(2) + + grad_input = grad_rois = None + if ctx.needs_input_grad[0]: + grad_input = rois.new_zeros(batch_size, num_channels, data_height, + data_width) + roi_align_cuda.backward(grad_output.contiguous(), rois, out_h, + out_w, spatial_scale, sample_num, + grad_input) + + return grad_input, grad_rois, None, None, None + + +roi_align = RoIAlignFunction.apply + + +class RoIAlign(nn.Module): + + def __init__(self, + out_size, + spatial_scale, + sample_num=0, + use_torchvision=False): + super(RoIAlign, self).__init__() + + self.out_size = _pair(out_size) + self.spatial_scale = float(spatial_scale) + self.sample_num = int(sample_num) + self.use_torchvision = use_torchvision + + def forward(self, features, rois): + if self.use_torchvision: + from torchvision.ops import roi_align as tv_roi_align + return tv_roi_align(features, rois, self.out_size, + self.spatial_scale, self.sample_num) + else: + return roi_align(features, rois, self.out_size, self.spatial_scale, + self.sample_num) + + def __repr__(self): + format_str = self.__class__.__name__ + format_str += '(out_size={}, spatial_scale={}, sample_num={}'.format( + self.out_size, self.spatial_scale, self.sample_num) + format_str += ', use_torchvision={})'.format(self.use_torchvision) + return format_str diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/setup.py new file mode 100644 index 000000000..f02a5ea30 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +setup( + name='roi_align_cuda', + ext_modules=[ + CUDAExtension('roi_align_cuda', [ + 'src/roi_align_cuda.cpp', + 'src/roi_align_kernel.cu', + ]), + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_cuda.cpp new file mode 100644 index 000000000..017f95dde --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_cuda.cpp @@ -0,0 +1,85 @@ +#include + +#include +#include + +int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor output); + +int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor bottom_grad); + +#define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int roi_align_forward_cuda(at::Tensor features, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, int sample_num, + at::Tensor output) { + CHECK_INPUT(features); + CHECK_INPUT(rois); + CHECK_INPUT(output); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int num_channels = features.size(1); + int data_height = features.size(2); + int data_width = features.size(3); + + ROIAlignForwardLaucher(features, rois, spatial_scale, sample_num, + num_channels, data_height, data_width, num_rois, + pooled_height, pooled_width, output); + + return 1; +} + +int roi_align_backward_cuda(at::Tensor top_grad, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, int sample_num, + at::Tensor bottom_grad) { + CHECK_INPUT(top_grad); + CHECK_INPUT(rois); + CHECK_INPUT(bottom_grad); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int num_channels = bottom_grad.size(1); + int data_height = bottom_grad.size(2); + int data_width = bottom_grad.size(3); + + ROIAlignBackwardLaucher(top_grad, rois, spatial_scale, sample_num, + num_channels, data_height, data_width, num_rois, + pooled_height, pooled_width, bottom_grad); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &roi_align_forward_cuda, "Roi_Align forward (CUDA)"); + m.def("backward", &roi_align_backward_cuda, "Roi_Align backward (CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_kernel.cu new file mode 100644 index 000000000..eb7cdaf1f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_align/src/roi_align_kernel.cu @@ -0,0 +1,282 @@ +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return min(optimal_block_num, max_block_num); +} + +template +__device__ scalar_t bilinear_interpolate(const scalar_t *bottom_data, + const int height, const int width, + scalar_t y, scalar_t x) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + return 0; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + int y_low = (int)y; + int x_low = (int)x; + int y_high; + int x_high; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (scalar_t)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (scalar_t)x_low; + } else { + x_high = x_low + 1; + } + + scalar_t ly = y - y_low; + scalar_t lx = x - x_low; + scalar_t hy = 1. - ly; + scalar_t hx = 1. - lx; + // do bilinear interpolation + scalar_t lt = bottom_data[y_low * width + x_low]; + scalar_t rt = bottom_data[y_low * width + x_high]; + scalar_t lb = bottom_data[y_high * width + x_low]; + scalar_t rb = bottom_data[y_high * width + x_high]; + scalar_t w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + scalar_t val = (w1 * lt + w2 * rt + w3 * lb + w4 * rb); + + return val; +} + +template +__global__ void ROIAlignForward(const int nthreads, const scalar_t *bottom_data, + const scalar_t *bottom_rois, + const scalar_t spatial_scale, + const int sample_num, const int channels, + const int height, const int width, + const int pooled_height, const int pooled_width, + scalar_t *top_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the aligned output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; + scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; + scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; + scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; + + // Force malformed ROIs to be 1x1 + scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); + scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); + + scalar_t bin_size_h = roi_height / pooled_height; + scalar_t bin_size_w = roi_width / pooled_width; + + const scalar_t *offset_bottom_data = + bottom_data + (roi_batch_ind * channels + c) * height * width; + + int sample_num_h = (sample_num > 0) + ? sample_num + : ceil(roi_height / pooled_height); // e.g., = 2 + int sample_num_w = + (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); + + scalar_t output_val = 0; + for (int iy = 0; iy < sample_num_h; iy++) { + const scalar_t y = roi_start_h + ph * bin_size_h + + (scalar_t)(iy + scalar_t(.5f)) * bin_size_h / + (scalar_t)(sample_num_h); + for (int ix = 0; ix < sample_num_w; ix++) { + const scalar_t x = roi_start_w + pw * bin_size_w + + (scalar_t)(ix + scalar_t(.5f)) * bin_size_w / + (scalar_t)(sample_num_w); + scalar_t val = bilinear_interpolate(offset_bottom_data, + height, width, y, x); + output_val += val; + } + } + output_val /= (sample_num_h * sample_num_w); + top_data[index] = output_val; + } +} + +int ROIAlignForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor output) { + const int output_size = num_rois * pooled_height * pooled_width * channels; + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + features.scalar_type(), "ROIAlignLaucherForward", ([&] { + const scalar_t *bottom_data = features.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *top_data = output.data(); + + ROIAlignForward + <<>>( + output_size, bottom_data, rois_data, scalar_t(spatial_scale), + sample_num, channels, height, width, pooled_height, + pooled_width, top_data); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__device__ void bilinear_interpolate_gradient(const int height, const int width, + scalar_t y, scalar_t x, + scalar_t &w1, scalar_t &w2, + scalar_t &w3, scalar_t &w4, + int &x_low, int &x_high, + int &y_low, int &y_high) { + // deal with cases that inverse elements are out of feature map boundary + if (y < -1.0 || y > height || x < -1.0 || x > width) { + w1 = w2 = w3 = w4 = 0.; + x_low = x_high = y_low = y_high = -1; + return; + } + + if (y <= 0) y = 0; + if (x <= 0) x = 0; + + y_low = (int)y; + x_low = (int)x; + + if (y_low >= height - 1) { + y_high = y_low = height - 1; + y = (scalar_t)y_low; + } else { + y_high = y_low + 1; + } + + if (x_low >= width - 1) { + x_high = x_low = width - 1; + x = (scalar_t)x_low; + } else { + x_high = x_low + 1; + } + + scalar_t ly = y - y_low; + scalar_t lx = x - x_low; + scalar_t hy = 1. - ly; + scalar_t hx = 1. - lx; + + w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + + return; +} + +template +__global__ void ROIAlignBackward( + const int nthreads, const scalar_t *top_diff, const scalar_t *bottom_rois, + const scalar_t spatial_scale, const int sample_num, const int channels, + const int height, const int width, const int pooled_height, + const int pooled_width, scalar_t *bottom_diff) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the aligned output + int pw = index % pooled_width; + int ph = (index / pooled_width) % pooled_height; + int c = (index / pooled_width / pooled_height) % channels; + int n = index / pooled_width / pooled_height / channels; + + const scalar_t *offset_bottom_rois = bottom_rois + n * 5; + int roi_batch_ind = offset_bottom_rois[0]; + scalar_t roi_start_w = offset_bottom_rois[1] * spatial_scale; + scalar_t roi_start_h = offset_bottom_rois[2] * spatial_scale; + scalar_t roi_end_w = (offset_bottom_rois[3] + 1) * spatial_scale; + scalar_t roi_end_h = (offset_bottom_rois[4] + 1) * spatial_scale; + + // Force malformed ROIs to be 1x1 + scalar_t roi_width = fmaxf((scalar_t)roi_end_w - roi_start_w, 0.); + scalar_t roi_height = fmaxf((scalar_t)roi_end_h - roi_start_h, 0.); + + scalar_t bin_size_h = roi_height / pooled_height; + scalar_t bin_size_w = roi_width / pooled_width; + + scalar_t *offset_bottom_diff = + bottom_diff + (roi_batch_ind * channels + c) * height * width; + int offset_top = (n * channels + c) * pooled_height * pooled_width + + ph * pooled_width + pw; + scalar_t offset_top_diff = top_diff[offset_top]; + + int sample_num_h = (sample_num > 0) + ? sample_num + : ceil(roi_height / pooled_height); // e.g., = 2 + int sample_num_w = + (sample_num > 0) ? sample_num : ceil(roi_width / pooled_width); + + const scalar_t count = (scalar_t)(sample_num_h * sample_num_w); + + for (int iy = 0; iy < sample_num_h; iy++) { + const scalar_t y = + roi_start_h + ph * bin_size_h + + (scalar_t)(iy + .5f) * bin_size_h / (scalar_t)(sample_num_h); + for (int ix = 0; ix < sample_num_w; ix++) { + const scalar_t x = + roi_start_w + pw * bin_size_w + + (scalar_t)(ix + .5f) * bin_size_w / (scalar_t)(sample_num_w); + scalar_t w1, w2, w3, w4; + int x_low, x_high, y_low, y_high; + + bilinear_interpolate_gradient( + height, width, y, x, w1, w2, w3, w4, x_low, x_high, y_low, y_high); + scalar_t g1 = offset_top_diff * w1 / count; + scalar_t g2 = offset_top_diff * w2 / count; + scalar_t g3 = offset_top_diff * w3 / count; + scalar_t g4 = offset_top_diff * w4 / count; + if (x_low >= 0 && x_high >= 0 && y_low >= 0 && y_high >= 0) { + atomicAdd(offset_bottom_diff + y_low * width + x_low, g1); + atomicAdd(offset_bottom_diff + y_low * width + x_high, g2); + atomicAdd(offset_bottom_diff + y_high * width + x_low, g3); + atomicAdd(offset_bottom_diff + y_high * width + x_high, g4); + } + } + } + } +} + +int ROIAlignBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const float spatial_scale, const int sample_num, + const int channels, const int height, + const int width, const int num_rois, + const int pooled_height, const int pooled_width, + at::Tensor bottom_grad) { + const int output_size = num_rois * pooled_height * pooled_width * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + top_grad.scalar_type(), "ROIAlignLaucherBackward", ([&] { + const scalar_t *top_diff = top_grad.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *bottom_diff = bottom_grad.data(); + if (sizeof(scalar_t) == sizeof(double)) { + fprintf(stderr, "double is not supported\n"); + exit(-1); + } + + ROIAlignBackward + <<>>( + output_size, top_diff, rois_data, spatial_scale, sample_num, + channels, height, width, pooled_height, pooled_width, + bottom_diff); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/__init__.py new file mode 100644 index 000000000..eb2c57eab --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/__init__.py @@ -0,0 +1,4 @@ +from .functions.roi_pool import roi_pool +from .modules.roi_pool import RoIPool + +__all__ = ['roi_pool', 'RoIPool'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py new file mode 100644 index 000000000..068da600e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/functions/roi_pool.py @@ -0,0 +1,55 @@ +import torch +from torch.autograd import Function + +from .. import roi_pool_cuda + + +class RoIPoolFunction(Function): + + @staticmethod + def forward(ctx, features, rois, out_size, spatial_scale): + if isinstance(out_size, int): + out_h = out_size + out_w = out_size + elif isinstance(out_size, tuple): + assert len(out_size) == 2 + assert isinstance(out_size[0], int) + assert isinstance(out_size[1], int) + out_h, out_w = out_size + else: + raise TypeError( + '"out_size" must be an integer or tuple of integers') + assert features.is_cuda + ctx.save_for_backward(rois) + num_channels = features.size(1) + num_rois = rois.size(0) + out_size = (num_rois, num_channels, out_h, out_w) + output = features.new_zeros(out_size) + argmax = features.new_zeros(out_size, dtype=torch.int) + roi_pool_cuda.forward(features, rois, out_h, out_w, spatial_scale, + output, argmax) + ctx.spatial_scale = spatial_scale + ctx.feature_size = features.size() + ctx.argmax = argmax + + return output + + @staticmethod + def backward(ctx, grad_output): + assert grad_output.is_cuda + spatial_scale = ctx.spatial_scale + feature_size = ctx.feature_size + argmax = ctx.argmax + rois = ctx.saved_tensors[0] + assert feature_size is not None + + grad_input = grad_rois = None + if ctx.needs_input_grad[0]: + grad_input = grad_output.new_zeros(feature_size) + roi_pool_cuda.backward(grad_output.contiguous(), rois, argmax, + spatial_scale, grad_input) + + return grad_input, grad_rois, None, None + + +roi_pool = RoIPoolFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/gradcheck.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/gradcheck.py new file mode 100644 index 000000000..c39616086 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/gradcheck.py @@ -0,0 +1,15 @@ +import torch +from torch.autograd import gradcheck + +import os.path as osp +import sys +sys.path.append(osp.abspath(osp.join(__file__, '../../'))) +from roi_pool import RoIPool # noqa: E402 + +feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda() +rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55], + [1, 67, 40, 110, 120]]).cuda() +inputs = (feat, rois) +print('Gradcheck for roi pooling...') +test = gradcheck(RoIPool(4, 1.0 / 8), inputs, eps=1e-5, atol=1e-3) +print(test) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/roi_pool.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/roi_pool.py new file mode 100644 index 000000000..d7fffd08c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/modules/roi_pool.py @@ -0,0 +1,14 @@ +from torch.nn.modules.module import Module +from ..functions.roi_pool import roi_pool + + +class RoIPool(Module): + + def __init__(self, out_size, spatial_scale): + super(RoIPool, self).__init__() + + self.out_size = out_size + self.spatial_scale = float(spatial_scale) + + def forward(self, features, rois): + return roi_pool(features, rois, self.out_size, self.spatial_scale) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py new file mode 100644 index 000000000..16991b889 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +setup( + name='roi_pool', + ext_modules=[ + CUDAExtension('roi_pool_cuda', [ + 'src/roi_pool_cuda.cpp', + 'src/roi_pool_kernel.cu', + ]) + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp new file mode 100644 index 000000000..7818aa784 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp @@ -0,0 +1,86 @@ +#include + +#include +#include + +int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int channels, + const int height, const int width, const int num_rois, + const int pooled_h, const int pooled_w, + at::Tensor output, at::Tensor argmax); + +int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const at::Tensor argmax, const float spatial_scale, + const int batch_size, const int channels, + const int height, const int width, + const int num_rois, const int pooled_h, + const int pooled_w, at::Tensor bottom_grad); + +#define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") +#define CHECK_CONTIGUOUS(x) \ + TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ") +#define CHECK_INPUT(x) \ + CHECK_CUDA(x); \ + CHECK_CONTIGUOUS(x) + +int roi_pooling_forward_cuda(at::Tensor features, at::Tensor rois, + int pooled_height, int pooled_width, + float spatial_scale, at::Tensor output, + at::Tensor argmax) { + CHECK_INPUT(features); + CHECK_INPUT(rois); + CHECK_INPUT(output); + CHECK_INPUT(argmax); + + // Number of ROIs + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + + int channels = features.size(1); + int height = features.size(2); + int width = features.size(3); + + ROIPoolForwardLaucher(features, rois, spatial_scale, channels, height, width, + num_rois, pooled_height, pooled_width, output, argmax); + + return 1; +} + +int roi_pooling_backward_cuda(at::Tensor top_grad, at::Tensor rois, + at::Tensor argmax, float spatial_scale, + at::Tensor bottom_grad) { + CHECK_INPUT(top_grad); + CHECK_INPUT(rois); + CHECK_INPUT(argmax); + CHECK_INPUT(bottom_grad); + + int pooled_height = top_grad.size(2); + int pooled_width = top_grad.size(3); + int num_rois = rois.size(0); + int size_rois = rois.size(1); + + if (size_rois != 5) { + printf("wrong roi size\n"); + return 0; + } + int batch_size = bottom_grad.size(0); + int channels = bottom_grad.size(1); + int height = bottom_grad.size(2); + int width = bottom_grad.size(3); + + ROIPoolBackwardLaucher(top_grad, rois, argmax, spatial_scale, batch_size, + channels, height, width, num_rois, pooled_height, + pooled_width, bottom_grad); + + return 1; +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &roi_pooling_forward_cuda, "Roi_Pooling forward (CUDA)"); + m.def("backward", &roi_pooling_backward_cuda, "Roi_Pooling backward (CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_kernel.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_kernel.cu new file mode 100644 index 000000000..b51bb043c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_kernel.cu @@ -0,0 +1,156 @@ +#include +#include + +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +#define THREADS_PER_BLOCK 1024 + +inline int GET_BLOCKS(const int N) { + int optimal_block_num = (N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK; + int max_block_num = 65000; + return min(optimal_block_num, max_block_num); +} + +template +__global__ void ROIPoolForward(const int nthreads, const scalar_t *bottom_data, + const scalar_t *rois, + const scalar_t spatial_scale, const int channels, + const int height, const int width, + const int pooled_h, const int pooled_w, + scalar_t *top_data, int *argmax_data) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + // (n, c, ph, pw) is an element in the pooled output + int pw = index % pooled_w; + int ph = (index / pooled_w) % pooled_h; + int c = (index / pooled_w / pooled_h) % channels; + int n = index / pooled_w / pooled_h / channels; + + const scalar_t *offset_rois = rois + n * 5; + int roi_batch_ind = offset_rois[0]; + // calculate the roi region on feature maps + scalar_t roi_x1 = offset_rois[1] * spatial_scale; + scalar_t roi_y1 = offset_rois[2] * spatial_scale; + scalar_t roi_x2 = (offset_rois[3] + 1) * spatial_scale; + scalar_t roi_y2 = (offset_rois[4] + 1) * spatial_scale; + + // force malformed rois to be 1x1 + scalar_t roi_w = roi_x2 - roi_x1; + scalar_t roi_h = roi_y2 - roi_y1; + if (roi_w <= 0 || roi_h <= 0) continue; + + scalar_t bin_size_w = roi_w / static_cast(pooled_w); + scalar_t bin_size_h = roi_h / static_cast(pooled_h); + + // the corresponding bin region + int bin_x1 = floor(static_cast(pw) * bin_size_w + roi_x1); + int bin_y1 = floor(static_cast(ph) * bin_size_h + roi_y1); + int bin_x2 = ceil(static_cast(pw + 1) * bin_size_w + roi_x1); + int bin_y2 = ceil(static_cast(ph + 1) * bin_size_h + roi_y1); + + // add roi offsets and clip to input boundaries + bin_x1 = min(max(bin_x1, 0), width); + bin_y1 = min(max(bin_y1, 0), height); + bin_x2 = min(max(bin_x2, 0), width); + bin_y2 = min(max(bin_y2, 0), height); + bool is_empty = (bin_y2 <= bin_y1) || (bin_x2 <= bin_x1); + + // If nothing is pooled, argmax = -1 causes nothing to be backprop'd + int max_idx = -1; + bottom_data += (roi_batch_ind * channels + c) * height * width; + + // Define an empty pooling region to be zero + scalar_t max_val = is_empty ? static_cast(0) + : bottom_data[bin_y1 * width + bin_x1] - 1; + + for (int h = bin_y1; h < bin_y2; ++h) { + for (int w = bin_x1; w < bin_x2; ++w) { + int offset = h * width + w; + if (bottom_data[offset] > max_val) { + max_val = bottom_data[offset]; + max_idx = offset; + } + } + } + top_data[index] = max_val; + if (argmax_data != NULL) argmax_data[index] = max_idx; + } +} + +int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, + const float spatial_scale, const int channels, + const int height, const int width, const int num_rois, + const int pooled_h, const int pooled_w, + at::Tensor output, at::Tensor argmax) { + const int output_size = num_rois * channels * pooled_h * pooled_w; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + features.type(), "ROIPoolLaucherForward", ([&] { + const scalar_t *bottom_data = features.data(); + const scalar_t *rois_data = rois.data(); + scalar_t *top_data = output.data(); + int *argmax_data = argmax.data(); + + ROIPoolForward + <<>>( + output_size, bottom_data, rois_data, scalar_t(spatial_scale), + channels, height, width, pooled_h, pooled_w, top_data, + argmax_data); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} + +template +__global__ void ROIPoolBackward(const int nthreads, const scalar_t *top_diff, + const scalar_t *rois, const int *argmax_data, + const scalar_t spatial_scale, + const int channels, const int height, + const int width, const int pooled_h, + const int pooled_w, scalar_t *bottom_diff) { + CUDA_1D_KERNEL_LOOP(index, nthreads) { + int pw = index % pooled_w; + int ph = (index / pooled_w) % pooled_h; + int c = (index / pooled_w / pooled_h) % channels; + int n = index / pooled_w / pooled_h / channels; + + int roi_batch_ind = rois[n * 5]; + int bottom_index = argmax_data[(n * channels + c) * pooled_h * pooled_w + + ph * pooled_w + pw]; + + atomicAdd(bottom_diff + (roi_batch_ind * channels + c) * height * width + + bottom_index, + top_diff[index]); + } +} + +int ROIPoolBackwardLaucher(const at::Tensor top_grad, const at::Tensor rois, + const at::Tensor argmax, const float spatial_scale, + const int batch_size, const int channels, + const int height, const int width, + const int num_rois, const int pooled_h, + const int pooled_w, at::Tensor bottom_grad) { + const int output_size = num_rois * pooled_h * pooled_w * channels; + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + top_grad.type(), "ROIPoolLaucherBackward", ([&] { + const scalar_t *top_diff = top_grad.data(); + const scalar_t *rois_data = rois.data(); + const int *argmax_data = argmax.data(); + scalar_t *bottom_diff = bottom_grad.data(); + + if (sizeof(scalar_t) == sizeof(double)) { + fprintf(stderr, "double is not supported\n"); + exit(-1); + } + + ROIPoolBackward + <<>>( + output_size, top_diff, rois_data, argmax_data, + scalar_t(spatial_scale), channels, height, width, pooled_h, + pooled_w, bottom_diff); + })); + THCudaCheck(cudaGetLastError()); + return 1; +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/__init__.py new file mode 100644 index 000000000..71058ad9a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/__init__.py @@ -0,0 +1,3 @@ +from .modules.sigmoid_focal_loss import SigmoidFocalLoss, sigmoid_focal_loss + +__all__ = ['SigmoidFocalLoss', 'sigmoid_focal_loss'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py new file mode 100644 index 000000000..e690f7630 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/functions/sigmoid_focal_loss.py @@ -0,0 +1,34 @@ +from torch.autograd import Function +from torch.autograd.function import once_differentiable + +from .. import sigmoid_focal_loss_cuda + + +class SigmoidFocalLossFunction(Function): + + @staticmethod + def forward(ctx, input, target, gamma=2.0, alpha=0.25): + ctx.save_for_backward(input, target) + num_classes = input.shape[1] + ctx.num_classes = num_classes + ctx.gamma = gamma + ctx.alpha = alpha + + loss = sigmoid_focal_loss_cuda.forward(input, target, num_classes, + gamma, alpha) + return loss + + @staticmethod + @once_differentiable + def backward(ctx, d_loss): + input, target = ctx.saved_tensors + num_classes = ctx.num_classes + gamma = ctx.gamma + alpha = ctx.alpha + d_loss = d_loss.contiguous() + d_input = sigmoid_focal_loss_cuda.backward(input, target, d_loss, + num_classes, gamma, alpha) + return d_input, None, None, None, None + + +sigmoid_focal_loss = SigmoidFocalLossFunction.apply diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py new file mode 100644 index 000000000..34202b566 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/modules/sigmoid_focal_loss.py @@ -0,0 +1,24 @@ +from torch import nn + +from ..functions.sigmoid_focal_loss import sigmoid_focal_loss + + +# TODO: remove this module +class SigmoidFocalLoss(nn.Module): + + def __init__(self, gamma, alpha): + super(SigmoidFocalLoss, self).__init__() + self.gamma = gamma + self.alpha = alpha + + def forward(self, logits, targets): + assert logits.is_cuda + loss = sigmoid_focal_loss(logits, targets, self.gamma, self.alpha) + return loss.sum() + + def __repr__(self): + tmpstr = self.__class__.__name__ + "(" + tmpstr += "gamma=" + str(self.gamma) + tmpstr += ", alpha=" + str(self.alpha) + tmpstr += ")" + return tmpstr diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/setup.py new file mode 100644 index 000000000..a70c65454 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +from torch.utils.cpp_extension import BuildExtension, CUDAExtension + +setup( + name='SigmoidFocalLoss', + ext_modules=[ + CUDAExtension('sigmoid_focal_loss_cuda', [ + 'src/sigmoid_focal_loss.cpp', + 'src/sigmoid_focal_loss_cuda.cu', + ]), + ], + cmdclass={'build_ext': BuildExtension}) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp new file mode 100644 index 000000000..20427518d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss.cpp @@ -0,0 +1,43 @@ +// modify from +// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/SigmoidFocalLoss.h +#include + +at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, + const float gamma, const float alpha); + +at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, + const float gamma, const float alpha); + +// Interface for Python +at::Tensor SigmoidFocalLoss_forward(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, const float gamma, + const float alpha) { + if (logits.type().is_cuda()) { + return SigmoidFocalLoss_forward_cuda(logits, targets, num_classes, gamma, + alpha); + } +} + +at::Tensor SigmoidFocalLoss_backward(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, const float gamma, + const float alpha) { + if (logits.type().is_cuda()) { + return SigmoidFocalLoss_backward_cuda(logits, targets, d_losses, + num_classes, gamma, alpha); + } +} + +PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { + m.def("forward", &SigmoidFocalLoss_forward, + "SigmoidFocalLoss forward (CUDA)"); + m.def("backward", &SigmoidFocalLoss_backward, + "SigmoidFocalLoss backward (CUDA)"); +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu new file mode 100644 index 000000000..aa1e4b9d8 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu @@ -0,0 +1,169 @@ +// modify from +// https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu + +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. +// This file is modified from +// https://github.com/pytorch/pytorch/blob/master/modules/detectron/sigmoid_focal_loss_op.cu +// Cheng-Yang Fu +// cyfu@cs.unc.edu +#include +#include + +#include +#include +#include + +#include + +// TODO make it in a common file +#define CUDA_1D_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; \ + i += blockDim.x * gridDim.x) + +template +__global__ void SigmoidFocalLossForward(const int nthreads, + const scalar_t *logits, + const long *targets, + const int num_classes, + const float gamma, const float alpha, + const int num, scalar_t *losses) { + CUDA_1D_KERNEL_LOOP(i, nthreads) { + int n = i / num_classes; + int d = i % num_classes; // current class[0~79]; + int t = targets[n]; // target class [1~80]; + + // Decide it is positive or negative case. + scalar_t c1 = (t == (d + 1)); + scalar_t c2 = (t >= 0 & t != (d + 1)); + + scalar_t zn = (1.0 - alpha); + scalar_t zp = (alpha); + + // p = 1. / 1. + expf(-x); p = sigmoid(x) + scalar_t p = 1. / (1. + expf(-logits[i])); + + // (1-p)**gamma * log(p) where + scalar_t term1 = powf((1. - p), gamma) * logf(max(p, FLT_MIN)); + + // p**gamma * log(1-p) + scalar_t term2 = + powf(p, gamma) * + (-1. * logits[i] * (logits[i] >= 0) - + logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))); + + losses[i] = 0.0; + losses[i] += -c1 * term1 * zp; + losses[i] += -c2 * term2 * zn; + + } // CUDA_1D_KERNEL_LOOP +} // SigmoidFocalLossForward + +template +__global__ void SigmoidFocalLossBackward( + const int nthreads, const scalar_t *logits, const long *targets, + const scalar_t *d_losses, const int num_classes, const float gamma, + const float alpha, const int num, scalar_t *d_logits) { + CUDA_1D_KERNEL_LOOP(i, nthreads) { + int n = i / num_classes; + int d = i % num_classes; // current class[0~79]; + int t = targets[n]; // target class [1~80], 0 is background; + + // Decide it is positive or negative case. + scalar_t c1 = (t == (d + 1)); + scalar_t c2 = (t >= 0 & t != (d + 1)); + + scalar_t zn = (1.0 - alpha); + scalar_t zp = (alpha); + // p = 1. / 1. + expf(-x); p = sigmoid(x) + scalar_t p = 1. / (1. + expf(-logits[i])); + + // (1-p)**g * (1 - p - g*p*log(p) + scalar_t term1 = + powf((1. - p), gamma) * (1. - p - (p * gamma * logf(max(p, FLT_MIN)))); + + // (p**g) * (g*(1-p)*log(1-p) - p) + scalar_t term2 = + powf(p, gamma) * + ((-1. * logits[i] * (logits[i] >= 0) - + logf(1. + expf(logits[i] - 2. * logits[i] * (logits[i] >= 0)))) * + (1. - p) * gamma - + p); + d_logits[i] = 0.0; + d_logits[i] += -c1 * term1 * zp; + d_logits[i] += -c2 * term2 * zn; + d_logits[i] = d_logits[i] * d_losses[i]; + + } // CUDA_1D_KERNEL_LOOP +} // SigmoidFocalLossBackward + +at::Tensor SigmoidFocalLoss_forward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const int num_classes, + const float gamma, const float alpha) { + AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); + AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); + AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); + + const int num_samples = logits.size(0); + + auto losses = at::empty({num_samples, logits.size(1)}, logits.options()); + auto losses_size = num_samples * logits.size(1); + + dim3 grid(std::min(THCCeilDiv(losses_size, 512L), 4096L)); + dim3 block(512); + + if (losses.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return losses; + } + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + logits.type(), "SigmoidFocalLoss_forward", [&] { + SigmoidFocalLossForward<<>>( + losses_size, logits.contiguous().data(), + targets.contiguous().data(), num_classes, gamma, alpha, + num_samples, losses.data()); + }); + THCudaCheck(cudaGetLastError()); + return losses; +} + +at::Tensor SigmoidFocalLoss_backward_cuda(const at::Tensor &logits, + const at::Tensor &targets, + const at::Tensor &d_losses, + const int num_classes, + const float gamma, + const float alpha) { + AT_ASSERTM(logits.type().is_cuda(), "logits must be a CUDA tensor"); + AT_ASSERTM(targets.type().is_cuda(), "targets must be a CUDA tensor"); + AT_ASSERTM(d_losses.type().is_cuda(), "d_losses must be a CUDA tensor"); + + AT_ASSERTM(logits.dim() == 2, "logits should be NxClass"); + + const int num_samples = logits.size(0); + AT_ASSERTM(logits.size(1) == num_classes, + "logits.size(1) should be num_classes"); + + auto d_logits = at::zeros({num_samples, num_classes}, logits.options()); + auto d_logits_size = num_samples * logits.size(1); + + dim3 grid(std::min(THCCeilDiv(d_logits_size, 512L), 4096L)); + dim3 block(512); + + if (d_logits.numel() == 0) { + THCudaCheck(cudaGetLastError()); + return d_logits; + } + + AT_DISPATCH_FLOATING_TYPES_AND_HALF( + logits.type(), "SigmoidFocalLoss_backward", [&] { + SigmoidFocalLossBackward<<>>( + d_logits_size, logits.contiguous().data(), + targets.contiguous().data(), + d_losses.contiguous().data(), num_classes, gamma, alpha, + num_samples, d_logits.data()); + }); + + THCudaCheck(cudaGetLastError()); + return d_logits; +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/__init__.py new file mode 100644 index 000000000..51b543342 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/__init__.py @@ -0,0 +1,10 @@ +from .collect_env import collect_env +from .flops_counter import get_model_complexity_info +from .logger import get_root_logger, print_log +from .registry import Registry, build_from_cfg + + +__all__ = [ + 'Registry', 'build_from_cfg', 'get_model_complexity_info', + 'get_root_logger', 'print_log', 'collect_env' +] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py new file mode 100644 index 000000000..dcc1d4e6e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/collect_env.py @@ -0,0 +1,63 @@ +import os.path as osp +import subprocess +import sys +from collections import defaultdict + +import cv2 +import mmcv +import torch +import torchvision + +import mmdet + + +def collect_env(): + env_info = {} + env_info['sys.platform'] = sys.platform + env_info['Python'] = sys.version.replace('\n', '') + + cuda_available = torch.cuda.is_available() + env_info['CUDA available'] = cuda_available + + if cuda_available: + from torch.utils.cpp_extension import CUDA_HOME + env_info['CUDA_HOME'] = CUDA_HOME + + if CUDA_HOME is not None and osp.isdir(CUDA_HOME): + try: + nvcc = osp.join(CUDA_HOME, 'bin/nvcc') + nvcc = subprocess.check_output( + '"{}" -V | tail -n1'.format(nvcc), shell=True) + nvcc = nvcc.decode('utf-8').strip() + except subprocess.SubprocessError: + nvcc = 'Not Available' + env_info['NVCC'] = nvcc + + devices = defaultdict(list) + for k in range(torch.cuda.device_count()): + devices[torch.cuda.get_device_name(k)].append(str(k)) + for name, devids in devices.items(): + env_info['GPU ' + ','.join(devids)] = name + + gcc = subprocess.check_output('gcc --version | head -n1', shell=True) + gcc = gcc.decode('utf-8').strip() + env_info['GCC'] = gcc + + env_info['PyTorch'] = torch.__version__ + env_info['PyTorch compiling details'] = torch.__config__.show() + + env_info['TorchVision'] = torchvision.__version__ + + env_info['OpenCV'] = cv2.__version__ + + env_info['MMCV'] = mmcv.__version__ + env_info['MMDetection'] = mmdet.__version__ + from mmdet.ops import get_compiler_version, get_compiling_cuda_version + env_info['MMDetection Compiler'] = get_compiler_version() + env_info['MMDetection CUDA Compiler'] = get_compiling_cuda_version() + return env_info + + +if __name__ == "__main__": + for name, val in collect_env().items(): + print('{}: {}'.format(name, val)) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/contextmanagers.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/contextmanagers.py new file mode 100644 index 000000000..0363f0145 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/contextmanagers.py @@ -0,0 +1,126 @@ +# coding: utf-8 +import asyncio +import contextlib +import logging +import os +import time +from typing import List + +import torch + +logger = logging.getLogger(__name__) + +DEBUG_COMPLETED_TIME = bool(os.environ.get('DEBUG_COMPLETED_TIME', False)) + + +@contextlib.asynccontextmanager +async def completed(trace_name='', + name='', + sleep_interval=0.05, + streams: List[torch.cuda.Stream] = None): + """ + Async context manager that waits for work to complete on + given CUDA streams. + + """ + if not torch.cuda.is_available(): + yield + return + + stream_before_context_switch = torch.cuda.current_stream() + if not streams: + streams = [stream_before_context_switch] + else: + streams = [s if s else stream_before_context_switch for s in streams] + + end_events = [ + torch.cuda.Event(enable_timing=DEBUG_COMPLETED_TIME) for _ in streams + ] + + if DEBUG_COMPLETED_TIME: + start = torch.cuda.Event(enable_timing=True) + stream_before_context_switch.record_event(start) + + cpu_start = time.monotonic() + logger.debug('%s %s starting, streams: %s', trace_name, name, streams) + grad_enabled_before = torch.is_grad_enabled() + try: + yield + finally: + current_stream = torch.cuda.current_stream() + assert current_stream == stream_before_context_switch + + if DEBUG_COMPLETED_TIME: + cpu_end = time.monotonic() + for i, stream in enumerate(streams): + event = end_events[i] + stream.record_event(event) + + grad_enabled_after = torch.is_grad_enabled() + + # observed change of torch.is_grad_enabled() during concurrent run of + # async_test_bboxes code + assert (grad_enabled_before == grad_enabled_after + ), 'Unexpected is_grad_enabled() value change' + + are_done = [e.query() for e in end_events] + logger.debug('%s %s completed: %s streams: %s', trace_name, name, + are_done, streams) + with torch.cuda.stream(stream_before_context_switch): + while not all(are_done): + await asyncio.sleep(sleep_interval) + are_done = [e.query() for e in end_events] + logger.debug( + '%s %s completed: %s streams: %s', + trace_name, + name, + are_done, + streams, + ) + + current_stream = torch.cuda.current_stream() + assert current_stream == stream_before_context_switch + + if DEBUG_COMPLETED_TIME: + cpu_time = (cpu_end - cpu_start) * 1000 + stream_times_ms = '' + for i, stream in enumerate(streams): + elapsed_time = start.elapsed_time(end_events[i]) + stream_times_ms += ' {} {:.2f} ms'.format(stream, elapsed_time) + logger.info('%s %s %.2f ms %s', trace_name, name, cpu_time, + stream_times_ms) + + +@contextlib.asynccontextmanager +async def concurrent(streamqueue: asyncio.Queue, + trace_name='concurrent', + name='stream'): + """Run code concurrently in different streams. + + :param streamqueue: asyncio.Queue instance. + + Queue tasks define the pool of streams used for concurrent execution. + + """ + if not torch.cuda.is_available(): + yield + return + + initial_stream = torch.cuda.current_stream() + + with torch.cuda.stream(initial_stream): + stream = await streamqueue.get() + assert isinstance(stream, torch.cuda.Stream) + + try: + with torch.cuda.stream(stream): + logger.debug('%s %s is starting, stream: %s', trace_name, name, + stream) + yield + current = torch.cuda.current_stream() + assert current == stream + logger.debug('%s %s has finished, stream: %s', trace_name, + name, stream) + finally: + streamqueue.task_done() + streamqueue.put_nowait(stream) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/flops_counter.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/flops_counter.py new file mode 100644 index 000000000..5d9cdfce8 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/flops_counter.py @@ -0,0 +1,433 @@ +# Modified from flops-counter.pytorch by Vladislav Sovrasov +# original repo: https://github.com/sovrasov/flops-counter.pytorch + +# MIT License + +# Copyright (c) 2018 Vladislav Sovrasov + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import sys + +import numpy as np +import torch +import torch.nn as nn +from torch.nn.modules.batchnorm import _BatchNorm +from torch.nn.modules.conv import _ConvNd, _ConvTransposeMixin +from torch.nn.modules.pooling import (_AdaptiveAvgPoolNd, _AdaptiveMaxPoolNd, + _AvgPoolNd, _MaxPoolNd) + +CONV_TYPES = (_ConvNd, ) +DECONV_TYPES = (_ConvTransposeMixin, ) +LINEAR_TYPES = (nn.Linear, ) +POOLING_TYPES = (_AvgPoolNd, _MaxPoolNd, _AdaptiveAvgPoolNd, + _AdaptiveMaxPoolNd) +RELU_TYPES = (nn.ReLU, nn.PReLU, nn.ELU, nn.LeakyReLU, nn.ReLU6) +BN_TYPES = (_BatchNorm, ) +UPSAMPLE_TYPES = (nn.Upsample, ) + +SUPPORTED_TYPES = ( + CONV_TYPES + DECONV_TYPES + LINEAR_TYPES + POOLING_TYPES + RELU_TYPES + + BN_TYPES + UPSAMPLE_TYPES) + + +def get_model_complexity_info(model, + input_res, + print_per_layer_stat=True, + as_strings=True, + input_constructor=None, + ost=sys.stdout): + assert type(input_res) is tuple + assert len(input_res) >= 2 + flops_model = add_flops_counting_methods(model) + flops_model.eval().start_flops_count() + if input_constructor: + input = input_constructor(input_res) + _ = flops_model(**input) + else: + batch = torch.ones(()).new_empty( + (1, *input_res), + dtype=next(flops_model.parameters()).dtype, + device=next(flops_model.parameters()).device) + flops_model(batch) + + if print_per_layer_stat: + print_model_with_flops(flops_model, ost=ost) + flops_count = flops_model.compute_average_flops_cost() + params_count = get_model_parameters_number(flops_model) + flops_model.stop_flops_count() + + if as_strings: + return flops_to_string(flops_count), params_to_string(params_count) + + return flops_count, params_count + + +def flops_to_string(flops, units='GMac', precision=2): + if units is None: + if flops // 10**9 > 0: + return str(round(flops / 10.**9, precision)) + ' GMac' + elif flops // 10**6 > 0: + return str(round(flops / 10.**6, precision)) + ' MMac' + elif flops // 10**3 > 0: + return str(round(flops / 10.**3, precision)) + ' KMac' + else: + return str(flops) + ' Mac' + else: + if units == 'GMac': + return str(round(flops / 10.**9, precision)) + ' ' + units + elif units == 'MMac': + return str(round(flops / 10.**6, precision)) + ' ' + units + elif units == 'KMac': + return str(round(flops / 10.**3, precision)) + ' ' + units + else: + return str(flops) + ' Mac' + + +def params_to_string(params_num): + """converting number to string + + :param float params_num: number + :returns str: number + + >>> params_to_string(1e9) + '1000.0 M' + >>> params_to_string(2e5) + '200.0 k' + >>> params_to_string(3e-9) + '3e-09' + """ + if params_num // 10**6 > 0: + return str(round(params_num / 10**6, 2)) + ' M' + elif params_num // 10**3: + return str(round(params_num / 10**3, 2)) + ' k' + else: + return str(params_num) + + +def print_model_with_flops(model, units='GMac', precision=3, ost=sys.stdout): + total_flops = model.compute_average_flops_cost() + + def accumulate_flops(self): + if is_supported_instance(self): + return self.__flops__ / model.__batch_counter__ + else: + sum = 0 + for m in self.children(): + sum += m.accumulate_flops() + return sum + + def flops_repr(self): + accumulated_flops_cost = self.accumulate_flops() + return ', '.join([ + flops_to_string( + accumulated_flops_cost, units=units, precision=precision), + '{:.3%} MACs'.format(accumulated_flops_cost / total_flops), + self.original_extra_repr() + ]) + + def add_extra_repr(m): + m.accumulate_flops = accumulate_flops.__get__(m) + flops_extra_repr = flops_repr.__get__(m) + if m.extra_repr != flops_extra_repr: + m.original_extra_repr = m.extra_repr + m.extra_repr = flops_extra_repr + assert m.extra_repr != m.original_extra_repr + + def del_extra_repr(m): + if hasattr(m, 'original_extra_repr'): + m.extra_repr = m.original_extra_repr + del m.original_extra_repr + if hasattr(m, 'accumulate_flops'): + del m.accumulate_flops + + model.apply(add_extra_repr) + print(model, file=ost) + model.apply(del_extra_repr) + + +def get_model_parameters_number(model): + params_num = sum(p.numel() for p in model.parameters() if p.requires_grad) + return params_num + + +def add_flops_counting_methods(net_main_module): + # adding additional methods to the existing module object, + # this is done this way so that each function has access to self object + net_main_module.start_flops_count = start_flops_count.__get__( + net_main_module) + net_main_module.stop_flops_count = stop_flops_count.__get__( + net_main_module) + net_main_module.reset_flops_count = reset_flops_count.__get__( + net_main_module) + net_main_module.compute_average_flops_cost = \ + compute_average_flops_cost.__get__(net_main_module) + + net_main_module.reset_flops_count() + + # Adding variables necessary for masked flops computation + net_main_module.apply(add_flops_mask_variable_or_reset) + + return net_main_module + + +def compute_average_flops_cost(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Returns current mean flops consumption per image. + """ + + batches_count = self.__batch_counter__ + flops_sum = 0 + for module in self.modules(): + if is_supported_instance(module): + flops_sum += module.__flops__ + + return flops_sum / batches_count + + +def start_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Activates the computation of mean flops consumption per image. + Call it before you run the network. + """ + add_batch_counter_hook_function(self) + self.apply(add_flops_counter_hook_function) + + +def stop_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Stops computing the mean flops consumption per image. + Call whenever you want to pause the computation. + """ + remove_batch_counter_hook_function(self) + self.apply(remove_flops_counter_hook_function) + + +def reset_flops_count(self): + """ + A method that will be available after add_flops_counting_methods() is + called on a desired net object. + Resets statistics computed so far. + """ + add_batch_counter_variables_or_reset(self) + self.apply(add_flops_counter_variable_or_reset) + + +def add_flops_mask(module, mask): + + def add_flops_mask_func(module): + if isinstance(module, torch.nn.Conv2d): + module.__mask__ = mask + + module.apply(add_flops_mask_func) + + +def remove_flops_mask(module): + module.apply(add_flops_mask_variable_or_reset) + + +def is_supported_instance(module): + if isinstance(module, SUPPORTED_TYPES): + return True + else: + return False + + +def empty_flops_counter_hook(module, input, output): + module.__flops__ += 0 + + +def upsample_flops_counter_hook(module, input, output): + output_size = output[0] + batch_size = output_size.shape[0] + output_elements_count = batch_size + for val in output_size.shape[1:]: + output_elements_count *= val + module.__flops__ += int(output_elements_count) + + +def relu_flops_counter_hook(module, input, output): + active_elements_count = output.numel() + module.__flops__ += int(active_elements_count) + + +def linear_flops_counter_hook(module, input, output): + input = input[0] + batch_size = input.shape[0] + module.__flops__ += int(batch_size * input.shape[1] * output.shape[1]) + + +def pool_flops_counter_hook(module, input, output): + input = input[0] + module.__flops__ += int(np.prod(input.shape)) + + +def bn_flops_counter_hook(module, input, output): + module.affine + input = input[0] + + batch_flops = np.prod(input.shape) + if module.affine: + batch_flops *= 2 + module.__flops__ += int(batch_flops) + + +def deconv_flops_counter_hook(conv_module, input, output): + # Can have multiple inputs, getting the first one + input = input[0] + + batch_size = input.shape[0] + input_height, input_width = input.shape[2:] + + kernel_height, kernel_width = conv_module.kernel_size + in_channels = conv_module.in_channels + out_channels = conv_module.out_channels + groups = conv_module.groups + + filters_per_channel = out_channels // groups + conv_per_position_flops = ( + kernel_height * kernel_width * in_channels * filters_per_channel) + + active_elements_count = batch_size * input_height * input_width + overall_conv_flops = conv_per_position_flops * active_elements_count + bias_flops = 0 + if conv_module.bias is not None: + output_height, output_width = output.shape[2:] + bias_flops = out_channels * batch_size * output_height * output_height + overall_flops = overall_conv_flops + bias_flops + + conv_module.__flops__ += int(overall_flops) + + +def conv_flops_counter_hook(conv_module, input, output): + # Can have multiple inputs, getting the first one + input = input[0] + + batch_size = input.shape[0] + output_dims = list(output.shape[2:]) + + kernel_dims = list(conv_module.kernel_size) + in_channels = conv_module.in_channels + out_channels = conv_module.out_channels + groups = conv_module.groups + + filters_per_channel = out_channels // groups + conv_per_position_flops = np.prod( + kernel_dims) * in_channels * filters_per_channel + + active_elements_count = batch_size * np.prod(output_dims) + + if conv_module.__mask__ is not None: + # (b, 1, h, w) + output_height, output_width = output.shape[2:] + flops_mask = conv_module.__mask__.expand(batch_size, 1, output_height, + output_width) + active_elements_count = flops_mask.sum() + + overall_conv_flops = conv_per_position_flops * active_elements_count + + bias_flops = 0 + + if conv_module.bias is not None: + + bias_flops = out_channels * active_elements_count + + overall_flops = overall_conv_flops + bias_flops + + conv_module.__flops__ += int(overall_flops) + + +def batch_counter_hook(module, input, output): + batch_size = 1 + if len(input) > 0: + # Can have multiple inputs, getting the first one + input = input[0] + batch_size = len(input) + else: + print('Warning! No positional inputs found for a module, ' + 'assuming batch size is 1.') + module.__batch_counter__ += batch_size + + +def add_batch_counter_variables_or_reset(module): + + module.__batch_counter__ = 0 + + +def add_batch_counter_hook_function(module): + if hasattr(module, '__batch_counter_handle__'): + return + + handle = module.register_forward_hook(batch_counter_hook) + module.__batch_counter_handle__ = handle + + +def remove_batch_counter_hook_function(module): + if hasattr(module, '__batch_counter_handle__'): + module.__batch_counter_handle__.remove() + del module.__batch_counter_handle__ + + +def add_flops_counter_variable_or_reset(module): + if is_supported_instance(module): + module.__flops__ = 0 + + +def add_flops_counter_hook_function(module): + if is_supported_instance(module): + if hasattr(module, '__flops_handle__'): + return + + if isinstance(module, CONV_TYPES): + handle = module.register_forward_hook(conv_flops_counter_hook) + elif isinstance(module, RELU_TYPES): + handle = module.register_forward_hook(relu_flops_counter_hook) + elif isinstance(module, LINEAR_TYPES): + handle = module.register_forward_hook(linear_flops_counter_hook) + elif isinstance(module, POOLING_TYPES): + handle = module.register_forward_hook(pool_flops_counter_hook) + elif isinstance(module, BN_TYPES): + handle = module.register_forward_hook(bn_flops_counter_hook) + elif isinstance(module, UPSAMPLE_TYPES): + handle = module.register_forward_hook(upsample_flops_counter_hook) + elif isinstance(module, DECONV_TYPES): + handle = module.register_forward_hook(deconv_flops_counter_hook) + else: + handle = module.register_forward_hook(empty_flops_counter_hook) + module.__flops_handle__ = handle + + +def remove_flops_counter_hook_function(module): + if is_supported_instance(module): + if hasattr(module, '__flops_handle__'): + module.__flops_handle__.remove() + del module.__flops_handle__ + + +# --- Masked flops counting +# Also being run in the initialization +def add_flops_mask_variable_or_reset(module): + if is_supported_instance(module): + module.__mask__ = None diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/logger.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/logger.py new file mode 100644 index 000000000..91b086e5d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/logger.py @@ -0,0 +1,66 @@ +import logging + +from mmcv.runner import get_dist_info + + +def get_root_logger(log_file=None, log_level=logging.INFO): + """Get the root logger. + + The logger will be initialized if it has not been initialized. By default a + StreamHandler will be added. If `log_file` is specified, a FileHandler will + also be added. The name of the root logger is the top-level package name, + e.g., "mmdet". + + Args: + log_file (str | None): The log filename. If specified, a FileHandler + will be added to the root logger. + log_level (int): The root logger level. Note that only the process of + rank 0 is affected, while other processes will set the level to + "Error" and be silent most of the time. + + Returns: + logging.Logger: The root logger. + """ + logger = logging.getLogger(__name__.split('.')[0]) # i.e., mmdet + # if the logger has been initialized, just return it + if logger.hasHandlers(): + return logger + + format_str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' + logging.basicConfig(format=format_str, level=log_level) + rank, _ = get_dist_info() + if rank != 0: + logger.setLevel('ERROR') + elif log_file is not None: + file_handler = logging.FileHandler(log_file, 'w') + file_handler.setFormatter(logging.Formatter(format_str)) + file_handler.setLevel(log_level) + logger.addHandler(file_handler) + + return logger + + +def print_log(msg, logger=None, level=logging.INFO): + """Print a log message. + + Args: + msg (str): The message to be logged. + logger (logging.Logger | str | None): The logger to be used. Some + special loggers are: + - "root": the root logger obtained with `get_root_logger()`. + - "silent": no message will be printed. + - None: The `print()` method will be used to print log messages. + level (int): Logging level. Only available when `logger` is a Logger + object or "root". + """ + if logger is None: + print(msg) + elif logger == 'root': + _logger = get_root_logger() + _logger.log(level, msg) + elif isinstance(logger, logging.Logger): + logger.log(level, msg) + elif logger != 'silent': + raise TypeError( + 'logger should be either a logging.Logger object, "root", ' + '"silent" or None, but got {}'.format(logger)) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py new file mode 100644 index 000000000..58b1c87dd --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/profiling.py @@ -0,0 +1,41 @@ +import contextlib +import sys +import time + +import torch + +if sys.version_info >= (3, 7): + + @contextlib.contextmanager + def profile_time(trace_name, + name, + enabled=True, + stream=None, + end_stream=None): + """Print time spent by CPU and GPU. + + Useful as a temporary context manager to find sweet spots of + code suitable for async implementation. + + """ + if (not enabled) or not torch.cuda.is_available(): + yield + return + stream = stream if stream else torch.cuda.current_stream() + end_stream = end_stream if end_stream else stream + start = torch.cuda.Event(enable_timing=True) + end = torch.cuda.Event(enable_timing=True) + stream.record_event(start) + try: + cpu_start = time.monotonic() + yield + finally: + cpu_end = time.monotonic() + end_stream.record_event(end) + end.synchronize() + cpu_time = (cpu_end - cpu_start) * 1000 + gpu_time = start.elapsed_time(end) + msg = "{} {} cpu_time {:.2f} ms ".format(trace_name, name, + cpu_time) + msg += "gpu_time {:.2f} ms stream {}".format(gpu_time, stream) + print(msg, end_stream) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py new file mode 100644 index 000000000..2bbb7f9a9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py @@ -0,0 +1,76 @@ +import inspect + +import mmcv + + +class Registry(object): + + def __init__(self, name): + self._name = name + self._module_dict = dict() + + def __repr__(self): + format_str = self.__class__.__name__ + '(name={}, items={})'.format( + self._name, list(self._module_dict.keys())) + return format_str + + @property + def name(self): + return self._name + + @property + def module_dict(self): + return self._module_dict + + def get(self, key): + return self._module_dict.get(key, None) + + def _register_module(self, module_class): + """Register a module. + + Args: + module (:obj:`nn.Module`): Module to be registered. + """ + if not inspect.isclass(module_class): + raise TypeError('module must be a class, but got {}'.format( + type(module_class))) + module_name = module_class.__name__ + if module_name in self._module_dict: + raise KeyError('{} is already registered in {}'.format( + module_name, self.name)) + self._module_dict[module_name] = module_class + + def register_module(self, cls): + self._register_module(cls) + return cls + + +def build_from_cfg(cfg, registry, default_args=None): + """Build a module from config dict. + + Args: + cfg (dict): Config dict. It should at least contain the key "type". + registry (:obj:`Registry`): The registry to search the type from. + default_args (dict, optional): Default initialization arguments. + + Returns: + obj: The constructed object. + """ + assert isinstance(cfg, dict) and 'type' in cfg + assert isinstance(default_args, dict) or default_args is None + args = cfg.copy() + obj_type = args.pop('type') + if mmcv.is_str(obj_type): + obj_type = registry.get(obj_type) + if obj_type is None: + raise KeyError('{} is not in the {} registry'.format( + obj_type, registry.name)) + elif inspect.isclass(obj_type): + obj_cls = obj_type + else: + raise TypeError('type must be a str or valid type, but got {}'.format( + type(obj_type))) + if default_args is not None: + for name, value in default_args.items(): + args.setdefault(name, value) + return obj_type(**args) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/util_mixins.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/util_mixins.py new file mode 100644 index 000000000..5585ac652 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/utils/util_mixins.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +""" +This module defines the :class:`NiceRepr` mixin class, which defines a +``__repr__`` and ``__str__`` method that only depend on a custom ``__nice__`` +method, which you must define. This means you only have to overload one +function instead of two. Furthermore, if the object defines a ``__len__`` +method, then the ``__nice__`` method defaults to something sensible, otherwise +it is treated as abstract and raises ``NotImplementedError``. + +To use simply have your object inherit from :class:`NiceRepr` +(multi-inheritance should be ok). + +This code was copied from the ubelt library: https://github.com/Erotemic/ubelt + +Example: + >>> # Objects that define __nice__ have a default __str__ and __repr__ + >>> class Student(NiceRepr): + ... def __init__(self, name): + ... self.name = name + ... def __nice__(self): + ... return self.name + >>> s1 = Student('Alice') + >>> s2 = Student('Bob') + >>> print('s1 = {}'.format(s1)) + >>> print('s2 = {}'.format(s2)) + s1 = + s2 = + +Example: + >>> # Objects that define __len__ have a default __nice__ + >>> class Group(NiceRepr): + ... def __init__(self, data): + ... self.data = data + ... def __len__(self): + ... return len(self.data) + >>> g = Group([1, 2, 3]) + >>> print('g = {}'.format(g)) + g = + +""" +import warnings + + +class NiceRepr(object): + """ + Inherit from this class and define ``__nice__`` to "nicely" print your + objects. + + Defines ``__str__`` and ``__repr__`` in terms of ``__nice__`` function + Classes that inherit from :class:`NiceRepr` should redefine ``__nice__``. + If the inheriting class has a ``__len__``, method then the default + ``__nice__`` method will return its length. + + Example: + >>> class Foo(NiceRepr): + ... def __nice__(self): + ... return 'info' + >>> foo = Foo() + >>> assert str(foo) == '' + >>> assert repr(foo).startswith('>> class Bar(NiceRepr): + ... pass + >>> bar = Bar() + >>> import pytest + >>> with pytest.warns(None) as record: + >>> assert 'object at' in str(bar) + >>> assert 'object at' in repr(bar) + + Example: + >>> class Baz(NiceRepr): + ... def __len__(self): + ... return 5 + >>> baz = Baz() + >>> assert str(baz) == '' + """ + + def __nice__(self): + if hasattr(self, '__len__'): + # It is a common pattern for objects to use __len__ in __nice__ + # As a convenience we define a default __nice__ for these objects + return str(len(self)) + else: + # In all other cases force the subclass to overload __nice__ + raise NotImplementedError( + 'Define the __nice__ method for {!r}'.format(self.__class__)) + + def __repr__(self): + try: + nice = self.__nice__() + classname = self.__class__.__name__ + return '<{0}({1}) at {2}>'.format(classname, nice, hex(id(self))) + except NotImplementedError as ex: + warnings.warn(str(ex), category=RuntimeWarning) + return object.__repr__(self) + + def __str__(self): + try: + classname = self.__class__.__name__ + nice = self.__nice__() + return '<{0}({1})>'.format(classname, nice) + except NotImplementedError as ex: + warnings.warn(str(ex), category=RuntimeWarning) + return object.__repr__(self) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/version.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/version.py new file mode 100644 index 000000000..6e49834e4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/mmdet/version.py @@ -0,0 +1,5 @@ +# GENERATED VERSION FILE +# TIME: Fri Oct 15 17:01:16 2021 + +__version__ = '0.6.0+0889383' +short_version = '0.6.0' diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/setup.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/setup.py new file mode 100644 index 000000000..6a8752079 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/setup.py @@ -0,0 +1,112 @@ +import os +import subprocess +import time +from setuptools import find_packages, setup + + +def readme(): + with open('README.md', encoding='utf-8') as f: + content = f.read() + return content + + +MAJOR = 0 +MINOR = 6 +PATCH = 0 +SUFFIX = '' +SHORT_VERSION = '{}.{}.{}{}'.format(MAJOR, MINOR, PATCH, SUFFIX) + +version_file = 'mmdet/version.py' + + +def get_git_hash(): + + def _minimal_ext_cmd(cmd): + # construct minimal environment + env = {} + for k in ['SYSTEMROOT', 'PATH', 'HOME']: + v = os.environ.get(k) + if v is not None: + env[k] = v + # LANGUAGE is used on win32 + env['LANGUAGE'] = 'C' + env['LANG'] = 'C' + env['LC_ALL'] = 'C' + out = subprocess.Popen( + cmd, stdout=subprocess.PIPE, env=env).communicate()[0] + return out + + try: + out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) + sha = out.strip().decode('ascii') + except OSError: + sha = 'unknown' + + return sha + + +def get_hash(): + if os.path.exists('.git'): + sha = get_git_hash()[:7] + elif os.path.exists(version_file): + try: + from mmdet.version import __version__ + sha = __version__.split('+')[-1] + except ImportError: + raise ImportError('Unable to get git version') + else: + sha = 'unknown' + + return sha + + +def write_version_py(): + content = """# GENERATED VERSION FILE +# TIME: {} + +__version__ = '{}' +short_version = '{}' +""" + sha = get_hash() + VERSION = SHORT_VERSION + '+' + sha + + with open(version_file, 'w') as f: + f.write(content.format(time.asctime(), VERSION, SHORT_VERSION)) + + +def get_version(): + with open(version_file, 'r') as f: + exec(compile(f.read(), version_file, 'exec')) + return locals()['__version__'] + + +if __name__ == '__main__': + write_version_py() + setup( + name='mmdet', + version=get_version(), + description='Open MMLab Detection Toolbox', + long_description=readme(), + keywords='computer vision, object detection', + url='https://github.com/open-mmlab/mmdetection', + packages=find_packages(exclude=('configs', 'tools', 'demo')), + package_data={'mmdet.ops': ['*/*.so']}, + classifiers=[ + 'Development Status :: 4 - Beta', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], + license='Apache License 2.0', + setup_requires=['pytest-runner'], + tests_require=['pytest'], + install_requires=[ + 'mmcv>=0.2.6', 'numpy', 'matplotlib', 'six', 'terminaltables', + 'pycocotools' + ], + zip_safe=False) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/test.py new file mode 100644 index 000000000..53d13f150 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/test.py @@ -0,0 +1,205 @@ +import os +import argparse +import os.path as osp +import torch +import torch.distributed as dist +import shutil +import tempfile + +import mmcv +from mmcv.runner import load_checkpoint, get_dist_info +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel + +from mmdet.apis import init_dist +from mmdet.core import results2json, coco_eval, wrap_fp16_model +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector + + +def single_gpu_test(model, data_loader, show=False): + model.eval() + results = [] + dataset = data_loader.dataset + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=not show, **data) + results.append(result) + + if show: + model.module.show_result(data, result, dataset.img_norm_cfg) + + batch_size = data['img'][0].size(0) + for _ in range(0, batch_size, 100): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None): + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(0, batch_size * world_size, 500): + prog_bar.update() + + # collect results from all ranks + results = collect_results(results, len(dataset), tmpdir) + + return results + + +def collect_results(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def parse_args(): + parser = argparse.ArgumentParser(description='MMDet test detector') + parser.add_argument('--config', help='test config file path') + parser.add_argument('--checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file') + parser.add_argument( + '--eval', + type=str, + nargs='+', + choices=['proposal', 'proposal_fast', 'bbox', 'segm', 'keypoints'], + help='eval types') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument('--tmpdir', help='tmp dir for writing some results') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + + args, unparsed = parser.parse_known_args() + + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # build the dataloader + # TODO: support multiple images per gpu (only minor changes are needed) + dataset = build_dataset(cfg.data.test) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=cfg.data.workers_per_gpu, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoint, this walkaround is + # for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader, args.show) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir) + + rank, _ = get_dist_info() + if args.out and rank == 0: + print('\nwriting results to {}'.format(args.out)) + mmcv.dump(outputs, args.out) + eval_types = args.eval + if eval_types: + print('Starting evaluate {}'.format(' and '.join(eval_types))) + if eval_types == ['proposal_fast']: + result_file = args.out + coco_eval(result_file, eval_types, dataset.coco) + else: + if not isinstance(outputs[0], dict): + result_files = results2json(dataset, outputs, args.out) + coco_eval(result_files, eval_types, dataset.coco) + else: + for name in outputs[0]: + print('\nEvaluating {}'.format(name)) + outputs_ = [out[name] for out in outputs] + result_file = args.out + '.{}'.format(name) + result_files = results2json(dataset, outputs_, + result_file) + coco_eval(result_files, eval_types, dataset.coco) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/analyze_logs.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/analyze_logs.py new file mode 100644 index 000000000..c9f603f46 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/analyze_logs.py @@ -0,0 +1,178 @@ +import argparse +import json +from collections import defaultdict + +import matplotlib.pyplot as plt +import numpy as np +import seaborn as sns + + +def cal_train_time(log_dicts, args): + for i, log_dict in enumerate(log_dicts): + print('{}Analyze train time of {}{}'.format('-' * 5, args.json_logs[i], + '-' * 5)) + all_times = [] + for epoch in log_dict.keys(): + if args.include_outliers: + all_times.append(log_dict[epoch]['time']) + else: + all_times.append(log_dict[epoch]['time'][1:]) + all_times = np.array(all_times) + epoch_ave_time = all_times.mean(-1) + slowest_epoch = epoch_ave_time.argmax() + fastest_epoch = epoch_ave_time.argmin() + std_over_epoch = epoch_ave_time.std() + print('slowest epoch {}, average time is {:.4f}'.format( + slowest_epoch + 1, epoch_ave_time[slowest_epoch])) + print('fastest epoch {}, average time is {:.4f}'.format( + fastest_epoch + 1, epoch_ave_time[fastest_epoch])) + print('time std over epochs is {:.4f}'.format(std_over_epoch)) + print('average iter time: {:.4f} s/iter'.format(np.mean(all_times))) + print() + + +def plot_curve(log_dicts, args): + if args.backend is not None: + plt.switch_backend(args.backend) + sns.set_style(args.style) + # if legend is None, use {filename}_{key} as legend + legend = args.legend + if legend is None: + legend = [] + for json_log in args.json_logs: + for metric in args.keys: + legend.append('{}_{}'.format(json_log, metric)) + assert len(legend) == (len(args.json_logs) * len(args.keys)) + metrics = args.keys + + num_metrics = len(metrics) + for i, log_dict in enumerate(log_dicts): + epochs = list(log_dict.keys()) + for j, metric in enumerate(metrics): + print('plot curve of {}, metric is {}'.format( + args.json_logs[i], metric)) + assert metric in log_dict[epochs[ + 0]], '{} does not contain metric {}'.format( + args.json_logs[i], metric) + + if 'mAP' in metric: + xs = np.arange(1, max(epochs) + 1) + ys = [] + for epoch in epochs: + ys += log_dict[epoch][metric] + ax = plt.gca() + ax.set_xticks(xs) + plt.xlabel('epoch') + plt.plot(xs, ys, label=legend[i * num_metrics + j], marker='o') + else: + xs = [] + ys = [] + num_iters_per_epoch = log_dict[epochs[0]]['iter'][-1] + for epoch in epochs: + iters = log_dict[epoch]['iter'] + if log_dict[epoch]['mode'][-1] == 'val': + iters = iters[:-1] + xs.append( + np.array(iters) + (epoch - 1) * num_iters_per_epoch) + ys.append(np.array(log_dict[epoch][metric][:len(iters)])) + xs = np.concatenate(xs) + ys = np.concatenate(ys) + plt.xlabel('iter') + plt.plot( + xs, ys, label=legend[i * num_metrics + j], linewidth=0.5) + plt.legend() + if args.title is not None: + plt.title(args.title) + if args.out is None: + plt.show() + else: + print('save curve to: {}'.format(args.out)) + plt.savefig(args.out) + plt.cla() + + +def add_plot_parser(subparsers): + parser_plt = subparsers.add_parser( + 'plot_curve', help='parser for plotting curves') + parser_plt.add_argument( + 'json_logs', + type=str, + nargs='+', + help='path of train log in json format') + parser_plt.add_argument( + '--keys', + type=str, + nargs='+', + default=['bbox_mAP'], + help='the metric that you want to plot') + parser_plt.add_argument('--title', type=str, help='title of figure') + parser_plt.add_argument( + '--legend', + type=str, + nargs='+', + default=None, + help='legend of each plot') + parser_plt.add_argument( + '--backend', type=str, default=None, help='backend of plt') + parser_plt.add_argument( + '--style', type=str, default='dark', help='style of plt') + parser_plt.add_argument('--out', type=str, default=None) + + +def add_time_parser(subparsers): + parser_time = subparsers.add_parser( + 'cal_train_time', + help='parser for computing the average time per training iteration') + parser_time.add_argument( + 'json_logs', + type=str, + nargs='+', + help='path of train log in json format') + parser_time.add_argument( + '--include-outliers', + action='store_true', + help='include the first value of every epoch when computing ' + 'the average time') + + +def parse_args(): + parser = argparse.ArgumentParser(description='Analyze Json Log') + # currently only support plot curve and calculate average train time + subparsers = parser.add_subparsers(dest='task', help='task parser') + add_plot_parser(subparsers) + add_time_parser(subparsers) + args = parser.parse_args() + return args + + +def load_json_logs(json_logs): + # load and convert json_logs to log_dict, key is epoch, value is a sub dict + # keys of sub dict is different metrics, e.g. memory, bbox_mAP + # value of sub dict is a list of corresponding values of all iterations + log_dicts = [dict() for _ in json_logs] + for json_log, log_dict in zip(json_logs, log_dicts): + with open(json_log, 'r') as log_file: + for l in log_file: + log = json.loads(l.strip()) + epoch = log.pop('epoch') + if epoch not in log_dict: + log_dict[epoch] = defaultdict(list) + for k, v in log.items(): + log_dict[epoch][k].append(v) + return log_dicts + + +def main(): + args = parse_args() + + json_logs = args.json_logs + for json_log in json_logs: + assert json_log.endswith('.json') + + log_dicts = load_json_logs(json_logs) + + eval(args.task)(log_dicts, args) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/coco_eval.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/coco_eval.py new file mode 100644 index 000000000..65e114ca2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/coco_eval.py @@ -0,0 +1,28 @@ +from argparse import ArgumentParser + +from mmdet.core import coco_eval + + +def main(): + parser = ArgumentParser(description='COCO Evaluation') + parser.add_argument('result', help='result file path') + parser.add_argument('--ann', help='annotation file path') + parser.add_argument( + '--types', + type=str, + nargs='+', + choices=['proposal_fast', 'proposal', 'bbox', 'segm', 'keypoint'], + default=['bbox'], + help='result types') + parser.add_argument( + '--max-dets', + type=int, + nargs='+', + default=[100, 300, 1000], + help='proposal numbers, only used for recall evaluation') + args = parser.parse_args() + coco_eval(args.result, args.types, args.ann, args.max_dets) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/convert_datasets/pascal_voc.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/convert_datasets/pascal_voc.py new file mode 100644 index 000000000..5fb5cb4b7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/convert_datasets/pascal_voc.py @@ -0,0 +1,140 @@ +import argparse +import os.path as osp +import xml.etree.ElementTree as ET + +import mmcv +import numpy as np + +from mmdet.core import voc_classes + +label_ids = {name: i + 1 for i, name in enumerate(voc_classes())} + + +def parse_xml(args): + xml_path, img_path = args + tree = ET.parse(xml_path) + root = tree.getroot() + size = root.find('size') + w = int(size.find('width').text) + h = int(size.find('height').text) + bboxes = [] + labels = [] + bboxes_ignore = [] + labels_ignore = [] + for obj in root.findall('object'): + name = obj.find('name').text + label = label_ids[name] + difficult = int(obj.find('difficult').text) + bnd_box = obj.find('bndbox') + bbox = [ + int(bnd_box.find('xmin').text), + int(bnd_box.find('ymin').text), + int(bnd_box.find('xmax').text), + int(bnd_box.find('ymax').text) + ] + if difficult: + bboxes_ignore.append(bbox) + labels_ignore.append(label) + else: + bboxes.append(bbox) + labels.append(label) + if not bboxes: + bboxes = np.zeros((0, 4)) + labels = np.zeros((0, )) + else: + bboxes = np.array(bboxes, ndmin=2) - 1 + labels = np.array(labels) + if not bboxes_ignore: + bboxes_ignore = np.zeros((0, 4)) + labels_ignore = np.zeros((0, )) + else: + bboxes_ignore = np.array(bboxes_ignore, ndmin=2) - 1 + labels_ignore = np.array(labels_ignore) + annotation = { + 'filename': img_path, + 'width': w, + 'height': h, + 'ann': { + 'bboxes': bboxes.astype(np.float32), + 'labels': labels.astype(np.int64), + 'bboxes_ignore': bboxes_ignore.astype(np.float32), + 'labels_ignore': labels_ignore.astype(np.int64) + } + } + return annotation + + +def cvt_annotations(devkit_path, years, split, out_file): + if not isinstance(years, list): + years = [years] + annotations = [] + for year in years: + filelist = osp.join(devkit_path, 'VOC{}/ImageSets/Main/{}.txt'.format( + year, split)) + if not osp.isfile(filelist): + print('filelist does not exist: {}, skip voc{} {}'.format( + filelist, year, split)) + return + img_names = mmcv.list_from_file(filelist) + xml_paths = [ + osp.join(devkit_path, 'VOC{}/Annotations/{}.xml'.format( + year, img_name)) for img_name in img_names + ] + img_paths = [ + 'VOC{}/JPEGImages/{}.jpg'.format(year, img_name) + for img_name in img_names + ] + part_annotations = mmcv.track_progress(parse_xml, + list(zip(xml_paths, img_paths))) + annotations.extend(part_annotations) + mmcv.dump(annotations, out_file) + return annotations + + +def parse_args(): + parser = argparse.ArgumentParser( + description='Convert PASCAL VOC annotations to mmdetection format') + parser.add_argument('devkit_path', help='pascal voc devkit path') + parser.add_argument('-o', '--out-dir', help='output path') + args = parser.parse_args() + return args + + +def main(): + args = parse_args() + devkit_path = args.devkit_path + out_dir = args.out_dir if args.out_dir else devkit_path + mmcv.mkdir_or_exist(out_dir) + + years = [] + if osp.isdir(osp.join(devkit_path, 'VOC2007')): + years.append('2007') + if osp.isdir(osp.join(devkit_path, 'VOC2012')): + years.append('2012') + if '2007' in years and '2012' in years: + years.append(['2007', '2012']) + if not years: + raise IOError('The devkit path {} contains neither "VOC2007" nor ' + '"VOC2012" subfolder'.format(devkit_path)) + for year in years: + if year == '2007': + prefix = 'voc07' + elif year == '2012': + prefix = 'voc12' + elif year == ['2007', '2012']: + prefix = 'voc0712' + for split in ['train', 'val', 'trainval']: + dataset_name = prefix + '_' + split + print('processing {} ...'.format(dataset_name)) + cvt_annotations(devkit_path, year, split, + osp.join(out_dir, dataset_name + '.pkl')) + if not isinstance(year, list): + dataset_name = prefix + '_test' + print('processing {} ...'.format(dataset_name)) + cvt_annotations(devkit_path, year, 'test', + osp.join(out_dir, dataset_name + '.pkl')) + print('Done!') + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/detectron2pytorch.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/detectron2pytorch.py new file mode 100644 index 000000000..0a90ad172 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/detectron2pytorch.py @@ -0,0 +1,88 @@ +import argparse +from collections import OrderedDict + +import mmcv +import torch + +arch_settings = {50: (3, 4, 6, 3), 101: (3, 4, 23, 3)} + + +def convert_bn(blobs, state_dict, caffe_name, torch_name, converted_names): + # detectron replace bn with affine channel layer + state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + + '_b']) + state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + + '_s']) + bn_size = state_dict[torch_name + '.weight'].size() + state_dict[torch_name + '.running_mean'] = torch.zeros(bn_size) + state_dict[torch_name + '.running_var'] = torch.ones(bn_size) + converted_names.add(caffe_name + '_b') + converted_names.add(caffe_name + '_s') + + +def convert_conv_fc(blobs, state_dict, caffe_name, torch_name, + converted_names): + state_dict[torch_name + '.weight'] = torch.from_numpy(blobs[caffe_name + + '_w']) + converted_names.add(caffe_name + '_w') + if caffe_name + '_b' in blobs: + state_dict[torch_name + '.bias'] = torch.from_numpy(blobs[caffe_name + + '_b']) + converted_names.add(caffe_name + '_b') + + +def convert(src, dst, depth): + """Convert keys in detectron pretrained ResNet models to pytorch style.""" + # load arch_settings + if depth not in arch_settings: + raise ValueError('Only support ResNet-50 and ResNet-101 currently') + block_nums = arch_settings[depth] + # load caffe model + caffe_model = mmcv.load(src, encoding='latin1') + blobs = caffe_model['blobs'] if 'blobs' in caffe_model else caffe_model + # convert to pytorch style + state_dict = OrderedDict() + converted_names = set() + convert_conv_fc(blobs, state_dict, 'conv1', 'conv1', converted_names) + convert_bn(blobs, state_dict, 'res_conv1_bn', 'bn1', converted_names) + for i in range(1, len(block_nums) + 1): + for j in range(block_nums[i - 1]): + if j == 0: + convert_conv_fc(blobs, state_dict, + 'res{}_{}_branch1'.format(i + 1, j), + 'layer{}.{}.downsample.0'.format(i, j), + converted_names) + convert_bn(blobs, state_dict, + 'res{}_{}_branch1_bn'.format(i + 1, j), + 'layer{}.{}.downsample.1'.format(i, j), + converted_names) + for k, letter in enumerate(['a', 'b', 'c']): + convert_conv_fc(blobs, state_dict, + 'res{}_{}_branch2{}'.format(i + 1, j, letter), + 'layer{}.{}.conv{}'.format(i, j, k + 1), + converted_names) + convert_bn(blobs, state_dict, + 'res{}_{}_branch2{}_bn'.format(i + 1, j, letter), + 'layer{}.{}.bn{}'.format(i, j, + k + 1), converted_names) + # check if all layers are converted + for key in blobs: + if key not in converted_names: + print('Not Convert: {}'.format(key)) + # save checkpoint + checkpoint = dict() + checkpoint['state_dict'] = state_dict + torch.save(checkpoint, dst) + + +def main(): + parser = argparse.ArgumentParser(description='Convert model keys') + parser.add_argument('src', help='src detectron model path') + parser.add_argument('dst', help='save path') + parser.add_argument('depth', type=int, help='ResNet model depth') + args = parser.parse_args() + convert(args.src, args.dst, args.depth) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/get_flops.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/get_flops.py new file mode 100644 index 000000000..e64bac6dc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/get_flops.py @@ -0,0 +1,52 @@ +import argparse + +from mmcv import Config + +from mmdet.models import build_detector +from mmdet.utils import get_model_complexity_info + + +def parse_args(): + parser = argparse.ArgumentParser(description='Train a detector') + parser.add_argument('config', help='train config file path') + parser.add_argument( + '--shape', + type=int, + nargs='+', + default=[1280, 800], + help='input image size') + args = parser.parse_args() + return args + + +def main(): + + args = parse_args() + + if len(args.shape) == 1: + input_shape = (3, args.shape[0], args.shape[0]) + elif len(args.shape) == 2: + input_shape = (3, ) + tuple(args.shape) + else: + raise ValueError('invalid input shape') + + cfg = Config.fromfile(args.config) + model = build_detector( + cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg).cuda() + model.eval() + + if hasattr(model, 'forward_dummy'): + model.forward = model.forward_dummy + else: + raise NotImplementedError( + 'FLOPs counter is currently not currently supported with {}'. + format(model.__class__.__name__)) + + flops, params = get_model_complexity_info(model, input_shape) + split_line = '=' * 30 + print('{0}\nInput shape: {1}\nFlops: {2}\nParams: {3}\n{0}'.format( + split_line, input_shape, flops, params)) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/publish_model.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/publish_model.py new file mode 100644 index 000000000..39795f14a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/publish_model.py @@ -0,0 +1,34 @@ +import argparse +import subprocess +import torch + + +def parse_args(): + parser = argparse.ArgumentParser( + description='Process a checkpoint to be published') + parser.add_argument('in_file', help='input checkpoint filename') + parser.add_argument('out_file', help='output checkpoint filename') + args = parser.parse_args() + return args + + +def process_checkpoint(in_file, out_file): + checkpoint = torch.load(in_file, map_location='cpu') + # remove optimizer for smaller file size + if 'optimizer' in checkpoint: + del checkpoint['optimizer'] + # if it is necessary to remove some sensitive data in checkpoint['meta'], + # add the code here. + torch.save(checkpoint, out_file) + sha = subprocess.check_output(['sha256sum', out_file]).decode() + final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) + subprocess.Popen(['mv', out_file, final_file]) + + +def main(): + args = parse_args() + process_checkpoint(args.in_file, args.out_file) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/test.py new file mode 100644 index 000000000..c7ce14e18 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/test.py @@ -0,0 +1,313 @@ +import argparse +import os +import os.path as osp +import pickle +import shutil +import tempfile + +import mmcv +import torch +import torch.distributed as dist +from mmcv.parallel import MMDataParallel, MMDistributedDataParallel +from mmcv.runner import get_dist_info, init_dist, load_checkpoint + +from mmdet.core import wrap_fp16_model +from mmdet.datasets import build_dataloader, build_dataset +from mmdet.models import build_detector + + +def single_gpu_test(model, data_loader, show=False): + model.eval() + results = [] + dataset = data_loader.dataset + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=not show, **data) + results.append(result) + + if show: + model.module.show_result(data, result) + + batch_size = data['img'][0].size(0) + for _ in range(batch_size): + prog_bar.update() + return results + + +def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False): + """Test model with multiple gpus. + + This method tests model with multiple gpus and collects the results + under two different modes: gpu and cpu modes. By setting 'gpu_collect=True' + it encodes results to gpu tensors and use gpu communication for results + collection. On cpu mode it saves the results on different gpus to 'tmpdir' + and collects them by the rank 0 worker. + + Args: + model (nn.Module): Model to be tested. + data_loader (nn.Dataloader): Pytorch data loader. + tmpdir (str): Path of directory to save the temporary results from + different gpus under cpu mode. + gpu_collect (bool): Option to use either gpu or cpu to collect results. + + Returns: + list: The prediction results. + """ + model.eval() + results = [] + dataset = data_loader.dataset + rank, world_size = get_dist_info() + if rank == 0: + prog_bar = mmcv.ProgressBar(len(dataset)) + for i, data in enumerate(data_loader): + with torch.no_grad(): + result = model(return_loss=False, rescale=True, **data) + results.append(result) + + if rank == 0: + batch_size = data['img'][0].size(0) + for _ in range(batch_size * world_size): + prog_bar.update() + + # collect results from all ranks + if gpu_collect: + results = collect_results_gpu(results, len(dataset)) + else: + results = collect_results_cpu(results, len(dataset), tmpdir) + return results + + +def collect_results_cpu(result_part, size, tmpdir=None): + rank, world_size = get_dist_info() + # create a tmp dir if it is not specified + if tmpdir is None: + MAX_LEN = 512 + # 32 is whitespace + dir_tensor = torch.full((MAX_LEN, ), + 32, + dtype=torch.uint8, + device='cuda') + if rank == 0: + tmpdir = tempfile.mkdtemp() + tmpdir = torch.tensor( + bytearray(tmpdir.encode()), dtype=torch.uint8, device='cuda') + dir_tensor[:len(tmpdir)] = tmpdir + dist.broadcast(dir_tensor, 0) + tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip() + else: + mmcv.mkdir_or_exist(tmpdir) + # dump the part result to the dir + mmcv.dump(result_part, osp.join(tmpdir, 'part_{}.pkl'.format(rank))) + dist.barrier() + # collect all parts + if rank != 0: + return None + else: + # load results of all parts from tmp dir + part_list = [] + for i in range(world_size): + part_file = osp.join(tmpdir, 'part_{}.pkl'.format(i)) + part_list.append(mmcv.load(part_file)) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + # remove tmp dir + shutil.rmtree(tmpdir) + return ordered_results + + +def collect_results_gpu(result_part, size): + rank, world_size = get_dist_info() + # dump result part to tensor with pickle + part_tensor = torch.tensor( + bytearray(pickle.dumps(result_part)), dtype=torch.uint8, device='cuda') + # gather all result part tensor shape + shape_tensor = torch.tensor(part_tensor.shape, device='cuda') + shape_list = [shape_tensor.clone() for _ in range(world_size)] + dist.all_gather(shape_list, shape_tensor) + # padding result part tensor to max length + shape_max = torch.tensor(shape_list).max() + part_send = torch.zeros(shape_max, dtype=torch.uint8, device='cuda') + part_send[:shape_tensor[0]] = part_tensor + part_recv_list = [ + part_tensor.new_zeros(shape_max) for _ in range(world_size) + ] + # gather all result part + dist.all_gather(part_recv_list, part_send) + + if rank == 0: + part_list = [] + for recv, shape in zip(part_recv_list, shape_list): + part_list.append( + pickle.loads(recv[:shape[0]].cpu().numpy().tobytes())) + # sort the results + ordered_results = [] + for res in zip(*part_list): + ordered_results.extend(list(res)) + # the dataloader may pad some samples + ordered_results = ordered_results[:size] + return ordered_results + + +class MultipleKVAction(argparse.Action): + """ + argparse action to split an argument into KEY=VALUE form + on the first = and append to a dictionary. + """ + + def _is_int(self, val): + try: + _ = int(val) + return True + except Exception: + return False + + def _is_float(self, val): + try: + _ = float(val) + return True + except Exception: + return False + + def _is_bool(self, val): + return val.lower() in ['true', 'false'] + + def __call__(self, parser, namespace, values, option_string=None): + options = {} + for val in values: + parts = val.split('=') + key = parts[0].strip() + if len(parts) > 2: + val = '='.join(parts[1:]) + else: + val = parts[1].strip() + # try parsing val to bool/int/float first + if self._is_bool(val): + import json + val = json.loads(val.lower()) + elif self._is_int(val): + val = int(val) + elif self._is_float(val): + val = float(val) + options[key] = val + setattr(namespace, self.dest, options) + + +def parse_args(): + parser = argparse.ArgumentParser( + description='MMDet test (and eval) a model') + parser.add_argument('config', help='test config file path') + parser.add_argument('checkpoint', help='checkpoint file') + parser.add_argument('--out', help='output result file in pickle format') + parser.add_argument( + '--format_only', + action='store_true', + help='Format the output results without perform evaluation. It is' + 'useful when you want to format the result to a specific format and ' + 'submit it to the test server') + parser.add_argument( + '--eval', + type=str, + nargs='+', + help='evaluation metrics, which depends on the dataset, e.g., "bbox",' + ' "segm", "proposal" for COCO, and "mAP", "recall" for PASCAL VOC') + parser.add_argument('--show', action='store_true', help='show results') + parser.add_argument( + '--gpu_collect', + action='store_true', + help='whether to use gpu to collect results.') + parser.add_argument( + '--tmpdir', + help='tmp directory used for collecting results from multiple ' + 'workers, available when gpu_collect is not specified') + parser.add_argument( + '--options', nargs='+', action=MultipleKVAction, help='custom options') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + args = parser.parse_args() + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + return args + + +def main(): + args = parse_args() + + assert args.out or args.eval or args.format_only or args.show, \ + ('Please specify at least one operation (save/eval/format/show the ' + 'results) with the argument "--out", "--eval", "--format_only" ' + 'or "--show"') + + if args.eval and args.format_only: + raise ValueError('--eval and --format_only cannot be both specified') + + if args.out is not None and not args.out.endswith(('.pkl', '.pickle')): + raise ValueError('The output file must be a pkl file.') + + cfg = mmcv.Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + cfg.model.pretrained = None + cfg.data.test.test_mode = True + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # build the dataloader + # TODO: support multiple images per gpu (only minor changes are needed) + dataset = build_dataset(cfg.data.test) + data_loader = build_dataloader( + dataset, + imgs_per_gpu=1, + workers_per_gpu=cfg.data.workers_per_gpu, + dist=distributed, + shuffle=False) + + # build the model and load checkpoint + model = build_detector(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) + fp16_cfg = cfg.get('fp16', None) + if fp16_cfg is not None: + wrap_fp16_model(model) + checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') + # old versions did not save class info in checkpoints, this walkaround is + # for backward compatibility + if 'CLASSES' in checkpoint['meta']: + model.CLASSES = checkpoint['meta']['CLASSES'] + else: + model.CLASSES = dataset.CLASSES + + if not distributed: + model = MMDataParallel(model, device_ids=[0]) + outputs = single_gpu_test(model, data_loader, args.show) + else: + model = MMDistributedDataParallel(model.cuda()) + outputs = multi_gpu_test(model, data_loader, args.tmpdir, + args.gpu_collect) + + rank, _ = get_dist_info() + if rank == 0: + if args.out: + print('\nwriting results to {}'.format(args.out)) + mmcv.dump(outputs, args.out) + kwargs = {} if args.options is None else args.options + if args.format_only: + dataset.format_results(outputs, **kwargs) + if args.eval: + dataset.evaluate(outputs, args.eval, **kwargs) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/upgrade_model_version.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/upgrade_model_version.py new file mode 100644 index 000000000..00bcdf44a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/upgrade_model_version.py @@ -0,0 +1,42 @@ +import argparse +import re +from collections import OrderedDict + +import torch + + +def convert(in_file, out_file): + """Convert keys in checkpoints. + + There can be some breaking changes during the development of mmdetection, + and this tool is used for upgrading checkpoints trained with old versions + to the latest one. + """ + checkpoint = torch.load(in_file) + in_state_dict = checkpoint.pop('state_dict') + out_state_dict = OrderedDict() + for key, val in in_state_dict.items(): + # Use ConvModule instead of nn.Conv2d in RetinaNet + # cls_convs.0.weight -> cls_convs.0.conv.weight + m = re.search(r'(cls_convs|reg_convs).\d.(weight|bias)', key) + if m is not None: + param = m.groups()[1] + new_key = key.replace(param, 'conv.{}'.format(param)) + out_state_dict[new_key] = val + continue + + out_state_dict[key] = val + checkpoint['state_dict'] = out_state_dict + torch.save(checkpoint, out_file) + + +def main(): + parser = argparse.ArgumentParser(description='Upgrade model version') + parser.add_argument('in_file', help='input checkpoint file') + parser.add_argument('out_file', help='output checkpoint file') + args = parser.parse_args() + convert(args.in_file, args.out_file) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/voc_eval.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/voc_eval.py new file mode 100644 index 000000000..478ec3cf4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/tools/voc_eval.py @@ -0,0 +1,62 @@ +from argparse import ArgumentParser + +import mmcv +import numpy as np + +from mmdet import datasets +from mmdet.core import eval_map + + +def voc_eval(result_file, dataset, iou_thr=0.5): + det_results = mmcv.load(result_file) + gt_bboxes = [] + gt_labels = [] + gt_ignore = [] + for i in range(len(dataset)): + ann = dataset.get_ann_info(i) + bboxes = ann['bboxes'] + labels = ann['labels'] + if 'bboxes_ignore' in ann: + ignore = np.concatenate([ + np.zeros(bboxes.shape[0], dtype=np.bool), + np.ones(ann['bboxes_ignore'].shape[0], dtype=np.bool) + ]) + gt_ignore.append(ignore) + bboxes = np.vstack([bboxes, ann['bboxes_ignore']]) + labels = np.concatenate([labels, ann['labels_ignore']]) + gt_bboxes.append(bboxes) + gt_labels.append(labels) + if not gt_ignore: + gt_ignore = gt_ignore + if hasattr(dataset, 'year') and dataset.year == 2007: + dataset_name = 'voc07' + else: + dataset_name = dataset.CLASSES + eval_map( + det_results, + gt_bboxes, + gt_labels, + gt_ignore=gt_ignore, + scale_ranges=None, + iou_thr=iou_thr, + dataset=dataset_name, + print_summary=True) + + +def main(): + parser = ArgumentParser(description='VOC Evaluation') + parser.add_argument('result', help='result file path') + parser.add_argument('config', help='config file path') + parser.add_argument( + '--iou-thr', + type=float, + default=0.5, + help='IoU threshold for evaluation') + args = parser.parse_args() + cfg = mmcv.Config.fromfile(args.config) + test_dataset = mmcv.runner.obj_from_dict(cfg.data.test, datasets) + voc_eval(args.result, test_dataset, args.iou_thr) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/train.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/train.py new file mode 100644 index 000000000..73d27c7e9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_detection/train.py @@ -0,0 +1,112 @@ +from __future__ import division + +import argparse +import torch +# torch.multiprocessing.set_sharing_strategy('file_system') +# for file_descriptor, but cause shm leak while nas optimizer +import os + +from mmcv import Config + +from mmdet import __version__ +from mmdet.datasets import build_dataset +from mmdet.apis import (train_detector, init_dist, get_root_logger, + set_random_seed) +from mmdet.models import build_detector + + +def parse_args(): + parser = argparse.ArgumentParser(description='Train a detector') + parser.add_argument('--config', help='train config file path') + parser.add_argument('--work_dir', default='/cache/tmp', help='path to save log and model') + parser.add_argument( + '--resume_from', help='the checkpoint file to resume from') + parser.add_argument( + '--validate', + action='store_true', + help='whether to evaluate the checkpoint during training') + parser.add_argument( + '--gpus', + type=int, + default=1, + help='number of gpus to use ' + '(only applicable to non-distributed training)') + parser.add_argument('--seed', type=int, default=None, help='random seed') + parser.add_argument( + '--launcher', + choices=['none', 'pytorch', 'slurm', 'mpi'], + default='none', + help='job launcher') + parser.add_argument('--local_rank', type=int, default=0) + + args, unparsed = parser.parse_known_args() + + + if 'LOCAL_RANK' not in os.environ: + os.environ['LOCAL_RANK'] = str(args.local_rank) + + # Solve SyncBN deadlock + os.environ["NCCL_LL_THRESHOLD"] = '0' + return args + + +def main(): + args = parse_args() + cfg = Config.fromfile(args.config) + # set cudnn_benchmark + if cfg.get('cudnn_benchmark', False): + torch.backends.cudnn.benchmark = True + # update configs according to CLI args + cfg.work_dir = args.work_dir + cfg.gpus = args.gpus + if args.resume_from is not None: + cfg.resume_from = args.resume_from + + # init distributed env first, since logger depends on the dist info. + if args.launcher == 'none': + distributed = False + else: + distributed = True + init_dist(args.launcher, **cfg.dist_params) + + # init logger before other steps + logger = get_root_logger(cfg.log_level) + logger.info('Distributed training: {}'.format(distributed)) + + # set random seeds + if args.seed is not None: + logger.info('Set random seed to {}'.format(args.seed)) + set_random_seed(args.seed) + model = build_detector( + cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg) + + train_dataset = build_dataset(cfg.data.train) + + model = torch.nn.parallel.DistributedDataParallel( + model.cuda(), find_unused_parameters=True, device_ids=[args.local_rank], output_device=args.local_rank) + print(model) + print("Model have {} paramerters.".format(sum(x.numel() for x in model.parameters()) / 1e6)) + print("Model have {} backbone.".format(sum(x.numel() for x in model.module.backbone.parameters()) / 1e6)) + print("Model have {} neck.".format(sum(x.numel() for x in model.module.neck.parameters()) / 1e6)) + print("Model have {} head.".format(sum(x.numel() for x in model.module.bbox_head.parameters()) / 1e6)) + + if cfg.checkpoint_config is not None: + # save mmdet version, config file content and class names in + # checkpoints as meta data + cfg.checkpoint_config.meta = dict( + mmdet_version=__version__, + config=cfg.text, + CLASSES=train_dataset.CLASSES) + # add an attribute for visualization convenience + model.CLASSES = train_dataset.CLASSES + train_detector( + model, + train_dataset, + cfg, + distributed=distributed, + validate=args.validate, + logger=logger) + + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/LICENSE b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/LICENSE new file mode 100644 index 000000000..d281f8971 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Wuyang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/README.md new file mode 100644 index 000000000..3422a3dd3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/README.md @@ -0,0 +1,48 @@ +## Prerequisites +- Ubuntu 16.04 +- Python 3.7 +- CUDA 11.1 (lower versions may work but were not tested) +- NVIDIA GPU (>= 11G graphic memory) + CuDNN v7.3 + +This repository has been tested on RTX 3090. Configurations (e.g batch size, image patch size) may need to be changed on different platforms. + +## Installation +* Clone this repo: +```bash +cd CDARTS_segmentation +``` +* Install dependencies: +```bash +bash install.sh +``` + +## Usage +### 0. Prepare the dataset +* Download the [leftImg8bit_trainvaltest.zip](https://www.cityscapes-dataset.com/file-handling/?packageID=3) and [gtFine_trainvaltest.zip](https://www.cityscapes-dataset.com/file-handling/?packageID=1) from the Cityscapes. +* Prepare the annotations by using the [createTrainIdLabelImgs.py](https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createTrainIdLabelImgs.py). +* Put the [file of image list](tools/datasets/cityscapes/) into where you save the dataset. + + +### 1. Train from scratch +* `cd HRTNet/train` +* Set the dataset path via `ln -s $YOUR_DATA_PATH ../DATASET` +* Set the output path via `mkdir ../OUTPUT` +* Train from scratch +``` +export DETECTRON2_DATASETS="$Your_DATA_PATH" +NGPUS=8 +python -m torch.distributed.launch --nproc_per_node=$NGPUS train.py --world_size $NGPUS --seed 12367 --config ../configs/cityscapes/cydas.yaml +``` + +### 2. Evaluation +We provide training models and logs, which can be downloaded from [Google Drive](https://drive.google.com/drive/folders/1CkFp24bEDq0wUp504BQ68jn5Vs069qox?usp=sharing). + +```bash +cd train +``` +* Download the pretrained weights of the from [Google Drive](https://drive.google.com/drive/folders/1CkFp24bEDq0wUp504BQ68jn5Vs069qox?usp=sharing). +* Set `config.model_path = $YOUR_MODEL_PATH` in `cydas.yaml`. +* Set `config.json_file = $CDARTS_MODEL` in `cydas.yaml`. +* Start the evaluation process: +```bash +CUDA_VISIBLE_DEVICES=0 python test.py \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/ade/cydas.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/ade/cydas.yaml new file mode 100644 index 000000000..f9d8ac370 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/ade/cydas.yaml @@ -0,0 +1,37 @@ +json_file: "jsons/big4.json" +data_path: "../DATASET/ADEChallengeData2016/" +dataset: "coco" +det2_cfg: "configs/ADE20K/base.yaml" +num_classes: 150 +max_iteration: 160000 +seed: 12345 +random_sample: False +eval_flag: True +opt: "sgd" +opt_eps: 0.001 +sched: "new" #"raw for original" +epochs: 1000 +drop_path_prob: 0.2 +image_height: 640 +image_width: 640 +eval_height: 640 +eval_width: 640 +crop_size: 640 +batch_size: 4 +mode: "poly" +base_lr: 0.05 +Fch: 16 +bn_momentum: 0.01 +warmup_start_lr: 5e-6 +warmup_iters: 1000 +weight_decay: 1e-4 +model_ema: True +model_ema_decay: 0.9998 +clip_grad: 1.0 +lamb: 0.2 +ignore: 255 +topk_percent: 0.2 +semantic_loss_weight: 1.0 +center_loss_weight: 200 +offset_loss_weight: 0.01 +eval_flip: False diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/cityscapes/cydas.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/cityscapes/cydas.yaml new file mode 100644 index 000000000..f0a06614c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/configs/cityscapes/cydas.yaml @@ -0,0 +1,24 @@ +data_path: "../DATASET/cityscapes/" +det2_cfg: "configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml" +seed: 12345 +random_sample: False +opt: "sgd" +opt_eps: 0.001 +sched: "new" #"raw for original" +epochs: 4000 +drop_path_prob: 0.2 +image_height: 512 +image_width: 1024 +eval_height: 1024 +eval_width: 2048 +batch_size: 4 +mode: "poly" +base_lr: 0.05 +workers: 4 +Fch: 6 +warmup_start_lr: 5e-6 +warmup_iters: 1000 +weight_decay: 1e-4 +model_ema: True +model_ema_decay: 0.9998 +stem_head_width: 1.0 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/__init__.py new file mode 100644 index 000000000..8f80b92dc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/__init__.py @@ -0,0 +1,285 @@ +from dataloaders.datasets import cityscapes, kd, coco, combine_dbs, pascal, sbd +from dataloaders.segdatasets import Cityscapes, CityscapesPanoptic, COCOPanoptic +from torch.utils.data import DataLoader +import torch.utils.data.distributed + +def make_data_loader(args, **kwargs): + root = args.data_path + if args.dist: + print("=> Using Distribued Sampler") + if args.dataset == 'cityscapes': + if args.autodeeplab == 'train': + train_set = cityscapes.CityscapesSegmentation(args, root, split='retrain') + num_class = train_set.NUM_CLASSES + train_sampler = torch.utils.data.distributed.DistributedSampler(train_set) + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, sampler=train_sampler, **kwargs) + + val_set = cityscapes.CityscapesSegmentation(args, root, split='val') + test_set = cityscapes.CityscapesSegmentation(args, root, split='test') + val_sampler = torch.utils.data.distributed.DistributedSampler(val_set) + test_sampler = torch.utils.data.distributed.DistributedSampler(test_set) + val_loader = DataLoader(val_set, batch_size=args.batch_size, shuffle=False, sampler=val_sampler, **kwargs) + test_loader = DataLoader(test_set, batch_size=args.batch_size, shuffle=False, sampler=test_sampler, **kwargs) + + elif args.autodeeplab == 'train_seg': + dataset_cfg = { + 'cityscapes': dict( + root=args.data_path, + split='train', + is_train=True, + crop_size=(args.image_height, args.image_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225) + )} + train_set = Cityscapes(**dataset_cfg['cityscapes']) + num_class = train_set.num_classes + train_sampler = torch.utils.data.distributed.DistributedSampler(train_set) + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, sampler=train_sampler, **kwargs) + + dataset_val_cfg = { + 'cityscapes': dict( + root=args.data_path, + split='val', + is_train=False, + crop_size=(args.eval_height, args.eval_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225) + )} + val_set = Cityscapes(**dataset_val_cfg['cityscapes']) + val_sampler = torch.utils.data.distributed.DistributedSampler(val_set) + val_loader = DataLoader(val_set, batch_size=max(1, args.batch_size//4), shuffle=False, sampler=val_sampler, num_workers=args.workers, pin_memory=True, drop_last=False) + + elif args.autodeeplab == 'train_seg_panoptic': + dataset_cfg = { + 'cityscapes_panoptic': dict( + root=args.data_path, + split='train', + is_train=True, + crop_size=(args.image_height, args.image_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + train_set = CityscapesPanoptic(**dataset_cfg['cityscapes_panoptic']) + num_class = train_set.num_classes + train_sampler = torch.utils.data.distributed.DistributedSampler(train_set) + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, sampler=train_sampler, **kwargs) + + dataset_val_cfg = { + 'cityscapes_panoptic': dict( + root=args.data_path, + split='val', + is_train=False, + crop_size=(args.eval_height, args.eval_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + val_set = Cityscapes(**dataset_val_cfg['cityscapes_panoptic']) + val_sampler = torch.utils.data.distributed.DistributedSampler(val_set) + val_loader = DataLoader(val_set, batch_size=max(1, args.batch_size//4), shuffle=False, sampler=val_sampler, num_workers=args.workers, pin_memory=True, drop_last=False) + else: + raise Exception('autodeeplab param not set properly') + + return train_loader, train_sampler, val_loader, val_sampler, num_class + + elif args.dataset == 'coco': + if args.autodeeplab == 'train_seg_panoptic': + dataset_cfg = { + 'coco_panoptic': dict( + root=args.data_path, + split='train2017', + is_train=True, + min_resize_value=args.image_height, + max_resize_value=args.image_height, + resize_factor=32, + crop_size=(args.image_height, args.image_width), + mirror=True, + min_scale=0.5, + max_scale=1.5, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + train_set = COCOPanoptic(**dataset_cfg['coco_panoptic']) + num_class = train_set.num_classes + train_sampler = torch.utils.data.distributed.DistributedSampler(train_set) + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, sampler=train_sampler, **kwargs) + + + # train_set = coco.COCOSegmentation(args, root, split='train') + # root=args.data_path + # val_set = coco.COCOSegmentation(args, root, split='val') + dataset_val_cfg = { + 'coco_panoptic': dict( + root=args.data_path, + split='val2017', + is_train=True, + min_resize_value=args.image_height, + max_resize_value=args.image_height, + resize_factor=32, + crop_size=(args.eval_height, args.eval_width), + mirror=False, + min_scale=1, + max_scale=1, + scale_step_size=0, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + val_set = COCOPanoptic(**dataset_val_cfg['coco_panoptic']) + val_sampler = torch.utils.data.distributed.DistributedSampler(val_set) + val_loader = DataLoader(val_set, batch_size=args.batch_size*4, shuffle=False, sampler=val_sampler, num_workers=args.workers, pin_memory=True, drop_last=False) + + return train_loader, train_sampler, val_loader, val_sampler, num_class + else: + raise NotImplementedError + + else: + if args.dataset == 'pascal': + train_set = pascal.VOCSegmentation(args, root, split='train') + val_set = pascal.VOCSegmentation(args, root, split='val') + if args.use_sbd: + sbd_train = sbd.SBDSegmentation(args, root, split=['train', 'val']) + train_set = combine_dbs.CombineDBs([train_set, sbd_train], excluded=[val_set]) + + num_class = train_set.NUM_CLASSES + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=True, **kwargs) + val_loader = DataLoader(val_set, batch_size=args.batch_size, shuffle=False, **kwargs) + test_loader = None + + return train_loader, train_loader, val_loader, test_loader, num_class + + elif args.dataset == 'cityscapes': + if args.autodeeplab == 'train_seg': + dataset_cfg = { + 'cityscapes': dict( + root=args.data_path, + split='train', + is_train=True, + crop_size=(args.image_height, args.image_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225) + )} + train_set = Cityscapes(**dataset_cfg['cityscapes']) + num_class = train_set.num_classes + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, **kwargs) + + dataset_val_cfg = { + 'cityscapes': dict( + root=args.data_path, + split='val', + is_train=False, + crop_size=(args.eval_height, args.eval_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225) + )} + val_set = Cityscapes(**dataset_val_cfg['cityscapes']) + val_loader = DataLoader(val_set, batch_size=max(1, args.batch_size//4), shuffle=False, num_workers=args.workers, pin_memory=True, drop_last=False) + + elif args.autodeeplab == 'train_seg_panoptic': + dataset_cfg = { + 'cityscapes_panoptic': dict( + root=args.data_path, + split='train', + is_train=True, + crop_size=(args.image_height, args.image_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + train_set = CityscapesPanoptic(**dataset_cfg['cityscapes_panoptic']) + num_class = train_set.num_classes + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=False, **kwargs) + + dataset_val_cfg = { + 'cityscapes_panoptic': dict( + root=args.data_path, + split='val', + is_train=False, + crop_size=(args.eval_height, args.eval_width), + mirror=True, + min_scale=0.5, + max_scale=2.0, + scale_step_size=0.1, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=True, + small_instance_area=4096, + small_instance_weight=3 + )} + val_set = Cityscapes(**dataset_val_cfg['cityscapes_panoptic']) + val_loader = DataLoader(val_set, batch_size=max(1, args.batch_size//4), shuffle=False, num_workers=args.workers, pin_memory=True, drop_last=False) + else: + raise Exception('autodeeplab param not set properly') + + return train_loader, val_loader, num_class + + + elif args.dataset == 'coco': + train_set = coco.COCOSegmentation(args, root, split='train') + val_set = coco.COCOSegmentation(args, root, split='val') + num_class = train_set.NUM_CLASSES + train_loader = DataLoader(train_set, batch_size=args.batch_size, shuffle=True, **kwargs) + val_loader = DataLoader(val_set, batch_size=args.batch_size, shuffle=False, **kwargs) + test_loader = None + return train_loader, train_loader, val_loader, test_loader, num_class + + elif args.dataset == 'kd': + train_set = kd.CityscapesSegmentation(args, root, split='train') + val_set = kd.CityscapesSegmentation(args, root, split='val') + test_set = kd.CityscapesSegmentation(args, root, split='test') + num_class = train_set.NUM_CLASSES + train_loader1 = DataLoader(train_set, batch_size=args.batch_size, shuffle=True, **kwargs) + train_loader2 = DataLoader(train_set, batch_size=args.batch_size, shuffle=True, **kwargs) + val_loader = DataLoader(val_set, batch_size=args.batch_size, shuffle=False, **kwargs) + test_loader = DataLoader(test_set, batch_size=args.batch_size, shuffle=False, **kwargs) + + return train_loader1, train_loader2, val_loader, test_loader, num_class + else: + raise NotImplementedError diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py new file mode 100644 index 000000000..e40fa4420 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/custom_transforms.py @@ -0,0 +1,326 @@ +import math +import torch +import random +import numpy as np +import torch.nn as nn +from numpy import int64 as int64 +import torchvision.transforms as transforms + +from PIL import Image, ImageOps, ImageFilter + + +class Normalize(object): + """Normalize a tensor image with mean and standard deviation. + Args: + mean (tuple): means for each channel. + std (tuple): standard deviations for each channel. + """ + + def __init__(self, mean=(0., 0., 0.), std=(1., 1., 1.)): + self.mean = mean + self.std = std + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + img = np.array(img).astype(np.float32) + mask = np.array(mask).astype(np.float32) + img /= 255.0 + img -= self.mean + img /= self.std + + return {'image': img, + 'label': mask} + + +class ToTensor(object): + """Convert ndarrays in sample to Tensors.""" + + def __call__(self, sample): + # swap color axis because + # numpy image: H x W x C + # torch image: C X H X W + img = sample['image'] + mask = sample['label'] + img = np.array(img).astype(np.float32).transpose((2, 0, 1)) + mask = np.array(mask).astype(np.float32) + + img = torch.from_numpy(img).float() + mask = torch.from_numpy(mask).float() + + return {'image': img, + 'label': mask} + + +class RandomHorizontalFlip(object): + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + if random.random() < 0.5: + img = img.transpose(Image.FLIP_LEFT_RIGHT) + mask = mask.transpose(Image.FLIP_LEFT_RIGHT) + + return {'image': img, + 'label': mask} + + +class RandomRotate(object): + def __init__(self, degree): + self.degree = degree + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + rotate_degree = random.uniform(-1 * self.degree, self.degree) + img = img.rotate(rotate_degree, Image.BILINEAR) + mask = mask.rotate(rotate_degree, Image.NEAREST) + + return {'image': img, + 'label': mask} + + +class RandomGaussianBlur(object): + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + if random.random() < 0.5: + img = img.filter(ImageFilter.GaussianBlur( + radius=random.random())) + + return {'image': img, + 'label': mask} + + +class RandomScaleCrop(object): + def __init__(self, base_size, crop_size, fill=0): + self.base_size = base_size + self.crop_size = crop_size + self.fill = fill + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + # random scale (short edge) + short_size = random.randint(int(self.base_size * 0.5), int(self.base_size * 2.0)) + w, h = img.size + if h > w: + ow = short_size + oh = int(1.0 * h * ow / w) + else: + oh = short_size + ow = int(1.0 * w * oh / h) + img = img.resize((ow, oh), Image.BILINEAR) + mask = mask.resize((ow, oh), Image.NEAREST) + # pad crop + if short_size < self.crop_size: + padh = self.crop_size - oh if oh < self.crop_size else 0 + padw = self.crop_size - ow if ow < self.crop_size else 0 + img = ImageOps.expand(img, border=(0, 0, padw, padh), fill=0) + mask = ImageOps.expand(mask, border=(0, 0, padw, padh), fill=self.fill) + # random crop crop_size + w, h = img.size + x1 = random.randint(0, w - self.crop_size) + y1 = random.randint(0, h - self.crop_size) + img = img.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + mask = mask.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + + return {'image': img, + 'label': mask} + + +class FixScaleCrop(object): + def __init__(self, crop_size): + self.crop_size = crop_size + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + w, h = img.size + if w > h: + oh = self.crop_size + ow = int(1.0 * w * oh / h) + else: + ow = self.crop_size + oh = int(1.0 * h * ow / w) + img = img.resize((ow, oh), Image.BILINEAR) + mask = mask.resize((ow, oh), Image.NEAREST) + # center crop + w, h = img.size + x1 = int(round((w - self.crop_size) / 2.)) + y1 = int(round((h - self.crop_size) / 2.)) + img = img.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + mask = mask.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + + return {'image': img, + 'label': mask} + + +# resize to 512*1024 +class FixedResize(object): + """change the short edge length to size""" + + def __init__(self, resize=512): + self.size1 = resize # size= 512 + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + assert img.size == mask.size + + w, h = img.size + if w > h: + oh = self.size1 + ow = int(1.0 * w * oh / h) + else: + ow = self.size1 + oh = int(1.0 * h * ow / w) + img = img.resize((ow, oh), Image.BILINEAR) + mask = mask.resize((ow, oh), Image.NEAREST) + return {'image': img, + 'label': mask} + + +# random crop 321*321 +class RandomCrop(object): + def __init__(self, crop_size=320): + self.crop_size = crop_size + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + w, h = img.size + x1 = random.randint(0, w - self.crop_size) + y1 = random.randint(0, h - self.crop_size) + img = img.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + mask = mask.crop((x1, y1, x1 + self.crop_size, y1 + self.crop_size)) + return {'image': img, + 'label': mask} + + +class RandomScale(object): + def __init__(self, scales=(1,)): + self.scales = scales + + def __call__(self, sample): + img = sample['image'] + mask = sample['label'] + w, h = img.size + scale = random.choice(self.scales) + w, h = int(w * scale), int(h * scale) + return {'image': img, + 'label': mask} + + +class Retrain_Preprocess(object): + def __init__(self, flip_prob, scale_range, crop, mean, std): + self.flip_prob = flip_prob + self.scale_range = scale_range + self.crop = crop + self.data_transforms = transforms.Compose([transforms.ToTensor(), + transforms.Normalize(mean=mean, std=std)]) + + def __call__(self, sample): + if self.flip_prob is not None and random.random() < self.flip_prob: + sample['image'] = sample['image'].transpose(Image.FLIP_LEFT_RIGHT) + sample['label'] = sample['label'].transpose(Image.FLIP_LEFT_RIGHT) + + if self.scale_range is not None: + w, h = sample['image'].size + rand_log_scale = math.log(self.scale_range[0], 2) + random.random() * \ + (math.log(self.scale_range[1], 2) - math.log(self.scale_range[0], 2)) + random_scale = math.pow(2, rand_log_scale) + new_size = (int(round(w * random_scale)), int(round(h * random_scale))) + sample['image'] = sample['image'].resize(new_size, Image.ANTIALIAS) + sample['label'] = sample['label'].resize(new_size, Image.NEAREST) + sample['image'] = self.data_transforms(sample['image']) + sample['label'] = torch.LongTensor(np.array(sample['label']).astype(int64)) + + if self.crop: + image, mask = sample['image'], sample['label'] + h, w = image.shape[1], image.shape[2] + pad_tb = max(0, self.crop[0] - h) + pad_lr = max(0, self.crop[1] - w) + image = nn.ZeroPad2d((0, pad_lr, 0, pad_tb))(image) + mask = nn.ConstantPad2d((0, pad_lr, 0, pad_tb), 255)(mask) + + h, w = image.shape[1], image.shape[2] + i = random.randint(0, h - self.crop[0]) + j = random.randint(0, w - self.crop[1]) + sample['image'] = image[:, i:i + self.crop[0], j:j + self.crop[1]] + sample['label'] = mask[i:i + self.crop[0], j:j + self.crop[1]] + return sample + + +class transform_tr(object): + def __init__(self, args, mean, std): + if args.multi_scale is None: + self.composed_transforms = transforms.Compose([ + FixedResize(resize=args.resize), + RandomCrop(crop_size=args.crop_size), + # tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size, fill=255), + # tr.RandomGaussianBlur(), + Normalize(mean, std), + ToTensor()]) + else: + self.composed_transforms = transforms.Compose([ + FixedResize(resize=args.resize), + RandomScale(scales=args.multi_scale), + RandomCrop(crop_size=args.crop_size), + # tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size, fill=255), + # tr.RandomGaussianBlur(), + Normalize(mean, std), + ToTensor()]) + + def __call__(self, sample): + return self.composed_transforms(sample) + + +class transform_val(object): + def __init__(self, args, mean, std): + self.composed_transforms = transforms.Compose([ + FixedResize(resize=args.resize), + FixScaleCrop(crop_size=args.crop_size), # TODO:CHECK THIS + Normalize(mean, std), + ToTensor()]) + + def __call__(self, sample): + return self.composed_transforms(sample) + + +class transform_val(object): + def __init__(self, args, mean, std): + self.composed_transforms = transforms.Compose([ + FixedResize(resize=args.crop_size), + Normalize(mean, std), + ToTensor()]) + + def __call__(self, sample): + return self.composed_transforms(sample) + + +class transform_ts(object): + def __init__(self, args, mean, std): + self.composed_transforms = transforms.Compose([ + FixedResize(resize=args.crop_size), + Normalize(mean, std), + ToTensor()]) + + def __call__(self, sample): + return self.composed_transforms(sample) + + +class transform_retr(object): + def __init__(self, args, mean, std): + crop_size = (args.crop_size, args.crop_size) if isinstance(args.crop_size, int) else args.crop_size + self.composed_transforms = Retrain_Preprocess(0.5, (0.5, 2), crop_size, mean, std) + + def __call__(self, sample): + return self.composed_transforms(sample) + + +class transform_reval(object): # we use multi_scale evaluate in evaluate.py so dont need resize in dataset + def __init__(self, args, mean, std): + self.composed_transforms = Retrain_Preprocess(None, None, None, mean, std) + + def __call__(self, sample): + return self.composed_transforms(sample) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/dataloader_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/dataloader_utils.py new file mode 100644 index 000000000..4bb600c35 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/dataloader_utils.py @@ -0,0 +1,104 @@ +import matplotlib.pyplot as plt +import numpy as np +import torch + +def decode_seg_map_sequence(label_masks, dataset='pascal'): + rgb_masks = [] + for label_mask in label_masks: + rgb_mask = decode_segmap(label_mask, dataset) + rgb_masks.append(rgb_mask) + rgb_masks = torch.from_numpy(np.array(rgb_masks).transpose([0, 3, 1, 2])) + return rgb_masks + + +def decode_segmap(label_mask, dataset, plot=False): + """Decode segmentation class labels into a color image + Args: + label_mask (np.ndarray): an (M,N) array of integer values denoting + the class label at each spatial location. + plot (bool, optional): whether to show the resulting color image + in a figure. + Returns: + (np.ndarray, optional): the resulting decoded color image. + """ + if dataset == 'pascal' or dataset == 'coco': + n_classes = 21 + label_colours = get_pascal_labels() + elif dataset == 'cityscapes': + n_classes = 19 + label_colours = get_cityscapes_labels() + elif dataset == 'kd': + n_classes = 19 + label_colours = get_cityscapes_labels() + else: + raise NotImplementedError + + r = label_mask.copy() + g = label_mask.copy() + b = label_mask.copy() + for ll in range(0, n_classes): + r[label_mask == ll] = label_colours[ll, 0] + g[label_mask == ll] = label_colours[ll, 1] + b[label_mask == ll] = label_colours[ll, 2] + rgb = np.zeros((label_mask.shape[0], label_mask.shape[1], 3)) + rgb[:, :, 0] = r / 255.0 + rgb[:, :, 1] = g / 255.0 + rgb[:, :, 2] = b / 255.0 + if plot: + plt.imshow(rgb) + plt.show() + else: + return rgb + + +def encode_segmap(mask): + """Encode segmentation label images as pascal classes + Args: + mask (np.ndarray): raw segmentation label image of dimension + (M, N, 3), in which the Pascal classes are encoded as colours. + Returns: + (np.ndarray): class map with dimensions (M,N), where the value at + a given location is the integer denoting the class index. + """ + mask = mask.astype(int) + label_mask = np.zeros((mask.shape[0], mask.shape[1]), dtype=np.int16) + for ii, label in enumerate(get_pascal_labels()): + label_mask[np.where(np.all(mask == label, axis=-1))[:2]] = ii + label_mask = label_mask.astype(int) + return label_mask + + +def get_cityscapes_labels(): + return np.array([ + [128, 64, 128], + [244, 35, 232], + [70, 70, 70], + [102, 102, 156], + [190, 153, 153], + [153, 153, 153], + [250, 170, 30], + [220, 220, 0], + [107, 142, 35], + [152, 251, 152], + [0, 130, 180], + [220, 20, 60], + [255, 0, 0], + [0, 0, 142], + [0, 0, 70], + [0, 60, 100], + [0, 80, 100], + [0, 0, 230], + [119, 11, 32]]) + + +def get_pascal_labels(): + """Load the mapping that associates pascal classes with label colors + Returns: + np.ndarray with dimensions (21, 3) + """ + return np.asarray([[0, 0, 0], [128, 0, 0], [0, 128, 0], [128, 128, 0], + [0, 0, 128], [128, 0, 128], [0, 128, 128], [128, 128, 128], + [64, 0, 0], [192, 0, 0], [64, 128, 0], [192, 128, 0], + [64, 0, 128], [192, 0, 128], [64, 128, 128], [192, 128, 128], + [0, 64, 0], [128, 64, 0], [0, 192, 0], [128, 192, 0], + [0, 64, 128]]) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/cityscapes.py new file mode 100644 index 000000000..ae45e87e4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/cityscapes.py @@ -0,0 +1,153 @@ +import os +import numpy as np +from PIL import Image +from torch.utils import data +from dataloaders import custom_transforms as tr + + +def twoTrainSeg(args, root): + images_base = os.path.join(root, 'leftImg8bit', 'train') + train_files = [os.path.join(looproot, filename) for looproot, _, filenames in os.walk(images_base) + for filename in filenames if filename.endswith('.png')] + number_images = len(train_files) + permuted_indices_ls = np.random.permutation(number_images) + indices_1 = permuted_indices_ls[: int(0.5 * number_images) + 1] + indices_2 = permuted_indices_ls[int(0.5 * number_images):] + if len(indices_1) % 2 != 0 or len(indices_2) % 2 != 0: + raise Exception('indices lists need to be even numbers for batch norm') + return CityscapesSegmentation(args, split='train', indices_for_split=indices_1), CityscapesSegmentation(args, + split='train', + indices_for_split=indices_2) + + +class CityscapesSegmentation(data.Dataset): + NUM_CLASSES = 19 + + CLASSES = [ + 'road', 'sidewalk', 'building', 'wall', 'fence', 'pole', 'traffic light', + 'traffic sign', 'vegetation', 'terrain', 'sky', 'person', 'rider', 'car', + 'truck', 'bus', 'train', 'motorcycle', 'bicycle' + ] + + def __init__(self, args, root, split="train", indices_for_split=None): + self.root = root + self.split = split + self.args = args + self.files = {} + self.mean = (0.485, 0.456, 0.406) + self.std = (0.229, 0.224, 0.225) + self.crop = self.args.crop_size + if split.startswith('re'): + self.images_base = os.path.join(self.root, 'leftImg8bit', self.split[2:]) + self.annotations_base = os.path.join(self.root, 'gtFine', self.split[2:]) + else: + self.images_base = os.path.join(self.root, 'leftImg8bit', self.split) + self.annotations_base = os.path.join(self.root, 'gtFine', self.split) + + self.files[split] = self.recursive_glob(rootdir=self.images_base, suffix='.png') + + if indices_for_split is not None: + self.files[split] = np.array(self.files[split])[indices_for_split].tolist() + + self.void_classes = [0, 1, 2, 3, 4, 5, 6, 9, 10, 14, 15, 16, 18, 29, 30, -1] + self.valid_classes = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] + self.class_names = ['unlabelled', 'road', 'sidewalk', 'building', 'wall', 'fence', + 'pole', 'traffic_light', 'traffic_sign', 'vegetation', 'terrain', + 'sky', 'person', 'rider', 'car', 'truck', 'bus', 'train', + 'motorcycle', 'bicycle'] + + self.ignore_index = 255 + self.class_map = dict(zip(self.valid_classes, range(self.NUM_CLASSES))) + + if not self.files[split]: + raise Exception("No files for split=[%s] found in %s" % (split, self.images_base)) + + print("Found %d %s images" % (len(self.files[split]), split)) + self.transform = self.get_transform() + + def __len__(self): + return len(self.files[self.split]) + + def __getitem__(self, index): + + img_path = self.files[self.split][index].rstrip() + lbl_path = os.path.join(self.annotations_base, + img_path.split(os.sep)[-2], + os.path.basename(img_path)[:-15] + 'gtFine_labelIds.png') + + _img = Image.open(img_path).convert('RGB') + _tmp = np.array(Image.open(lbl_path), dtype=np.uint8) + _tmp = self.encode_segmap(_tmp) + _target = Image.fromarray(_tmp) + + sample = {'image': _img, 'label': _target} + return self.transform(sample) + + def encode_segmap(self, mask): + # Put all void classes to zero + for _voidc in self.void_classes: + mask[mask == _voidc] = self.ignore_index + for _validc in self.valid_classes: + mask[mask == _validc] = self.class_map[_validc] + return mask + + def recursive_glob(self, rootdir='.', suffix=''): + """Performs recursive glob with given suffix and rootdir + :param rootdir is the root directory + :param suffix is the suffix to be searched + """ + return [os.path.join(looproot, filename) + for looproot, _, filenames in os.walk(rootdir) + for filename in filenames if filename.endswith(suffix)] + + def get_transform(self): + if self.split == 'train': + return tr.transform_tr(self.args, self.mean, self.std) + elif self.split == 'val': + return tr.transform_val(self.args, self.mean, self.std) + elif self.split == 'test': + return tr.transform_ts(self.args, self.mean, self.std) + elif self.split == 'retrain': + return tr.transform_retr(self.args, self.mean, self.std) + elif self.split == 'reval': + return tr.transform_reval(self.args, self.mean, self.std) + + +if __name__ == '__main__': + from dataloaders.dataloader_utils import decode_segmap + from torch.utils.data import DataLoader + import matplotlib.pyplot as plt + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.resize = 513 + args.base_size = 513 + args.crop_size = 513 + + cityscapes_train = CityscapesSegmentation(args, split='retrain') + + dataloader = DataLoader(cityscapes_train, batch_size=2, shuffle=True, num_workers=2) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='cityscapes') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + + plt.show(block=True) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/coco.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/coco.py new file mode 100644 index 000000000..5827425c0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/coco.py @@ -0,0 +1,160 @@ +import numpy as np +import torch +from torch.utils.data import Dataset +from tqdm import trange +import os +from pycocotools.coco import COCO +from pycocotools import mask +from torchvision import transforms +from dataloaders import custom_transforms as tr +from PIL import Image, ImageFile +ImageFile.LOAD_TRUNCATED_IMAGES = True + + +class COCOSegmentation(Dataset): + NUM_CLASSES = 21 + CAT_LIST = [0, 5, 2, 16, 9, 44, 6, 3, 17, 62, 21, 67, 18, 19, 4, + 1, 64, 20, 63, 7, 72] + + def __init__(self, + args, + base_dir, + split='train', + year='2017'): + super().__init__() + ann_file = os.path.join(base_dir, 'annotations/instances_{}{}.json'.format(split, year)) + ids_file = os.path.join(base_dir, 'annotations/{}_ids_{}.pth'.format(split, year)) + # self.img_dir = os.path.join(base_dir, 'images/{}{}'.format(split, year)) + self.img_dir = os.path.join(base_dir, '{}{}'.format(split, year)) + self.split = split + self.coco = COCO(ann_file) + self.coco_mask = mask + if os.path.exists(ids_file): + self.ids = torch.load(ids_file) + else: + ids = list(self.coco.imgs.keys()) + self.ids = self._preprocess(ids, ids_file) + self.args = args + + def __getitem__(self, index): + _img, _target = self._make_img_gt_point_pair(index) + sample = {'image': _img, 'label': _target} + + if self.split == "train": + return self.transform_tr(sample) + elif self.split == 'val': + return self.transform_val(sample) + + def _make_img_gt_point_pair(self, index): + coco = self.coco + img_id = self.ids[index] + img_metadata = coco.loadImgs(img_id)[0] + path = img_metadata['file_name'] + _img = Image.open(os.path.join(self.img_dir, path)).convert('RGB') + cocotarget = coco.loadAnns(coco.getAnnIds(imgIds=img_id)) + _target = Image.fromarray(self._gen_seg_mask( + cocotarget, img_metadata['height'], img_metadata['width'])) + + return _img, _target + + def _preprocess(self, ids, ids_file): + print("Preprocessing mask, this will take a while. " + \ + "But don't worry, it only run once for each split.") + tbar = trange(len(ids)) + new_ids = [] + for i in tbar: + img_id = ids[i] + cocotarget = self.coco.loadAnns(self.coco.getAnnIds(imgIds=img_id)) + img_metadata = self.coco.loadImgs(img_id)[0] + mask = self._gen_seg_mask(cocotarget, img_metadata['height'], + img_metadata['width']) + # more than 1k pixels + if (mask > 0).sum() > 1000: + new_ids.append(img_id) + tbar.set_description('Doing: {}/{}, got {} qualified images'. \ + format(i, len(ids), len(new_ids))) + print('Found number of qualified images: ', len(new_ids)) + torch.save(new_ids, ids_file) + return new_ids + + def _gen_seg_mask(self, target, h, w): + mask = np.zeros((h, w), dtype=np.uint8) + coco_mask = self.coco_mask + for instance in target: + rle = coco_mask.frPyObjects(instance['segmentation'], h, w) + m = coco_mask.decode(rle) + cat = instance['category_id'] + if cat in self.CAT_LIST: + c = self.CAT_LIST.index(cat) + else: + continue + if len(m.shape) < 3: + mask[:, :] += (mask == 0) * (m * c) + else: + mask[:, :] += (mask == 0) * (((np.sum(m, axis=2)) > 0) * c).astype(np.uint8) + return mask + + def transform_tr(self, sample): + composed_transforms = transforms.Compose([ + tr.RandomHorizontalFlip(), + tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size), + tr.RandomGaussianBlur(), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + def transform_val(self, sample): + + composed_transforms = transforms.Compose([ + tr.FixScaleCrop(crop_size=self.args.crop_size), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + + def __len__(self): + return len(self.ids) + + + +if __name__ == "__main__": + from dataloaders import custom_transforms as tr + from dataloaders.dataloader_utils import decode_segmap + from torch.utils.data import DataLoader + from torchvision import transforms + import matplotlib.pyplot as plt + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.base_size = 513 + args.crop_size = 513 + + coco_val = COCOSegmentation(args, split='val', year='2017') + + dataloader = DataLoader(coco_val, batch_size=4, shuffle=True, num_workers=0) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='coco') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + + plt.show(block=True) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/combine_dbs.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/combine_dbs.py new file mode 100644 index 000000000..b251a736b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/combine_dbs.py @@ -0,0 +1,100 @@ +import torch.utils.data as data + + +class CombineDBs(data.Dataset): + NUM_CLASSES = 21 + def __init__(self, dataloaders, excluded=None): + self.dataloaders = dataloaders + self.excluded = excluded + self.im_ids = [] + + # Combine object lists + for dl in dataloaders: + for elem in dl.im_ids: + if elem not in self.im_ids: + self.im_ids.append(elem) + + # Exclude + if excluded: + for dl in excluded: + for elem in dl.im_ids: + if elem in self.im_ids: + self.im_ids.remove(elem) + + # Get object pointers + self.cat_list = [] + self.im_list = [] + new_im_ids = [] + num_images = 0 + for ii, dl in enumerate(dataloaders): + for jj, curr_im_id in enumerate(dl.im_ids): + if (curr_im_id in self.im_ids) and (curr_im_id not in new_im_ids): + num_images += 1 + new_im_ids.append(curr_im_id) + self.cat_list.append({'db_ii': ii, 'cat_ii': jj}) + + self.im_ids = new_im_ids + print('Combined number of images: {:d}'.format(num_images)) + + def __getitem__(self, index): + + _db_ii = self.cat_list[index]["db_ii"] + _cat_ii = self.cat_list[index]['cat_ii'] + sample = self.dataloaders[_db_ii].__getitem__(_cat_ii) + + if 'meta' in sample.keys(): + sample['meta']['db'] = str(self.dataloaders[_db_ii]) + + return sample + + def __len__(self): + return len(self.cat_list) + + def __str__(self): + include_db = [str(db) for db in self.dataloaders] + exclude_db = [str(db) for db in self.excluded] + return 'Included datasets:'+str(include_db)+'\n'+'Excluded datasets:'+str(exclude_db) + + +if __name__ == "__main__": + import matplotlib.pyplot as plt + from dataloaders.datasets import pascal, sbd + from dataloaders import sbd + import torch + import numpy as np + from dataloaders.dataloader_utils import decode_segmap + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.base_size = 513 + args.crop_size = 513 + + pascal_voc_val = pascal.VOCSegmentation(args, split='val') + sbd = sbd.SBDSegmentation(args, split=['train', 'val']) + pascal_voc_train = pascal.VOCSegmentation(args, split='train') + + dataset = CombineDBs([pascal_voc_train, sbd], excluded=[pascal_voc_val]) + dataloader = torch.utils.data.DataLoader(dataset, batch_size=2, shuffle=True, num_workers=0) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='pascal') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + plt.show(block=True) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/kd.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/kd.py new file mode 100644 index 000000000..ef7820ca0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/kd.py @@ -0,0 +1,139 @@ +import os +import numpy as np +import scipy.misc as m +from PIL import Image +from torch.utils import data +from torchvision import transforms +from dataloaders import custom_transforms as tr +import pandas as pd + +class CityscapesSegmentation(data.Dataset): + NUM_CLASSES = 7 + + def __init__(self, args, root, split="train"): + + self.root = root + self.split = split + self.args = args + self.files = {} + + self.images_base = os.path.join(self.root, 'kd-cityscapes-sources', self.split) + self.annotations_base = os.path.join(self.root, 'kd-cityscapes-gt', self.split) + + self.files[split] = self.recursive_glob(rootdir=self.images_base, suffix='.png') + self.map = pd.read_csv('label_map.txt', header=0, sep='\t') + self.map['#id'] = self.map['#id'] + 6 + + self.dict_map = dict(zip(self.map['#id'],self.map['categoryId'])) + if not self.files[split]: + raise Exception("No files for split=[%s] found in %s" % (split, self.images_base)) + + print("Found %d %s images" % (len(self.files[split]), split)) + + def __len__(self): + return len(self.files[self.split]) + + def __getitem__(self, index): + + img_path = self.files[self.split][index].rstrip() + lbl_path = os.path.join(self.annotations_base, + img_path.split(os.sep)[-2], + os.path.basename(img_path)) + + _img = Image.open(img_path).convert('RGB') + _tmp = np.array(Image.open(lbl_path), dtype=np.uint8) + _tmp = self.encode_segmap(_tmp) + _target = Image.fromarray(_tmp) + + sample = {'image': _img, 'label': _target} + + if self.split == 'train': + return self.transform_tr(sample) + elif self.split == 'val': + return self.transform_val(sample) + elif self.split == 'test': + return self.transform_ts(sample) + + def encode_segmap(self, mask): + + mask = mask + 6 + for label_id, cl in self.dict_map.items(): + mask[mask == label_id] = cl + + return mask + + def recursive_glob(self, rootdir='.', suffix=''): + """Performs recursive glob with given suffix and rootdir + :param rootdir is the root directory + :param suffix is the suffix to be searched + """ + return [os.path.join(looproot, filename) + for looproot, _, filenames in os.walk(rootdir) + for filename in filenames if filename.endswith(suffix)] + + def transform_tr(self, sample): + composed_transforms = transforms.Compose([ + tr.RandomHorizontalFlip(), + tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size, fill=255), + tr.RandomGaussianBlur(), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + def transform_val(self, sample): + + composed_transforms = transforms.Compose([ + tr.FixScaleCrop(crop_size=self.args.crop_size), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + def transform_ts(self, sample): + + composed_transforms = transforms.Compose([ + tr.FixedResize(size=self.args.crop_size), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + +if __name__ == '__main__': + from dataloaders.dataloader_utils import decode_segmap + from torch.utils.data import DataLoader + import matplotlib.pyplot as plt + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.base_size = 513 + args.crop_size = 513 + + cityscapes_train = CityscapesSegmentation(args, split='train') + + dataloader = DataLoader(cityscapes_train, batch_size=2, shuffle=True, num_workers=2) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='cityscapes') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + + plt.show(block=True) + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py new file mode 100644 index 000000000..e28015d54 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/pascal.py @@ -0,0 +1,144 @@ +from __future__ import print_function, division +import os +from PIL import Image +import numpy as np +from torch.utils.data import Dataset +from torchvision import transforms +from dataloaders import custom_transforms as tr + +class VOCSegmentation(Dataset): + """ + PascalVoc dataset + """ + NUM_CLASSES = 21 + + def __init__(self, + args, + base_dir, + split='train', + ): + """ + :param base_dir: path to VOC dataset directory + :param split: train/val + :param transform: transform to apply + """ + super().__init__() + self._base_dir = base_dir + self._image_dir = os.path.join(self._base_dir, 'JPEGImages') + self._cat_dir = os.path.join(self._base_dir, 'SegmentationClass') + + if isinstance(split, str): + self.split = [split] + else: + split.sort() + self.split = split + + self.args = args + + _splits_dir = os.path.join(self._base_dir, 'ImageSets', 'Segmentation') + + self.im_ids = [] + self.images = [] + self.categories = [] + + for splt in self.split: + with open(os.path.join(os.path.join(_splits_dir, splt + '.txt')), "r") as f: + lines = f.read().splitlines() + + for ii, line in enumerate(lines): + _image = os.path.join(self._image_dir, line + ".jpg") + _cat = os.path.join(self._cat_dir, line + ".png") + assert os.path.isfile(_image) + assert os.path.isfile(_cat) + self.im_ids.append(line) + self.images.append(_image) + self.categories.append(_cat) + + assert (len(self.images) == len(self.categories)) + + # Display stats + print('Number of images in {}: {:d}'.format(split, len(self.images))) + + def __len__(self): + return len(self.images) + + + def __getitem__(self, index): + _img, _target = self._make_img_gt_point_pair(index) + sample = {'image': _img, 'label': _target} + + for split in self.split: + if split == "train": + return self.transform_tr(sample) + elif split == 'val': + return self.transform_val(sample) + + + def _make_img_gt_point_pair(self, index): + _img = Image.open(self.images[index]).convert('RGB') + _target = Image.open(self.categories[index]) + + return _img, _target + + def transform_tr(self, sample): + composed_transforms = transforms.Compose([ + tr.RandomHorizontalFlip(), + tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size), + tr.RandomGaussianBlur(), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + def transform_val(self, sample): + + composed_transforms = transforms.Compose([ + tr.FixScaleCrop(crop_size=self.args.crop_size), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + def __str__(self): + return 'VOC2012(split=' + str(self.split) + ')' + + +if __name__ == '__main__': + from dataloaders.dataloader_utils import decode_segmap + from torch.utils.data import DataLoader + import matplotlib.pyplot as plt + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.base_size = 513 + args.crop_size = 513 + + voc_train = VOCSegmentation(args, split='train') + + dataloader = DataLoader(voc_train, batch_size=5, shuffle=True, num_workers=0) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='pascal') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + + plt.show(block=True) + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/sbd.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/sbd.py new file mode 100644 index 000000000..e1977437f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/datasets/sbd.py @@ -0,0 +1,128 @@ +from __future__ import print_function, division +import os + +import numpy as np +import scipy.io +import torch.utils.data as data +from PIL import Image + +from torchvision import transforms +from dataloaders import custom_transforms as tr + +class SBDSegmentation(data.Dataset): + NUM_CLASSES = 21 + + def __init__(self, + args, + base_dir, + split='train', + ): + """ + :param base_dir: path to VOC dataset directory + :param split: train/val + :param transform: transform to apply + """ + super().__init__() + self._base_dir = base_dir + self._dataset_dir = os.path.join(self._base_dir, 'dataset') + self._image_dir = os.path.join(self._dataset_dir, 'img') + self._cat_dir = os.path.join(self._dataset_dir, 'cls') + + + if isinstance(split, str): + self.split = [split] + else: + split.sort() + self.split = split + + self.args = args + + # Get list of all images from the split and check that the files exist + self.im_ids = [] + self.images = [] + self.categories = [] + for splt in self.split: + with open(os.path.join(self._dataset_dir, splt + '.txt'), "r") as f: + lines = f.read().splitlines() + + for line in lines: + _image = os.path.join(self._image_dir, line + ".jpg") + _categ= os.path.join(self._cat_dir, line + ".mat") + assert os.path.isfile(_image) + assert os.path.isfile(_categ) + self.im_ids.append(line) + self.images.append(_image) + self.categories.append(_categ) + + assert (len(self.images) == len(self.categories)) + + # Display stats + print('Number of images: {:d}'.format(len(self.images))) + + + def __getitem__(self, index): + _img, _target = self._make_img_gt_point_pair(index) + sample = {'image': _img, 'label': _target} + + return self.transform(sample) + + def __len__(self): + return len(self.images) + + def _make_img_gt_point_pair(self, index): + _img = Image.open(self.images[index]).convert('RGB') + _target = Image.fromarray(scipy.io.loadmat(self.categories[index])["GTcls"][0]['Segmentation'][0]) + + return _img, _target + + def transform(self, sample): + composed_transforms = transforms.Compose([ + tr.RandomHorizontalFlip(), + tr.RandomScaleCrop(base_size=self.args.base_size, crop_size=self.args.crop_size), + tr.RandomGaussianBlur(), + tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)), + tr.ToTensor()]) + + return composed_transforms(sample) + + + def __str__(self): + return 'SBDSegmentation(split=' + str(self.split) + ')' + + +if __name__ == '__main__': + from dataloaders.dataloader_utils import decode_segmap + from torch.utils.data import DataLoader + import matplotlib.pyplot as plt + import argparse + + parser = argparse.ArgumentParser() + args = parser.parse_args() + args.base_size = 513 + args.crop_size = 513 + + sbd_train = SBDSegmentation(args, split='train') + dataloader = DataLoader(sbd_train, batch_size=2, shuffle=True, num_workers=2) + + for ii, sample in enumerate(dataloader): + for jj in range(sample["image"].size()[0]): + img = sample['image'].numpy() + gt = sample['label'].numpy() + tmp = np.array(gt[jj]).astype(np.uint8) + segmap = decode_segmap(tmp, dataset='pascal') + img_tmp = np.transpose(img[jj], axes=[1, 2, 0]) + img_tmp *= (0.229, 0.224, 0.225) + img_tmp += (0.485, 0.456, 0.406) + img_tmp *= 255.0 + img_tmp = img_tmp.astype(np.uint8) + plt.figure() + plt.title('display') + plt.subplot(211) + plt.imshow(img_tmp) + plt.subplot(212) + plt.imshow(segmap) + + if ii == 1: + break + + plt.show(block=True) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/__init__.py new file mode 100644 index 000000000..8f70169fc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/__init__.py @@ -0,0 +1,4 @@ +from .base_dataset import BaseDataset +from .cityscapes import Cityscapes +from .cityscapes_panoptic import CityscapesPanoptic +from .coco_panoptic import COCOPanoptic diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/base_dataset.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/base_dataset.py new file mode 100644 index 000000000..73c7003fc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/base_dataset.py @@ -0,0 +1,182 @@ +# ------------------------------------------------------------------------------ +# Base class for loading a segmentation Dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import os + +import numpy as np +from PIL import Image, ImageOps + +import torch +from torch.utils import data + + +class BaseDataset(data.Dataset): + """ + Base class for segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225)): + self.root = root + self.split = split + self.is_train = is_train + + self.crop_h, self.crop_w = crop_size + + self.mirror = mirror + self.min_scale = min_scale + self.max_scale = max_scale + self.scale_step_size = scale_step_size + + self.mean = mean + self.std = std + + self.pad_value = tuple([int(v * 255) for v in self.mean]) + + # ======== override the following fields ======== + self.ignore_label = 255 + self.label_pad_value = (self.ignore_label, ) + self.label_dtype = 'uint8' + + # list of image filename (required) + self.img_list = [] + # list of label filename (required) + self.ann_list = [] + # list of instance dictionary (optional) + self.ins_list = [] + + self.has_instance = False + self.label_divisor = 1000 + + self.raw_label_transform = None + self.pre_augmentation_transform = None + self.transform = None + self.target_transform = None + + def __len__(self): + return len(self.img_list) + + def __getitem__(self, index): + # TODO: handle transform properly when there is no label + dataset_dict = {} + assert os.path.exists(self.img_list[index]), 'Path does not exist: {}'.format(self.img_list[index]) + image = self.read_image(self.img_list[index], 'RGB') + if not self.is_train: + # Do not save this during training. + dataset_dict['raw_image'] = image.copy() + if self.ann_list is not None: + assert os.path.exists(self.ann_list[index]), 'Path does not exist: {}'.format(self.ann_list[index]) + label = self.read_label(self.ann_list[index], self.label_dtype) + else: + label = None + raw_label = label.copy() + if self.raw_label_transform is not None: + raw_label = self.raw_label_transform(raw_label, self.ins_list[index])['semantic'] + if not self.is_train: + # Do not save this during training + dataset_dict['raw_label'] = raw_label + size = image.shape + dataset_dict['raw_size'] = np.array(size) + # To save prediction for official evaluation. + name = os.path.splitext(os.path.basename(self.ann_list[index]))[0] + # TODO: how to return the filename? + # dataset_dict['name'] = np.array(name) + + # Resize and pad image to the same size before data augmentation. + if self.pre_augmentation_transform is not None: + image, label = self.pre_augmentation_transform(image, label) + size = image.shape + dataset_dict['size'] = np.array(size) + else: + dataset_dict['size'] = dataset_dict['raw_size'] + + # Apply data augmentation. + if self.transform is not None: + image, label = self.transform(image, label) + + dataset_dict['image'] = image + if not self.has_instance: + dataset_dict['semantic'] = torch.as_tensor(label.astype('long')) + return dataset_dict + + # Generate training target. + if self.target_transform is not None: + label_dict = self.target_transform(label, self.ins_list[index]) + for key in label_dict.keys(): + dataset_dict[key] = label_dict[key] + + return dataset_dict + + @staticmethod + def read_image(file_name, format=None): + image = Image.open(file_name) + + # capture and ignore this bug: https://github.com/python-pillow/Pillow/issues/3973 + try: + image = ImageOps.exif_transpose(image) + except Exception: + pass + + if format is not None: + # PIL only supports RGB, so convert to RGB and flip channels over below + conversion_format = format + if format == "BGR": + conversion_format = "RGB" + image = image.convert(conversion_format) + image = np.asarray(image) + if format == "BGR": + # flip channels if needed + image = image[:, :, ::-1] + # PIL squeezes out the channel dimension for "L", so make it HWC + if format == "L": + image = np.expand_dims(image, -1) + return image + + @staticmethod + def read_label(file_name, dtype='uint8'): + # In some cases, `uint8` is not enough for label + label = Image.open(file_name) + return np.asarray(label, dtype=dtype) + + def reverse_transform(self, image_tensor): + """Reverse the normalization on image. + Args: + image_tensor: torch.Tensor, the normalized image tensor. + Returns: + image: numpy.array, the original image before normalization. + """ + dtype = image_tensor.dtype + mean = torch.as_tensor(self.mean, dtype=dtype, device=image_tensor.device) + std = torch.as_tensor(self.std, dtype=dtype, device=image_tensor.device) + image_tensor.mul_(std[:, None, None]).add_(mean[:, None, None]) + image = image_tensor.mul(255)\ + .clamp(0, 255)\ + .byte()\ + .permute(1, 2, 0)\ + .cpu().numpy() + return image + + @staticmethod + def train_id_to_eval_id(): + return None diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py new file mode 100644 index 000000000..a1ec79466 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes.py @@ -0,0 +1,150 @@ +# ------------------------------------------------------------------------------ +# Loads Cityscapes semantic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import glob +import os + +import numpy as np + +from .base_dataset import BaseDataset +from .utils import DatasetDescriptor +from ..transforms import build_transforms + +_CITYSCAPES_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train': 2975, + 'trainval': 3475, + 'val': 500, + 'test': 1525}, + num_classes=19, + ignore_label=255, +) + +_CITYSCAPES_TRAIN_ID_TO_EVAL_ID = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 31, 32, 33] + +# A map from data type to folder name that saves the data. +_FOLDERS_MAP = { + 'image': 'leftImg8bit', + 'label': 'gtFine', +} + +# A map from data type to filename postfix. +_POSTFIX_MAP = { + 'image': '_leftImg8bit', + 'label': '_gtFine_labelTrainIds', +} + +# A map from data type to data format. +_DATA_FORMAT_MAP = { + 'image': 'png', + 'label': 'png', +} + + +class Cityscapes(BaseDataset): + """ + Cityscapes semantic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + **kwargs): + super(Cityscapes, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + self.num_classes = _CITYSCAPES_INFORMATION.num_classes + self.ignore_label = _CITYSCAPES_INFORMATION.ignore_label + self.label_pad_value = (self.ignore_label, ) + + # Get image and annotation list. + self.img_list = self._get_files('image', self.split) + self.ann_list = self._get_files('label', self.split) + + assert len(self) == _CITYSCAPES_INFORMATION.splits_to_sizes[self.split] + + self.transform = build_transforms(self, is_train) + + def _get_files(self, data, dataset_split): + """Gets files for the specified data type and dataset split. + Args: + data: String, desired data ('image' or 'label'). + dataset_split: String, dataset split ('train', 'val', 'test') + Returns: + A list of sorted file names or None when getting label for test set. + """ + if data == 'label' and dataset_split == 'test': + return None + pattern = '*%s.%s' % (_POSTFIX_MAP[data], _DATA_FORMAT_MAP[data]) + search_files = os.path.join( + self.root, _FOLDERS_MAP[data], dataset_split, '*', pattern) + filenames = glob.glob(search_files) + return sorted(filenames) + + @staticmethod + def train_id_to_eval_id(): + return _CITYSCAPES_TRAIN_ID_TO_EVAL_ID + + def _convert_train_id_to_eval_id(self, prediction): + """Converts the predicted label for evaluation. + There are cases where the training labels are not equal to the evaluation + labels. This function is used to perform the conversion so that we could + evaluate the results on the evaluation server. + Args: + prediction: Semantic segmentation prediction. + Returns: + Semantic segmentation prediction whose labels have been changed. + """ + converted_prediction = prediction.copy() + for train_id, eval_id in enumerate(self.train_id_to_eval_id()): + converted_prediction[prediction == train_id] = eval_id + + return converted_prediction + + @staticmethod + def create_label_colormap(): + """Creates a label colormap used in CITYSCAPES segmentation benchmark. + Returns: + A colormap for visualizing segmentation results. + """ + colormap = np.zeros((256, 3), dtype=np.uint8) + colormap[0] = [128, 64, 128] + colormap[1] = [244, 35, 232] + colormap[2] = [70, 70, 70] + colormap[3] = [102, 102, 156] + colormap[4] = [190, 153, 153] + colormap[5] = [153, 153, 153] + colormap[6] = [250, 170, 30] + colormap[7] = [220, 220, 0] + colormap[8] = [107, 142, 35] + colormap[9] = [152, 251, 152] + colormap[10] = [70, 130, 180] + colormap[11] = [220, 20, 60] + colormap[12] = [255, 0, 0] + colormap[13] = [0, 0, 142] + colormap[14] = [0, 0, 70] + colormap[15] = [0, 60, 100] + colormap[16] = [0, 80, 100] + colormap[17] = [0, 0, 230] + colormap[18] = [119, 11, 32] + return colormap diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py new file mode 100644 index 000000000..baa5174cf --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py @@ -0,0 +1,130 @@ +# ------------------------------------------------------------------------------ +# Loads Cityscapes panoptic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import json +import os + +import numpy as np + +from .cityscapes import Cityscapes +from .utils import DatasetDescriptor +from ..transforms import build_transforms, PanopticTargetGenerator, SemanticTargetGenerator + +_CITYSCAPES_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train': 2975, + 'trainval': 3475, + 'val': 500, + 'test': 1525}, + num_classes=19, + ignore_label=255, +) + +# Add 1 void label. +_CITYSCAPES_PANOPTIC_TRAIN_ID_TO_EVAL_ID = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 31, 32, 33, 0] + +_CITYSCAPES_THING_LIST = [11, 12, 13, 14, 15, 16, 17, 18] + + +class CityscapesPanoptic(Cityscapes): + """ + Cityscapes panoptic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + semantic_only: Bool, only use semantic segmentation label. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=False, + small_instance_area=0, + small_instance_weight=1, + **kwargs): + super(CityscapesPanoptic, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + self.num_classes = _CITYSCAPES_INFORMATION.num_classes + self.ignore_label = _CITYSCAPES_INFORMATION.ignore_label + self.label_pad_value = (0, 0, 0) + + self.has_instance = True + self.label_divisor = 1000 + self.label_dtype = np.float32 + self.thing_list = _CITYSCAPES_THING_LIST + + # Get image and annotation list. + if split == 'test': + self.img_list = self._get_files('image', self.split) + self.ann_list = None + self.ins_list = None + else: + self.img_list = [] + self.ann_list = [] + self.ins_list = [] + json_filename = os.path.join(self.root, 'gtFine', 'cityscapes_panoptic_{}_trainId.json'.format(self.split)) + dataset = json.load(open(json_filename)) + for img in dataset['images']: + img_file_name = img['file_name'] + self.img_list.append(os.path.join( + self.root, 'leftImg8bit', self.split, img_file_name.split('_')[0], + img_file_name.replace('_gtFine', ''))) + for ann in dataset['annotations']: + ann_file_name = ann['file_name'] + self.ann_list.append(os.path.join( + self.root, 'gtFine', 'cityscapes_panoptic_{}_trainId'.format(self.split), ann_file_name)) + self.ins_list.append(ann['segments_info']) + + assert len(self) == _CITYSCAPES_INFORMATION.splits_to_sizes[self.split] + + self.transform = build_transforms(self, is_train) + if semantic_only: + self.target_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + else: + self.target_transform = PanopticTargetGenerator(self.ignore_label, self.rgb2id, _CITYSCAPES_THING_LIST, + sigma=8, ignore_stuff_in_offset=ignore_stuff_in_offset, + small_instance_area=small_instance_area, + small_instance_weight=small_instance_weight) + # Generates semantic label for evaluation. + self.raw_label_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + + @staticmethod + def train_id_to_eval_id(): + return _CITYSCAPES_PANOPTIC_TRAIN_ID_TO_EVAL_ID + + @staticmethod + def rgb2id(color): + """Converts the color to panoptic label. + Color is created by `color = [segmentId % 256, segmentId // 256, segmentId // 256 // 256]`. + Args: + color: Ndarray or a tuple, color encoded image. + Returns: + Panoptic label. + """ + if isinstance(color, np.ndarray) and len(color.shape) == 3: + if color.dtype == np.uint8: + color = color.astype(np.int32) + return color[:, :, 0] + 256 * color[:, :, 1] + 256 * 256 * color[:, :, 2] + return int(color[0] + 256 * color[1] + 256 * 256 * color[2]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/coco_panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/coco_panoptic.py new file mode 100644 index 000000000..6de52e3d2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/coco_panoptic.py @@ -0,0 +1,299 @@ +# ------------------------------------------------------------------------------ +# Loads COCO panoptic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import json +import os + +import numpy as np + +from .base_dataset import BaseDataset +from .utils import DatasetDescriptor +from ..transforms import build_transforms, Resize, PanopticTargetGenerator, SemanticTargetGenerator + +_COCO_PANOPTIC_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train2017': 118287, + 'trainval2017': 123287, + 'val2017': 5000, + 'test-dev2017': 20288, + 'test2017': 40670}, # `test` includes `test-dev` and `test-challenge` + num_classes=133, + ignore_label=255, +) + +# Add 1 void label. +_COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID = ( + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 67, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 92, 93, 95, 100, 107, 109, 112, + 118, 119, 122, 125, 128, 130, 133, 138, 141, 144, 145, 147, 148, 149, 151, 154, 155, 156, 159, 161, 166, 168, 171, + 175, 176, 177, 178, 180, 181, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 0]) + +_COCO_PANOPTIC_EVAL_ID_TO_TRAIN_ID = { + v: k for k, v in enumerate(_COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID[:-1]) +} + +_COCO_PANOPTIC_THING_LIST = list(range(80)) # the first 80 classes are `thing` classes + +COCO_CATEGORIES = [ + {"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"}, + {"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"}, + {"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"}, + {"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"}, + {"color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"}, + {"color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"}, + {"color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"}, + {"color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"}, + {"color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"}, + {"color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"}, + {"color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"}, + {"color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"}, + {"color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"}, + {"color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"}, + {"color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"}, + {"color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"}, + {"color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"}, + {"color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"}, + {"color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"}, + {"color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"}, + {"color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"}, + {"color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"}, + {"color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"}, + {"color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"}, + {"color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"}, + {"color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"}, + {"color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"}, + {"color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"}, + {"color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"}, + {"color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"}, + {"color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"}, + {"color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"}, + {"color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"}, + {"color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"}, + {"color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"}, + {"color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"}, + {"color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"}, + {"color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"}, + {"color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"}, + {"color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"}, + {"color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"}, + {"color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"}, + {"color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"}, + {"color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"}, + {"color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"}, + {"color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"}, + {"color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"}, + {"color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"}, + {"color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"}, + {"color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"}, + {"color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"}, + {"color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"}, + {"color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"}, + {"color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"}, + {"color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"}, + {"color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"}, + {"color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"}, + {"color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"}, + {"color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"}, + {"color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"}, + {"color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"}, + {"color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"}, + {"color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"}, + {"color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"}, + {"color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"}, + {"color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"}, + {"color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"}, + {"color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"}, + {"color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"}, + {"color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"}, + {"color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"}, + {"color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"}, + {"color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"}, + {"color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"}, + {"color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"}, + {"color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"}, + {"color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"}, + {"color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"}, + {"color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"}, + {"color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"}, + {"color": [255, 255, 128], "isthing": 0, "id": 92, "name": "banner"}, + {"color": [147, 211, 203], "isthing": 0, "id": 93, "name": "blanket"}, + {"color": [150, 100, 100], "isthing": 0, "id": 95, "name": "bridge"}, + {"color": [168, 171, 172], "isthing": 0, "id": 100, "name": "cardboard"}, + {"color": [146, 112, 198], "isthing": 0, "id": 107, "name": "counter"}, + {"color": [210, 170, 100], "isthing": 0, "id": 109, "name": "curtain"}, + {"color": [92, 136, 89], "isthing": 0, "id": 112, "name": "door-stuff"}, + {"color": [218, 88, 184], "isthing": 0, "id": 118, "name": "floor-wood"}, + {"color": [241, 129, 0], "isthing": 0, "id": 119, "name": "flower"}, + {"color": [217, 17, 255], "isthing": 0, "id": 122, "name": "fruit"}, + {"color": [124, 74, 181], "isthing": 0, "id": 125, "name": "gravel"}, + {"color": [70, 70, 70], "isthing": 0, "id": 128, "name": "house"}, + {"color": [255, 228, 255], "isthing": 0, "id": 130, "name": "light"}, + {"color": [154, 208, 0], "isthing": 0, "id": 133, "name": "mirror-stuff"}, + {"color": [193, 0, 92], "isthing": 0, "id": 138, "name": "net"}, + {"color": [76, 91, 113], "isthing": 0, "id": 141, "name": "pillow"}, + {"color": [255, 180, 195], "isthing": 0, "id": 144, "name": "platform"}, + {"color": [106, 154, 176], "isthing": 0, "id": 145, "name": "playingfield"}, + {"color": [230, 150, 140], "isthing": 0, "id": 147, "name": "railroad"}, + {"color": [60, 143, 255], "isthing": 0, "id": 148, "name": "river"}, + {"color": [128, 64, 128], "isthing": 0, "id": 149, "name": "road"}, + {"color": [92, 82, 55], "isthing": 0, "id": 151, "name": "roof"}, + {"color": [254, 212, 124], "isthing": 0, "id": 154, "name": "sand"}, + {"color": [73, 77, 174], "isthing": 0, "id": 155, "name": "sea"}, + {"color": [255, 160, 98], "isthing": 0, "id": 156, "name": "shelf"}, + {"color": [255, 255, 255], "isthing": 0, "id": 159, "name": "snow"}, + {"color": [104, 84, 109], "isthing": 0, "id": 161, "name": "stairs"}, + {"color": [169, 164, 131], "isthing": 0, "id": 166, "name": "tent"}, + {"color": [225, 199, 255], "isthing": 0, "id": 168, "name": "towel"}, + {"color": [137, 54, 74], "isthing": 0, "id": 171, "name": "wall-brick"}, + {"color": [135, 158, 223], "isthing": 0, "id": 175, "name": "wall-stone"}, + {"color": [7, 246, 231], "isthing": 0, "id": 176, "name": "wall-tile"}, + {"color": [107, 255, 200], "isthing": 0, "id": 177, "name": "wall-wood"}, + {"color": [58, 41, 149], "isthing": 0, "id": 178, "name": "water-other"}, + {"color": [183, 121, 142], "isthing": 0, "id": 180, "name": "window-blind"}, + {"color": [255, 73, 97], "isthing": 0, "id": 181, "name": "window-other"}, + {"color": [107, 142, 35], "isthing": 0, "id": 184, "name": "tree-merged"}, + {"color": [190, 153, 153], "isthing": 0, "id": 185, "name": "fence-merged"}, + {"color": [146, 139, 141], "isthing": 0, "id": 186, "name": "ceiling-merged"}, + {"color": [70, 130, 180], "isthing": 0, "id": 187, "name": "sky-other-merged"}, + {"color": [134, 199, 156], "isthing": 0, "id": 188, "name": "cabinet-merged"}, + {"color": [209, 226, 140], "isthing": 0, "id": 189, "name": "table-merged"}, + {"color": [96, 36, 108], "isthing": 0, "id": 190, "name": "floor-other-merged"}, + {"color": [96, 96, 96], "isthing": 0, "id": 191, "name": "pavement-merged"}, + {"color": [64, 170, 64], "isthing": 0, "id": 192, "name": "mountain-merged"}, + {"color": [152, 251, 152], "isthing": 0, "id": 193, "name": "grass-merged"}, + {"color": [208, 229, 228], "isthing": 0, "id": 194, "name": "dirt-merged"}, + {"color": [206, 186, 171], "isthing": 0, "id": 195, "name": "paper-merged"}, + {"color": [152, 161, 64], "isthing": 0, "id": 196, "name": "food-other-merged"}, + {"color": [116, 112, 0], "isthing": 0, "id": 197, "name": "building-other-merged"}, + {"color": [0, 114, 143], "isthing": 0, "id": 198, "name": "rock-merged"}, + {"color": [102, 102, 156], "isthing": 0, "id": 199, "name": "wall-other-merged"}, + {"color": [250, 141, 255], "isthing": 0, "id": 200, "name": "rug-merged"}, +] + + +class COCOPanoptic(BaseDataset): + """ + COCO panoptic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + semantic_only: Bool, only use semantic segmentation label. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + """ + def __init__(self, + root, + split, + min_resize_value=641, + max_resize_value=641, + resize_factor=32, + is_train=True, + crop_size=(641, 641), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=False, + small_instance_area=0, + small_instance_weight=1, + **kwargs): + super(COCOPanoptic, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + assert split in _COCO_PANOPTIC_INFORMATION.splits_to_sizes.keys() + + self.num_classes = _COCO_PANOPTIC_INFORMATION.num_classes + self.ignore_label = _COCO_PANOPTIC_INFORMATION.ignore_label + self.label_pad_value = (0, 0, 0) + + self.has_instance = True + self.label_divisor = 256 + self.label_dtype = np.float32 + self.thing_list = _COCO_PANOPTIC_THING_LIST + + # Get image and annotation list. + if 'test' in split: + self.img_list = [] + self.ann_list = None + self.ins_list = None + json_filename = os.path.join(self.root, 'annotations', 'image_info_{}.json'.format(self.split)) + dataset = json.load(open(json_filename)) + for img in dataset['images']: + img_file_name = img['file_name'] + self.img_list.append(os.path.join(self.root, 'test2017', img_file_name)) + else: + self.img_list = [] + self.ann_list = [] + self.ins_list = [] + json_filename = os.path.join(self.root, 'annotations', 'panoptic_{}_trainId.json'.format(self.split)) + dataset = json.load(open(json_filename)) + # First sort by image id. + images = sorted(dataset['images'], key=lambda i: i['id']) + annotations = sorted(dataset['annotations'], key=lambda i: i['image_id']) + for img in images: + img_file_name = img['file_name'] + self.img_list.append(os.path.join(self.root, self.split, img_file_name)) + for ann in annotations: + ann_file_name = ann['file_name'] + self.ann_list.append(os.path.join( + self.root, 'annotations', 'panoptic_{}'.format(self.split), ann_file_name)) + self.ins_list.append(ann['segments_info']) + + assert len(self) == _COCO_PANOPTIC_INFORMATION.splits_to_sizes[self.split] + + self.pre_augmentation_transform = Resize(min_resize_value, max_resize_value, resize_factor) + self.transform = build_transforms(self, is_train) + if semantic_only: + self.target_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + else: + self.target_transform = PanopticTargetGenerator(self.ignore_label, self.rgb2id, _COCO_PANOPTIC_THING_LIST, + sigma=8, ignore_stuff_in_offset=ignore_stuff_in_offset, + small_instance_area=small_instance_area, + small_instance_weight=small_instance_weight) + # Generates semantic label for evaluation. + self.raw_label_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + + @staticmethod + def train_id_to_eval_id(): + return _COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID + + @staticmethod + def rgb2id(color): + """Converts the color to panoptic label. + Color is created by `color = [segmentId % 256, segmentId // 256, segmentId // 256 // 256]`. + Args: + color: Ndarray or a tuple, color encoded image. + Returns: + Panoptic label. + """ + if isinstance(color, np.ndarray) and len(color.shape) == 3: + if color.dtype == np.uint8: + color = color.astype(np.int32) + return color[:, :, 0] + 256 * color[:, :, 1] + 256 * 256 * color[:, :, 2] + return int(color[0] + 256 * color[1] + 256 * 256 * color[2]) + + @staticmethod + def create_label_colormap(): + """Creates a label colormap used in COCO panoptic benchmark. + Returns: + A colormap for visualizing segmentation results. + """ + colormap = np.zeros((256, 3), dtype=np.uint8) + for i, color in enumerate(COCO_CATEGORIES): + colormap[i] = color['color'] + return colormap diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/utils.py new file mode 100644 index 000000000..3149ad666 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/utils.py @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/datasets/data_generator.py +# ------------------------------------------------------------------------------ + +import collections + +# Named tuple to describe the dataset properties. +DatasetDescriptor = collections.namedtuple( + 'DatasetDescriptor', + [ + 'splits_to_sizes', # Splits of the dataset into training, val and test. + 'num_classes', # Number of semantic classes, including the + # background class (if exists). For example, there + # are 20 foreground classes + 1 background class in + # the PASCAL VOC 2012 dataset. Thus, we set + # num_classes=21. + 'ignore_label', # Ignore label value. + ]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/__init__.py new file mode 100644 index 000000000..c37854af0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/__init__.py @@ -0,0 +1,3 @@ +from .build import build_transforms +from .pre_augmentation_transforms import Resize +from .target_transforms import PanopticTargetGenerator, SemanticTargetGenerator diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py new file mode 100644 index 000000000..08742bc0d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/build.py @@ -0,0 +1,57 @@ +# ------------------------------------------------------------------------------ +# Builds transformation for both image and labels. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from . import transforms as T + + +def build_transforms(dataset, is_train=True): + if is_train: + min_scale = dataset.min_scale + max_scale = dataset.max_scale + scale_step_size = dataset.scale_step_size + crop_h = dataset.crop_h + crop_w = dataset.crop_w + pad_value = dataset.pad_value + ignore_label = dataset.label_pad_value + flip_prob = 0.5 if dataset.mirror else 0 + mean = dataset.mean + std = dataset.std + else: + # no data augmentation + min_scale = 1 + max_scale = 1 + scale_step_size = 0 + flip_prob = 0 + crop_h = dataset.crop_h + crop_w = dataset.crop_w + pad_value = dataset.pad_value + ignore_label = dataset.label_pad_value + mean = dataset.mean + std = dataset.std + + transforms = T.Compose( + [ + T.RandomScale( + min_scale, + max_scale, + scale_step_size + ), + T.RandomCrop( + crop_h, + crop_w, + pad_value, + ignore_label, + random_pad=is_train + ), + T.RandomHorizontalFlip(flip_prob), + T.ToTensor(), + T.Normalize( + mean, + std + ) + ] + ) + + return transforms diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/pre_augmentation_transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/pre_augmentation_transforms.py new file mode 100644 index 000000000..b4d98648b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/pre_augmentation_transforms.py @@ -0,0 +1,92 @@ +# ------------------------------------------------------------------------------ +# Builds transformation before data augmentation. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import warnings + +import cv2 +import math +import numpy as np + + +class Resize(object): + """ + Applies random scale augmentation. + Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/input_preprocess.py#L28 + Arguments: + min_resize_value: Desired size of the smaller image side, no resize if set to None + max_resize_value: Maximum allowed size of the larger image side, no limit if set to None + resize_factor: Resized dimensions are multiple of factor plus one. + keep_aspect_ratio: Boolean, keep aspect ratio or not. If True, the input + will be resized while keeping the original aspect ratio. If False, the + input will be resized to [max_resize_value, max_resize_value] without + keeping the original aspect ratio. + align_corners: If True, exactly align all 4 corners of input and output. + """ + def __init__(self, min_resize_value=None, max_resize_value=None, resize_factor=None, + keep_aspect_ratio=True, align_corners=False): + if min_resize_value is not None and min_resize_value < 0: + min_resize_value = None + if max_resize_value is not None and max_resize_value < 0: + max_resize_value = None + if resize_factor is not None and resize_factor < 0: + resize_factor = None + self.min_resize_value = min_resize_value + self.max_resize_value = max_resize_value + self.resize_factor = resize_factor + self.keep_aspect_ratio = keep_aspect_ratio + self.align_corners = align_corners + + if self.align_corners: + warnings.warn('`align_corners = True` is not supported by opencv.') + + if self.max_resize_value is not None: + # Modify the max_size to be a multiple of factor plus 1 and make sure the max dimension after resizing + # is no larger than max_size. + if self.resize_factor is not None: + self.max_resize_value = (self.max_resize_value - (self.max_resize_value - 1) % self.resize_factor) + + def __call__(self, image, label): + if self.min_resize_value is None: + return image, label + [orig_height, orig_width, _] = image.shape + orig_min_size = np.minimum(orig_height, orig_width) + + # Calculate the larger of the possible sizes + large_scale_factor = self.min_resize_value / orig_min_size + large_height = int(math.floor(orig_height * large_scale_factor)) + large_width = int(math.floor(orig_width * large_scale_factor)) + large_size = np.array([large_height, large_width]) + + new_size = large_size + if self.max_resize_value is not None: + # Calculate the smaller of the possible sizes, use that if the larger is too big. + orig_max_size = np.maximum(orig_height, orig_width) + small_scale_factor = self.max_resize_value / orig_max_size + small_height = int(math.floor(orig_height * small_scale_factor)) + small_width = int(math.floor(orig_width * small_scale_factor)) + small_size = np.array([small_height, small_width]) + + if np.max(large_size) > self.max_resize_value: + new_size = small_size + + # Ensure that both output sides are multiples of factor plus one. + if self.resize_factor is not None: + new_size += (self.resize_factor - (new_size - 1) % self.resize_factor) % self.resize_factor + # If new_size exceeds largest allowed size + new_size[new_size > self.max_resize_value] -= self.resize_factor + + if not self.keep_aspect_ratio: + # If not keep the aspect ratio, we resize everything to max_size, allowing + # us to do pre-processing without extra padding. + new_size = [np.max(new_size), np.max(new_size)] + + # TODO: cv2 uses align_corner=False + # TODO: use fvcore (https://github.com/facebookresearch/fvcore/blob/master/fvcore/transforms/transform.py#L377) + image_dtype = image.dtype + label_dtype = label.dtype + # cv2: (width, height) + image = cv2.resize(image.astype(np.float), (new_size[1], new_size[0]), interpolation=cv2.INTER_LINEAR) + label = cv2.resize(label.astype(np.float), (new_size[1], new_size[0]), interpolation=cv2.INTER_NEAREST) + return image.astype(image_dtype), label.astype(label_dtype) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/target_transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/target_transforms.py new file mode 100644 index 000000000..47a3f3959 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/target_transforms.py @@ -0,0 +1,200 @@ +# ------------------------------------------------------------------------------ +# Generates targets for Panoptic-DeepLab. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import numpy as np + +import torch + + +class PanopticTargetGenerator(object): + """ + Generates panoptic training target for Panoptic-DeepLab. + Annotation is assumed to have Cityscapes format. + Arguments: + ignore_label: Integer, the ignore label for semantic segmentation. + rgb2id: Function, panoptic label is encoded in a colored image, this function convert color to the + corresponding panoptic label. + thing_list: List, a list of thing classes + sigma: the sigma for Gaussian kernel. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + ignore_crowd_in_semantic: Boolean, whether to ignore crowd region in semantic segmentation branch, + crowd region is ignored in the original TensorFlow implementation. + """ + def __init__(self, ignore_label, rgb2id, thing_list, sigma=8, ignore_stuff_in_offset=False, + small_instance_area=0, small_instance_weight=1, ignore_crowd_in_semantic=False): + self.ignore_label = ignore_label + self.rgb2id = rgb2id + self.thing_list = thing_list + self.ignore_stuff_in_offset = ignore_stuff_in_offset + self.small_instance_area = small_instance_area + self.small_instance_weight = small_instance_weight + self.ignore_crowd_in_semantic = ignore_crowd_in_semantic + + self.sigma = sigma + size = 6 * sigma + 3 + x = np.arange(0, size, 1, float) + y = x[:, np.newaxis] + x0, y0 = 3 * sigma + 1, 3 * sigma + 1 + self.g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2)) + + def __call__(self, panoptic, segments): + """Generates the training target. + reference: https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createPanopticImgs.py + reference: https://github.com/facebookresearch/detectron2/blob/master/datasets/prepare_panoptic_fpn.py#L18 + Args: + panoptic: numpy.array, colored image encoding panoptic label. + segments: List, a list of dictionary containing information of every segment, it has fields: + - id: panoptic id, after decoding `panoptic`. + - category_id: semantic class id. + - area: segment area. + - bbox: segment bounding box. + - iscrowd: crowd region. + Returns: + A dictionary with fields: + - semantic: Tensor, semantic label, shape=(H, W). + - foreground: Tensor, foreground mask label, shape=(H, W). + - center: Tensor, center heatmap, shape=(1, H, W). + - center_points: List, center coordinates, with tuple (y-coord, x-coord). + - offset: Tensor, offset, shape=(2, H, W), first dim is (offset_y, offset_x). + - semantic_weights: Tensor, loss weight for semantic prediction, shape=(H, W). + - center_weights: Tensor, ignore region of center prediction, shape=(H, W), used as weights for center + regression 0 is ignore, 1 is has instance. Multiply this mask to loss. + - offset_weights: Tensor, ignore region of offset prediction, shape=(H, W), used as weights for offset + regression 0 is ignore, 1 is has instance. Multiply this mask to loss. + """ + panoptic = self.rgb2id(panoptic) + height, width = panoptic.shape[0], panoptic.shape[1] + semantic = np.zeros_like(panoptic, dtype=np.uint8) + self.ignore_label + foreground = np.zeros_like(panoptic, dtype=np.uint8) + center = np.zeros((1, height, width), dtype=np.float32) + center_pts = [] + offset = np.zeros((2, height, width), dtype=np.float32) + y_coord = np.ones_like(panoptic, dtype=np.float32) + x_coord = np.ones_like(panoptic, dtype=np.float32) + y_coord = np.cumsum(y_coord, axis=0) - 1 + x_coord = np.cumsum(x_coord, axis=1) - 1 + # Generate pixel-wise loss weights + semantic_weights = np.ones_like(panoptic, dtype=np.uint8) + # 0: ignore, 1: has instance + # three conditions for a region to be ignored for instance branches: + # (1) It is labeled as `ignore_label` + # (2) It is crowd region (iscrowd=1) + # (3) (Optional) It is stuff region (for offset branch) + center_weights = np.zeros_like(panoptic, dtype=np.uint8) + offset_weights = np.zeros_like(panoptic, dtype=np.uint8) + for seg in segments: + cat_id = seg["category_id"] + if self.ignore_crowd_in_semantic: + if not seg['iscrowd']: + semantic[panoptic == seg["id"]] = cat_id + else: + semantic[panoptic == seg["id"]] = cat_id + if cat_id in self.thing_list: + foreground[panoptic == seg["id"]] = 1 + if not seg['iscrowd']: + # Ignored regions are not in `segments`. + # Handle crowd region. + center_weights[panoptic == seg["id"]] = 1 + if self.ignore_stuff_in_offset: + # Handle stuff region. + if cat_id in self.thing_list: + offset_weights[panoptic == seg["id"]] = 1 + else: + offset_weights[panoptic == seg["id"]] = 1 + if cat_id in self.thing_list: + # find instance center + mask_index = np.where(panoptic == seg["id"]) + if len(mask_index[0]) == 0: + # the instance is completely cropped + continue + + # Find instance area + ins_area = len(mask_index[0]) + if ins_area < self.small_instance_area: + semantic_weights[panoptic == seg["id"]] = self.small_instance_weight + + center_y, center_x = np.mean(mask_index[0]), np.mean(mask_index[1]) + center_pts.append([center_y, center_x]) + + # generate center heatmap + y, x = int(center_y), int(center_x) + # outside image boundary + if x < 0 or y < 0 or \ + x >= width or y >= height: + continue + sigma = self.sigma + # upper left + ul = int(np.round(x - 3 * sigma - 1)), int(np.round(y - 3 * sigma - 1)) + # bottom right + br = int(np.round(x + 3 * sigma + 2)), int(np.round(y + 3 * sigma + 2)) + + c, d = max(0, -ul[0]), min(br[0], width) - ul[0] + a, b = max(0, -ul[1]), min(br[1], height) - ul[1] + + cc, dd = max(0, ul[0]), min(br[0], width) + aa, bb = max(0, ul[1]), min(br[1], height) + center[0, aa:bb, cc:dd] = np.maximum( + center[0, aa:bb, cc:dd], self.g[a:b, c:d]) + + # generate offset (2, h, w) -> (y-dir, x-dir) + offset_y_index = (np.zeros_like(mask_index[0]), mask_index[0], mask_index[1]) + offset_x_index = (np.ones_like(mask_index[0]), mask_index[0], mask_index[1]) + offset[offset_y_index] = center_y - y_coord[mask_index] + offset[offset_x_index] = center_x - x_coord[mask_index] + + return dict( + semantic=torch.as_tensor(semantic.astype('long')), + foreground=torch.as_tensor(foreground.astype('long')), + center=torch.as_tensor(center.astype(np.float32)), + center_points=center_pts, + offset=torch.as_tensor(offset.astype(np.float32)), + semantic_weights=torch.as_tensor(semantic_weights.astype(np.float32)), + center_weights=torch.as_tensor(center_weights.astype(np.float32)), + offset_weights=torch.as_tensor(offset_weights.astype(np.float32)) + ) + + +class SemanticTargetGenerator(object): + """ + Generates semantic training target only for Panoptic-DeepLab (no instance). + Annotation is assumed to have Cityscapes format. + Arguments: + ignore_label: Integer, the ignore label for semantic segmentation. + rgb2id: Function, panoptic label is encoded in a colored image, this function convert color to the + corresponding panoptic label. + thing_list: List, a list of thing classes + sigma: the sigma for Gaussian kernel. + """ + def __init__(self, ignore_label, rgb2id): + self.ignore_label = ignore_label + self.rgb2id = rgb2id + + def __call__(self, panoptic, segments): + """Generates the training target. + reference: https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createPanopticImgs.py + reference: https://github.com/facebookresearch/detectron2/blob/master/datasets/prepare_panoptic_fpn.py#L18 + Args: + panoptic: numpy.array, colored image encoding panoptic label. + segments: List, a list of dictionary containing information of every segment, it has fields: + - id: panoptic id, after decoding `panoptic`. + - category_id: semantic class id. + - area: segment area. + - bbox: segment bounding box. + - iscrowd: crowd region. + Returns: + A dictionary with fields: + - semantic: Tensor, semantic label, shape=(H, W). + """ + panoptic = self.rgb2id(panoptic) + semantic = np.zeros_like(panoptic, dtype=np.uint8) + self.ignore_label + for seg in segments: + cat_id = seg["category_id"] + semantic[panoptic == seg["id"]] = cat_id + + return dict( + semantic=torch.as_tensor(semantic.astype('long')) + ) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/transforms.py new file mode 100644 index 000000000..a6404a665 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/dataloaders/transforms/transforms.py @@ -0,0 +1,172 @@ +# ------------------------------------------------------------------------------ +# Data augmentation following DeepLab +# (https://github.com/tensorflow/models/blob/master/research/deeplab/input_preprocess.py#L28). +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import random + +import cv2 +import numpy as np +from torchvision.transforms import functional as F + + +class Compose(object): + """ + Composes a sequence of transforms. + Arguments: + transforms: A list of transforms. + """ + def __init__(self, transforms): + self.transforms = transforms + + def __call__(self, image, label): + for t in self.transforms: + image, label = t(image, label) + return image, label + + def __repr__(self): + format_string = self.__class__.__name__ + "(" + for t in self.transforms: + format_string += "\n" + format_string += " {0}".format(t) + format_string += "\n)" + return format_string + + +class ToTensor(object): + """ + Converts image to torch Tensor. + """ + def __call__(self, image, label): + return F.to_tensor(image), label + + +class Normalize(object): + """ + Normalizes image by mean and std. + """ + def __init__(self, mean, std): + self.mean = mean + self.std = std + + def __call__(self, image, label): + image = F.normalize(image, mean=self.mean, std=self.std) + return image, label + + +class RandomScale(object): + """ + Applies random scale augmentation. + Arguments: + min_scale: Minimum scale value. + max_scale: Maximum scale value. + scale_step_size: The step size from minimum to maximum value. + """ + def __init__(self, min_scale, max_scale, scale_step_size): + self.min_scale = min_scale + self.max_scale = max_scale + self.scale_step_size = scale_step_size + + @staticmethod + def get_random_scale(min_scale_factor, max_scale_factor, step_size): + """Gets a random scale value. + Args: + min_scale_factor: Minimum scale value. + max_scale_factor: Maximum scale value. + step_size: The step size from minimum to maximum value. + Returns: + A random scale value selected between minimum and maximum value. + Raises: + ValueError: min_scale_factor has unexpected value. + """ + if min_scale_factor < 0 or min_scale_factor > max_scale_factor: + raise ValueError('Unexpected value of min_scale_factor.') + + if min_scale_factor == max_scale_factor: + return min_scale_factor + + # When step_size = 0, we sample the value uniformly from [min, max). + if step_size == 0: + return random.uniform(min_scale_factor, max_scale_factor) + + # When step_size != 0, we randomly select one discrete value from [min, max]. + num_steps = int((max_scale_factor - min_scale_factor) / step_size + 1) + scale_factors = np.linspace(min_scale_factor, max_scale_factor, num_steps) + np.random.shuffle(scale_factors) + return scale_factors[0] + + def __call__(self, image, label): + f_scale = self.get_random_scale(self.min_scale, self.max_scale, self.scale_step_size) + # TODO: cv2 uses align_corner=False + # TODO: use fvcore (https://github.com/facebookresearch/fvcore/blob/master/fvcore/transforms/transform.py#L377) + image_dtype = image.dtype + label_dtype = label.dtype + image = cv2.resize(image.astype(np.float), None, fx=f_scale, fy=f_scale, interpolation=cv2.INTER_LINEAR) + label = cv2.resize(label.astype(np.float), None, fx=f_scale, fy=f_scale, interpolation=cv2.INTER_NEAREST) + return image.astype(image_dtype), label.astype(label_dtype) + + +class RandomCrop(object): + """ + Applies random crop augmentation. + Arguments: + crop_h: Integer, crop height size. + crop_w: Integer, crop width size. + pad_value: Tuple, pad value for image, length 3. + ignore_label: Tuple, pad value for label, length could be 1 (semantic) or 3 (panoptic). + random_pad: Bool, when crop size larger than image size, whether to randomly pad four boundaries, + or put image to top-left and only pad bottom and right boundaries. + """ + def __init__(self, crop_h, crop_w, pad_value, ignore_label, random_pad): + self.crop_h = crop_h + self.crop_w = crop_w + self.pad_value = pad_value + self.ignore_label = ignore_label + self.random_pad = random_pad + + def __call__(self, image, label): + img_h, img_w = image.shape[0], image.shape[1] + # save dtype + image_dtype = image.dtype + label_dtype = label.dtype + # padding + pad_h = max(self.crop_h - img_h, 0) + pad_w = max(self.crop_w - img_w, 0) + if pad_h > 0 or pad_w > 0: + if self.random_pad: + pad_top = random.randint(0, pad_h) + pad_bottom = pad_h - pad_top + pad_left = random.randint(0, pad_w) + pad_right = pad_w - pad_left + else: + pad_top, pad_bottom, pad_left, pad_right = 0, pad_h, 0, pad_w + img_pad = cv2.copyMakeBorder(image, pad_top, pad_bottom, pad_left, pad_right, cv2.BORDER_CONSTANT, + value=self.pad_value) + label_pad = cv2.copyMakeBorder(label, pad_top, pad_bottom, pad_left, pad_right, cv2.BORDER_CONSTANT, + value=self.ignore_label) + else: + img_pad, label_pad = image, label + img_h, img_w = img_pad.shape[0], img_pad.shape[1] + h_off = random.randint(0, img_h - self.crop_h) + w_off = random.randint(0, img_w - self.crop_w) + image = np.asarray(img_pad[h_off:h_off + self.crop_h, w_off:w_off + self.crop_w], np.float32) + label = np.asarray(label_pad[h_off:h_off + self.crop_h, w_off:w_off + self.crop_w], np.float32) + return image.astype(image_dtype), label.astype(label_dtype) + + +class RandomHorizontalFlip(object): + """ + Applies random flip augmentation. + Arguments: + prob: Probability of flip. + """ + def __init__(self, prob=0.5): + self.prob = prob + + def __call__(self, image, label): + if random.random() < self.prob: + # https://discuss.pytorch.org/t/torch-from-numpy-not-support-negative-strides/3663 + image = image[:, ::-1].copy() + label = label[:, ::-1].copy() + return image, label diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/__init__.py new file mode 100644 index 000000000..623b156d9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/__init__.py @@ -0,0 +1,4 @@ +from .default import _C as config +from .default import update_config +seg_config = config +update_seg_config = update_config \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/default.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/default.py new file mode 100644 index 000000000..1bbc14f37 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/default.py @@ -0,0 +1,306 @@ +import os + +from yacs.config import CfgNode as CN + +_C = CN() + +# ----------------------------------------------------------------------------- +# Misc +# ----------------------------------------------------------------------------- +_C.OUTPUT_DIR = '' +_C.GPUS = (0,) +_C.WORKERS = 4 +# Logging frequency +_C.PRINT_FREQ = 20 +# Checkpoint frequency +_C.CKPT_FREQ = 5000 + +# ----------------------------------------------------------------------------- +# CUDNN +# ----------------------------------------------------------------------------- +_C.CUDNN = CN() +_C.CUDNN.BENCHMARK = True +_C.CUDNN.DETERMINISTIC = False +_C.CUDNN.ENABLED = True + +# ----------------------------------------------------------------------------- +# Model +# ----------------------------------------------------------------------------- +_C.MODEL = CN() +_C.MODEL.META_ARCHITECTURE = 'panoptic_deeplab' +# pretrained model (including decoder, head, etc) on other dataset +# need to do a net surgery to remove classifiers etc. +_C.MODEL.WEIGHTS = '' + +_C.MODEL.BN_MOMENTUM = 0.1 + +# ---------------------------------------------------------------------------- # +# Backbone options +# ---------------------------------------------------------------------------- # +_C.MODEL.BACKBONE = CN() + +# META could be +# resnet +# mobilenet_v2 +# mnasnet +_C.MODEL.BACKBONE.META = 'resnet' + +# NAME could be +# For resnet: +# 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'wide_resnet50_2', 'wide_resnet101_2' +# For mobilenet_v2: +# 'mobilenet_v2' +# For mnasnet: +# 'mnasnet0_5', 'mnasnet0_75' (no official weight), 'mnasnet1_0', 'mnasnet1_3' (no official weight) +_C.MODEL.BACKBONE.NAME = "resnet50" +# Controls output stride +_C.MODEL.BACKBONE.DILATION = (False, False, True) +# pretrained backbone provided by official PyTorch modelzoo +_C.MODEL.BACKBONE.PRETRAINED = True +_C.MODEL.BACKBONE.WEIGHTS = '' + +# Low-level feature key +# For resnet backbone: +# res2: 256 +# res3: 512 +# res4: 1024 +# res5: 2048 + +# For mobilenet_v2 backbone: +# layer_4: 24 +# layer_7: 32 +# layer_14: 96 +# layer_18: 320 + +# For mnasnet backbone: +# layer_9: 24 (0_5: 16) +# layer_10: 40 (0_5: 24) +# layer_12: 96 (0_5: 48) +# layer_14: 320 (0_5: 160) + +# ---------------------------------------------------------------------------- # +# Decoder options +# ---------------------------------------------------------------------------- # +_C.MODEL.DECODER = CN() +_C.MODEL.DECODER.IN_CHANNELS = 2048 +_C.MODEL.DECODER.FEATURE_KEY = 'res5' +_C.MODEL.DECODER.DECODER_CHANNELS = 256 +_C.MODEL.DECODER.ATROUS_RATES = (6, 12, 18) + +# TODO: pass these into the decoder. +_C.MODEL.DECODER.CONV_TYPE = 'depthwise_separable_conv' +_C.MODEL.DECODER.CONV_KERNEL = 5 +_C.MODEL.DECODER.CONV_PADDING = 2 +_C.MODEL.DECODER.CONV_STACK = 1 + +# ---------------------------------------------------------------------------- # +# DeepLabV3+ options +# ---------------------------------------------------------------------------- # +_C.MODEL.DEEPLABV3PLUS = CN() +_C.MODEL.DEEPLABV3PLUS.LOW_LEVEL_CHANNELS = 256 +_C.MODEL.DEEPLABV3PLUS.LOW_LEVEL_KEY = 'res2' +_C.MODEL.DEEPLABV3PLUS.LOW_LEVEL_CHANNELS_PROJECT = 48 + +# ---------------------------------------------------------------------------- # +# Panoptic-DeepLab options +# ---------------------------------------------------------------------------- # +_C.MODEL.PANOPTIC_DEEPLAB = CN() +_C.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_CHANNELS = (512, 256) +_C.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_KEY = ('res3', 'res2') +_C.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_CHANNELS_PROJECT = (64, 32) +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE = CN() +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.ENABLE = False +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.LOW_LEVEL_CHANNELS_PROJECT = (32, 16) +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.DECODER_CHANNELS = 128 +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.HEAD_CHANNELS = 128 +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.ASPP_CHANNELS = 256 +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.NUM_CLASSES = (1, 2) +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.CLASS_KEY = ('center', 'offset') +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.FOREGROUND_SEG = False +_C.MODEL.PANOPTIC_DEEPLAB.INSTANCE.FOREGROUND_ARCH = 'v1' + +# ----------------------------------------------------------------------------- +# DATASET +# ----------------------------------------------------------------------------- +_C.DATASET = CN() +_C.DATASET.ROOT = './datasets/cityscapes' +_C.DATASET.DATASET = 'cityscapes' +_C.DATASET.NUM_CLASSES = 19 +_C.DATASET.TRAIN_SPLIT = 'train' +_C.DATASET.TEST_SPLIT = 'val' +_C.DATASET.CROP_SIZE = (513, 1025) +_C.DATASET.MIRROR = True +_C.DATASET.MIN_SCALE = 0.5 +_C.DATASET.MAX_SCALE = 2.0 +_C.DATASET.SCALE_STEP_SIZE = 0.1 +_C.DATASET.MEAN = (0.485, 0.456, 0.406) +_C.DATASET.STD = (0.229, 0.224, 0.225) +_C.DATASET.SEMANTIC_ONLY = False +_C.DATASET.IGNORE_STUFF_IN_OFFSET = True +_C.DATASET.SMALL_INSTANCE_AREA = 0 +_C.DATASET.SMALL_INSTANCE_WEIGHT = 1 + +_C.DATASET.MIN_RESIZE_VALUE = -1 +_C.DATASET.MAX_RESIZE_VALUE = -1 +_C.DATASET.RESIZE_FACTOR = -1 + +# ----------------------------------------------------------------------------- +# Solver +# ----------------------------------------------------------------------------- +_C.SOLVER = CN() +_C.SOLVER.BASE_LR = 0.01 +_C.SOLVER.WEIGHT_DECAY = 0.0001 +# Weight decay of norm layers. +_C.SOLVER.WEIGHT_DECAY_NORM = 0.0 +# Bias. +_C.SOLVER.BIAS_LR_FACTOR = 2.0 +_C.SOLVER.WEIGHT_DECAY_BIAS = 0.0 +_C.SOLVER.MOMENTUM = 0.9 +_C.SOLVER.OPTIMIZER = 'sgd' +_C.SOLVER.ADAM_BETAS = (0.9, 0.999) +_C.SOLVER.ADAM_EPS = 1e-08 + +_C.SOLVER.LR_SCHEDULER_NAME = 'WarmupPolyLR' +# The iteration number to decrease learning rate by GAMMA. +_C.SOLVER.STEPS = (30000,) +_C.SOLVER.GAMMA = 0.1 + +_C.SOLVER.WARMUP_FACTOR = 1.0 / 1000 +_C.SOLVER.WARMUP_ITERS = 1000 +_C.SOLVER.WARMUP_METHOD = "linear" + +_C.SOLVER.POLY_LR_POWER = 0.9 +_C.SOLVER.POLY_LR_CONSTANT_ENDING = 0 + +_C.SOLVER.CLIP_GRADIENTS = CN() +_C.SOLVER.CLIP_GRADIENTS.ENABLED = False +# Type of gradient clipping, currently 2 values are supported: +# - "value": the absolute values of elements of each gradients are clipped +# - "norm": the norm of the gradient for each parameter is clipped thus +# affecting all elements in the parameter +_C.SOLVER.CLIP_GRADIENTS.CLIP_TYPE = "value" +# Maximum absolute value used for clipping gradients +_C.SOLVER.CLIP_GRADIENTS.CLIP_VALUE = 1.0 +# Floating point number p for L-p norm to be used with the "norm" +# gradient clipping type; for L-inf, please specify .inf +_C.SOLVER.CLIP_GRADIENTS.NORM_TYPE = 2.0 + +# ----------------------------------------------------------------------------- +# Loss +# ----------------------------------------------------------------------------- +_C.LOSS = CN() + +_C.LOSS.SEMANTIC = CN() +_C.LOSS.SEMANTIC.NAME = 'cross_entropy' +# TODO: make `ignore` more consistent +_C.LOSS.SEMANTIC.IGNORE = 255 +_C.LOSS.SEMANTIC.REDUCTION = 'mean' +_C.LOSS.SEMANTIC.THRESHOLD = 0.7 +_C.LOSS.SEMANTIC.MIN_KEPT = 100000 +_C.LOSS.SEMANTIC.TOP_K_PERCENT = 1.0 +_C.LOSS.SEMANTIC.WEIGHT = 1.0 + +_C.LOSS.CENTER = CN() +_C.LOSS.CENTER.NAME = 'mse' +_C.LOSS.CENTER.REDUCTION = 'none' +_C.LOSS.CENTER.WEIGHT = 200.0 + +_C.LOSS.OFFSET = CN() +_C.LOSS.OFFSET.NAME = 'l1' +_C.LOSS.OFFSET.REDUCTION = 'none' +_C.LOSS.OFFSET.WEIGHT = 0.01 + +_C.LOSS.FOREGROUND = CN() +_C.LOSS.FOREGROUND.NAME = 'cross_entropy' +_C.LOSS.FOREGROUND.IGNORE = 255 +_C.LOSS.FOREGROUND.REDUCTION = 'mean' +_C.LOSS.FOREGROUND.THRESHOLD = 0.7 +_C.LOSS.FOREGROUND.MIN_KEPT = 100000 +_C.LOSS.FOREGROUND.TOP_K_PERCENT = 1.0 +_C.LOSS.FOREGROUND.WEIGHT = 1.0 + +# ----------------------------------------------------------------------------- +# TRAIN +# ----------------------------------------------------------------------------- +_C.TRAIN = CN() + +_C.TRAIN.IMS_PER_BATCH = 32 +_C.TRAIN.MAX_ITER = 90000 +_C.TRAIN.RESUME = False + +# ----------------------------------------------------------------------------- +# DATALOADER +# ----------------------------------------------------------------------------- +_C.DATALOADER = CN() + +_C.DATALOADER.SAMPLER_TRAIN = 'TrainingSampler' +_C.DATALOADER.TRAIN_SHUFFLE = True + +_C.DATALOADER.NUM_WORKERS = 4 + +# ----------------------------------------------------------------------------- +# DEBUG +# ----------------------------------------------------------------------------- +_C.DEBUG = CN() +_C.DEBUG.DEBUG = True +_C.DEBUG.DEBUG_FREQ = 100 +_C.DEBUG.TARGET_KEYS = ('semantic', 'center', 'offset', 'semantic_weights', 'center_weights', 'offset_weights') +_C.DEBUG.OUTPUT_KEYS = ('semantic', 'center', 'offset') +_C.DEBUG.KEEP_INTERVAL = 1000 + +# ----------------------------------------------------------------------------- +# TEST +# ----------------------------------------------------------------------------- +_C.TEST = CN() + +_C.TEST.GPUS = (0, ) +_C.TEST.CROP_SIZE = (1025, 2049) + +_C.TEST.SEMANTIC_FOLDER = 'semantic' +_C.TEST.INSTANCE_FOLDER = 'instance' +_C.TEST.PANOPTIC_FOLDER = 'panoptic' +_C.TEST.FOREGROUND_FOLDER = 'foreground' + +_C.TEST.EVAL_INSTANCE = False +_C.TEST.EVAL_PANOPTIC = False +_C.TEST.EVAL_FOREGROUND = False + +_C.TEST.MODEL_FILE = '' +_C.TEST.TEST_TIME_AUGMENTATION = False +_C.TEST.FLIP_TEST = False +_C.TEST.SCALE_LIST = [1] + +_C.TEST.DEBUG = False + +_C.TEST.ORACLE_SEMANTIC = False +_C.TEST.ORACLE_FOREGROUND = False +_C.TEST.ORACLE_CENTER = False +_C.TEST.ORACLE_OFFSET = False + +_C.TEST.INSTANCE_SCORE_TYPE = "semantic" + +# ----------------------------------------------------------------------------- +# POST PROCESSING +# Panoptic post-processing params +# ----------------------------------------------------------------------------- +_C.POST_PROCESSING = CN() +_C.POST_PROCESSING.CENTER_THRESHOLD = 0.1 +_C.POST_PROCESSING.NMS_KERNEL = 7 +_C.POST_PROCESSING.TOP_K_INSTANCE = 200 +_C.POST_PROCESSING.STUFF_AREA = 2048 + + +def update_config(cfg, args): + cfg.defrost() + + cfg.merge_from_file(args.cfg) + cfg.merge_from_list(args.opts) + + cfg.freeze() + + +if __name__ == '__main__': + import sys + + with open(sys.argv[1], 'w') as f: + print(_C, file=f) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py new file mode 100644 index 000000000..24992ad39 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/config/hrnet_config.py @@ -0,0 +1,130 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) Microsoft +# Licensed under the MIT License. +# Create by Bin Xiao (Bin.Xiao@microsoft.com) +# Modified by Ke Sun (sunk@mail.ustc.edu.cn), Rainbowsecret (yuyua@microsoft.com) +# ------------------------------------------------------------------------------ + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from yacs.config import CfgNode as CN + + +# configs for HRNet48 +HRNET_48 = CN() +HRNET_48.FINAL_CONV_KERNEL = 1 + +HRNET_48.STAGE1 = CN() +HRNET_48.STAGE1.NUM_MODULES = 1 +HRNET_48.STAGE1.NUM_BRANCHES = 1 +HRNET_48.STAGE1.NUM_BLOCKS = [4] +HRNET_48.STAGE1.NUM_CHANNELS = [64] +HRNET_48.STAGE1.BLOCK = 'BOTTLENECK' +HRNET_48.STAGE1.FUSE_METHOD = 'SUM' + +HRNET_48.STAGE2 = CN() +HRNET_48.STAGE2.NUM_MODULES = 1 +HRNET_48.STAGE2.NUM_BRANCHES = 2 +HRNET_48.STAGE2.NUM_BLOCKS = [4, 4] +HRNET_48.STAGE2.NUM_CHANNELS = [48, 96] +HRNET_48.STAGE2.BLOCK = 'BASIC' +HRNET_48.STAGE2.FUSE_METHOD = 'SUM' + +HRNET_48.STAGE3 = CN() +HRNET_48.STAGE3.NUM_MODULES = 4 +HRNET_48.STAGE3.NUM_BRANCHES = 3 +HRNET_48.STAGE3.NUM_BLOCKS = [4, 4, 4] +HRNET_48.STAGE3.NUM_CHANNELS = [48, 96, 192] +HRNET_48.STAGE3.BLOCK = 'BASIC' +HRNET_48.STAGE3.FUSE_METHOD = 'SUM' + +HRNET_48.STAGE4 = CN() +HRNET_48.STAGE4.NUM_MODULES = 3 +HRNET_48.STAGE4.NUM_BRANCHES = 4 +HRNET_48.STAGE4.NUM_BLOCKS = [4, 4, 4, 4] +HRNET_48.STAGE4.NUM_CHANNELS = [48, 96, 192, 384] +HRNET_48.STAGE4.BLOCK = 'BASIC' +HRNET_48.STAGE4.FUSE_METHOD = 'SUM' + + +# configs for HRNet32 +HRNET_32 = CN() +HRNET_32.FINAL_CONV_KERNEL = 1 + +HRNET_32.STAGE1 = CN() +HRNET_32.STAGE1.NUM_MODULES = 1 +HRNET_32.STAGE1.NUM_BRANCHES = 1 +HRNET_32.STAGE1.NUM_BLOCKS = [4] +HRNET_32.STAGE1.NUM_CHANNELS = [64] +HRNET_32.STAGE1.BLOCK = 'BOTTLENECK' +HRNET_32.STAGE1.FUSE_METHOD = 'SUM' + +HRNET_32.STAGE2 = CN() +HRNET_32.STAGE2.NUM_MODULES = 1 +HRNET_32.STAGE2.NUM_BRANCHES = 2 +HRNET_32.STAGE2.NUM_BLOCKS = [4, 4] +HRNET_32.STAGE2.NUM_CHANNELS = [32, 64] +HRNET_32.STAGE2.BLOCK = 'BASIC' +HRNET_32.STAGE2.FUSE_METHOD = 'SUM' + +HRNET_32.STAGE3 = CN() +HRNET_32.STAGE3.NUM_MODULES = 4 +HRNET_32.STAGE3.NUM_BRANCHES = 3 +HRNET_32.STAGE3.NUM_BLOCKS = [4, 4, 4] +HRNET_32.STAGE3.NUM_CHANNELS = [32, 64, 128] +HRNET_32.STAGE3.BLOCK = 'BASIC' +HRNET_32.STAGE3.FUSE_METHOD = 'SUM' + +HRNET_32.STAGE4 = CN() +HRNET_32.STAGE4.NUM_MODULES = 3 +HRNET_32.STAGE4.NUM_BRANCHES = 4 +HRNET_32.STAGE4.NUM_BLOCKS = [4, 4, 4, 4] +HRNET_32.STAGE4.NUM_CHANNELS = [32, 64, 128, 256] +HRNET_32.STAGE4.BLOCK = 'BASIC' +HRNET_32.STAGE4.FUSE_METHOD = 'SUM' + + +# configs for HRNet18 +HRNET_18 = CN() +HRNET_18.FINAL_CONV_KERNEL = 1 + +HRNET_18.STAGE1 = CN() +HRNET_18.STAGE1.NUM_MODULES = 1 +HRNET_18.STAGE1.NUM_BRANCHES = 1 +HRNET_18.STAGE1.NUM_BLOCKS = [4] +HRNET_18.STAGE1.NUM_CHANNELS = [64] +HRNET_18.STAGE1.BLOCK = 'BOTTLENECK' +HRNET_18.STAGE1.FUSE_METHOD = 'SUM' + +HRNET_18.STAGE2 = CN() +HRNET_18.STAGE2.NUM_MODULES = 1 +HRNET_18.STAGE2.NUM_BRANCHES = 2 +HRNET_18.STAGE2.NUM_BLOCKS = [4, 4] +HRNET_18.STAGE2.NUM_CHANNELS = [18, 36] +HRNET_18.STAGE2.BLOCK = 'BASIC' +HRNET_18.STAGE2.FUSE_METHOD = 'SUM' + +HRNET_18.STAGE3 = CN() +HRNET_18.STAGE3.NUM_MODULES = 4 +HRNET_18.STAGE3.NUM_BRANCHES = 3 +HRNET_18.STAGE3.NUM_BLOCKS = [4, 4, 4] +HRNET_18.STAGE3.NUM_CHANNELS = [18, 36, 72] +HRNET_18.STAGE3.BLOCK = 'BASIC' +HRNET_18.STAGE3.FUSE_METHOD = 'SUM' + +HRNET_18.STAGE4 = CN() +HRNET_18.STAGE4.NUM_MODULES = 3 +HRNET_18.STAGE4.NUM_BRANCHES = 4 +HRNET_18.STAGE4.NUM_BLOCKS = [4, 4, 4, 4] +HRNET_18.STAGE4.NUM_CHANNELS = [18, 36, 72, 144] +HRNET_18.STAGE4.BLOCK = 'BASIC' +HRNET_18.STAGE4.FUSE_METHOD = 'SUM' + + +MODEL_CONFIGS = { + 'hrnet18': HRNET_18, + 'hrnet32': HRNET_32, + 'hrnet48': HRNET_48, +} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/__init__.py new file mode 100644 index 000000000..c121b9063 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/__init__.py @@ -0,0 +1,2 @@ +from .build import ( + build_dataset_from_cfg, build_train_loader_from_cfg, build_test_loader_from_cfg) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/build.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/build.py new file mode 100644 index 000000000..4bb6bbe25 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/build.py @@ -0,0 +1,159 @@ +# ------------------------------------------------------------------------------ +# Builds dataloader. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import logging + +import torch +import numpy as np + +from .datasets import Cityscapes, CityscapesPanoptic, COCOPanoptic +from . import samplers +from segmentation.utils.comm import get_world_size +from segmentation.utils.env import seed_all_rng + + +def build_dataset_from_cfg(config, is_train=True): + """Builds dataset from configuration file. + Args: + config: the configuration file. + is_train: Bool, training or testing, it automatically handles data augmentation. + + Returns: + A torch Dataset. + """ + dataset_map = { + 'cityscapes': Cityscapes, + 'cityscapes_panoptic': CityscapesPanoptic, + 'coco_panoptic': COCOPanoptic, + } + + dataset_cfg = { + 'cityscapes': dict( + root=config.DATASET.ROOT, + split=config.DATASET.TRAIN_SPLIT if is_train else config.DATASET.TEST_SPLIT, + is_train=is_train, + crop_size=config.DATASET.CROP_SIZE if is_train else config.TEST.CROP_SIZE, + mirror=config.DATASET.MIRROR, + min_scale=config.DATASET.MIN_SCALE, + max_scale=config.DATASET.MAX_SCALE, + scale_step_size=config.DATASET.SCALE_STEP_SIZE, + mean=config.DATASET.MEAN, + std=config.DATASET.STD + ), + 'cityscapes_panoptic': dict( + root=config.DATASET.ROOT, + split=config.DATASET.TRAIN_SPLIT if is_train else config.DATASET.TEST_SPLIT, + is_train=is_train, + crop_size=config.DATASET.CROP_SIZE if is_train else config.TEST.CROP_SIZE, + mirror=config.DATASET.MIRROR, + min_scale=config.DATASET.MIN_SCALE, + max_scale=config.DATASET.MAX_SCALE, + scale_step_size=config.DATASET.SCALE_STEP_SIZE, + mean=config.DATASET.MEAN, + std=config.DATASET.STD, + semantic_only=config.DATASET.SEMANTIC_ONLY, + ignore_stuff_in_offset=config.DATASET.IGNORE_STUFF_IN_OFFSET, + small_instance_area=config.DATASET.SMALL_INSTANCE_AREA, + small_instance_weight=config.DATASET.SMALL_INSTANCE_WEIGHT + ), + 'coco_panoptic': dict( + root=config.DATASET.ROOT, + split=config.DATASET.TRAIN_SPLIT if is_train else config.DATASET.TEST_SPLIT, + min_resize_value=config.DATASET.MIN_RESIZE_VALUE, + max_resize_value=config.DATASET.MAX_RESIZE_VALUE, + resize_factor=config.DATASET.RESIZE_FACTOR, + is_train=is_train, + crop_size=config.DATASET.CROP_SIZE if is_train else config.TEST.CROP_SIZE, + mirror=config.DATASET.MIRROR, + min_scale=config.DATASET.MIN_SCALE, + max_scale=config.DATASET.MAX_SCALE, + scale_step_size=config.DATASET.SCALE_STEP_SIZE, + mean=config.DATASET.MEAN, + std=config.DATASET.STD, + semantic_only=config.DATASET.SEMANTIC_ONLY, + ignore_stuff_in_offset=config.DATASET.IGNORE_STUFF_IN_OFFSET, + small_instance_area=config.DATASET.SMALL_INSTANCE_AREA, + small_instance_weight=config.DATASET.SMALL_INSTANCE_WEIGHT + ), + } + + dataset = dataset_map[config.DATASET.DATASET]( + **dataset_cfg[config.DATASET.DATASET] + ) + return dataset + + +def build_train_loader_from_cfg(config): + """Builds dataloader from configuration file. + Args: + config: the configuration file. + + Returns: + A torch Dataloader. + """ + num_workers = get_world_size() + images_per_batch = config.TRAIN.IMS_PER_BATCH + assert ( + images_per_batch % num_workers == 0 + ), "TRAIN.IMS_PER_BATCH ({}) must be divisible by the number of workers ({}).".format( + images_per_batch, num_workers + ) + assert ( + images_per_batch >= num_workers + ), "TRAIN.IMS_PER_BATCH ({}) must be larger than the number of workers ({}).".format( + images_per_batch, num_workers + ) + images_per_worker = images_per_batch // num_workers + + dataset = build_dataset_from_cfg(config, is_train=True) + + sampler_name = config.DATALOADER.SAMPLER_TRAIN + logger = logging.getLogger(__name__) + logger.info("Using training sampler {}".format(sampler_name)) + if sampler_name == "TrainingSampler": + sampler = samplers.TrainingSampler(len(dataset), shuffle=config.DATALOADER.TRAIN_SHUFFLE) + else: + raise ValueError("Unknown training sampler: {}".format(sampler_name)) + + batch_sampler = torch.utils.data.sampler.BatchSampler( + sampler, images_per_worker, drop_last=True + ) + # drop_last so the batch always have the same size + data_loader = torch.utils.data.DataLoader( + dataset, + num_workers=config.DATALOADER.NUM_WORKERS, + batch_sampler=batch_sampler, + worker_init_fn=worker_init_reset_seed, + ) + + return data_loader + + +def build_test_loader_from_cfg(config): + """Builds dataloader from configuration file. + Args: + config: the configuration file. + + Returns: + A torch Dataloader. + """ + dataset = build_dataset_from_cfg(config, is_train=False) + + sampler = samplers.InferenceSampler(len(dataset)) + # Always use 1 image per worker during inference since this is the + # standard when reporting inference time in papers. + batch_sampler = torch.utils.data.sampler.BatchSampler(sampler, 1, drop_last=False) + + data_loader = torch.utils.data.DataLoader( + dataset, + num_workers=config.DATALOADER.NUM_WORKERS, + batch_sampler=batch_sampler, + ) + + return data_loader + + +def worker_init_reset_seed(worker_id): + seed_all_rng(np.random.randint(2 ** 31) + worker_id) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/__init__.py new file mode 100644 index 000000000..8f70169fc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/__init__.py @@ -0,0 +1,4 @@ +from .base_dataset import BaseDataset +from .cityscapes import Cityscapes +from .cityscapes_panoptic import CityscapesPanoptic +from .coco_panoptic import COCOPanoptic diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/base_dataset.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/base_dataset.py new file mode 100644 index 000000000..73c7003fc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/base_dataset.py @@ -0,0 +1,182 @@ +# ------------------------------------------------------------------------------ +# Base class for loading a segmentation Dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import os + +import numpy as np +from PIL import Image, ImageOps + +import torch +from torch.utils import data + + +class BaseDataset(data.Dataset): + """ + Base class for segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225)): + self.root = root + self.split = split + self.is_train = is_train + + self.crop_h, self.crop_w = crop_size + + self.mirror = mirror + self.min_scale = min_scale + self.max_scale = max_scale + self.scale_step_size = scale_step_size + + self.mean = mean + self.std = std + + self.pad_value = tuple([int(v * 255) for v in self.mean]) + + # ======== override the following fields ======== + self.ignore_label = 255 + self.label_pad_value = (self.ignore_label, ) + self.label_dtype = 'uint8' + + # list of image filename (required) + self.img_list = [] + # list of label filename (required) + self.ann_list = [] + # list of instance dictionary (optional) + self.ins_list = [] + + self.has_instance = False + self.label_divisor = 1000 + + self.raw_label_transform = None + self.pre_augmentation_transform = None + self.transform = None + self.target_transform = None + + def __len__(self): + return len(self.img_list) + + def __getitem__(self, index): + # TODO: handle transform properly when there is no label + dataset_dict = {} + assert os.path.exists(self.img_list[index]), 'Path does not exist: {}'.format(self.img_list[index]) + image = self.read_image(self.img_list[index], 'RGB') + if not self.is_train: + # Do not save this during training. + dataset_dict['raw_image'] = image.copy() + if self.ann_list is not None: + assert os.path.exists(self.ann_list[index]), 'Path does not exist: {}'.format(self.ann_list[index]) + label = self.read_label(self.ann_list[index], self.label_dtype) + else: + label = None + raw_label = label.copy() + if self.raw_label_transform is not None: + raw_label = self.raw_label_transform(raw_label, self.ins_list[index])['semantic'] + if not self.is_train: + # Do not save this during training + dataset_dict['raw_label'] = raw_label + size = image.shape + dataset_dict['raw_size'] = np.array(size) + # To save prediction for official evaluation. + name = os.path.splitext(os.path.basename(self.ann_list[index]))[0] + # TODO: how to return the filename? + # dataset_dict['name'] = np.array(name) + + # Resize and pad image to the same size before data augmentation. + if self.pre_augmentation_transform is not None: + image, label = self.pre_augmentation_transform(image, label) + size = image.shape + dataset_dict['size'] = np.array(size) + else: + dataset_dict['size'] = dataset_dict['raw_size'] + + # Apply data augmentation. + if self.transform is not None: + image, label = self.transform(image, label) + + dataset_dict['image'] = image + if not self.has_instance: + dataset_dict['semantic'] = torch.as_tensor(label.astype('long')) + return dataset_dict + + # Generate training target. + if self.target_transform is not None: + label_dict = self.target_transform(label, self.ins_list[index]) + for key in label_dict.keys(): + dataset_dict[key] = label_dict[key] + + return dataset_dict + + @staticmethod + def read_image(file_name, format=None): + image = Image.open(file_name) + + # capture and ignore this bug: https://github.com/python-pillow/Pillow/issues/3973 + try: + image = ImageOps.exif_transpose(image) + except Exception: + pass + + if format is not None: + # PIL only supports RGB, so convert to RGB and flip channels over below + conversion_format = format + if format == "BGR": + conversion_format = "RGB" + image = image.convert(conversion_format) + image = np.asarray(image) + if format == "BGR": + # flip channels if needed + image = image[:, :, ::-1] + # PIL squeezes out the channel dimension for "L", so make it HWC + if format == "L": + image = np.expand_dims(image, -1) + return image + + @staticmethod + def read_label(file_name, dtype='uint8'): + # In some cases, `uint8` is not enough for label + label = Image.open(file_name) + return np.asarray(label, dtype=dtype) + + def reverse_transform(self, image_tensor): + """Reverse the normalization on image. + Args: + image_tensor: torch.Tensor, the normalized image tensor. + Returns: + image: numpy.array, the original image before normalization. + """ + dtype = image_tensor.dtype + mean = torch.as_tensor(self.mean, dtype=dtype, device=image_tensor.device) + std = torch.as_tensor(self.std, dtype=dtype, device=image_tensor.device) + image_tensor.mul_(std[:, None, None]).add_(mean[:, None, None]) + image = image_tensor.mul(255)\ + .clamp(0, 255)\ + .byte()\ + .permute(1, 2, 0)\ + .cpu().numpy() + return image + + @staticmethod + def train_id_to_eval_id(): + return None diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes.py new file mode 100644 index 000000000..a1ec79466 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes.py @@ -0,0 +1,150 @@ +# ------------------------------------------------------------------------------ +# Loads Cityscapes semantic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import glob +import os + +import numpy as np + +from .base_dataset import BaseDataset +from .utils import DatasetDescriptor +from ..transforms import build_transforms + +_CITYSCAPES_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train': 2975, + 'trainval': 3475, + 'val': 500, + 'test': 1525}, + num_classes=19, + ignore_label=255, +) + +_CITYSCAPES_TRAIN_ID_TO_EVAL_ID = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 31, 32, 33] + +# A map from data type to folder name that saves the data. +_FOLDERS_MAP = { + 'image': 'leftImg8bit', + 'label': 'gtFine', +} + +# A map from data type to filename postfix. +_POSTFIX_MAP = { + 'image': '_leftImg8bit', + 'label': '_gtFine_labelTrainIds', +} + +# A map from data type to data format. +_DATA_FORMAT_MAP = { + 'image': 'png', + 'label': 'png', +} + + +class Cityscapes(BaseDataset): + """ + Cityscapes semantic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + **kwargs): + super(Cityscapes, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + self.num_classes = _CITYSCAPES_INFORMATION.num_classes + self.ignore_label = _CITYSCAPES_INFORMATION.ignore_label + self.label_pad_value = (self.ignore_label, ) + + # Get image and annotation list. + self.img_list = self._get_files('image', self.split) + self.ann_list = self._get_files('label', self.split) + + assert len(self) == _CITYSCAPES_INFORMATION.splits_to_sizes[self.split] + + self.transform = build_transforms(self, is_train) + + def _get_files(self, data, dataset_split): + """Gets files for the specified data type and dataset split. + Args: + data: String, desired data ('image' or 'label'). + dataset_split: String, dataset split ('train', 'val', 'test') + Returns: + A list of sorted file names or None when getting label for test set. + """ + if data == 'label' and dataset_split == 'test': + return None + pattern = '*%s.%s' % (_POSTFIX_MAP[data], _DATA_FORMAT_MAP[data]) + search_files = os.path.join( + self.root, _FOLDERS_MAP[data], dataset_split, '*', pattern) + filenames = glob.glob(search_files) + return sorted(filenames) + + @staticmethod + def train_id_to_eval_id(): + return _CITYSCAPES_TRAIN_ID_TO_EVAL_ID + + def _convert_train_id_to_eval_id(self, prediction): + """Converts the predicted label for evaluation. + There are cases where the training labels are not equal to the evaluation + labels. This function is used to perform the conversion so that we could + evaluate the results on the evaluation server. + Args: + prediction: Semantic segmentation prediction. + Returns: + Semantic segmentation prediction whose labels have been changed. + """ + converted_prediction = prediction.copy() + for train_id, eval_id in enumerate(self.train_id_to_eval_id()): + converted_prediction[prediction == train_id] = eval_id + + return converted_prediction + + @staticmethod + def create_label_colormap(): + """Creates a label colormap used in CITYSCAPES segmentation benchmark. + Returns: + A colormap for visualizing segmentation results. + """ + colormap = np.zeros((256, 3), dtype=np.uint8) + colormap[0] = [128, 64, 128] + colormap[1] = [244, 35, 232] + colormap[2] = [70, 70, 70] + colormap[3] = [102, 102, 156] + colormap[4] = [190, 153, 153] + colormap[5] = [153, 153, 153] + colormap[6] = [250, 170, 30] + colormap[7] = [220, 220, 0] + colormap[8] = [107, 142, 35] + colormap[9] = [152, 251, 152] + colormap[10] = [70, 130, 180] + colormap[11] = [220, 20, 60] + colormap[12] = [255, 0, 0] + colormap[13] = [0, 0, 142] + colormap[14] = [0, 0, 70] + colormap[15] = [0, 60, 100] + colormap[16] = [0, 80, 100] + colormap[17] = [0, 0, 230] + colormap[18] = [119, 11, 32] + return colormap diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes_panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes_panoptic.py new file mode 100644 index 000000000..baa5174cf --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/cityscapes_panoptic.py @@ -0,0 +1,130 @@ +# ------------------------------------------------------------------------------ +# Loads Cityscapes panoptic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import json +import os + +import numpy as np + +from .cityscapes import Cityscapes +from .utils import DatasetDescriptor +from ..transforms import build_transforms, PanopticTargetGenerator, SemanticTargetGenerator + +_CITYSCAPES_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train': 2975, + 'trainval': 3475, + 'val': 500, + 'test': 1525}, + num_classes=19, + ignore_label=255, +) + +# Add 1 void label. +_CITYSCAPES_PANOPTIC_TRAIN_ID_TO_EVAL_ID = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 31, 32, 33, 0] + +_CITYSCAPES_THING_LIST = [11, 12, 13, 14, 15, 16, 17, 18] + + +class CityscapesPanoptic(Cityscapes): + """ + Cityscapes panoptic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + semantic_only: Bool, only use semantic segmentation label. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + """ + def __init__(self, + root, + split, + is_train=True, + crop_size=(513, 1025), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=False, + small_instance_area=0, + small_instance_weight=1, + **kwargs): + super(CityscapesPanoptic, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + self.num_classes = _CITYSCAPES_INFORMATION.num_classes + self.ignore_label = _CITYSCAPES_INFORMATION.ignore_label + self.label_pad_value = (0, 0, 0) + + self.has_instance = True + self.label_divisor = 1000 + self.label_dtype = np.float32 + self.thing_list = _CITYSCAPES_THING_LIST + + # Get image and annotation list. + if split == 'test': + self.img_list = self._get_files('image', self.split) + self.ann_list = None + self.ins_list = None + else: + self.img_list = [] + self.ann_list = [] + self.ins_list = [] + json_filename = os.path.join(self.root, 'gtFine', 'cityscapes_panoptic_{}_trainId.json'.format(self.split)) + dataset = json.load(open(json_filename)) + for img in dataset['images']: + img_file_name = img['file_name'] + self.img_list.append(os.path.join( + self.root, 'leftImg8bit', self.split, img_file_name.split('_')[0], + img_file_name.replace('_gtFine', ''))) + for ann in dataset['annotations']: + ann_file_name = ann['file_name'] + self.ann_list.append(os.path.join( + self.root, 'gtFine', 'cityscapes_panoptic_{}_trainId'.format(self.split), ann_file_name)) + self.ins_list.append(ann['segments_info']) + + assert len(self) == _CITYSCAPES_INFORMATION.splits_to_sizes[self.split] + + self.transform = build_transforms(self, is_train) + if semantic_only: + self.target_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + else: + self.target_transform = PanopticTargetGenerator(self.ignore_label, self.rgb2id, _CITYSCAPES_THING_LIST, + sigma=8, ignore_stuff_in_offset=ignore_stuff_in_offset, + small_instance_area=small_instance_area, + small_instance_weight=small_instance_weight) + # Generates semantic label for evaluation. + self.raw_label_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + + @staticmethod + def train_id_to_eval_id(): + return _CITYSCAPES_PANOPTIC_TRAIN_ID_TO_EVAL_ID + + @staticmethod + def rgb2id(color): + """Converts the color to panoptic label. + Color is created by `color = [segmentId % 256, segmentId // 256, segmentId // 256 // 256]`. + Args: + color: Ndarray or a tuple, color encoded image. + Returns: + Panoptic label. + """ + if isinstance(color, np.ndarray) and len(color.shape) == 3: + if color.dtype == np.uint8: + color = color.astype(np.int32) + return color[:, :, 0] + 256 * color[:, :, 1] + 256 * 256 * color[:, :, 2] + return int(color[0] + 256 * color[1] + 256 * 256 * color[2]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/coco_panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/coco_panoptic.py new file mode 100644 index 000000000..6de52e3d2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/coco_panoptic.py @@ -0,0 +1,299 @@ +# ------------------------------------------------------------------------------ +# Loads COCO panoptic dataset. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import json +import os + +import numpy as np + +from .base_dataset import BaseDataset +from .utils import DatasetDescriptor +from ..transforms import build_transforms, Resize, PanopticTargetGenerator, SemanticTargetGenerator + +_COCO_PANOPTIC_INFORMATION = DatasetDescriptor( + splits_to_sizes={'train2017': 118287, + 'trainval2017': 123287, + 'val2017': 5000, + 'test-dev2017': 20288, + 'test2017': 40670}, # `test` includes `test-dev` and `test-challenge` + num_classes=133, + ignore_label=255, +) + +# Add 1 void label. +_COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID = ( + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 67, 70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90, 92, 93, 95, 100, 107, 109, 112, + 118, 119, 122, 125, 128, 130, 133, 138, 141, 144, 145, 147, 148, 149, 151, 154, 155, 156, 159, 161, 166, 168, 171, + 175, 176, 177, 178, 180, 181, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + 200, 0]) + +_COCO_PANOPTIC_EVAL_ID_TO_TRAIN_ID = { + v: k for k, v in enumerate(_COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID[:-1]) +} + +_COCO_PANOPTIC_THING_LIST = list(range(80)) # the first 80 classes are `thing` classes + +COCO_CATEGORIES = [ + {"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"}, + {"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"}, + {"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"}, + {"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"}, + {"color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"}, + {"color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"}, + {"color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"}, + {"color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"}, + {"color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"}, + {"color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"}, + {"color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"}, + {"color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"}, + {"color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"}, + {"color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"}, + {"color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"}, + {"color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"}, + {"color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"}, + {"color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"}, + {"color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"}, + {"color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"}, + {"color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"}, + {"color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"}, + {"color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"}, + {"color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"}, + {"color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"}, + {"color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"}, + {"color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"}, + {"color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"}, + {"color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"}, + {"color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"}, + {"color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"}, + {"color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"}, + {"color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"}, + {"color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"}, + {"color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"}, + {"color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"}, + {"color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"}, + {"color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"}, + {"color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"}, + {"color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"}, + {"color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"}, + {"color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"}, + {"color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"}, + {"color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"}, + {"color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"}, + {"color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"}, + {"color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"}, + {"color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"}, + {"color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"}, + {"color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"}, + {"color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"}, + {"color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"}, + {"color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"}, + {"color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"}, + {"color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"}, + {"color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"}, + {"color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"}, + {"color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"}, + {"color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"}, + {"color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"}, + {"color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"}, + {"color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"}, + {"color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"}, + {"color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"}, + {"color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"}, + {"color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"}, + {"color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"}, + {"color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"}, + {"color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"}, + {"color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"}, + {"color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"}, + {"color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"}, + {"color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"}, + {"color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"}, + {"color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"}, + {"color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"}, + {"color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"}, + {"color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"}, + {"color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"}, + {"color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"}, + {"color": [255, 255, 128], "isthing": 0, "id": 92, "name": "banner"}, + {"color": [147, 211, 203], "isthing": 0, "id": 93, "name": "blanket"}, + {"color": [150, 100, 100], "isthing": 0, "id": 95, "name": "bridge"}, + {"color": [168, 171, 172], "isthing": 0, "id": 100, "name": "cardboard"}, + {"color": [146, 112, 198], "isthing": 0, "id": 107, "name": "counter"}, + {"color": [210, 170, 100], "isthing": 0, "id": 109, "name": "curtain"}, + {"color": [92, 136, 89], "isthing": 0, "id": 112, "name": "door-stuff"}, + {"color": [218, 88, 184], "isthing": 0, "id": 118, "name": "floor-wood"}, + {"color": [241, 129, 0], "isthing": 0, "id": 119, "name": "flower"}, + {"color": [217, 17, 255], "isthing": 0, "id": 122, "name": "fruit"}, + {"color": [124, 74, 181], "isthing": 0, "id": 125, "name": "gravel"}, + {"color": [70, 70, 70], "isthing": 0, "id": 128, "name": "house"}, + {"color": [255, 228, 255], "isthing": 0, "id": 130, "name": "light"}, + {"color": [154, 208, 0], "isthing": 0, "id": 133, "name": "mirror-stuff"}, + {"color": [193, 0, 92], "isthing": 0, "id": 138, "name": "net"}, + {"color": [76, 91, 113], "isthing": 0, "id": 141, "name": "pillow"}, + {"color": [255, 180, 195], "isthing": 0, "id": 144, "name": "platform"}, + {"color": [106, 154, 176], "isthing": 0, "id": 145, "name": "playingfield"}, + {"color": [230, 150, 140], "isthing": 0, "id": 147, "name": "railroad"}, + {"color": [60, 143, 255], "isthing": 0, "id": 148, "name": "river"}, + {"color": [128, 64, 128], "isthing": 0, "id": 149, "name": "road"}, + {"color": [92, 82, 55], "isthing": 0, "id": 151, "name": "roof"}, + {"color": [254, 212, 124], "isthing": 0, "id": 154, "name": "sand"}, + {"color": [73, 77, 174], "isthing": 0, "id": 155, "name": "sea"}, + {"color": [255, 160, 98], "isthing": 0, "id": 156, "name": "shelf"}, + {"color": [255, 255, 255], "isthing": 0, "id": 159, "name": "snow"}, + {"color": [104, 84, 109], "isthing": 0, "id": 161, "name": "stairs"}, + {"color": [169, 164, 131], "isthing": 0, "id": 166, "name": "tent"}, + {"color": [225, 199, 255], "isthing": 0, "id": 168, "name": "towel"}, + {"color": [137, 54, 74], "isthing": 0, "id": 171, "name": "wall-brick"}, + {"color": [135, 158, 223], "isthing": 0, "id": 175, "name": "wall-stone"}, + {"color": [7, 246, 231], "isthing": 0, "id": 176, "name": "wall-tile"}, + {"color": [107, 255, 200], "isthing": 0, "id": 177, "name": "wall-wood"}, + {"color": [58, 41, 149], "isthing": 0, "id": 178, "name": "water-other"}, + {"color": [183, 121, 142], "isthing": 0, "id": 180, "name": "window-blind"}, + {"color": [255, 73, 97], "isthing": 0, "id": 181, "name": "window-other"}, + {"color": [107, 142, 35], "isthing": 0, "id": 184, "name": "tree-merged"}, + {"color": [190, 153, 153], "isthing": 0, "id": 185, "name": "fence-merged"}, + {"color": [146, 139, 141], "isthing": 0, "id": 186, "name": "ceiling-merged"}, + {"color": [70, 130, 180], "isthing": 0, "id": 187, "name": "sky-other-merged"}, + {"color": [134, 199, 156], "isthing": 0, "id": 188, "name": "cabinet-merged"}, + {"color": [209, 226, 140], "isthing": 0, "id": 189, "name": "table-merged"}, + {"color": [96, 36, 108], "isthing": 0, "id": 190, "name": "floor-other-merged"}, + {"color": [96, 96, 96], "isthing": 0, "id": 191, "name": "pavement-merged"}, + {"color": [64, 170, 64], "isthing": 0, "id": 192, "name": "mountain-merged"}, + {"color": [152, 251, 152], "isthing": 0, "id": 193, "name": "grass-merged"}, + {"color": [208, 229, 228], "isthing": 0, "id": 194, "name": "dirt-merged"}, + {"color": [206, 186, 171], "isthing": 0, "id": 195, "name": "paper-merged"}, + {"color": [152, 161, 64], "isthing": 0, "id": 196, "name": "food-other-merged"}, + {"color": [116, 112, 0], "isthing": 0, "id": 197, "name": "building-other-merged"}, + {"color": [0, 114, 143], "isthing": 0, "id": 198, "name": "rock-merged"}, + {"color": [102, 102, 156], "isthing": 0, "id": 199, "name": "wall-other-merged"}, + {"color": [250, 141, 255], "isthing": 0, "id": 200, "name": "rug-merged"}, +] + + +class COCOPanoptic(BaseDataset): + """ + COCO panoptic segmentation dataset. + Arguments: + root: Str, root directory. + split: Str, data split, e.g. train/val/test. + is_train: Bool, for training or testing. + crop_size: Tuple, crop size. + mirror: Bool, whether to apply random horizontal flip. + min_scale: Float, min scale in scale augmentation. + max_scale: Float, max scale in scale augmentation. + scale_step_size: Float, step size to select random scale. + mean: Tuple, image mean. + std: Tuple, image std. + semantic_only: Bool, only use semantic segmentation label. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + """ + def __init__(self, + root, + split, + min_resize_value=641, + max_resize_value=641, + resize_factor=32, + is_train=True, + crop_size=(641, 641), + mirror=True, + min_scale=0.5, + max_scale=2., + scale_step_size=0.25, + mean=(0.485, 0.456, 0.406), + std=(0.229, 0.224, 0.225), + semantic_only=False, + ignore_stuff_in_offset=False, + small_instance_area=0, + small_instance_weight=1, + **kwargs): + super(COCOPanoptic, self).__init__(root, split, is_train, crop_size, mirror, min_scale, max_scale, + scale_step_size, mean, std) + + assert split in _COCO_PANOPTIC_INFORMATION.splits_to_sizes.keys() + + self.num_classes = _COCO_PANOPTIC_INFORMATION.num_classes + self.ignore_label = _COCO_PANOPTIC_INFORMATION.ignore_label + self.label_pad_value = (0, 0, 0) + + self.has_instance = True + self.label_divisor = 256 + self.label_dtype = np.float32 + self.thing_list = _COCO_PANOPTIC_THING_LIST + + # Get image and annotation list. + if 'test' in split: + self.img_list = [] + self.ann_list = None + self.ins_list = None + json_filename = os.path.join(self.root, 'annotations', 'image_info_{}.json'.format(self.split)) + dataset = json.load(open(json_filename)) + for img in dataset['images']: + img_file_name = img['file_name'] + self.img_list.append(os.path.join(self.root, 'test2017', img_file_name)) + else: + self.img_list = [] + self.ann_list = [] + self.ins_list = [] + json_filename = os.path.join(self.root, 'annotations', 'panoptic_{}_trainId.json'.format(self.split)) + dataset = json.load(open(json_filename)) + # First sort by image id. + images = sorted(dataset['images'], key=lambda i: i['id']) + annotations = sorted(dataset['annotations'], key=lambda i: i['image_id']) + for img in images: + img_file_name = img['file_name'] + self.img_list.append(os.path.join(self.root, self.split, img_file_name)) + for ann in annotations: + ann_file_name = ann['file_name'] + self.ann_list.append(os.path.join( + self.root, 'annotations', 'panoptic_{}'.format(self.split), ann_file_name)) + self.ins_list.append(ann['segments_info']) + + assert len(self) == _COCO_PANOPTIC_INFORMATION.splits_to_sizes[self.split] + + self.pre_augmentation_transform = Resize(min_resize_value, max_resize_value, resize_factor) + self.transform = build_transforms(self, is_train) + if semantic_only: + self.target_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + else: + self.target_transform = PanopticTargetGenerator(self.ignore_label, self.rgb2id, _COCO_PANOPTIC_THING_LIST, + sigma=8, ignore_stuff_in_offset=ignore_stuff_in_offset, + small_instance_area=small_instance_area, + small_instance_weight=small_instance_weight) + # Generates semantic label for evaluation. + self.raw_label_transform = SemanticTargetGenerator(self.ignore_label, self.rgb2id) + + @staticmethod + def train_id_to_eval_id(): + return _COCO_PANOPTIC_TRAIN_ID_TO_EVAL_ID + + @staticmethod + def rgb2id(color): + """Converts the color to panoptic label. + Color is created by `color = [segmentId % 256, segmentId // 256, segmentId // 256 // 256]`. + Args: + color: Ndarray or a tuple, color encoded image. + Returns: + Panoptic label. + """ + if isinstance(color, np.ndarray) and len(color.shape) == 3: + if color.dtype == np.uint8: + color = color.astype(np.int32) + return color[:, :, 0] + 256 * color[:, :, 1] + 256 * 256 * color[:, :, 2] + return int(color[0] + 256 * color[1] + 256 * 256 * color[2]) + + @staticmethod + def create_label_colormap(): + """Creates a label colormap used in COCO panoptic benchmark. + Returns: + A colormap for visualizing segmentation results. + """ + colormap = np.zeros((256, 3), dtype=np.uint8) + for i, color in enumerate(COCO_CATEGORIES): + colormap[i] = color['color'] + return colormap diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/utils.py new file mode 100644 index 000000000..3149ad666 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/datasets/utils.py @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/datasets/data_generator.py +# ------------------------------------------------------------------------------ + +import collections + +# Named tuple to describe the dataset properties. +DatasetDescriptor = collections.namedtuple( + 'DatasetDescriptor', + [ + 'splits_to_sizes', # Splits of the dataset into training, val and test. + 'num_classes', # Number of semantic classes, including the + # background class (if exists). For example, there + # are 20 foreground classes + 1 background class in + # the PASCAL VOC 2012 dataset. Thus, we set + # num_classes=21. + 'ignore_label', # Ignore label value. + ]) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py new file mode 100644 index 000000000..bd4fd75a5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/__init__.py @@ -0,0 +1 @@ +from .distributed_sampler import TrainingSampler, InferenceSampler diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/distributed_sampler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/distributed_sampler.py new file mode 100644 index 000000000..865bf0be3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/samplers/distributed_sampler.py @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/samplers/distributed_sampler.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import itertools +import math +from collections import defaultdict +from typing import Optional +import torch +from torch.utils.data.sampler import Sampler + +from segmentation.utils import comm + + +class TrainingSampler(Sampler): + """ + In training, we only care about the "infinite stream" of training data. + So this sampler produces an infinite stream of indices and + all workers cooperate to correctly shuffle the indices and sample different indices. + The samplers in each worker effectively produces `indices[worker_id::num_workers]` + where `indices` is an infinite stream of indices consisting of + `shuffle(range(size)) + shuffle(range(size)) + ...` (if shuffle is True) + or `range(size) + range(size) + ...` (if shuffle is False) + """ + + def __init__(self, size, shuffle=True, seed=None): + """ + Args: + size (int): the total number of data of the underlying dataset to sample from + shuffle (bool): whether to shuffle the indices or not + seed (int): the initial seed of the shuffle. Must be the same + across all workers. If None, will use a random seed shared + among workers (require synchronization among all workers). + """ + self._size = size + assert size > 0 + self._shuffle = shuffle + if seed is None: + seed = comm.shared_random_seed() + self._seed = int(seed) + + self._rank = comm.get_rank() + self._world_size = comm.get_world_size() + + def __iter__(self): + start = self._rank + yield from itertools.islice(self._infinite_indices(), start, None, self._world_size) + + def __len__(self): + return self._size + + def _infinite_indices(self): + g = torch.Generator() + g.manual_seed(self._seed) + while True: + if self._shuffle: + yield from torch.randperm(self._size, generator=g) + else: + yield from torch.arange(self._size) + + +class InferenceSampler(Sampler): + """ + Produce indices for inference. + Inference needs to run on the __exact__ set of samples, + therefore when the total number of samples is not divisible by the number of workers, + this sampler produces different number of samples on different workers. + """ + + def __init__(self, size): + """ + Args: + size (int): the total number of data of the underlying dataset to sample from + """ + self._size = size + assert size > 0 + self._rank = comm.get_rank() + self._world_size = comm.get_world_size() + + shard_size = (self._size - 1) // self._world_size + 1 + begin = shard_size * self._rank + end = min(shard_size * (self._rank + 1), self._size) + self._local_indices = range(begin, end) + + def __iter__(self): + yield from self._local_indices + + def __len__(self): + return len(self._local_indices) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/__init__.py new file mode 100644 index 000000000..c37854af0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/__init__.py @@ -0,0 +1,3 @@ +from .build import build_transforms +from .pre_augmentation_transforms import Resize +from .target_transforms import PanopticTargetGenerator, SemanticTargetGenerator diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/build.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/build.py new file mode 100644 index 000000000..08742bc0d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/build.py @@ -0,0 +1,57 @@ +# ------------------------------------------------------------------------------ +# Builds transformation for both image and labels. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from . import transforms as T + + +def build_transforms(dataset, is_train=True): + if is_train: + min_scale = dataset.min_scale + max_scale = dataset.max_scale + scale_step_size = dataset.scale_step_size + crop_h = dataset.crop_h + crop_w = dataset.crop_w + pad_value = dataset.pad_value + ignore_label = dataset.label_pad_value + flip_prob = 0.5 if dataset.mirror else 0 + mean = dataset.mean + std = dataset.std + else: + # no data augmentation + min_scale = 1 + max_scale = 1 + scale_step_size = 0 + flip_prob = 0 + crop_h = dataset.crop_h + crop_w = dataset.crop_w + pad_value = dataset.pad_value + ignore_label = dataset.label_pad_value + mean = dataset.mean + std = dataset.std + + transforms = T.Compose( + [ + T.RandomScale( + min_scale, + max_scale, + scale_step_size + ), + T.RandomCrop( + crop_h, + crop_w, + pad_value, + ignore_label, + random_pad=is_train + ), + T.RandomHorizontalFlip(flip_prob), + T.ToTensor(), + T.Normalize( + mean, + std + ) + ] + ) + + return transforms diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/pre_augmentation_transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/pre_augmentation_transforms.py new file mode 100644 index 000000000..b4d98648b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/pre_augmentation_transforms.py @@ -0,0 +1,92 @@ +# ------------------------------------------------------------------------------ +# Builds transformation before data augmentation. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import warnings + +import cv2 +import math +import numpy as np + + +class Resize(object): + """ + Applies random scale augmentation. + Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/input_preprocess.py#L28 + Arguments: + min_resize_value: Desired size of the smaller image side, no resize if set to None + max_resize_value: Maximum allowed size of the larger image side, no limit if set to None + resize_factor: Resized dimensions are multiple of factor plus one. + keep_aspect_ratio: Boolean, keep aspect ratio or not. If True, the input + will be resized while keeping the original aspect ratio. If False, the + input will be resized to [max_resize_value, max_resize_value] without + keeping the original aspect ratio. + align_corners: If True, exactly align all 4 corners of input and output. + """ + def __init__(self, min_resize_value=None, max_resize_value=None, resize_factor=None, + keep_aspect_ratio=True, align_corners=False): + if min_resize_value is not None and min_resize_value < 0: + min_resize_value = None + if max_resize_value is not None and max_resize_value < 0: + max_resize_value = None + if resize_factor is not None and resize_factor < 0: + resize_factor = None + self.min_resize_value = min_resize_value + self.max_resize_value = max_resize_value + self.resize_factor = resize_factor + self.keep_aspect_ratio = keep_aspect_ratio + self.align_corners = align_corners + + if self.align_corners: + warnings.warn('`align_corners = True` is not supported by opencv.') + + if self.max_resize_value is not None: + # Modify the max_size to be a multiple of factor plus 1 and make sure the max dimension after resizing + # is no larger than max_size. + if self.resize_factor is not None: + self.max_resize_value = (self.max_resize_value - (self.max_resize_value - 1) % self.resize_factor) + + def __call__(self, image, label): + if self.min_resize_value is None: + return image, label + [orig_height, orig_width, _] = image.shape + orig_min_size = np.minimum(orig_height, orig_width) + + # Calculate the larger of the possible sizes + large_scale_factor = self.min_resize_value / orig_min_size + large_height = int(math.floor(orig_height * large_scale_factor)) + large_width = int(math.floor(orig_width * large_scale_factor)) + large_size = np.array([large_height, large_width]) + + new_size = large_size + if self.max_resize_value is not None: + # Calculate the smaller of the possible sizes, use that if the larger is too big. + orig_max_size = np.maximum(orig_height, orig_width) + small_scale_factor = self.max_resize_value / orig_max_size + small_height = int(math.floor(orig_height * small_scale_factor)) + small_width = int(math.floor(orig_width * small_scale_factor)) + small_size = np.array([small_height, small_width]) + + if np.max(large_size) > self.max_resize_value: + new_size = small_size + + # Ensure that both output sides are multiples of factor plus one. + if self.resize_factor is not None: + new_size += (self.resize_factor - (new_size - 1) % self.resize_factor) % self.resize_factor + # If new_size exceeds largest allowed size + new_size[new_size > self.max_resize_value] -= self.resize_factor + + if not self.keep_aspect_ratio: + # If not keep the aspect ratio, we resize everything to max_size, allowing + # us to do pre-processing without extra padding. + new_size = [np.max(new_size), np.max(new_size)] + + # TODO: cv2 uses align_corner=False + # TODO: use fvcore (https://github.com/facebookresearch/fvcore/blob/master/fvcore/transforms/transform.py#L377) + image_dtype = image.dtype + label_dtype = label.dtype + # cv2: (width, height) + image = cv2.resize(image.astype(np.float), (new_size[1], new_size[0]), interpolation=cv2.INTER_LINEAR) + label = cv2.resize(label.astype(np.float), (new_size[1], new_size[0]), interpolation=cv2.INTER_NEAREST) + return image.astype(image_dtype), label.astype(label_dtype) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/target_transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/target_transforms.py new file mode 100644 index 000000000..47a3f3959 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/target_transforms.py @@ -0,0 +1,200 @@ +# ------------------------------------------------------------------------------ +# Generates targets for Panoptic-DeepLab. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import numpy as np + +import torch + + +class PanopticTargetGenerator(object): + """ + Generates panoptic training target for Panoptic-DeepLab. + Annotation is assumed to have Cityscapes format. + Arguments: + ignore_label: Integer, the ignore label for semantic segmentation. + rgb2id: Function, panoptic label is encoded in a colored image, this function convert color to the + corresponding panoptic label. + thing_list: List, a list of thing classes + sigma: the sigma for Gaussian kernel. + ignore_stuff_in_offset: Boolean, whether to ignore stuff region when training the offset branch. + small_instance_area: Integer, indicates largest area for small instances. + small_instance_weight: Integer, indicates semantic loss weights for small instances. + ignore_crowd_in_semantic: Boolean, whether to ignore crowd region in semantic segmentation branch, + crowd region is ignored in the original TensorFlow implementation. + """ + def __init__(self, ignore_label, rgb2id, thing_list, sigma=8, ignore_stuff_in_offset=False, + small_instance_area=0, small_instance_weight=1, ignore_crowd_in_semantic=False): + self.ignore_label = ignore_label + self.rgb2id = rgb2id + self.thing_list = thing_list + self.ignore_stuff_in_offset = ignore_stuff_in_offset + self.small_instance_area = small_instance_area + self.small_instance_weight = small_instance_weight + self.ignore_crowd_in_semantic = ignore_crowd_in_semantic + + self.sigma = sigma + size = 6 * sigma + 3 + x = np.arange(0, size, 1, float) + y = x[:, np.newaxis] + x0, y0 = 3 * sigma + 1, 3 * sigma + 1 + self.g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2)) + + def __call__(self, panoptic, segments): + """Generates the training target. + reference: https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createPanopticImgs.py + reference: https://github.com/facebookresearch/detectron2/blob/master/datasets/prepare_panoptic_fpn.py#L18 + Args: + panoptic: numpy.array, colored image encoding panoptic label. + segments: List, a list of dictionary containing information of every segment, it has fields: + - id: panoptic id, after decoding `panoptic`. + - category_id: semantic class id. + - area: segment area. + - bbox: segment bounding box. + - iscrowd: crowd region. + Returns: + A dictionary with fields: + - semantic: Tensor, semantic label, shape=(H, W). + - foreground: Tensor, foreground mask label, shape=(H, W). + - center: Tensor, center heatmap, shape=(1, H, W). + - center_points: List, center coordinates, with tuple (y-coord, x-coord). + - offset: Tensor, offset, shape=(2, H, W), first dim is (offset_y, offset_x). + - semantic_weights: Tensor, loss weight for semantic prediction, shape=(H, W). + - center_weights: Tensor, ignore region of center prediction, shape=(H, W), used as weights for center + regression 0 is ignore, 1 is has instance. Multiply this mask to loss. + - offset_weights: Tensor, ignore region of offset prediction, shape=(H, W), used as weights for offset + regression 0 is ignore, 1 is has instance. Multiply this mask to loss. + """ + panoptic = self.rgb2id(panoptic) + height, width = panoptic.shape[0], panoptic.shape[1] + semantic = np.zeros_like(panoptic, dtype=np.uint8) + self.ignore_label + foreground = np.zeros_like(panoptic, dtype=np.uint8) + center = np.zeros((1, height, width), dtype=np.float32) + center_pts = [] + offset = np.zeros((2, height, width), dtype=np.float32) + y_coord = np.ones_like(panoptic, dtype=np.float32) + x_coord = np.ones_like(panoptic, dtype=np.float32) + y_coord = np.cumsum(y_coord, axis=0) - 1 + x_coord = np.cumsum(x_coord, axis=1) - 1 + # Generate pixel-wise loss weights + semantic_weights = np.ones_like(panoptic, dtype=np.uint8) + # 0: ignore, 1: has instance + # three conditions for a region to be ignored for instance branches: + # (1) It is labeled as `ignore_label` + # (2) It is crowd region (iscrowd=1) + # (3) (Optional) It is stuff region (for offset branch) + center_weights = np.zeros_like(panoptic, dtype=np.uint8) + offset_weights = np.zeros_like(panoptic, dtype=np.uint8) + for seg in segments: + cat_id = seg["category_id"] + if self.ignore_crowd_in_semantic: + if not seg['iscrowd']: + semantic[panoptic == seg["id"]] = cat_id + else: + semantic[panoptic == seg["id"]] = cat_id + if cat_id in self.thing_list: + foreground[panoptic == seg["id"]] = 1 + if not seg['iscrowd']: + # Ignored regions are not in `segments`. + # Handle crowd region. + center_weights[panoptic == seg["id"]] = 1 + if self.ignore_stuff_in_offset: + # Handle stuff region. + if cat_id in self.thing_list: + offset_weights[panoptic == seg["id"]] = 1 + else: + offset_weights[panoptic == seg["id"]] = 1 + if cat_id in self.thing_list: + # find instance center + mask_index = np.where(panoptic == seg["id"]) + if len(mask_index[0]) == 0: + # the instance is completely cropped + continue + + # Find instance area + ins_area = len(mask_index[0]) + if ins_area < self.small_instance_area: + semantic_weights[panoptic == seg["id"]] = self.small_instance_weight + + center_y, center_x = np.mean(mask_index[0]), np.mean(mask_index[1]) + center_pts.append([center_y, center_x]) + + # generate center heatmap + y, x = int(center_y), int(center_x) + # outside image boundary + if x < 0 or y < 0 or \ + x >= width or y >= height: + continue + sigma = self.sigma + # upper left + ul = int(np.round(x - 3 * sigma - 1)), int(np.round(y - 3 * sigma - 1)) + # bottom right + br = int(np.round(x + 3 * sigma + 2)), int(np.round(y + 3 * sigma + 2)) + + c, d = max(0, -ul[0]), min(br[0], width) - ul[0] + a, b = max(0, -ul[1]), min(br[1], height) - ul[1] + + cc, dd = max(0, ul[0]), min(br[0], width) + aa, bb = max(0, ul[1]), min(br[1], height) + center[0, aa:bb, cc:dd] = np.maximum( + center[0, aa:bb, cc:dd], self.g[a:b, c:d]) + + # generate offset (2, h, w) -> (y-dir, x-dir) + offset_y_index = (np.zeros_like(mask_index[0]), mask_index[0], mask_index[1]) + offset_x_index = (np.ones_like(mask_index[0]), mask_index[0], mask_index[1]) + offset[offset_y_index] = center_y - y_coord[mask_index] + offset[offset_x_index] = center_x - x_coord[mask_index] + + return dict( + semantic=torch.as_tensor(semantic.astype('long')), + foreground=torch.as_tensor(foreground.astype('long')), + center=torch.as_tensor(center.astype(np.float32)), + center_points=center_pts, + offset=torch.as_tensor(offset.astype(np.float32)), + semantic_weights=torch.as_tensor(semantic_weights.astype(np.float32)), + center_weights=torch.as_tensor(center_weights.astype(np.float32)), + offset_weights=torch.as_tensor(offset_weights.astype(np.float32)) + ) + + +class SemanticTargetGenerator(object): + """ + Generates semantic training target only for Panoptic-DeepLab (no instance). + Annotation is assumed to have Cityscapes format. + Arguments: + ignore_label: Integer, the ignore label for semantic segmentation. + rgb2id: Function, panoptic label is encoded in a colored image, this function convert color to the + corresponding panoptic label. + thing_list: List, a list of thing classes + sigma: the sigma for Gaussian kernel. + """ + def __init__(self, ignore_label, rgb2id): + self.ignore_label = ignore_label + self.rgb2id = rgb2id + + def __call__(self, panoptic, segments): + """Generates the training target. + reference: https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createPanopticImgs.py + reference: https://github.com/facebookresearch/detectron2/blob/master/datasets/prepare_panoptic_fpn.py#L18 + Args: + panoptic: numpy.array, colored image encoding panoptic label. + segments: List, a list of dictionary containing information of every segment, it has fields: + - id: panoptic id, after decoding `panoptic`. + - category_id: semantic class id. + - area: segment area. + - bbox: segment bounding box. + - iscrowd: crowd region. + Returns: + A dictionary with fields: + - semantic: Tensor, semantic label, shape=(H, W). + """ + panoptic = self.rgb2id(panoptic) + semantic = np.zeros_like(panoptic, dtype=np.uint8) + self.ignore_label + for seg in segments: + cat_id = seg["category_id"] + semantic[panoptic == seg["id"]] = cat_id + + return dict( + semantic=torch.as_tensor(semantic.astype('long')) + ) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/transforms.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/transforms.py new file mode 100644 index 000000000..a6404a665 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/data/transforms/transforms.py @@ -0,0 +1,172 @@ +# ------------------------------------------------------------------------------ +# Data augmentation following DeepLab +# (https://github.com/tensorflow/models/blob/master/research/deeplab/input_preprocess.py#L28). +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import random + +import cv2 +import numpy as np +from torchvision.transforms import functional as F + + +class Compose(object): + """ + Composes a sequence of transforms. + Arguments: + transforms: A list of transforms. + """ + def __init__(self, transforms): + self.transforms = transforms + + def __call__(self, image, label): + for t in self.transforms: + image, label = t(image, label) + return image, label + + def __repr__(self): + format_string = self.__class__.__name__ + "(" + for t in self.transforms: + format_string += "\n" + format_string += " {0}".format(t) + format_string += "\n)" + return format_string + + +class ToTensor(object): + """ + Converts image to torch Tensor. + """ + def __call__(self, image, label): + return F.to_tensor(image), label + + +class Normalize(object): + """ + Normalizes image by mean and std. + """ + def __init__(self, mean, std): + self.mean = mean + self.std = std + + def __call__(self, image, label): + image = F.normalize(image, mean=self.mean, std=self.std) + return image, label + + +class RandomScale(object): + """ + Applies random scale augmentation. + Arguments: + min_scale: Minimum scale value. + max_scale: Maximum scale value. + scale_step_size: The step size from minimum to maximum value. + """ + def __init__(self, min_scale, max_scale, scale_step_size): + self.min_scale = min_scale + self.max_scale = max_scale + self.scale_step_size = scale_step_size + + @staticmethod + def get_random_scale(min_scale_factor, max_scale_factor, step_size): + """Gets a random scale value. + Args: + min_scale_factor: Minimum scale value. + max_scale_factor: Maximum scale value. + step_size: The step size from minimum to maximum value. + Returns: + A random scale value selected between minimum and maximum value. + Raises: + ValueError: min_scale_factor has unexpected value. + """ + if min_scale_factor < 0 or min_scale_factor > max_scale_factor: + raise ValueError('Unexpected value of min_scale_factor.') + + if min_scale_factor == max_scale_factor: + return min_scale_factor + + # When step_size = 0, we sample the value uniformly from [min, max). + if step_size == 0: + return random.uniform(min_scale_factor, max_scale_factor) + + # When step_size != 0, we randomly select one discrete value from [min, max]. + num_steps = int((max_scale_factor - min_scale_factor) / step_size + 1) + scale_factors = np.linspace(min_scale_factor, max_scale_factor, num_steps) + np.random.shuffle(scale_factors) + return scale_factors[0] + + def __call__(self, image, label): + f_scale = self.get_random_scale(self.min_scale, self.max_scale, self.scale_step_size) + # TODO: cv2 uses align_corner=False + # TODO: use fvcore (https://github.com/facebookresearch/fvcore/blob/master/fvcore/transforms/transform.py#L377) + image_dtype = image.dtype + label_dtype = label.dtype + image = cv2.resize(image.astype(np.float), None, fx=f_scale, fy=f_scale, interpolation=cv2.INTER_LINEAR) + label = cv2.resize(label.astype(np.float), None, fx=f_scale, fy=f_scale, interpolation=cv2.INTER_NEAREST) + return image.astype(image_dtype), label.astype(label_dtype) + + +class RandomCrop(object): + """ + Applies random crop augmentation. + Arguments: + crop_h: Integer, crop height size. + crop_w: Integer, crop width size. + pad_value: Tuple, pad value for image, length 3. + ignore_label: Tuple, pad value for label, length could be 1 (semantic) or 3 (panoptic). + random_pad: Bool, when crop size larger than image size, whether to randomly pad four boundaries, + or put image to top-left and only pad bottom and right boundaries. + """ + def __init__(self, crop_h, crop_w, pad_value, ignore_label, random_pad): + self.crop_h = crop_h + self.crop_w = crop_w + self.pad_value = pad_value + self.ignore_label = ignore_label + self.random_pad = random_pad + + def __call__(self, image, label): + img_h, img_w = image.shape[0], image.shape[1] + # save dtype + image_dtype = image.dtype + label_dtype = label.dtype + # padding + pad_h = max(self.crop_h - img_h, 0) + pad_w = max(self.crop_w - img_w, 0) + if pad_h > 0 or pad_w > 0: + if self.random_pad: + pad_top = random.randint(0, pad_h) + pad_bottom = pad_h - pad_top + pad_left = random.randint(0, pad_w) + pad_right = pad_w - pad_left + else: + pad_top, pad_bottom, pad_left, pad_right = 0, pad_h, 0, pad_w + img_pad = cv2.copyMakeBorder(image, pad_top, pad_bottom, pad_left, pad_right, cv2.BORDER_CONSTANT, + value=self.pad_value) + label_pad = cv2.copyMakeBorder(label, pad_top, pad_bottom, pad_left, pad_right, cv2.BORDER_CONSTANT, + value=self.ignore_label) + else: + img_pad, label_pad = image, label + img_h, img_w = img_pad.shape[0], img_pad.shape[1] + h_off = random.randint(0, img_h - self.crop_h) + w_off = random.randint(0, img_w - self.crop_w) + image = np.asarray(img_pad[h_off:h_off + self.crop_h, w_off:w_off + self.crop_w], np.float32) + label = np.asarray(label_pad[h_off:h_off + self.crop_h, w_off:w_off + self.crop_w], np.float32) + return image.astype(image_dtype), label.astype(label_dtype) + + +class RandomHorizontalFlip(object): + """ + Applies random flip augmentation. + Arguments: + prob: Probability of flip. + """ + def __init__(self, prob=0.5): + self.prob = prob + + def __call__(self, image, label): + if random.random() < self.prob: + # https://discuss.pytorch.org/t/torch-from-numpy-not-support-negative-strides/3663 + image = image[:, ::-1].copy() + label = label[:, ::-1].copy() + return image, label diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py new file mode 100644 index 000000000..a7d97b42d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/__init__.py @@ -0,0 +1,5 @@ +from .semantic import SemanticEvaluator +from .instance import CityscapesInstanceEvaluator +from .panoptic import CityscapesPanopticEvaluator +from .coco_instance import COCOInstanceEvaluator +from .coco_panoptic import COCOPanopticEvaluator diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_instance.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_instance.py new file mode 100644 index 000000000..23d294462 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_instance.py @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/coco_evaluation.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import logging +from collections import OrderedDict +import os +import glob +import copy +import json + +import numpy as np + +from fvcore.common.file_io import PathManager +import pycocotools.mask as mask_util + + +class COCOInstanceEvaluator: + """ + Evaluate COCO instance segmentation + """ + def __init__(self, output_dir=None, train_id_to_eval_id=None, + gt_dir='./datasets/coco/annotations/instances_val2017.json'): + """ + Args: + output_dir (str): an output directory to dump results. + train_id_to_eval_id (list): maps training id to evaluation id. + gt_dir (str): path to ground truth annotations. + """ + if output_dir is None: + raise ValueError('Must provide a output directory.') + self._output_dir = output_dir + if self._output_dir: + PathManager.mkdirs(self._output_dir) + self._train_id_to_eval_id = train_id_to_eval_id + + self._predictions = [] + self._predictions_json = os.path.join(output_dir, 'predictions.json') + + self._logger = logging.getLogger(__name__) + + self._gt_dir = gt_dir + + def update(self, instances, image_filename=None): + if image_filename is None: + raise ValueError('Need to provide image_filename.') + num_instances = len(instances) + + for i in range(num_instances): + pred_class = instances[i]['pred_class'] + if self._train_id_to_eval_id is not None: + pred_class = self._train_id_to_eval_id[pred_class] + image_id = int(os.path.basename(image_filename).split('.')[0]) + score = instances[i]['score'] + mask = instances[i]['pred_mask'].astype("uint8") + # use RLE to encode the masks, because they are too large and takes memory + # since this evaluator stores outputs of the entire dataset + mask_rle = mask_util.encode(np.array(mask[:, :, None], order="F", dtype="uint8"))[0] + # "counts" is an array encoded by mask_util as a byte-stream. Python3's + # json writer which always produces strings cannot serialize a bytestream + # unless you decode it. Thankfully, utf-8 works out (which is also what + # the pycocotools/_mask.pyx does). + mask_rle["counts"] = mask_rle["counts"].decode("utf-8") + + self._predictions.append( + { + 'image_id': image_id, + 'category_id': pred_class, + 'segmentation': mask_rle, + 'score': float(score) + } + ) + + def evaluate(self): + """ + Returns: + dict: has a key "segm", whose value is a dict of "AP" and "AP50". + """ + from pycocotools.coco import COCO + from pycocotools.cocoeval import COCOeval + + if self._gt_dir is None: + raise ValueError('Must provide coco gt path for evaluation.') + + self._logger.info("Evaluating results under {} ...".format(self._output_dir)) + + coco_gt = COCO(self._gt_dir) + + coco_results = copy.deepcopy(self._predictions) + # When evaluating mask AP, if the results contain bbox, cocoapi will + # use the box area as the area of the instance, instead of the mask area. + # This leads to a different definition of small/medium/large. + # We remove the bbox field to let mask AP use mask area. + for c in coco_results: + c.pop("bbox", None) + + with PathManager.open(self._predictions_json, "w") as f: + f.write(json.dumps(coco_results)) + + coco_dt = coco_gt.loadRes(coco_results) + coco_eval = COCOeval(coco_gt, coco_dt, 'segm') + + coco_eval.evaluate() + coco_eval.accumulate() + coco_eval.summarize() + return coco_eval.stats diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_panoptic.py new file mode 100644 index 000000000..30c77f6a4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/coco_panoptic.py @@ -0,0 +1,137 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/panoptic_evaluation.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import logging +from collections import OrderedDict +import os +import json + +import numpy as np +from tabulate import tabulate + +from fvcore.common.file_io import PathManager +from segmentation.utils import save_annotation + +logger = logging.getLogger(__name__) + + +class COCOPanopticEvaluator: + """ + Evaluate panoptic segmentation + """ + def __init__(self, output_dir=None, train_id_to_eval_id=None, label_divisor=256, void_label=65280, + gt_dir='./datasets/coco', split='val2017', num_classes=133): + """ + Args: + corresponding pixels should be ignored. + output_dir (str): an output directory to dump results. + train_id_to_eval_id (list): maps training id to evaluation id. + label_divisor (int): + void_label (int): + gt_dir (str): path to ground truth annotations. + split (str): evaluation split. + num_classes (int): number of classes. + """ + if output_dir is None: + raise ValueError('Must provide a output directory.') + self._output_dir = output_dir + if self._output_dir: + PathManager.mkdirs(self._output_dir) + self._panoptic_dir = os.path.join(self._output_dir, 'predictions') + if self._panoptic_dir: + PathManager.mkdirs(self._panoptic_dir) + + self._predictions = [] + self._predictions_json = os.path.join(output_dir, 'predictions.json') + + self._train_id_to_eval_id = train_id_to_eval_id + self._label_divisor = label_divisor + self._void_label = void_label + self._num_classes = num_classes + + self._logger = logging.getLogger(__name__) + + self._gt_json_file = os.path.join(gt_dir, 'annotations', 'panoptic_{}.json'.format(split)) + self._gt_folder = os.path.join(gt_dir, 'annotations', 'panoptic_{}'.format(split)) + self._pred_json_file = os.path.join(output_dir, 'predictions.json') + self._pred_folder = self._panoptic_dir + + def update(self, panoptic, image_filename=None, image_id=None): + from panopticapi.utils import id2rgb + + if image_filename is None: + raise ValueError('Need to provide image_filename.') + if image_id is None: + raise ValueError('Need to provide image_id.') + + # Change void region. + panoptic[panoptic == self._void_label] = 0 + + segments_info = [] + for pan_lab in np.unique(panoptic): + pred_class = pan_lab // self._label_divisor + if self._train_id_to_eval_id is not None: + pred_class = self._train_id_to_eval_id[pred_class] + + segments_info.append( + { + 'id': int(pan_lab), + 'category_id': int(pred_class), + } + ) + + save_annotation(id2rgb(panoptic), self._panoptic_dir, image_filename, add_colormap=False) + self._predictions.append( + { + 'image_id': int(image_id), + 'file_name': image_filename + '.png', + 'segments_info': segments_info, + } + ) + + def evaluate(self): + from panopticapi.evaluation import pq_compute + + gt_json_file = self._gt_json_file + gt_folder = self._gt_folder + pred_json_file = self._pred_json_file + pred_folder = self._pred_folder + + with open(gt_json_file, "r") as f: + json_data = json.load(f) + json_data["annotations"] = self._predictions + with PathManager.open(self._predictions_json, "w") as f: + f.write(json.dumps(json_data)) + + pq_res = pq_compute(gt_json_file, pred_json_file, gt_folder, pred_folder) + + res = {} + res["PQ"] = 100 * pq_res["All"]["pq"] + res["SQ"] = 100 * pq_res["All"]["sq"] + res["RQ"] = 100 * pq_res["All"]["rq"] + res["PQ_th"] = 100 * pq_res["Things"]["pq"] + res["SQ_th"] = 100 * pq_res["Things"]["sq"] + res["RQ_th"] = 100 * pq_res["Things"]["rq"] + res["PQ_st"] = 100 * pq_res["Stuff"]["pq"] + res["SQ_st"] = 100 * pq_res["Stuff"]["sq"] + res["RQ_st"] = 100 * pq_res["Stuff"]["rq"] + + results = OrderedDict({"panoptic_seg": res}) + self._logger.info(results) + _print_panoptic_results(pq_res) + + return results + + +def _print_panoptic_results(pq_res): + headers = ["", "PQ", "SQ", "RQ", "#categories"] + data = [] + for name in ["All", "Things", "Stuff"]: + row = [name] + [pq_res[name][k] * 100 for k in ["pq", "sq", "rq"]] + [pq_res[name]["n"]] + data.append(row) + table = tabulate( + data, headers=headers, tablefmt="pipe", floatfmt=".3f", stralign="center", numalign="center" + ) + logger.info("Panoptic Evaluation Results:\n" + table) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/instance.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/instance.py new file mode 100644 index 000000000..50a932049 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/instance.py @@ -0,0 +1,97 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/cityscapes_evaluation.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import logging +from collections import OrderedDict +import os +import glob + +from fvcore.common.file_io import PathManager +from segmentation.utils import save_annotation + + +class CityscapesInstanceEvaluator: + """ + Evaluate Cityscapes instance segmentation + """ + def __init__(self, output_dir=None, train_id_to_eval_id=None, gt_dir='./datasets/cityscapes/gtFine/val'): + """ + Args: + output_dir (str): an output directory to dump results. + train_id_to_eval_id (list): maps training id to evaluation id. + gt_dir (str): path to ground truth annotations (gtFine). + """ + if output_dir is None: + raise ValueError('Must provide a output directory.') + self._output_dir = output_dir + if self._output_dir: + PathManager.mkdirs(self._output_dir) + self._mask_dir = os.path.join(self._output_dir, 'mask') + if self._mask_dir: + PathManager.mkdirs(self._mask_dir) + self._train_id_to_eval_id = train_id_to_eval_id + + self._logger = logging.getLogger(__name__) + + self._gt_dir = gt_dir + + def update(self, instances, image_filename=None): + pred_txt = os.path.join(self._output_dir, image_filename + "_pred.txt") + num_instances = len(instances) + + with open(pred_txt, "w") as fout: + for i in range(num_instances): + pred_class = instances[i]['pred_class'] + if self._train_id_to_eval_id is not None: + pred_class = self._train_id_to_eval_id[pred_class] + + score = instances[i]['score'] + mask = instances[i]['pred_mask'].astype("uint8") + png_filename = os.path.join( + self._mask_dir, image_filename + "_{}_{}.png".format(i, pred_class) + ) + + save_annotation(mask, self._mask_dir, image_filename + "_{}_{}".format(i, pred_class), + add_colormap=False, scale_values=True) + fout.write("{} {} {}\n".format(os.path.join('mask', os.path.basename(png_filename)), pred_class, score)) + + def evaluate(self): + """ + Returns: + dict: has a key "segm", whose value is a dict of "AP" and "AP50". + """ + import cityscapesscripts.evaluation.evalInstanceLevelSemanticLabeling as cityscapes_eval + + if self._gt_dir is None: + raise ValueError('Must provide cityscapes path for evaluation.') + + self._logger.info("Evaluating results under {} ...".format(self._output_dir)) + + # set some global states in cityscapes evaluation API, before evaluating + cityscapes_eval.args.predictionPath = os.path.abspath(self._output_dir) + cityscapes_eval.args.predictionWalk = None + cityscapes_eval.args.JSONOutput = False + cityscapes_eval.args.colorized = False + cityscapes_eval.args.gtInstancesFile = os.path.join(self._output_dir, "gtInstances.json") + + # These lines are adopted from + # https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/evaluation/evalInstanceLevelSemanticLabeling.py # noqa + gt_dir = PathManager.get_local_path(self._gt_dir) + groundTruthImgList = glob.glob(os.path.join(gt_dir, "*", "*_gtFine_instanceIds.png")) + assert len( + groundTruthImgList + ), "Cannot find any ground truth images to use for evaluation. Searched for: {}".format( + cityscapes_eval.args.groundTruthSearch + ) + predictionImgList = [] + for gt in groundTruthImgList: + predictionImgList.append(cityscapes_eval.getPrediction(gt, cityscapes_eval.args)) + results = cityscapes_eval.evaluateImgLists( + predictionImgList, groundTruthImgList, cityscapes_eval.args + )["averages"] + + ret = OrderedDict() + ret["segm"] = {"AP": results["allAp"] * 100, "AP50": results["allAp50%"] * 100} + return ret diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py new file mode 100644 index 000000000..5c4702c1e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/panoptic.py @@ -0,0 +1,127 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/panoptic_evaluation.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import contextlib +import io +import logging +from collections import OrderedDict +import os +import json + +import numpy as np + +from fvcore.common.file_io import PathManager +from segmentation.utils import save_annotation + + +class CityscapesPanopticEvaluator: + """ + Evaluate panoptic segmentation + """ + def __init__(self, output_dir=None, train_id_to_eval_id=None, label_divisor=1000, void_label=255000, + gt_dir='./datasets/cityscapes', split='val', num_classes=19): + """ + Args: + corresponding pixels should be ignored. + output_dir (str): an output directory to dump results. + train_id_to_eval_id (list): maps training id to evaluation id. + label_divisor (int): + void_label (int): + gt_dir (str): path to ground truth annotations. + split (str): evaluation split. + num_classes (int): number of classes. + """ + if output_dir is None: + raise ValueError('Must provide a output directory.') + self._output_dir = output_dir + if self._output_dir: + PathManager.mkdirs(self._output_dir) + self._panoptic_dir = os.path.join(self._output_dir, 'predictions') + if self._panoptic_dir: + PathManager.mkdirs(self._panoptic_dir) + + self._predictions = [] + self._predictions_json = os.path.join(output_dir, 'predictions.json') + + self._train_id_to_eval_id = train_id_to_eval_id + self._label_divisor = label_divisor + self._void_label = void_label + self._num_classes = num_classes + + self._logger = logging.getLogger(__name__) + + self._gt_json_file = os.path.join(gt_dir, 'gtFine', 'cityscapes_panoptic_{}.json'.format(split)) + self._gt_folder = os.path.join(gt_dir, 'gtFine', 'cityscapes_panoptic_{}'.format(split)) + self._pred_json_file = os.path.join(output_dir, 'predictions.json') + self._pred_folder = self._panoptic_dir + self._resultsFile = os.path.join(output_dir, 'resultPanopticSemanticLabeling.json') + + @staticmethod + def id2rgb(id_map): + if isinstance(id_map, np.ndarray): + id_map_copy = id_map.copy() + rgb_shape = tuple(list(id_map.shape) + [3]) + rgb_map = np.zeros(rgb_shape, dtype=np.uint8) + for i in range(3): + rgb_map[..., i] = id_map_copy % 256 + id_map_copy //= 256 + return rgb_map + color = [] + for _ in range(3): + color.append(id_map % 256) + id_map //= 256 + return color + + def update(self, panoptic, image_filename=None, image_id=None): + if image_filename is None: + raise ValueError('Need to provide image_filename.') + if image_id is None: + raise ValueError('Need to provide image_id.') + + # Change void region. + panoptic[panoptic == self._void_label] = 0 + + segments_info = [] + for pan_lab in np.unique(panoptic): + pred_class = pan_lab // self._label_divisor + if self._train_id_to_eval_id is not None: + pred_class = self._train_id_to_eval_id[pred_class] + + segments_info.append( + { + 'id': int(pan_lab), + 'category_id': int(pred_class), + } + ) + + save_annotation(self.id2rgb(panoptic), self._panoptic_dir, image_filename, add_colormap=False) + self._predictions.append( + { + 'image_id': image_id, + 'file_name': image_filename + '.png', + 'segments_info': segments_info, + } + ) + + def evaluate(self): + import cityscapesscripts.evaluation.evalPanopticSemanticLabeling as cityscapes_eval + + gt_json_file = self._gt_json_file + gt_folder = self._gt_folder + pred_json_file = self._pred_json_file + pred_folder = self._pred_folder + resultsFile = self._resultsFile + + with open(gt_json_file, "r") as f: + json_data = json.load(f) + json_data["annotations"] = self._predictions + with PathManager.open(self._predictions_json, "w") as f: + f.write(json.dumps(json_data)) + + with contextlib.redirect_stdout(io.StringIO()): + results = cityscapes_eval.evaluatePanoptic(gt_json_file, gt_folder, pred_json_file, pred_folder, resultsFile) + + self._logger.info(results) + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py new file mode 100644 index 000000000..f4ee46859 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py @@ -0,0 +1,106 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/sem_seg_evaluation.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import logging +from collections import OrderedDict + +import numpy as np + +from fvcore.common.file_io import PathManager +from segmentation.utils import save_annotation + + +class SemanticEvaluator: + """ + Evaluate semantic segmentation + """ + def __init__(self, num_classes, ignore_label=255, output_dir=None, train_id_to_eval_id=None): + """ + Args: + num_classes (int): number of classes + ignore_label (int): value in semantic segmentation ground truth. Predictions for the + corresponding pixels should be ignored. + output_dir (str): an output directory to dump results. + train_id_to_eval_id (list): maps training id to evaluation id. + """ + self._output_dir = output_dir + if self._output_dir: + PathManager.mkdirs(self._output_dir) + self._num_classes = num_classes + self._ignore_label = ignore_label + self._N = num_classes + 1 # store ignore label in the last class + self._train_id_to_eval_id = train_id_to_eval_id + + self._conf_matrix = np.zeros((self._N, self._N), dtype=np.int64) + self._logger = logging.getLogger(__name__) + + @staticmethod + def _convert_train_id_to_eval_id(prediction, train_id_to_eval_id): + """Converts the predicted label for evaluation. + There are cases where the training labels are not equal to the evaluation + labels. This function is used to perform the conversion so that we could + evaluate the results on the evaluation server. + Args: + prediction: Semantic segmentation prediction. + train_id_to_eval_id (list): maps training id to evaluation id. + Returns: + Semantic segmentation prediction whose labels have been changed. + """ + converted_prediction = prediction.copy() + for train_id, eval_id in enumerate(train_id_to_eval_id): + converted_prediction[prediction == train_id] = eval_id + + return converted_prediction + + def update(self, pred, gt, image_filename=None): + pred = pred.astype(np.int) + gt = gt.astype(np.int) + gt[gt == self._ignore_label] = self._num_classes + + self._conf_matrix += np.bincount( + self._N * pred.reshape(-1) + gt.reshape(-1), minlength=self._N ** 2 + ).reshape(self._N, self._N) + + if self._output_dir: + if self._train_id_to_eval_id is not None: + pred = self._convert_train_id_to_eval_id(pred, self._train_id_to_eval_id) + if image_filename is None: + raise ValueError('Need to provide filename to save.') + save_annotation( + pred, self._output_dir, image_filename, add_colormap=False) + + def evaluate(self): + """ + Evaluates standard semantic segmentation metrics (http://cocodataset.org/#stuff-eval): + * Mean intersection-over-union averaged across classes (mIoU) + * Frequency Weighted IoU (fwIoU) + * Mean pixel accuracy averaged across classes (mACC) + * Pixel Accuracy (pACC) + """ + acc = np.zeros(self._num_classes, dtype=np.float) + iou = np.zeros(self._num_classes, dtype=np.float) + tp = self._conf_matrix.diagonal()[:-1].astype(np.float) + pos_gt = np.sum(self._conf_matrix[:-1, :-1], axis=0).astype(np.float) + class_weights = pos_gt / np.sum(pos_gt) + pos_pred = np.sum(self._conf_matrix[:-1, :-1], axis=1).astype(np.float) + acc_valid = pos_gt > 0 + acc[acc_valid] = tp[acc_valid] / pos_gt[acc_valid] + iou_valid = (pos_gt + pos_pred) > 0 + union = pos_gt + pos_pred - tp + iou[acc_valid] = tp[acc_valid] / union[acc_valid] + macc = np.sum(acc) / np.sum(acc_valid) + miou = np.sum(iou) / np.sum(iou_valid) + fiou = np.sum(iou * class_weights) + pacc = np.sum(tp) / np.sum(pos_gt) + + res = {} + res["mIoU"] = 100 * miou + res["fwIoU"] = 100 * fiou + res["mACC"] = 100 * macc + res["pACC"] = 100 * pacc + + results = OrderedDict({"sem_seg": res}) + self._logger.info(results) + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/__init__.py new file mode 100644 index 000000000..163bf5e21 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/__init__.py @@ -0,0 +1 @@ +from .build import build_segmentation_model_from_cfg diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/__init__.py new file mode 100644 index 000000000..b834e0361 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/__init__.py @@ -0,0 +1,5 @@ +from .resnet import * +from .mobilenet import * +from .mnasnet import * +from .hrnet import * +from .xception import * diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/hrnet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/hrnet.py new file mode 100644 index 000000000..72110375c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/hrnet.py @@ -0,0 +1,526 @@ +""" +MIT License + +Copyright (c) 2019 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" +import os +import logging +import torch.nn as nn +import torch.nn.functional as F +from torchvision.models.utils import load_state_dict_from_url + +logger = logging.getLogger('hrnet_backbone') + +__all__ = ['hrnet18', 'hrnet32', 'hrnet48'] + + +model_urls = { + # all the checkpoints come from https://github.com/HRNet/HRNet-Image-Classification + 'hrnet18': 'https://opr0mq.dm.files.1drv.com/y4mIoWpP2n-LUohHHANpC0jrOixm1FZgO2OsUtP2DwIozH5RsoYVyv_De5wDgR6XuQmirMV3C0AljLeB-zQXevfLlnQpcNeJlT9Q8LwNYDwh3TsECkMTWXCUn3vDGJWpCxQcQWKONr5VQWO1hLEKPeJbbSZ6tgbWwJHgHF7592HY7ilmGe39o5BhHz7P9QqMYLBts6V7QGoaKrr0PL3wvvR4w', + 'hrnet32': 'https://opr74a.dm.files.1drv.com/y4mKOuRSNGQQlp6wm_a9bF-UEQwp6a10xFCLhm4bqjDu6aSNW9yhDRM7qyx0vK0WTh42gEaniUVm3h7pg0H-W0yJff5qQtoAX7Zze4vOsqjoIthp-FW3nlfMD0-gcJi8IiVrMWqVOw2N3MbCud6uQQrTaEAvAdNjtjMpym1JghN-F060rSQKmgtq5R-wJe185IyW4-_c5_ItbhYpCyLxdqdEQ', + 'hrnet48': 'https://optgaw.dm.files.1drv.com/y4mWNpya38VArcDInoPaL7GfPMgcop92G6YRkabO1QTSWkCbo7djk8BFZ6LK_KHHIYE8wqeSAChU58NVFOZEvqFaoz392OgcyBrq_f8XGkusQep_oQsuQ7DPQCUrdLwyze_NlsyDGWot0L9agkQ-M_SfNr10ETlCF5R7BdKDZdupmcMXZc-IE3Ysw1bVHdOH4l-XEbEKFAi6ivPUbeqlYkRMQ' +} + + +def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): + """3x3 convolution with padding""" + return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, + padding=dilation, groups=groups, bias=False, dilation=dilation) + + +def conv1x1(in_planes, out_planes, stride=1): + """1x1 convolution""" + return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, + base_width=64, dilation=1, norm_layer=None): + super(BasicBlock, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + if groups != 1 or base_width != 64: + raise ValueError('BasicBlock only supports groups=1 and base_width=64') + if dilation > 1: + raise NotImplementedError("Dilation > 1 not supported in BasicBlock") + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + self.conv1 = conv3x3(inplanes, planes, stride) + self.bn1 = norm_layer(planes) + self.relu = nn.ReLU(inplace=True) + self.conv2 = conv3x3(planes, planes) + self.bn2 = norm_layer(planes) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + + expansion = 4 + + def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, + base_width=64, dilation=1, norm_layer=None): + super(Bottleneck, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + width = int(planes * (base_width / 64.)) * groups + # Both self.conv2 and self.downsample layers downsample the input when stride != 1 + self.conv1 = conv1x1(inplanes, width) + self.bn1 = norm_layer(width) + self.conv2 = conv3x3(width, width, stride, groups, dilation) + self.bn2 = norm_layer(width) + self.conv3 = conv1x1(width, planes * self.expansion) + self.bn3 = norm_layer(planes * self.expansion) + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class HighResolutionModule(nn.Module): + def __init__(self, num_branches, blocks, num_blocks, num_inchannels, + num_channels, fuse_method, multi_scale_output=True, norm_layer=None): + super(HighResolutionModule, self).__init__() + self._check_branches( + num_branches, blocks, num_blocks, num_inchannels, num_channels) + + if norm_layer is None: + norm_layer = nn.BatchNorm2d + self.norm_layer = norm_layer + + self.num_inchannels = num_inchannels + self.fuse_method = fuse_method + self.num_branches = num_branches + + self.multi_scale_output = multi_scale_output + + self.branches = self._make_branches( + num_branches, blocks, num_blocks, num_channels) + self.fuse_layers = self._make_fuse_layers() + self.relu = nn.ReLU(inplace=True) + + def _check_branches(self, num_branches, blocks, num_blocks, + num_inchannels, num_channels): + if num_branches != len(num_blocks): + error_msg = 'NUM_BRANCHES({}) <> NUM_BLOCKS({})'.format( + num_branches, len(num_blocks)) + logger.error(error_msg) + raise ValueError(error_msg) + + if num_branches != len(num_channels): + error_msg = 'NUM_BRANCHES({}) <> NUM_CHANNELS({})'.format( + num_branches, len(num_channels)) + logger.error(error_msg) + raise ValueError(error_msg) + + if num_branches != len(num_inchannels): + error_msg = 'NUM_BRANCHES({}) <> NUM_INCHANNELS({})'.format( + num_branches, len(num_inchannels)) + logger.error(error_msg) + raise ValueError(error_msg) + + def _make_one_branch(self, branch_index, block, num_blocks, num_channels, + stride=1): + downsample = None + if stride != 1 or \ + self.num_inchannels[branch_index] != num_channels[branch_index] * block.expansion: + downsample = nn.Sequential( + nn.Conv2d(self.num_inchannels[branch_index], + num_channels[branch_index] * block.expansion, + kernel_size=1, stride=stride, bias=False), + self.norm_layer(num_channels[branch_index] * block.expansion), + ) + + layers = [] + layers.append(block(self.num_inchannels[branch_index], + num_channels[branch_index], stride, downsample, norm_layer=self.norm_layer)) + self.num_inchannels[branch_index] = \ + num_channels[branch_index] * block.expansion + for i in range(1, num_blocks[branch_index]): + layers.append(block(self.num_inchannels[branch_index], + num_channels[branch_index], norm_layer=self.norm_layer)) + + return nn.Sequential(*layers) + + def _make_branches(self, num_branches, block, num_blocks, num_channels): + branches = [] + + for i in range(num_branches): + branches.append( + self._make_one_branch(i, block, num_blocks, num_channels)) + + return nn.ModuleList(branches) + + def _make_fuse_layers(self): + if self.num_branches == 1: + return None + + num_branches = self.num_branches + num_inchannels = self.num_inchannels + fuse_layers = [] + for i in range(num_branches if self.multi_scale_output else 1): + fuse_layer = [] + for j in range(num_branches): + if j > i: + fuse_layer.append(nn.Sequential( + nn.Conv2d(num_inchannels[j], + num_inchannels[i], + 1, + 1, + 0, + bias=False), + self.norm_layer(num_inchannels[i]))) + elif j == i: + fuse_layer.append(None) + else: + conv3x3s = [] + for k in range(i-j): + if k == i - j - 1: + num_outchannels_conv3x3 = num_inchannels[i] + conv3x3s.append(nn.Sequential( + nn.Conv2d(num_inchannels[j], + num_outchannels_conv3x3, + 3, 2, 1, bias=False), + self.norm_layer(num_outchannels_conv3x3))) + else: + num_outchannels_conv3x3 = num_inchannels[j] + conv3x3s.append(nn.Sequential( + nn.Conv2d(num_inchannels[j], + num_outchannels_conv3x3, + 3, 2, 1, bias=False), + self.norm_layer(num_outchannels_conv3x3), + nn.ReLU(inplace=True))) + fuse_layer.append(nn.Sequential(*conv3x3s)) + fuse_layers.append(nn.ModuleList(fuse_layer)) + + return nn.ModuleList(fuse_layers) + + def get_num_inchannels(self): + return self.num_inchannels + + def forward(self, x): + if self.num_branches == 1: + return [self.branches[0](x[0])] + + for i in range(self.num_branches): + x[i] = self.branches[i](x[i]) + + x_fuse = [] + for i in range(len(self.fuse_layers)): + y = x[0] if i == 0 else self.fuse_layers[i][0](x[0]) + for j in range(1, self.num_branches): + if i == j: + y = y + x[j] + elif j > i: + width_output = x[i].shape[-1] + height_output = x[i].shape[-2] + y = y + F.interpolate( + self.fuse_layers[i][j](x[j]), + size=[height_output, width_output], + mode='bilinear', + align_corners=True + ) + else: + y = y + self.fuse_layers[i][j](x[j]) + x_fuse.append(self.relu(y)) + + return x_fuse + + +blocks_dict = { + 'BASIC': BasicBlock, + 'BOTTLENECK': Bottleneck +} + + +class HighResolutionNet(nn.Module): + + def __init__(self, + cfg, + norm_layer=None): + super(HighResolutionNet, self).__init__() + + if norm_layer is None: + norm_layer = nn.BatchNorm2d + self.norm_layer = norm_layer + # stem network + # stem net + self.conv1 = nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1, + bias=False) + self.bn1 = self.norm_layer(64) + self.conv2 = nn.Conv2d(64, 64, kernel_size=3, stride=2, padding=1, + bias=False) + self.bn2 = self.norm_layer(64) + self.relu = nn.ReLU(inplace=True) + + # stage 1 + self.stage1_cfg = cfg['STAGE1'] + num_channels = self.stage1_cfg['NUM_CHANNELS'][0] + block = blocks_dict[self.stage1_cfg['BLOCK']] + num_blocks = self.stage1_cfg['NUM_BLOCKS'][0] + self.layer1 = self._make_layer(block, 64, num_channels, num_blocks) + stage1_out_channel = block.expansion*num_channels + + # stage 2 + self.stage2_cfg = cfg['STAGE2'] + num_channels = self.stage2_cfg['NUM_CHANNELS'] + block = blocks_dict[self.stage2_cfg['BLOCK']] + num_channels = [ + num_channels[i] * block.expansion for i in range(len(num_channels))] + self.transition1 = self._make_transition_layer( + [stage1_out_channel], num_channels) + self.stage2, pre_stage_channels = self._make_stage( + self.stage2_cfg, num_channels) + + # stage 3 + self.stage3_cfg = cfg['STAGE3'] + num_channels = self.stage3_cfg['NUM_CHANNELS'] + block = blocks_dict[self.stage3_cfg['BLOCK']] + num_channels = [ + num_channels[i] * block.expansion for i in range(len(num_channels))] + self.transition2 = self._make_transition_layer( + pre_stage_channels, num_channels) + self.stage3, pre_stage_channels = self._make_stage( + self.stage3_cfg, num_channels) + + # stage 4 + self.stage4_cfg = cfg['STAGE4'] + num_channels = self.stage4_cfg['NUM_CHANNELS'] + block = blocks_dict[self.stage4_cfg['BLOCK']] + num_channels = [ + num_channels[i] * block.expansion for i in range(len(num_channels))] + self.transition3 = self._make_transition_layer( + pre_stage_channels, num_channels) + self.stage4, pre_stage_channels = self._make_stage( + self.stage4_cfg, num_channels, multi_scale_output=True) + + + def _make_transition_layer( + self, num_channels_pre_layer, num_channels_cur_layer): + num_branches_cur = len(num_channels_cur_layer) + num_branches_pre = len(num_channels_pre_layer) + + transition_layers = [] + for i in range(num_branches_cur): + if i < num_branches_pre: + if num_channels_cur_layer[i] != num_channels_pre_layer[i]: + transition_layers.append(nn.Sequential( + nn.Conv2d(num_channels_pre_layer[i], + num_channels_cur_layer[i], + 3, + 1, + 1, + bias=False), + self.norm_layer(num_channels_cur_layer[i]), + nn.ReLU(inplace=True))) + else: + transition_layers.append(None) + else: + conv3x3s = [] + for j in range(i+1-num_branches_pre): + inchannels = num_channels_pre_layer[-1] + outchannels = num_channels_cur_layer[i] \ + if j == i-num_branches_pre else inchannels + conv3x3s.append(nn.Sequential( + nn.Conv2d( + inchannels, outchannels, 3, 2, 1, bias=False), + self.norm_layer(outchannels), + nn.ReLU(inplace=True))) + transition_layers.append(nn.Sequential(*conv3x3s)) + + return nn.ModuleList(transition_layers) + + def _make_layer(self, block, inplanes, planes, blocks, stride=1): + downsample = None + if stride != 1 or inplanes != planes * block.expansion: + downsample = nn.Sequential( + nn.Conv2d(inplanes, planes * block.expansion, + kernel_size=1, stride=stride, bias=False), + self.norm_layer(planes * block.expansion), + ) + + layers = [] + layers.append(block(inplanes, planes, stride, downsample, norm_layer=self.norm_layer)) + inplanes = planes * block.expansion + for i in range(1, blocks): + layers.append(block(inplanes, planes, norm_layer=self.norm_layer)) + + return nn.Sequential(*layers) + + def _make_stage(self, layer_config, num_inchannels, + multi_scale_output=True): + num_modules = layer_config['NUM_MODULES'] + num_branches = layer_config['NUM_BRANCHES'] + num_blocks = layer_config['NUM_BLOCKS'] + num_channels = layer_config['NUM_CHANNELS'] + block = blocks_dict[layer_config['BLOCK']] + fuse_method = layer_config['FUSE_METHOD'] + + modules = [] + for i in range(num_modules): + # multi_scale_output is only used last module + if not multi_scale_output and i == num_modules - 1: + reset_multi_scale_output = False + else: + reset_multi_scale_output = True + + modules.append( + HighResolutionModule(num_branches, + block, + num_blocks, + num_inchannels, + num_channels, + fuse_method, + reset_multi_scale_output, + norm_layer=self.norm_layer) + ) + num_inchannels = modules[-1].get_num_inchannels() + + return nn.Sequential(*modules), num_inchannels + + + def forward(self, x): + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.conv2(x) + x = self.bn2(x) + x = self.relu(x) + x = self.layer1(x) + + x_list = [] + for i in range(self.stage2_cfg['NUM_BRANCHES']): + if self.transition1[i] is not None: + x_list.append(self.transition1[i](x)) + else: + x_list.append(x) + y_list = self.stage2(x_list) + + x_list = [] + for i in range(self.stage3_cfg['NUM_BRANCHES']): + if self.transition2[i] is not None: + if i < self.stage2_cfg['NUM_BRANCHES']: + x_list.append(self.transition2[i](y_list[i])) + else: + x_list.append(self.transition2[i](y_list[-1])) + else: + x_list.append(y_list[i]) + y_list = self.stage3(x_list) + + x_list = [] + for i in range(self.stage4_cfg['NUM_BRANCHES']): + if self.transition3[i] is not None: + if i < self.stage3_cfg['NUM_BRANCHES']: + x_list.append(self.transition3[i](y_list[i])) + else: + x_list.append(self.transition3[i](y_list[-1])) + else: + x_list.append(y_list[i]) + x = self.stage4(x_list) + + outputs = {} + # See note [TorchScript super()] + outputs['res2'] = x[0] # 1/4 + outputs['res3'] = x[1] # 1/8 + outputs['res4'] = x[2] # 1/16 + outputs['res5'] = x[3] # 1/32 + + return outputs + + +def _hrnet(arch, pretrained, progress, **kwargs): + try: + from ...config.hrnet_config import MODEL_CONFIGS + except ImportError: + from segmentation.config.hrnet_config import MODEL_CONFIGS + model = HighResolutionNet(MODEL_CONFIGS[arch], **kwargs) + if pretrained: + if int(os.environ.get("mapillary_pretrain", 0)): + logger.info("load the mapillary pretrained hrnet-w48 weights.") + model_url = model_urls['hrnet48_mapillary_pretrain'] + else: + model_url = model_urls[arch] + + state_dict = load_state_dict_from_url(model_url, + progress=progress) + model.load_state_dict(state_dict, strict=False) + return model + + +def hrnet18(pretrained=False, progress=True, **kwargs): + r"""HRNet-18 model + """ + return _hrnet('hrnet18', pretrained, progress, + **kwargs) + + +def hrnet32(pretrained=False, progress=True, **kwargs): + r"""HRNet-32 model + """ + return _hrnet('hrnet32', pretrained, progress, + **kwargs) + + +def hrnet48(pretrained=False, progress=True, **kwargs): + r"""HRNet-48 model + """ + return _hrnet('hrnet48', pretrained, progress, + **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py new file mode 100644 index 000000000..db5461b99 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mnasnet.py @@ -0,0 +1,280 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/pytorch/vision/blob/master/torchvision/models/mnasnet.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import math +import warnings + +import torch +import torch.nn as nn +from torchvision.models.utils import load_state_dict_from_url + +__all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3'] + +_MODEL_URLS = { + "mnasnet0_5": + "https://download.pytorch.org/models/mnasnet0.5_top1_67.823-3ffadce67e.pth", + "mnasnet0_75": None, + "mnasnet1_0": + "https://download.pytorch.org/models/mnasnet1.0_top1_73.512-f206786ef8.pth", + "mnasnet1_3": None +} + +# Paper suggests 0.9997 momentum, for TensorFlow. Equivalent PyTorch momentum is +# 1.0 - tensorflow. +_BN_MOMENTUM = 1 - 0.9997 + + +class _InvertedResidual(nn.Module): + + def __init__(self, in_ch, out_ch, kernel_size, stride, expansion_factor, + bn_momentum=0.1): + super(_InvertedResidual, self).__init__() + assert stride in [1, 2] + assert kernel_size in [3, 5] + mid_ch = in_ch * expansion_factor + self.apply_residual = (in_ch == out_ch and stride == 1) + self.layers = nn.Sequential( + # Pointwise + nn.Conv2d(in_ch, mid_ch, 1, bias=False), + nn.BatchNorm2d(mid_ch, momentum=bn_momentum), + nn.ReLU(inplace=True), + # Depthwise + nn.Conv2d(mid_ch, mid_ch, kernel_size, padding=kernel_size // 2, + stride=stride, groups=mid_ch, bias=False), + nn.BatchNorm2d(mid_ch, momentum=bn_momentum), + nn.ReLU(inplace=True), + # Linear pointwise. Note that there's no activation. + nn.Conv2d(mid_ch, out_ch, 1, bias=False), + nn.BatchNorm2d(out_ch, momentum=bn_momentum)) + + def forward(self, input): + if self.apply_residual: + return self.layers(input) + input + else: + return self.layers(input) + + +def _stack(in_ch, out_ch, kernel_size, stride, exp_factor, repeats, + bn_momentum): + """ Creates a stack of inverted residuals. """ + assert repeats >= 1 + # First one has no skip, because feature map size changes. + first = _InvertedResidual(in_ch, out_ch, kernel_size, stride, exp_factor, + bn_momentum=bn_momentum) + remaining = [] + for _ in range(1, repeats): + remaining.append( + _InvertedResidual(out_ch, out_ch, kernel_size, 1, exp_factor, + bn_momentum=bn_momentum)) + return nn.Sequential(first, *remaining) + + +def _round_to_multiple_of(val, divisor, round_up_bias=0.9): + """ Asymmetric rounding to make `val` divisible by `divisor`. With default + bias, will round up, unless the number is no more than 10% greater than the + smaller divisible value, i.e. (83, 8) -> 80, but (84, 8) -> 88. """ + assert 0.0 < round_up_bias < 1.0 + new_val = max(divisor, int(val + divisor / 2) // divisor * divisor) + return new_val if new_val >= round_up_bias * val else new_val + divisor + + +def _get_depths(alpha): + """ Scales tensor depths as in reference MobileNet code, prefers rouding up + rather than down. """ + depths = [32, 16, 24, 40, 80, 96, 192, 320] + return [_round_to_multiple_of(depth * alpha, 8) for depth in depths] + + +class MNASNet(torch.nn.Module): + """ MNASNet, as described in https://arxiv.org/pdf/1807.11626.pdf. This + implements the B1 variant of the model. + >>> model = MNASNet(1000, 1.0) + >>> x = torch.rand(1, 3, 224, 224) + >>> y = model(x) + >>> y.dim() + 1 + >>> y.nelement() + 1000 + """ + # Version 2 adds depth scaling in the initial stages of the network. + _version = 2 + + def __init__(self, alpha, num_classes=1000, dropout=0.2): + super(MNASNet, self).__init__() + assert alpha > 0.0 + self.alpha = alpha + self.num_classes = num_classes + depths = _get_depths(alpha) + layers = [ + # First layer: regular conv. + nn.Conv2d(3, depths[0], 3, padding=1, stride=2, bias=False), + nn.BatchNorm2d(depths[0], momentum=_BN_MOMENTUM), + nn.ReLU(inplace=True), + # Depthwise separable, no skip. + nn.Conv2d(depths[0], depths[0], 3, padding=1, stride=1, + groups=depths[0], bias=False), + nn.BatchNorm2d(depths[0], momentum=_BN_MOMENTUM), + nn.ReLU(inplace=True), + nn.Conv2d(depths[0], depths[1], 1, padding=0, stride=1, bias=False), + nn.BatchNorm2d(depths[1], momentum=_BN_MOMENTUM), + # MNASNet blocks: stacks of inverted residuals. + _stack(depths[1], depths[2], 3, 2, 3, 3, _BN_MOMENTUM), + _stack(depths[2], depths[3], 5, 2, 3, 3, _BN_MOMENTUM), + _stack(depths[3], depths[4], 5, 2, 6, 3, _BN_MOMENTUM), + _stack(depths[4], depths[5], 3, 1, 6, 2, _BN_MOMENTUM), + _stack(depths[5], depths[6], 5, 2, 6, 4, _BN_MOMENTUM), + _stack(depths[6], depths[7], 3, 1, 6, 1, _BN_MOMENTUM), + # Final mapping to classifier input. + # nn.Conv2d(depths[7], 1280, 1, padding=0, stride=1, bias=False), + # nn.BatchNorm2d(1280, momentum=_BN_MOMENTUM), + # nn.ReLU(inplace=True), + ] + self.layers = nn.Sequential(*layers) + # self.classifier = nn.Sequential(nn.Dropout(p=dropout, inplace=True), + # nn.Linear(1280, num_classes)) + self._initialize_weights() + + def forward(self, x): + outputs = {} + for i, module in enumerate(self.layers): + x = module(x) + outputs['layer_%d' % (i + 1)] = x + return outputs + # x = self.layers(x) + # # Equivalent to global avgpool and removing H and W dimensions. + # x = x.mean([2, 3]) + # return self.classifier(x) + + def _initialize_weights(self): + for m in self.modules(): + if isinstance(m, nn.Conv2d): + nn.init.kaiming_normal_(m.weight, mode="fan_out", + nonlinearity="relu") + if m.bias is not None: + nn.init.zeros_(m.bias) + elif isinstance(m, nn.BatchNorm2d): + nn.init.ones_(m.weight) + nn.init.zeros_(m.bias) + elif isinstance(m, nn.Linear): + nn.init.kaiming_uniform_(m.weight, mode="fan_out", + nonlinearity="sigmoid") + nn.init.zeros_(m.bias) + + def _load_from_state_dict(self, state_dict, prefix, local_metadata, strict, + missing_keys, unexpected_keys, error_msgs): + version = local_metadata.get("version", None) + assert version in [1, 2] + + if version == 1 and not self.alpha == 1.0: + # In the initial version of the model (v1), stem was fixed-size. + # All other layer configurations were the same. This will patch + # the model so that it's identical to v1. Model with alpha 1.0 is + # unaffected. + depths = _get_depths(self.alpha) + v1_stem = [ + nn.Conv2d(3, 32, 3, padding=1, stride=2, bias=False), + nn.BatchNorm2d(32, momentum=_BN_MOMENTUM), + nn.ReLU(inplace=True), + nn.Conv2d(32, 32, 3, padding=1, stride=1, groups=32, + bias=False), + nn.BatchNorm2d(32, momentum=_BN_MOMENTUM), + nn.ReLU(inplace=True), + nn.Conv2d(32, 16, 1, padding=0, stride=1, bias=False), + nn.BatchNorm2d(16, momentum=_BN_MOMENTUM), + _stack(16, depths[2], 3, 2, 3, 3, _BN_MOMENTUM), + ] + for idx, layer in enumerate(v1_stem): + self.layers[idx] = layer + + # The model is now identical to v1, and must be saved as such. + self._version = 1 + warnings.warn( + "A new version of MNASNet model has been implemented. " + "Your checkpoint was saved using the previous version. " + "This checkpoint will load and work as before, but " + "you may want to upgrade by training a newer model or " + "transfer learning from an updated ImageNet checkpoint.", + UserWarning) + + super(MNASNet, self)._load_from_state_dict( + state_dict, prefix, local_metadata, strict, missing_keys, + unexpected_keys, error_msgs) + + +def _load_pretrained(model_name, model, progress): + if model_name not in _MODEL_URLS or _MODEL_URLS[model_name] is None: + raise ValueError( + "No checkpoint is available for model type {}".format(model_name)) + checkpoint_url = _MODEL_URLS[model_name] + model.load_state_dict( + load_state_dict_from_url(checkpoint_url, progress=progress), strict=False) + + +def mnasnet0_5(pretrained=False, progress=True, **kwargs): + """MNASNet with depth multiplier of 0.5 from + `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" + `_. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + model = MNASNet(0.5, **kwargs) + if pretrained: + _load_pretrained("mnasnet0_5", model, progress) + return model + + +def mnasnet0_75(pretrained=False, progress=True, **kwargs): + """MNASNet with depth multiplier of 0.75 from + `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" + `_. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + model = MNASNet(0.75, **kwargs) + if pretrained: + _load_pretrained("mnasnet0_75", model, progress) + return model + + +def mnasnet1_0(pretrained=False, progress=True, **kwargs): + """MNASNet with depth multiplier of 1.0 from + `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" + `_. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + model = MNASNet(1.0, **kwargs) + if pretrained: + _load_pretrained("mnasnet1_0", model, progress) + return model + + +def mnasnet1_3(pretrained=False, progress=True, **kwargs): + """MNASNet with depth multiplier of 1.3 from + `"MnasNet: Platform-Aware Neural Architecture Search for Mobile" + `_. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + model = MNASNet(1.3, **kwargs) + if pretrained: + _load_pretrained("mnasnet1_3", model, progress) + return model + + +if __name__ == '__main__': + import torch + + model = mnasnet0_5(pretrained=False) + print(model) + data = torch.zeros(1, 3, 224, 224) + results = model.forward(data) + + for key in results.keys(): + print(key, results[key].size()) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mobilenet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mobilenet.py new file mode 100644 index 000000000..5ae4a4dec --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/mobilenet.py @@ -0,0 +1,214 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/pytorch/vision/blob/master/torchvision/models/mobilenet.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from torch import nn +from torchvision.models.utils import load_state_dict_from_url + + +__all__ = ['MobileNetV2', 'mobilenet_v2'] + + +model_urls = { + 'mobilenet_v2': 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth', +} + + +def _make_divisible(v, divisor, min_value=None): + """ + This function is taken from the original tf repo. + It ensures that all layers have a channel number that is divisible by 8 + It can be seen here: + https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py + :param v: + :param divisor: + :param min_value: + :return: + """ + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + # Make sure that round down does not go down by more than 10%. + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +class ConvBNReLU(nn.Sequential): + def __init__(self, in_planes, out_planes, kernel_size=3, stride=1, groups=1): + padding = (kernel_size - 1) // 2 + super(ConvBNReLU, self).__init__( + nn.Conv2d(in_planes, out_planes, kernel_size, stride, padding, groups=groups, bias=False), + nn.BatchNorm2d(out_planes), + nn.ReLU6(inplace=True) + ) + + +class InvertedResidual(nn.Module): + def __init__(self, inp, oup, stride, expand_ratio): + super(InvertedResidual, self).__init__() + self.stride = stride + assert stride in [1, 2] + + hidden_dim = int(round(inp * expand_ratio)) + self.use_res_connect = self.stride == 1 and inp == oup + + layers = [] + if expand_ratio != 1: + # pw + layers.append(ConvBNReLU(inp, hidden_dim, kernel_size=1)) + layers.extend([ + # dw + ConvBNReLU(hidden_dim, hidden_dim, stride=stride, groups=hidden_dim), + # pw-linear + nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False), + nn.BatchNorm2d(oup), + ]) + self.conv = nn.Sequential(*layers) + + def forward(self, x): + if self.use_res_connect: + return x + self.conv(x) + else: + return self.conv(x) + + +class MobileNetV2(nn.Module): + def __init__(self, + width_mult=1.0, + inverted_residual_setting=None, + round_nearest=8, + block=None): + """ + MobileNet V2 main class + Args: + width_mult (float): Width multiplier - adjusts number of channels in each layer by this amount + inverted_residual_setting: Network structure + round_nearest (int): Round the number of channels in each layer to be a multiple of this number + Set to 1 to turn off rounding + block: Module specifying inverted residual building block for mobilenet + """ + super(MobileNetV2, self).__init__() + + if block is None: + block = InvertedResidual + input_channel = 32 + last_channel = 1280 + + if inverted_residual_setting is None: + inverted_residual_setting = [ + # t, c, n, s + [1, 16, 1, 1], + [6, 24, 2, 2], + [6, 32, 3, 2], + [6, 64, 4, 2], + [6, 96, 3, 1], + [6, 160, 3, 2], + [6, 320, 1, 1], + ] + + # op(slim.conv2d, stride=2, num_outputs=32, kernel_size=[3, 3]), layer_1 + # op(ops.expanded_conv, expansion_size=expand_input(1, divisible_by=1), num_outputs=16), layer_2 + # op(ops.expanded_conv, stride=2, num_outputs=24), layer_3 + # op(ops.expanded_conv, stride=1, num_outputs=24), layer_4 + # op(ops.expanded_conv, stride=2, num_outputs=32), layer_5 + # op(ops.expanded_conv, stride=1, num_outputs=32), layer_6 + # op(ops.expanded_conv, stride=1, num_outputs=32), layer_7 + # op(ops.expanded_conv, stride=2, num_outputs=64), layer_8 + # op(ops.expanded_conv, stride=1, num_outputs=64), layer_9 + # op(ops.expanded_conv, stride=1, num_outputs=64), layer_10 + # op(ops.expanded_conv, stride=1, num_outputs=64), layer_11 + # op(ops.expanded_conv, stride=1, num_outputs=96), layer_12 + # op(ops.expanded_conv, stride=1, num_outputs=96), layer_13 + # op(ops.expanded_conv, stride=1, num_outputs=96), layer_14 + # op(ops.expanded_conv, stride=2, num_outputs=160), layer_15 + # op(ops.expanded_conv, stride=1, num_outputs=160), layer_16 + # op(ops.expanded_conv, stride=1, num_outputs=160), layer_17 + # op(ops.expanded_conv, stride=1, num_outputs=320), layer_18 ==> use this + # op(slim.conv2d, stride=1, kernel_size=[1, 1], num_outputs=1280) layer_19 + + # only check the first element, assuming user knows t,c,n,s are required + if len(inverted_residual_setting) == 0 or len(inverted_residual_setting[0]) != 4: + raise ValueError("inverted_residual_setting should be non-empty " + "or a 4-element list, got {}".format(inverted_residual_setting)) + + # building first layer + input_channel = _make_divisible(input_channel * width_mult, round_nearest) + self.last_channel = _make_divisible(last_channel * max(1.0, width_mult), round_nearest) + features = [ConvBNReLU(3, input_channel, stride=2)] + # building inverted residual blocks + for t, c, n, s in inverted_residual_setting: + output_channel = _make_divisible(c * width_mult, round_nearest) + for i in range(n): + stride = s if i == 0 else 1 + features.append(block(input_channel, output_channel, stride, expand_ratio=t)) + input_channel = output_channel + # building last several layers + # features.append(ConvBNReLU(input_channel, self.last_channel, kernel_size=1)) + # make it nn.Sequential + self.features = nn.Sequential(*features) + + # building classifier + # self.classifier = nn.Sequential( + # nn.Dropout(0.2), + # nn.Linear(self.last_channel, num_classes), + # ) + + # weight initialization + for m in self.modules(): + if isinstance(m, nn.Conv2d): + nn.init.kaiming_normal_(m.weight, mode='fan_out') + if m.bias is not None: + nn.init.zeros_(m.bias) + elif isinstance(m, nn.BatchNorm2d): + nn.init.ones_(m.weight) + nn.init.zeros_(m.bias) + elif isinstance(m, nn.Linear): + nn.init.normal_(m.weight, 0, 0.01) + nn.init.zeros_(m.bias) + + def _forward_impl(self, x): + outputs = {} + # This exists since TorchScript doesn't support inheritance, so the superclass method + # (this one) needs to have a name other than `forward` that can be accessed in a subclass + # x = self.features(x) + for i, module in enumerate(self.features): + x = module(x) + outputs['layer_%d' % (i + 1)] = x + # Cannot use "squeeze" as batch-size can be 1 => must use reshape with x.shape[0] + # x = nn.functional.adaptive_avg_pool2d(x, 1).reshape(x.shape[0], -1) + # x = self.classifier(x) + # return x + return outputs + + def forward(self, x): + return self._forward_impl(x) + + +def mobilenet_v2(pretrained=False, progress=True, **kwargs): + """ + Constructs a MobileNetV2 architecture from + `"MobileNetV2: Inverted Residuals and Linear Bottlenecks" `_. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + model = MobileNetV2(**kwargs) + if pretrained: + state_dict = load_state_dict_from_url(model_urls['mobilenet_v2'], + progress=progress) + model.load_state_dict(state_dict, strict=False) + return model + + +if __name__ == '__main__': + import torch + + model = mobilenet_v2(pretrained=False) + print(model) + data = torch.zeros(1, 3, 224, 224) + results = model.forward(data) + + for key in results.keys(): + print(key, results[key].size()) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/resnet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/resnet.py new file mode 100644 index 000000000..e936eba23 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/resnet.py @@ -0,0 +1,351 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch.nn as nn +from torchvision.models.utils import load_state_dict_from_url + + +__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', + 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', + 'wide_resnet50_2', 'wide_resnet101_2'] + + +model_urls = { + 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', + 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', + 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', + 'resnet101': 'https://download.pytorch.org/models/resnet101-5d3b4d8f.pth', + 'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth', + 'resnext50_32x4d': 'https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth', + 'resnext101_32x8d': 'https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth', + 'wide_resnet50_2': 'https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth', + 'wide_resnet101_2': 'https://download.pytorch.org/models/wide_resnet101_2-32ee1156.pth', +} + + +def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): + """3x3 convolution with padding""" + return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, + padding=dilation, groups=groups, bias=False, dilation=dilation) + + +def conv1x1(in_planes, out_planes, stride=1): + """1x1 convolution""" + return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False) + + +class BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, + base_width=64, dilation=1, norm_layer=None): + super(BasicBlock, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + if groups != 1 or base_width != 64: + raise ValueError('BasicBlock only supports groups=1 and base_width=64') + if dilation > 1: + raise NotImplementedError("Dilation > 1 not supported in BasicBlock") + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + self.conv1 = conv3x3(inplanes, planes, stride) + self.bn1 = norm_layer(planes) + self.relu = nn.ReLU(inplace=True) + self.conv2 = conv3x3(planes, planes) + self.bn2 = norm_layer(planes) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class Bottleneck(nn.Module): + # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) + # while original implementation places the stride at the first 1x1 convolution(self.conv1) + # according to "Deep residual learning for image recognition"https://arxiv.org/abs/1512.03385. + # This variant is also known as ResNet V1.5 and improves accuracy according to + # https://ngc.nvidia.com/catalog/model-scripts/nvidia:resnet_50_v1_5_for_pytorch. + + expansion = 4 + + def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, + base_width=64, dilation=1, norm_layer=None): + super(Bottleneck, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + width = int(planes * (base_width / 64.)) * groups + # Both self.conv2 and self.downsample layers downsample the input when stride != 1 + self.conv1 = conv1x1(inplanes, width) + self.bn1 = norm_layer(width) + self.conv2 = conv3x3(width, width, stride, groups, dilation) + self.bn2 = norm_layer(width) + self.conv3 = conv1x1(width, planes * self.expansion) + self.bn3 = norm_layer(planes * self.expansion) + self.relu = nn.ReLU(inplace=True) + self.downsample = downsample + self.stride = stride + + def forward(self, x): + identity = x + + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + + out = self.conv3(out) + out = self.bn3(out) + + if self.downsample is not None: + identity = self.downsample(x) + + out += identity + out = self.relu(out) + + return out + + +class ResNet(nn.Module): + + def __init__(self, block, layers, zero_init_residual=False, + groups=1, width_per_group=64, replace_stride_with_dilation=None, + norm_layer=None): + super(ResNet, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + self._norm_layer = norm_layer + + self.inplanes = 64 + self.dilation = 1 + if replace_stride_with_dilation is None: + # each element in the tuple indicates if we should replace + # the 2x2 stride with a dilated convolution instead + replace_stride_with_dilation = [False, False, False] + if len(replace_stride_with_dilation) != 3: + raise ValueError("replace_stride_with_dilation should be None " + "or a 3-element tuple, got {}".format(replace_stride_with_dilation)) + self.groups = groups + self.base_width = width_per_group + self.conv1 = nn.Conv2d(3, self.inplanes, kernel_size=7, stride=2, padding=3, + bias=False) + self.bn1 = norm_layer(self.inplanes) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + self.layer1 = self._make_layer(block, 64, layers[0]) + self.layer2 = self._make_layer(block, 128, layers[1], stride=2, + dilate=replace_stride_with_dilation[0]) + self.layer3 = self._make_layer(block, 256, layers[2], stride=2, + dilate=replace_stride_with_dilation[1]) + self.layer4 = self._make_layer(block, 512, layers[3], stride=2, + dilate=replace_stride_with_dilation[2]) + # self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) + # self.fc = nn.Linear(512 * block.expansion, num_classes) + + for m in self.modules(): + if isinstance(m, nn.Conv2d): + nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') + elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)): + nn.init.constant_(m.weight, 1) + nn.init.constant_(m.bias, 0) + + # Zero-initialize the last BN in each residual branch, + # so that the residual branch starts with zeros, and each residual block behaves like an identity. + # This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677 + if zero_init_residual: + for m in self.modules(): + if isinstance(m, Bottleneck): + nn.init.constant_(m.bn3.weight, 0) + elif isinstance(m, BasicBlock): + nn.init.constant_(m.bn2.weight, 0) + + def _make_layer(self, block, planes, blocks, stride=1, dilate=False): + norm_layer = self._norm_layer + downsample = None + previous_dilation = self.dilation + if dilate: + self.dilation *= stride + stride = 1 + if stride != 1 or self.inplanes != planes * block.expansion: + downsample = nn.Sequential( + conv1x1(self.inplanes, planes * block.expansion, stride), + norm_layer(planes * block.expansion), + ) + + layers = [] + layers.append(block(self.inplanes, planes, stride, downsample, self.groups, + self.base_width, previous_dilation, norm_layer)) + self.inplanes = planes * block.expansion + for _ in range(1, blocks): + layers.append(block(self.inplanes, planes, groups=self.groups, + base_width=self.base_width, dilation=self.dilation, + norm_layer=norm_layer)) + + return nn.Sequential(*layers) + + def _forward_impl(self, x): + outputs = {} + # See note [TorchScript super()] + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + x = self.maxpool(x) + outputs['stem'] = x + + x = self.layer1(x) # 1/4 + outputs['res2'] = x + + x = self.layer2(x) # 1/8 + outputs['res3'] = x + + x = self.layer3(x) # 1/16 + outputs['res4'] = x + + x = self.layer4(x) # 1/32 + outputs['res5'] = x + + return outputs + + def forward(self, x): + return self._forward_impl(x) + + +def _resnet(arch, block, layers, pretrained, progress, **kwargs): + model = ResNet(block, layers, **kwargs) + if pretrained: + state_dict = load_state_dict_from_url(model_urls[arch], + progress=progress) + model.load_state_dict(state_dict, strict=False) + return model + + +def resnet18(pretrained=False, progress=True, **kwargs): + r"""ResNet-18 model from + `"Deep Residual Learning for Image Recognition" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + return _resnet('resnet18', BasicBlock, [2, 2, 2, 2], pretrained, progress, + **kwargs) + + +def resnet34(pretrained=False, progress=True, **kwargs): + r"""ResNet-34 model from + `"Deep Residual Learning for Image Recognition" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + return _resnet('resnet34', BasicBlock, [3, 4, 6, 3], pretrained, progress, + **kwargs) + + +def resnet50(pretrained=False, progress=True, **kwargs): + r"""ResNet-50 model from + `"Deep Residual Learning for Image Recognition" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + return _resnet('resnet50', Bottleneck, [3, 4, 6, 3], pretrained, progress, + **kwargs) + + +def resnet101(pretrained=False, progress=True, **kwargs): + r"""ResNet-101 model from + `"Deep Residual Learning for Image Recognition" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + return _resnet('resnet101', Bottleneck, [3, 4, 23, 3], pretrained, progress, + **kwargs) + + +def resnet152(pretrained=False, progress=True, **kwargs): + r"""ResNet-152 model from + `"Deep Residual Learning for Image Recognition" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + return _resnet('resnet152', Bottleneck, [3, 8, 36, 3], pretrained, progress, + **kwargs) + + +def resnext50_32x4d(pretrained=False, progress=True, **kwargs): + r"""ResNeXt-50 32x4d model from + `"Aggregated Residual Transformation for Deep Neural Networks" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + kwargs['groups'] = 32 + kwargs['width_per_group'] = 4 + return _resnet('resnext50_32x4d', Bottleneck, [3, 4, 6, 3], + pretrained, progress, **kwargs) + + +def resnext101_32x8d(pretrained=False, progress=True, **kwargs): + r"""ResNeXt-101 32x8d model from + `"Aggregated Residual Transformation for Deep Neural Networks" `_ + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + kwargs['groups'] = 32 + kwargs['width_per_group'] = 8 + return _resnet('resnext101_32x8d', Bottleneck, [3, 4, 23, 3], + pretrained, progress, **kwargs) + + +def wide_resnet50_2(pretrained=False, progress=True, **kwargs): + r"""Wide ResNet-50-2 model from + `"Wide Residual Networks" `_ + The model is the same as ResNet except for the bottleneck number of channels + which is twice larger in every block. The number of channels in outer 1x1 + convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 + channels, and in Wide ResNet-50-2 has 2048-1024-2048. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + kwargs['width_per_group'] = 64 * 2 + return _resnet('wide_resnet50_2', Bottleneck, [3, 4, 6, 3], + pretrained, progress, **kwargs) + + +def wide_resnet101_2(pretrained=False, progress=True, **kwargs): + r"""Wide ResNet-101-2 model from + `"Wide Residual Networks" `_ + The model is the same as ResNet except for the bottleneck number of channels + which is twice larger in every block. The number of channels in outer 1x1 + convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2048 + channels, and in Wide ResNet-50-2 has 2048-1024-2048. + Args: + pretrained (bool): If True, returns a model pre-trained on ImageNet + progress (bool): If True, displays a progress bar of the download to stderr + """ + kwargs['width_per_group'] = 64 * 2 + return _resnet('wide_resnet101_2', Bottleneck, [3, 4, 23, 3], + pretrained, progress, **kwargs) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/xception.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/xception.py new file mode 100644 index 000000000..1fa7e39e2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/backbone/xception.py @@ -0,0 +1,237 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/LikeLy-Journey/SegmenTron/blob/master/segmentron/models/backbones/xception.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import torch.nn as nn +from torchvision.models.utils import load_state_dict_from_url + +__all__ = ['Xception65', 'xception65'] + + +model_urls = { + 'xception65': 'https://github.com/LikeLy-Journey/SegmenTron/releases/download/v0.1.0/tf-xception65-270e81cf.pth', +} + + +class SeparableConv2d(nn.Module): + def __init__(self, inplanes, planes, kernel_size=3, stride=1, dilation=1, relu_first=True, + bias=False, norm_layer=nn.BatchNorm2d): + super(SeparableConv2d, self).__init__() + depthwise = nn.Conv2d(inplanes, inplanes, kernel_size, + stride=stride, padding=dilation, + dilation=dilation, groups=inplanes, bias=bias) + bn_depth = norm_layer(inplanes) + pointwise = nn.Conv2d(inplanes, planes, 1, bias=bias) + bn_point = norm_layer(planes) + + if relu_first: + self.block = nn.Sequential(OrderedDict([('relu', nn.ReLU()), + ('depthwise', depthwise), + ('bn_depth', bn_depth), + ('pointwise', pointwise), + ('bn_point', bn_point) + ])) + else: + self.block = nn.Sequential(OrderedDict([('depthwise', depthwise), + ('bn_depth', bn_depth), + ('relu1', nn.ReLU(inplace=True)), + ('pointwise', pointwise), + ('bn_point', bn_point), + ('relu2', nn.ReLU(inplace=True)) + ])) + + def forward(self, x): + return self.block(x) + + +class XceptionBlock(nn.Module): + def __init__(self, channel_list, stride=1, dilation=1, skip_connection_type='conv', relu_first=True, + low_feat=False, norm_layer=nn.BatchNorm2d): + super(XceptionBlock, self).__init__() + + assert len(channel_list) == 4 + self.skip_connection_type = skip_connection_type + self.relu_first = relu_first + self.low_feat = low_feat + + if self.skip_connection_type == 'conv': + self.conv = nn.Conv2d(channel_list[0], channel_list[-1], 1, stride=stride, bias=False) + self.bn = norm_layer(channel_list[-1]) + + self.sep_conv1 = SeparableConv2d(channel_list[0], channel_list[1], dilation=dilation, + relu_first=relu_first, norm_layer=norm_layer) + self.sep_conv2 = SeparableConv2d(channel_list[1], channel_list[2], dilation=dilation, + relu_first=relu_first, norm_layer=norm_layer) + self.sep_conv3 = SeparableConv2d(channel_list[2], channel_list[3], dilation=dilation, + relu_first=relu_first, stride=stride, norm_layer=norm_layer) + self.last_inp_channels = channel_list[3] + + def forward(self, inputs): + sc1 = self.sep_conv1(inputs) + sc2 = self.sep_conv2(sc1) + residual = self.sep_conv3(sc2) + + if self.skip_connection_type == 'conv': + shortcut = self.conv(inputs) + shortcut = self.bn(shortcut) + outputs = residual + shortcut + elif self.skip_connection_type == 'sum': + outputs = residual + inputs + elif self.skip_connection_type == 'none': + outputs = residual + else: + raise ValueError('Unsupported skip connection type.') + + if self.low_feat: + return outputs, sc2 + else: + return outputs + + +class Xception65(nn.Module): + def __init__(self, replace_stride_with_dilation=None, + norm_layer=None): + super(Xception65, self).__init__() + if norm_layer is None: + norm_layer = nn.BatchNorm2d + if replace_stride_with_dilation is None: + # each element in the tuple indicates if we should replace + # the 2x2 stride with a dilated convolution instead + replace_stride_with_dilation = [False, False, False] + if len(replace_stride_with_dilation) != 3: + raise ValueError("replace_stride_with_dilation should be None " + "or a 3-element tuple, got {}".format(replace_stride_with_dilation)) + if replace_stride_with_dilation[1]: + assert replace_stride_with_dilation[2] + output_stride = 8 + elif replace_stride_with_dilation[2]: + output_stride = 16 + else: + output_stride = 32 + + if output_stride == 32: + entry_block3_stride = 2 + middle_block_dilation = 1 + exit_block_dilations = (1, 1) + exit_block_stride = 2 + elif output_stride == 16: + entry_block3_stride = 2 + middle_block_dilation = 1 + exit_block_dilations = (1, 2) + exit_block_stride = 1 + elif output_stride == 8: + entry_block3_stride = 1 + middle_block_dilation = 2 + exit_block_dilations = (2, 4) + exit_block_stride = 1 + else: + raise NotImplementedError + + # Entry flow + self.conv1 = nn.Conv2d(3, 32, 3, stride=2, padding=1, bias=False) + self.bn1 = norm_layer(32) + self.relu = nn.ReLU() + + self.conv2 = nn.Conv2d(32, 64, 3, stride=1, padding=1, bias=False) + self.bn2 = norm_layer(64) + + self.block1 = XceptionBlock([64, 128, 128, 128], stride=2, norm_layer=norm_layer) + self.block2 = XceptionBlock([128, 256, 256, 256], stride=2, low_feat=True, norm_layer=norm_layer) + self.block3 = XceptionBlock([256, 728, 728, 728], stride=entry_block3_stride, low_feat=True, + norm_layer=norm_layer) + + # Middle flow (16 units) + self.block4 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block5 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block6 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block7 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block8 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block9 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block10 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block11 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block12 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block13 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block14 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block15 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block16 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block17 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block18 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + self.block19 = XceptionBlock([728, 728, 728, 728], dilation=middle_block_dilation, + skip_connection_type='sum', norm_layer=norm_layer) + + # Exit flow + self.block20 = XceptionBlock([728, 728, 1024, 1024], stride=exit_block_stride, + dilation=exit_block_dilations[0], norm_layer=norm_layer) + self.block21 = XceptionBlock([1024, 1536, 1536, 2048], dilation=exit_block_dilations[1], + skip_connection_type='none', relu_first=False, norm_layer=norm_layer) + + def forward(self, x): + outputs = {} + # Entry flow + x = self.conv1(x) + x = self.bn1(x) + x = self.relu(x) + + x = self.conv2(x) + x = self.bn2(x) + x = self.relu(x) + outputs['stem'] = x + + x = self.block1(x) + x, c1 = self.block2(x) # b, h//4, w//4, 256 + outputs['res2'] = c1 + x, c2 = self.block3(x) # b, h//8, w//8, 728 + outputs['res3'] = c2 + + # Middle flow + x = self.block4(x) + x = self.block5(x) + x = self.block6(x) + x = self.block7(x) + x = self.block8(x) + x = self.block9(x) + x = self.block10(x) + x = self.block11(x) + x = self.block12(x) + x = self.block13(x) + x = self.block14(x) + x = self.block15(x) + x = self.block16(x) + x = self.block17(x) + x = self.block18(x) + c3 = self.block19(x) + outputs['res4'] = c3 + + # Exit flow + x = self.block20(c3) + c4 = self.block21(x) + outputs['res5'] = c4 + + return outputs + + +def xception65(pretrained=False, progress=True, **kwargs): + model = Xception65(**kwargs) + if pretrained: + state_dict = load_state_dict_from_url(model_urls['xception65'], + progress=progress) + model.load_state_dict(state_dict, strict=False) + return model diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/build.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/build.py new file mode 100644 index 000000000..e0b0f83b0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/build.py @@ -0,0 +1,133 @@ +# ------------------------------------------------------------------------------ +# Builds model. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch + +from .backbone import resnet, mobilenet, mnasnet, hrnet, xception +from .meta_arch import DeepLabV3, DeepLabV3Plus, PanopticDeepLab +from .loss import RegularCE, OhemCE, DeepLabCE, L1Loss, MSELoss, CrossEntropyLoss + + +def build_segmentation_model_from_cfg(config): + """Builds segmentation model with specific configuration. + Args: + config: the configuration. + + Returns: + A nn.Module segmentation model. + """ + model_map = { + 'deeplabv3': DeepLabV3, + 'deeplabv3plus': DeepLabV3Plus, + 'panoptic_deeplab': PanopticDeepLab, + } + + model_cfg = { + 'deeplabv3': dict( + replace_stride_with_dilation=config.MODEL.BACKBONE.DILATION, + in_channels=config.MODEL.DECODER.IN_CHANNELS, + feature_key=config.MODEL.DECODER.FEATURE_KEY, + decoder_channels=config.MODEL.DECODER.DECODER_CHANNELS, + atrous_rates=config.MODEL.DECODER.ATROUS_RATES, + num_classes=config.DATASET.NUM_CLASSES, + semantic_loss=build_loss_from_cfg(config.LOSS.SEMANTIC), + semantic_loss_weight=config.LOSS.SEMANTIC.WEIGHT, + ), + 'deeplabv3plus': dict( + replace_stride_with_dilation=config.MODEL.BACKBONE.DILATION, + in_channels=config.MODEL.DECODER.IN_CHANNELS, + feature_key=config.MODEL.DECODER.FEATURE_KEY, + low_level_channels=config.MODEL.DEEPLABV3PLUS.LOW_LEVEL_CHANNELS, + low_level_key=config.MODEL.DEEPLABV3PLUS.LOW_LEVEL_KEY, + low_level_channels_project=config.MODEL.DEEPLABV3PLUS.LOW_LEVEL_CHANNELS_PROJECT, + decoder_channels=config.MODEL.DECODER.DECODER_CHANNELS, + atrous_rates=config.MODEL.DECODER.ATROUS_RATES, + num_classes=config.DATASET.NUM_CLASSES, + semantic_loss=build_loss_from_cfg(config.LOSS.SEMANTIC), + semantic_loss_weight=config.LOSS.SEMANTIC.WEIGHT, + ), + 'panoptic_deeplab': dict( + replace_stride_with_dilation=config.MODEL.BACKBONE.DILATION, + in_channels=config.MODEL.DECODER.IN_CHANNELS, + feature_key=config.MODEL.DECODER.FEATURE_KEY, + low_level_channels=config.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_CHANNELS, + low_level_key=config.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_KEY, + low_level_channels_project=config.MODEL.PANOPTIC_DEEPLAB.LOW_LEVEL_CHANNELS_PROJECT, + decoder_channels=config.MODEL.DECODER.DECODER_CHANNELS, + atrous_rates=config.MODEL.DECODER.ATROUS_RATES, + num_classes=config.DATASET.NUM_CLASSES, + has_instance=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.ENABLE, + instance_low_level_channels_project=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.LOW_LEVEL_CHANNELS_PROJECT, + instance_decoder_channels=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.DECODER_CHANNELS, + instance_head_channels=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.HEAD_CHANNELS, + instance_aspp_channels=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.ASPP_CHANNELS, + instance_num_classes=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.NUM_CLASSES, + instance_class_key=config.MODEL.PANOPTIC_DEEPLAB.INSTANCE.CLASS_KEY, + semantic_loss=build_loss_from_cfg(config.LOSS.SEMANTIC), + semantic_loss_weight=config.LOSS.SEMANTIC.WEIGHT, + center_loss=build_loss_from_cfg(config.LOSS.CENTER), + center_loss_weight=config.LOSS.CENTER.WEIGHT, + offset_loss=build_loss_from_cfg(config.LOSS.OFFSET), + offset_loss_weight=config.LOSS.OFFSET.WEIGHT, + ), + } + + if config.MODEL.BACKBONE.META == 'resnet': + backbone = resnet.__dict__[config.MODEL.BACKBONE.NAME]( + pretrained=config.MODEL.BACKBONE.PRETRAINED, + replace_stride_with_dilation=model_cfg[config.MODEL.META_ARCHITECTURE]['replace_stride_with_dilation'] + ) + elif config.MODEL.BACKBONE.META == 'mobilenet_v2': + backbone = mobilenet.__dict__[config.MODEL.BACKBONE.NAME]( + pretrained=config.MODEL.BACKBONE.PRETRAINED, + ) + elif config.MODEL.BACKBONE.META == 'mnasnet': + backbone = mnasnet.__dict__[config.MODEL.BACKBONE.NAME]( + pretrained=config.MODEL.BACKBONE.PRETRAINED, + ) + elif config.MODEL.BACKBONE.META == 'hrnet': + backbone = hrnet.__dict__[config.MODEL.BACKBONE.NAME]( + pretrained=config.MODEL.BACKBONE.PRETRAINED, + ) + elif config.MODEL.BACKBONE.META == 'xception': + backbone = xception.__dict__[config.MODEL.BACKBONE.NAME]( + pretrained=config.MODEL.BACKBONE.PRETRAINED, + replace_stride_with_dilation=model_cfg[config.MODEL.META_ARCHITECTURE]['replace_stride_with_dilation'] + ) + else: + raise ValueError('Unknown meta backbone {}, please first implement it.'.format(config.MODEL.BACKBONE.META)) + + model = model_map[config.MODEL.META_ARCHITECTURE]( + backbone, + **model_cfg[config.MODEL.META_ARCHITECTURE] + ) + # set batchnorm momentum + for module in model.modules(): + if isinstance(module, torch.nn.BatchNorm2d): + module.momentum = config.MODEL.BN_MOMENTUM + return model + + +def build_loss_from_cfg(config): + """Builds loss function with specific configuration. + Args: + config: the configuration. + + Returns: + A nn.Module loss. + """ + if config.NAME == 'cross_entropy': + # return CrossEntropyLoss(ignore_index=config.IGNORE, reduction='mean') + return RegularCE(ignore_label=config.IGNORE) + elif config.NAME == 'ohem': + return OhemCE(ignore_label=config.IGNORE, threshold=config.THRESHOLD, min_kept=config.MIN_KEPT) + elif config.NAME == 'hard_pixel_mining': + return DeepLabCE(ignore_label=config.IGNORE, top_k_percent_pixels=config.TOP_K_PERCENT) + elif config.NAME == 'mse': + return MSELoss(reduction=config.REDUCTION) + elif config.NAME == 'l1': + return L1Loss(reduction=config.REDUCTION) + else: + raise ValueError('Unknown loss type: {}'.format(config.NAME)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/__init__.py new file mode 100644 index 000000000..825fad92c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/__init__.py @@ -0,0 +1,4 @@ +from .aspp import ASPP +from .deeplabv3 import DeepLabV3Decoder +from .deeplabv3plus import DeepLabV3PlusDecoder +from .panoptic_deeplab import PanopticDeepLabDecoder diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/aspp.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/aspp.py new file mode 100644 index 000000000..7d986760f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/aspp.py @@ -0,0 +1,76 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/pytorch/vision/blob/master/torchvision/models/segmentation/deeplabv3.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch +from torch import nn +from torch.nn import functional as F + +__all__ = ["ASPP"] + + +class ASPPConv(nn.Sequential): + def __init__(self, in_channels, out_channels, dilation): + modules = [ + nn.Conv2d(in_channels, out_channels, 3, padding=dilation, dilation=dilation, bias=False), + nn.BatchNorm2d(out_channels), + nn.ReLU() + ] + super(ASPPConv, self).__init__(*modules) + + +class ASPPPooling(nn.Module): + def __init__(self, in_channels, out_channels): + super(ASPPPooling, self).__init__() + self.aspp_pooling = nn.Sequential( + nn.AdaptiveAvgPool2d(1), + nn.Conv2d(in_channels, out_channels, 1, bias=False), + nn.ReLU() + ) + + def set_image_pooling(self, pool_size=None): + if pool_size is None: + self.aspp_pooling[0] = nn.AdaptiveAvgPool2d(1) + else: + self.aspp_pooling[0] = nn.AvgPool2d(kernel_size=pool_size, stride=1) + + def forward(self, x): + size = x.shape[-2:] + x = self.aspp_pooling(x) + return F.interpolate(x, size=size, mode='bilinear', align_corners=True) + + +class ASPP(nn.Module): + def __init__(self, in_channels, out_channels, atrous_rates): + super(ASPP, self).__init__() + # out_channels = 256 + modules = [] + modules.append(nn.Sequential( + nn.Conv2d(in_channels, out_channels, 1, bias=False), + nn.BatchNorm2d(out_channels), + nn.ReLU())) + + rate1, rate2, rate3 = tuple(atrous_rates) + modules.append(ASPPConv(in_channels, out_channels, rate1)) + modules.append(ASPPConv(in_channels, out_channels, rate2)) + modules.append(ASPPConv(in_channels, out_channels, rate3)) + modules.append(ASPPPooling(in_channels, out_channels)) + + self.convs = nn.ModuleList(modules) + + self.project = nn.Sequential( + nn.Conv2d(5 * out_channels, out_channels, 1, bias=False), + nn.BatchNorm2d(out_channels), + nn.ReLU(), + nn.Dropout(0.5)) + + def set_image_pooling(self, pool_size): + self.convs[-1].set_image_pooling(pool_size) + + def forward(self, x): + res = [] + for conv in self.convs: + res.append(conv(x)) + res = torch.cat(res, dim=1) + return self.project(res) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py new file mode 100644 index 000000000..a2c9c46b8 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/conv_module.py @@ -0,0 +1,73 @@ +# ------------------------------------------------------------------------------ +# Common modules. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from functools import partial + +import torch +from torch import nn +from torch.nn import functional as F + + +def basic_conv(in_planes, out_planes, kernel_size, stride=1, padding=1, groups=1, + with_bn=True, with_relu=True): + """convolution with bn and relu""" + module = [] + has_bias = not with_bn + module.append( + nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, padding=padding, groups=groups, + bias=has_bias) + ) + if with_bn: + module.append(nn.BatchNorm2d(out_planes)) + if with_relu: + module.append(nn.ReLU()) + return nn.Sequential(*module) + + +def depthwise_separable_conv(in_planes, out_planes, kernel_size, stride=1, padding=1, groups=1, + with_bn=True, with_relu=True): + """depthwise separable convolution with bn and relu""" + del groups + + module = [] + module.extend([ + basic_conv(in_planes, in_planes, kernel_size, stride, padding, groups=in_planes, + with_bn=True, with_relu=True), + nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=1, padding=0, bias=False), + ]) + if with_bn: + module.append(nn.BatchNorm2d(out_planes)) + if with_relu: + module.append(nn.ReLU()) + return nn.Sequential(*module) + + +def stacked_conv(in_planes, out_planes, kernel_size, num_stack, stride=1, padding=1, groups=1, + with_bn=True, with_relu=True, conv_type='basic_conv'): + """stacked convolution with bn and relu""" + if num_stack < 1: + assert ValueError('`num_stack` has to be a positive integer.') + if conv_type == 'basic_conv': + conv = partial(basic_conv, out_planes=out_planes, kernel_size=kernel_size, stride=stride, + padding=padding, groups=groups, with_bn=with_bn, with_relu=with_relu) + elif conv_type == 'depthwise_separable_conv': + conv = partial(depthwise_separable_conv, out_planes=out_planes, kernel_size=kernel_size, stride=stride, + padding=padding, groups=1, with_bn=with_bn, with_relu=with_relu) + else: + raise ValueError('Unknown conv_type: {}'.format(conv_type)) + module = [] + module.append(conv(in_planes=in_planes)) + for n in range(1, num_stack): + module.append(conv(in_planes=out_planes)) + return nn.Sequential(*module) + + +if __name__ == '__main__': + import torch + + model = stacked_conv(4, 2, 3, 3) + print(model) + data = torch.zeros(1, 4, 5, 5) + print(model.forward(data).shape) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3.py new file mode 100644 index 000000000..98f5ee5b2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3.py @@ -0,0 +1,37 @@ +# ------------------------------------------------------------------------------ +# DeepLabV3 decoder. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +from torch import nn + +from .aspp import ASPP + + +__all__ = ["DeepLabV3Decoder"] + + +class DeepLabV3Decoder(nn.Module): + def __init__(self, in_channels, feature_key, decoder_channels, atrous_rates, num_classes): + super(DeepLabV3Decoder, self).__init__() + self.aspp = ASPP(in_channels, out_channels=decoder_channels, atrous_rates=atrous_rates) + self.feature_key = feature_key + self.classifier = nn.Sequential( + nn.Conv2d(decoder_channels, decoder_channels, 3, padding=1, bias=False), + nn.BatchNorm2d(decoder_channels), + nn.ReLU(), + nn.Conv2d(decoder_channels, num_classes, 1) + ) + + def set_image_pooling(self, pool_size): + self.aspp.set_image_pooling(pool_size) + + def forward(self, features): + pred = OrderedDict() + res5 = features[self.feature_key] + x = self.aspp(res5) + x = self.classifier(x) + pred['semantic'] = x + return pred diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3plus.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3plus.py new file mode 100644 index 000000000..f178a0dd9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/deeplabv3plus.py @@ -0,0 +1,59 @@ +# ------------------------------------------------------------------------------ +# DeepLabV3+ decoder. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import torch +from torch import nn +from torch.nn import functional as F + +from .aspp import ASPP +from .conv_module import stacked_conv + + +__all__ = ["DeepLabV3PlusDecoder"] + + +class DeepLabV3PlusDecoder(nn.Module): + def __init__(self, in_channels, feature_key, low_level_channels, low_level_key, low_level_channels_project, + decoder_channels, atrous_rates, num_classes): + super(DeepLabV3PlusDecoder, self).__init__() + self.aspp = ASPP(in_channels, out_channels=decoder_channels, atrous_rates=atrous_rates) + self.feature_key = feature_key + self.low_level_key = low_level_key + # Transform low-level feature + # low_level_channels_project = 48 + self.project = nn.Sequential( + nn.Conv2d(low_level_channels, low_level_channels_project, 1, bias=False), + nn.BatchNorm2d(low_level_channels_project), + nn.ReLU() + ) + # Fuse + self.fuse = stacked_conv( + decoder_channels + low_level_channels_project, + decoder_channels, + kernel_size=3, + padding=1, + num_stack=2, + conv_type='depthwise_separable_conv' + ) + self.classifier = nn.Conv2d(decoder_channels, num_classes, 1) + + def set_image_pooling(self, pool_size): + self.aspp.set_image_pooling(pool_size) + + def forward(self, features): + pred = OrderedDict() + l = features[self.low_level_key] + x = features[self.feature_key] + x = self.aspp(x) + # low-level feature + l = self.project(l) + x = F.interpolate(x, size=l.size()[2:], mode='bilinear', align_corners=True) + x = torch.cat((x, l), dim=1) + x = self.fuse(x) + x = self.classifier(x) + pred['semantic'] = x + return pred diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/panoptic_deeplab.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/panoptic_deeplab.py new file mode 100644 index 000000000..8d387e717 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/decoder/panoptic_deeplab.py @@ -0,0 +1,162 @@ +# ------------------------------------------------------------------------------ +# Panoptic-DeepLab decoder. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict +from functools import partial + +import torch +from torch import nn +from torch.nn import functional as F + +from .aspp import ASPP +from .conv_module import stacked_conv + + +__all__ = ["PanopticDeepLabDecoder"] + + +class SinglePanopticDeepLabDecoder(nn.Module): + def __init__(self, in_channels, feature_key, low_level_channels, low_level_key, low_level_channels_project, + decoder_channels, atrous_rates, aspp_channels=None): + super(SinglePanopticDeepLabDecoder, self).__init__() + if aspp_channels is None: + aspp_channels = decoder_channels + self.aspp = ASPP(in_channels, out_channels=aspp_channels, atrous_rates=atrous_rates) + self.feature_key = feature_key + self.decoder_stage = len(low_level_channels) + assert self.decoder_stage == len(low_level_key) + assert self.decoder_stage == len(low_level_channels_project) + self.low_level_key = low_level_key + fuse_conv = partial(stacked_conv, kernel_size=5, num_stack=1, padding=2, + conv_type='depthwise_separable_conv') + + # Transform low-level feature + project = [] + # Fuse + fuse = [] + # Top-down direction, i.e. starting from largest stride + for i in range(self.decoder_stage): + project.append( + nn.Sequential( + nn.Conv2d(low_level_channels[i], low_level_channels_project[i], 1, bias=False), + nn.BatchNorm2d(low_level_channels_project[i]), + nn.ReLU() + ) + ) + if i == 0: + fuse_in_channels = aspp_channels + low_level_channels_project[i] + else: + fuse_in_channels = decoder_channels + low_level_channels_project[i] + fuse.append( + fuse_conv( + fuse_in_channels, + decoder_channels, + ) + ) + self.project = nn.ModuleList(project) + self.fuse = nn.ModuleList(fuse) + + def set_image_pooling(self, pool_size): + self.aspp.set_image_pooling(pool_size) + + def forward(self, features): + x = features[self.feature_key] + x = self.aspp(x) + + # build decoder + for i in range(self.decoder_stage): + l = features[self.low_level_key[i]] + l = self.project[i](l) + x = F.interpolate(x, size=l.size()[2:], mode='bilinear', align_corners=True) + x = torch.cat((x, l), dim=1) + x = self.fuse[i](x) + + return x + + +class SinglePanopticDeepLabHead(nn.Module): + def __init__(self, decoder_channels, head_channels, num_classes, class_key): + super(SinglePanopticDeepLabHead, self).__init__() + fuse_conv = partial(stacked_conv, kernel_size=5, num_stack=1, padding=2, + conv_type='depthwise_separable_conv') + + self.num_head = len(num_classes) + assert self.num_head == len(class_key) + + classifier = {} + for i in range(self.num_head): + classifier[class_key[i]] = nn.Sequential( + fuse_conv( + decoder_channels, + head_channels, + ), + nn.Conv2d(head_channels, num_classes[i], 1) + ) + self.classifier = nn.ModuleDict(classifier) + self.class_key = class_key + + def forward(self, x): + pred = OrderedDict() + # build classifier + for key in self.class_key: + pred[key] = self.classifier[key](x) + + return pred + + +class PanopticDeepLabDecoder(nn.Module): + def __init__(self, in_channels, feature_key, low_level_channels, low_level_key, low_level_channels_project, + decoder_channels, atrous_rates, num_classes, **kwargs): + super(PanopticDeepLabDecoder, self).__init__() + # Build semantic decoder + self.semantic_decoder = SinglePanopticDeepLabDecoder(in_channels, feature_key, low_level_channels, + low_level_key, low_level_channels_project, + decoder_channels, atrous_rates) + self.semantic_head = SinglePanopticDeepLabHead(decoder_channels, decoder_channels, [num_classes], ['semantic']) + # Build instance decoder + self.instance_decoder = None + self.instance_head = None + if kwargs.get('has_instance', False): + instance_decoder_kwargs = dict( + in_channels=in_channels, + feature_key=feature_key, + low_level_channels=low_level_channels, + low_level_key=low_level_key, + low_level_channels_project=kwargs['instance_low_level_channels_project'], + decoder_channels=kwargs['instance_decoder_channels'], + atrous_rates=atrous_rates, + aspp_channels=kwargs['instance_aspp_channels'] + ) + self.instance_decoder = SinglePanopticDeepLabDecoder(**instance_decoder_kwargs) + instance_head_kwargs = dict( + decoder_channels=kwargs['instance_decoder_channels'], + head_channels=kwargs['instance_head_channels'], + num_classes=kwargs['instance_num_classes'], + class_key=kwargs['instance_class_key'] + ) + self.instance_head = SinglePanopticDeepLabHead(**instance_head_kwargs) + + def set_image_pooling(self, pool_size): + self.semantic_decoder.set_image_pooling(pool_size) + if self.instance_decoder is not None: + self.instance_decoder.set_image_pooling(pool_size) + + def forward(self, features): + pred = OrderedDict() + + # Semantic branch + semantic = self.semantic_decoder(features) + semantic = self.semantic_head(semantic) + for key in semantic.keys(): + pred[key] = semantic[key] + + # Instance branch + if self.instance_decoder is not None: + instance = self.instance_decoder(features) + instance = self.instance_head(instance) + for key in instance.keys(): + pred[key] = instance[key] + + return pred diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py new file mode 100644 index 000000000..f9cccc9b7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/__init__.py @@ -0,0 +1,7 @@ +from torch import nn + +from .criterion import RegularCE, OhemCE, DeepLabCE + +L1Loss = nn.L1Loss +MSELoss = nn.MSELoss +CrossEntropyLoss = nn.CrossEntropyLoss diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py new file mode 100644 index 000000000..e9880152b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py @@ -0,0 +1,112 @@ +# ------------------------------------------------------------------------------ +# Loss functions. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch +import torch.nn as nn +from torch.nn import functional as F + + +class RegularCE(nn.Module): + """ + Regular cross entropy loss for semantic segmentation, support pixel-wise loss weight. + Arguments: + ignore_label: Integer, label to ignore. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, weight=None): + super(RegularCE, self).__init__() + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + mask = labels.contiguous().view(-1) != self.ignore_label + + pixel_losses = pixel_losses[mask] + return pixel_losses.mean() + + +class OhemCE(nn.Module): + """ + Online hard example mining with cross entropy loss, for semantic segmentation. + This is widely used in PyTorch semantic segmentation frameworks. + Reference: https://github.com/HRNet/HRNet-Semantic-Segmentation/blob/1b3ae72f6025bde4ea404305d502abea3c2f5266/lib/core/criterion.py#L29 + Arguments: + ignore_label: Integer, label to ignore. + threshold: Float, threshold for softmax score (of gt class), only predictions with softmax score + below this threshold will be kept. + min_kept: Integer, minimum number of pixels to be kept, it is used to adjust the + threshold value to avoid number of examples being too small. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, threshold=0.7, + min_kept=100000, weight=None): + super(OhemCE, self).__init__() + self.threshold = threshold + self.min_kept = max(1, min_kept) + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + predictions = F.softmax(logits, dim=1) + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + mask = labels.contiguous().view(-1) != self.ignore_label + + tmp_labels = labels.clone() + tmp_labels[tmp_labels == self.ignore_label] = 0 + # Get the score for gt class at each pixel location. + predictions = predictions.gather(1, tmp_labels.unsqueeze(1)) + predictions, indices = predictions.contiguous().view(-1, )[mask].contiguous().sort() + min_value = predictions[min(self.min_kept, predictions.numel() - 1)] + threshold = max(min_value, self.threshold) + + pixel_losses = pixel_losses[mask][indices] + pixel_losses = pixel_losses[predictions < threshold] + return pixel_losses.mean() + + +class DeepLabCE(nn.Module): + """ + Hard pixel mining mining with cross entropy loss, for semantic segmentation. + This is used in TensorFlow DeepLab frameworks. + Reference: https://github.com/tensorflow/models/blob/bd488858d610e44df69da6f89277e9de8a03722c/research/deeplab/utils/train_utils.py#L33 + Arguments: + ignore_label: Integer, label to ignore. + top_k_percent_pixels: Float, the value lies in [0.0, 1.0]. When its value < 1.0, only compute the loss for + the top k percent pixels (e.g., the top 20% pixels). This is useful for hard pixel mining. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, top_k_percent_pixels=1.0, weight=None): + super(DeepLabCE, self).__init__() + self.top_k_percent_pixels = top_k_percent_pixels + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + if self.top_k_percent_pixels == 1.0: + return pixel_losses.mean() + + top_k_pixels = int(self.top_k_percent_pixels * pixel_losses.numel()) + pixel_losses, _ = torch.topk(pixel_losses, top_k_pixels) + return pixel_losses.mean() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/__init__.py new file mode 100644 index 000000000..da75f9485 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/__init__.py @@ -0,0 +1,3 @@ +from .deeplabv3 import DeepLabV3 +from .deeplabv3plus import DeepLabV3Plus +from .panoptic_deeplab import PanopticDeepLab diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/base.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/base.py new file mode 100644 index 000000000..eb3e2b4b2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/base.py @@ -0,0 +1,64 @@ +# ------------------------------------------------------------------------------ +# Base model for segmentation. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +from torch import nn +from torch.nn import functional as F + + +class BaseSegmentationModel(nn.Module): + """ + Base class for segmentation models. + Arguments: + backbone: A nn.Module of backbone model. + decoder: A nn.Module of decoder. + """ + def __init__(self, backbone, decoder): + super(BaseSegmentationModel, self).__init__() + self.backbone = backbone + self.decoder = decoder + + def _init_params(self): + # Backbone is already initialized (either from pre-trained checkpoint or random init). + for m in self.decoder.modules(): + if isinstance(m, nn.Conv2d): + nn.init.normal_(m.weight, std=0.001) + elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)): + nn.init.constant_(m.weight, 1) + nn.init.constant_(m.bias, 0) + + def set_image_pooling(self, pool_size): + self.decoder.set_image_pooling(pool_size) + + def _upsample_predictions(self, pred, input_shape): + """Upsamples final prediction. + Args: + pred (dict): stores all output of the segmentation model. + input_shape (tuple): spatial resolution of the desired shape. + Returns: + result (OrderedDict): upsampled dictionary. + """ + result = OrderedDict() + for key in pred.keys(): + out = F.interpolate(pred[key], size=input_shape, mode='bilinear', align_corners=True) + result[key] = out + return result + + def forward(self, x, targets=None): + input_shape = x.shape[-2:] + + # contract: features is a dict of tensors + features = self.backbone(x) + pred = self.decoder(features) + results = self._upsample_predictions(pred, input_shape) + + if targets is None: + return results + else: + return self.loss(results, targets) + + def loss(self, results, targets=None): + raise NotImplementedError diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3.py new file mode 100644 index 000000000..ee6517db4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3.py @@ -0,0 +1,58 @@ +# ------------------------------------------------------------------------------ +# DeepLabV3 meta architecture. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import torch +from torch import nn + +from .base import BaseSegmentationModel +from segmentation.model.decoder import DeepLabV3Decoder +from segmentation.utils import AverageMeter + + +__all__ = ["DeepLabV3"] + + +class DeepLabV3(BaseSegmentationModel): + """ + Implements DeepLabV3 model from + `"Rethinking Atrous Convolution for Semantic Image Segmentation" + `_. + Arguments: + backbone (nn.Module): the network used to compute the features for the model. + The backbone should return an OrderedDict[Tensor], with the key being + "out" for the last feature map used, and "aux" if an auxiliary classifier + is used. + in_channels (int): number of input channels from the backbone + feature_key (str): name of input feature from backbone + decoder_channels (int): number of channels in decoder + atrous_rates (tuple): atrous rates for ASPP + num_classes (int): number of classes + semantic_loss (nn.Module): loss function + semantic_loss_weight (float): loss weight + """ + + def __init__(self, backbone, in_channels, feature_key, decoder_channels, atrous_rates, num_classes, + semantic_loss, semantic_loss_weight, **kwargs): + decoder = DeepLabV3Decoder(in_channels, feature_key, decoder_channels, atrous_rates, num_classes) + super(DeepLabV3, self).__init__(backbone, decoder) + + self.semantic_loss = semantic_loss + self.semantic_loss_weight = semantic_loss_weight + + self.loss_meter_dict = OrderedDict() + self.loss_meter_dict['Loss'] = AverageMeter() + + # Initialize parameters. + self._init_params() + + def loss(self, results, targets=None): + batch_size = results['semantic'].size(0) + if targets is not None: + semantic_loss = self.semantic_loss(results['semantic'], targets['semantic']) * self.semantic_loss_weight + self.loss_meter_dict['Loss'].update(semantic_loss.detach().cpu().item(), batch_size) + results['loss'] = semantic_loss + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py new file mode 100644 index 000000000..066d90bd7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/deeplabv3plus.py @@ -0,0 +1,63 @@ +# ------------------------------------------------------------------------------ +# DeepLabV3+ meta architecture. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import torch +from torch import nn + +from .base import BaseSegmentationModel +from segmentation.model.decoder import DeepLabV3PlusDecoder +from segmentation.utils import AverageMeter + + +__all__ = ["DeepLabV3Plus"] + + +class DeepLabV3Plus(BaseSegmentationModel): + """ + Implements DeepLabV3+ model from + `"Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation" + `_. + Arguments: + backbone (nn.Module): the network used to compute the features for the model. + The backbone should return an OrderedDict[Tensor], with the key being + "out" for the last feature map used, and "aux" if an auxiliary classifier + is used. + in_channels (int): number of input channels from the backbone + feature_key (str): name of input feature from backbone + low_level_channels (int): channels of low-level features + low_level_key (str): name of low-level features used in decoder + low_level_channels_project (int): channels of low-level features after projection in decoder + decoder_channels (int): number of channels in decoder + atrous_rates (tuple): atrous rates for ASPP + num_classes (int): number of classes + semantic_loss (nn.Module): loss function + semantic_loss_weight (float): loss weight + """ + + def __init__(self, backbone, in_channels, feature_key, low_level_channels, low_level_key, + low_level_channels_project, decoder_channels, atrous_rates, num_classes, + semantic_loss, semantic_loss_weight, **kwargs): + decoder = DeepLabV3PlusDecoder(in_channels, feature_key, low_level_channels, low_level_key, + low_level_channels_project, decoder_channels, atrous_rates, num_classes) + super(DeepLabV3Plus, self).__init__(backbone, decoder) + + self.semantic_loss = semantic_loss + self.semantic_loss_weight = semantic_loss_weight + + self.loss_meter_dict = OrderedDict() + self.loss_meter_dict['Loss'] = AverageMeter() + + # Initialize parameters. + self._init_params() + + def loss(self, results, targets=None): + batch_size = results['semantic'].size(0) + if targets is not None: + semantic_loss = self.semantic_loss(results['semantic'], targets['semantic']) * self.semantic_loss_weight + self.loss_meter_dict['Loss'].update(semantic_loss.detach().cpu().item(), batch_size) + results['loss'] = semantic_loss + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/panoptic_deeplab.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/panoptic_deeplab.py new file mode 100644 index 000000000..4371a89a0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/meta_arch/panoptic_deeplab.py @@ -0,0 +1,135 @@ +# ------------------------------------------------------------------------------ +# Panoptic-DeepLab meta architecture. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import torch +from torch import nn +from torch.nn import functional as F + +from .base import BaseSegmentationModel +from segmentation.model.decoder import PanopticDeepLabDecoder +from segmentation.utils import AverageMeter + + +__all__ = ["PanopticDeepLab"] + + +class PanopticDeepLab(BaseSegmentationModel): + """ + Implements Panoptic-DeepLab model from + `"Panoptic-DeepLab: A Simple, Strong, and Fast Baseline for Bottom-Up Panoptic Segmentation" + `_. + Arguments: + backbone (nn.Module): the network used to compute the features for the model. + The backbone should return an OrderedDict[Tensor], with the key being + "out" for the last feature map used, and "aux" if an auxiliary classifier + is used. + in_channels (int): number of input channels from the backbone + feature_key (str): names of input feature from backbone + low_level_channels (list): a list of channels of low-level features + low_level_key (list): a list of name of low-level features used in decoder + low_level_channels_project (list): a list of channels of low-level features after projection in decoder + decoder_channels (int): number of channels in decoder + atrous_rates (tuple): atrous rates for ASPP + num_classes (int): number of classes + semantic_loss (nn.Module): loss function + semantic_loss_weight (float): loss weight + center_loss (nn.Module): loss function + center_loss_weight (float): loss weight + offset_loss (nn.Module): loss function + offset_loss_weight (float): loss weight + **kwargs: arguments for instance head + """ + + def __init__(self, backbone, in_channels, feature_key, low_level_channels, low_level_key, + low_level_channels_project, decoder_channels, atrous_rates, num_classes, + semantic_loss, semantic_loss_weight, center_loss, center_loss_weight, + offset_loss, offset_loss_weight, **kwargs): + decoder = PanopticDeepLabDecoder(in_channels, feature_key, low_level_channels, low_level_key, + low_level_channels_project, decoder_channels, atrous_rates, num_classes, + **kwargs) + super(PanopticDeepLab, self).__init__(backbone, decoder) + + self.semantic_loss = semantic_loss + self.semantic_loss_weight = semantic_loss_weight + self.loss_meter_dict = OrderedDict() + self.loss_meter_dict['Loss'] = AverageMeter() + self.loss_meter_dict['Semantic loss'] = AverageMeter() + + if kwargs.get('has_instance', False): + self.center_loss = center_loss + self.center_loss_weight = center_loss_weight + self.offset_loss = offset_loss + self.offset_loss_weight = offset_loss_weight + self.loss_meter_dict['Center loss'] = AverageMeter() + self.loss_meter_dict['Offset loss'] = AverageMeter() + else: + self.center_loss = None + self.center_loss_weight = 0 + self.offset_loss = None + self.offset_loss_weight = 0 + + # Initialize parameters. + self._init_params() + + def _upsample_predictions(self, pred, input_shape): + """Upsamples final prediction, with special handling to offset. + Args: + pred (dict): stores all output of the segmentation model. + input_shape (tuple): spatial resolution of the desired shape. + Returns: + result (OrderedDict): upsampled dictionary. + """ + # Override upsample method to correctly handle `offset` + result = OrderedDict() + for key in pred.keys(): + out = F.interpolate(pred[key], size=input_shape, mode='bilinear', align_corners=True) + if 'offset' in key: + scale = (input_shape[0] - 1) // (pred[key].shape[2] - 1) + out *= scale + result[key] = out + return result + + def loss(self, results, targets=None): + batch_size = results['semantic'].size(0) + loss = 0 + if targets is not None: + if 'semantic_weights' in targets.keys(): + semantic_loss = self.semantic_loss( + results['semantic'], targets['semantic'], semantic_weights=targets['semantic_weights'] + ) * self.semantic_loss_weight + else: + semantic_loss = self.semantic_loss( + results['semantic'], targets['semantic']) * self.semantic_loss_weight + self.loss_meter_dict['Semantic loss'].update(semantic_loss.detach().cpu().item(), batch_size) + loss += semantic_loss + if self.center_loss is not None: + # Pixel-wise loss weight + center_loss_weights = targets['center_weights'][:, None, :, :].expand_as(results['center']) + center_loss = self.center_loss(results['center'], targets['center']) * center_loss_weights + # safe division + if center_loss_weights.sum() > 0: + center_loss = center_loss.sum() / center_loss_weights.sum() * self.center_loss_weight + else: + center_loss = center_loss.sum() * 0 + self.loss_meter_dict['Center loss'].update(center_loss.detach().cpu().item(), batch_size) + loss += center_loss + if self.offset_loss is not None: + # Pixel-wise loss weight + offset_loss_weights = targets['offset_weights'][:, None, :, :].expand_as(results['offset']) + offset_loss = self.offset_loss(results['offset'], targets['offset']) * offset_loss_weights + # safe division + if offset_loss_weights.sum() > 0: + offset_loss = offset_loss.sum() / offset_loss_weights.sum() * self.offset_loss_weight + else: + offset_loss = offset_loss.sum() * 0 + self.loss_meter_dict['Offset loss'].update(offset_loss.detach().cpu().item(), batch_size) + loss += offset_loss + # In distributed DataParallel, this is the loss on one machine, need to average the loss again + # in train loop. + results['loss'] = loss + self.loss_meter_dict['Loss'].update(loss.detach().cpu().item(), batch_size) + return results diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/__init__.py new file mode 100644 index 000000000..821efbf69 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/__init__.py @@ -0,0 +1,3 @@ +from .semantic_post_processing import get_semantic_segmentation +from .instance_post_processing import get_panoptic_segmentation +from .evaluation_format import get_cityscapes_instance_format diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/evaluation_format.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/evaluation_format.py new file mode 100644 index 000000000..16e6211f6 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/evaluation_format.py @@ -0,0 +1,60 @@ +# ------------------------------------------------------------------------------ +# Generates the correct format for official evaluation code. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import OrderedDict + +import numpy as np + + +def get_cityscapes_instance_format(panoptic, sem, ctr_hmp, label_divisor, score_type="semantic"): + """ + Get Cityscapes instance segmentation format. + Arguments: + panoptic: A Numpy Ndarray of shape [H, W]. + sem: A Numpy Ndarray of shape [C, H, W] of raw semantic output. + ctr_hmp: A Numpy Ndarray of shape [H, W] of raw center heatmap output. + label_divisor: An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id. + score_type: A string, how to calculates confidence scores for instance segmentation. + - "semantic": average of semantic segmentation confidence within the instance mask. + - "instance": confidence of heatmap at center point of the instance mask. + - "both": multiply "semantic" and "instance". + Returns: + A List contains instance segmentation in Cityscapes format. + """ + instances = [] + + pan_labels = np.unique(panoptic) + for pan_lab in pan_labels: + if pan_lab % label_divisor == 0: + # This is either stuff or ignored region. + continue + + ins = OrderedDict() + + train_class_id = pan_lab // label_divisor + ins['pred_class'] = train_class_id + + mask = panoptic == pan_lab + ins['pred_mask'] = np.array(mask, dtype='uint8') + + sem_scores = sem[train_class_id, ...] + ins_score = np.mean(sem_scores[mask]) + # mask center point + mask_index = np.where(panoptic == pan_lab) + center_y, center_x = np.mean(mask_index[0]), np.mean(mask_index[1]) + ctr_score = ctr_hmp[int(center_y), int(center_x)] + + if score_type == "semantic": + ins['score'] = ins_score + elif score_type == "instance": + ins['score'] = ctr_score + elif score_type == "both": + ins['score'] = ins_score * ctr_score + else: + raise ValueError("Unknown confidence score type: {}".format(score_type)) + + instances.append(ins) + + return instances diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/instance_post_processing.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/instance_post_processing.py new file mode 100644 index 000000000..cf02f6028 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/instance_post_processing.py @@ -0,0 +1,237 @@ +# ------------------------------------------------------------------------------ +# Post-processing to get instance and panoptic segmentation results. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch +import torch.nn.functional as F + +from .semantic_post_processing import get_semantic_segmentation + +__all__ = ['find_instance_center', 'get_instance_segmentation', 'get_panoptic_segmentation'] + + +def find_instance_center(ctr_hmp, threshold=0.1, nms_kernel=3, top_k=None): + """ + Find the center points from the center heatmap. + Arguments: + ctr_hmp: A Tensor of shape [N, 1, H, W] of raw center heatmap output, where N is the batch size, + for consistent, we only support N=1. + threshold: A Float, threshold applied to center heatmap score. + nms_kernel: An Integer, NMS max pooling kernel size. + top_k: An Integer, top k centers to keep. + Returns: + A Tensor of shape [K, 2] where K is the number of center points. The order of second dim is (y, x). + """ + if ctr_hmp.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + + # thresholding, setting values below threshold to -1 + ctr_hmp = F.threshold(ctr_hmp, threshold, -1) + + # NMS + nms_padding = (nms_kernel - 1) // 2 + ctr_hmp_max_pooled = F.max_pool2d(ctr_hmp, kernel_size=nms_kernel, stride=1, padding=nms_padding) + ctr_hmp[ctr_hmp != ctr_hmp_max_pooled] = -1 + + # squeeze first two dimensions + ctr_hmp = ctr_hmp.squeeze() + assert len(ctr_hmp.size()) == 2, 'Something is wrong with center heatmap dimension.' + + # find non-zero elements + ctr_all = torch.nonzero(ctr_hmp > 0) + if top_k is None: + return ctr_all + elif ctr_all.size(0) < top_k: + return ctr_all + else: + # find top k centers. + top_k_scores, _ = torch.topk(torch.flatten(ctr_hmp), top_k) + return torch.nonzero(ctr_hmp > top_k_scores[-1]) + + +def group_pixels(ctr, offsets): + """ + Gives each pixel in the image an instance id. + Arguments: + ctr: A Tensor of shape [K, 2] where K is the number of center points. The order of second dim is (y, x). + offsets: A Tensor of shape [N, 2, H, W] of raw offset output, where N is the batch size, + for consistent, we only support N=1. The order of second dim is (offset_y, offset_x). + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel). + """ + if offsets.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + + offsets = offsets.squeeze(0) + height, width = offsets.size()[1:] + + # generates a coordinate map, where each location is the coordinate of that loc + y_coord = torch.arange(height, dtype=offsets.dtype, device=offsets.device).repeat(1, width, 1).transpose(1, 2) + x_coord = torch.arange(width, dtype=offsets.dtype, device=offsets.device).repeat(1, height, 1) + coord = torch.cat((y_coord, x_coord), dim=0) + + ctr_loc = coord + offsets + ctr_loc = ctr_loc.reshape((2, height * width)).transpose(1, 0) + + # ctr: [K, 2] -> [K, 1, 2] + # ctr_loc = [H*W, 2] -> [1, H*W, 2] + ctr = ctr.unsqueeze(1) + ctr_loc = ctr_loc.unsqueeze(0) + + # distance: [K, H*W] + distance = torch.norm(ctr - ctr_loc, dim=-1) + + # finds center with minimum distance at each location, offset by 1, to reserve id=0 for stuff + instance_id = torch.argmin(distance, dim=0).reshape((1, height, width)) + 1 + return instance_id + + +def get_instance_segmentation(sem_seg, ctr_hmp, offsets, thing_list, threshold=0.1, nms_kernel=3, top_k=None, + thing_seg=None): + """ + Post-processing for instance segmentation, gets class agnostic instance id map. + Arguments: + sem_seg: A Tensor of shape [1, H, W], predicted semantic label. + ctr_hmp: A Tensor of shape [N, 1, H, W] of raw center heatmap output, where N is the batch size, + for consistent, we only support N=1. + offsets: A Tensor of shape [N, 2, H, W] of raw offset output, where N is the batch size, + for consistent, we only support N=1. The order of second dim is (offset_y, offset_x). + thing_list: A List of thing class id. + threshold: A Float, threshold applied to center heatmap score. + nms_kernel: An Integer, NMS max pooling kernel size. + top_k: An Integer, top k centers to keep. + thing_seg: A Tensor of shape [1, H, W], predicted foreground mask, if not provided, inference from + semantic prediction. + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel). + A Tensor of shape [1, K, 2] where K is the number of center points. The order of second dim is (y, x). + """ + if thing_seg is None: + # gets foreground segmentation + thing_seg = torch.zeros_like(sem_seg) + for thing_class in thing_list: + thing_seg[sem_seg == thing_class] = 1 + + ctr = find_instance_center(ctr_hmp, threshold=threshold, nms_kernel=nms_kernel, top_k=top_k) + if ctr.size(0) == 0: + return torch.zeros_like(sem_seg), ctr.unsqueeze(0) + ins_seg = group_pixels(ctr, offsets) + return thing_seg * ins_seg, ctr.unsqueeze(0) + + +def merge_semantic_and_instance(sem_seg, ins_seg, label_divisor, thing_list, stuff_area, void_label): + """ + Post-processing for panoptic segmentation, by merging semantic segmentation label and class agnostic + instance segmentation label. + Arguments: + sem_seg: A Tensor of shape [1, H, W], predicted semantic label. + ins_seg: A Tensor of shape [1, H, W], predicted instance label. + label_divisor: An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id. + thing_list: A List of thing class id. + stuff_area: An Integer, remove stuff whose area is less tan stuff_area. + void_label: An Integer, indicates the region has no confident prediction. + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel). + Raises: + ValueError, if batch size is not 1. + """ + # In case thing mask does not align with semantic prediction + pan_seg = torch.zeros_like(sem_seg) + void_label + thing_seg = ins_seg > 0 + semantic_thing_seg = torch.zeros_like(sem_seg) + for thing_class in thing_list: + semantic_thing_seg[sem_seg == thing_class] = 1 + + # keep track of instance id for each class + class_id_tracker = {} + + # paste thing by majority voting + instance_ids = torch.unique(ins_seg) + for ins_id in instance_ids: + if ins_id == 0: + continue + # Make sure only do majority voting within semantic_thing_seg + thing_mask = (ins_seg == ins_id) & (semantic_thing_seg == 1) + if torch.nonzero(thing_mask).size(0) == 0: + continue + class_id, _ = torch.mode(sem_seg[thing_mask].view(-1, )) + if class_id.item() in class_id_tracker: + new_ins_id = class_id_tracker[class_id.item()] + else: + class_id_tracker[class_id.item()] = 1 + new_ins_id = 1 + class_id_tracker[class_id.item()] += 1 + pan_seg[thing_mask] = class_id * label_divisor + new_ins_id + + # paste stuff to unoccupied area + class_ids = torch.unique(sem_seg) + for class_id in class_ids: + if class_id.item() in thing_list: + # thing class + continue + # calculate stuff area + stuff_mask = (sem_seg == class_id) & (~thing_seg) + area = torch.nonzero(stuff_mask).size(0) + if area >= stuff_area: + pan_seg[stuff_mask] = class_id * label_divisor + + return pan_seg + + +def get_panoptic_segmentation(sem, ctr_hmp, offsets, thing_list, label_divisor, stuff_area, void_label, + threshold=0.1, nms_kernel=3, top_k=None, foreground_mask=None): + """ + Post-processing for panoptic segmentation. + Arguments: + sem: A Tensor of shape [N, C, H, W] of raw semantic output, where N is the batch size, for consistent, + we only support N=1. Or, a processed Tensor of shape [1, H, W]. + ctr_hmp: A Tensor of shape [N, 1, H, W] of raw center heatmap output, where N is the batch size, + for consistent, we only support N=1. + offsets: A Tensor of shape [N, 2, H, W] of raw offset output, where N is the batch size, + for consistent, we only support N=1. The order of second dim is (offset_y, offset_x). + thing_list: A List of thing class id. + label_divisor: An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id. + stuff_area: An Integer, remove stuff whose area is less tan stuff_area. + void_label: An Integer, indicates the region has no confident prediction. + threshold: A Float, threshold applied to center heatmap score. + nms_kernel: An Integer, NMS max pooling kernel size. + top_k: An Integer, top k centers to keep. + foreground_mask: A Tensor of shape [N, 2, H, W] of raw foreground mask, where N is the batch size, + we only support N=1. Or, a processed Tensor of shape [1, H, W]. + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel), int64. + Raises: + ValueError, if batch size is not 1. + """ + if sem.dim() != 4 and sem.dim() != 3: + raise ValueError('Semantic prediction with un-supported dimension: {}.'.format(sem.dim())) + if sem.dim() == 4 and sem.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + if ctr_hmp.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + if offsets.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + if foreground_mask is not None: + if foreground_mask.dim() != 4 and foreground_mask.dim() != 3: + raise ValueError('Foreground prediction with un-supported dimension: {}.'.format(sem.dim())) + + if sem.dim() == 4: + semantic = get_semantic_segmentation(sem) + else: + semantic = sem + + if foreground_mask is not None: + if foreground_mask.dim() == 4: + thing_seg = get_semantic_segmentation(foreground_mask) + else: + thing_seg = foreground_mask + else: + thing_seg = None + + instance, center = get_instance_segmentation(semantic, ctr_hmp, offsets, thing_list, + threshold=threshold, nms_kernel=nms_kernel, top_k=top_k, + thing_seg=thing_seg) + panoptic = merge_semantic_and_instance(semantic, instance, label_divisor, thing_list, stuff_area, void_label) + + return panoptic, center diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/semantic_post_processing.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/semantic_post_processing.py new file mode 100644 index 000000000..7c700f2ac --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/model/post_processing/semantic_post_processing.py @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Post-processing to get semantic segmentation results. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import torch + +__all__ = ['get_semantic_segmentation'] + + +def get_semantic_segmentation(sem): + """ + Post-processing for semantic segmentation branch. + Arguments: + sem: A Tensor of shape [N, C, H, W], where N is the batch size, for consistent, we only + support N=1. + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel). + Raises: + ValueError, if batch size is not 1. + """ + if sem.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + sem = sem.squeeze(0) + return torch.argmax(sem, dim=0, keepdim=True) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/__init__.py new file mode 100644 index 000000000..27b524036 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/__init__.py @@ -0,0 +1,3 @@ +from .build import build_optimizer, build_lr_scheduler +from .lr_scheduler import WarmupMultiStepLR, WarmupCosineLR, WarmupPolyLR +from .utils import get_lr_group_id diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py new file mode 100644 index 000000000..5e80f5cbc --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/build.py @@ -0,0 +1,185 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/solver/build.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from enum import Enum +from typing import Any, Callable, Dict, Iterable, List, Set, Type, Union +import torch + +from .lr_scheduler import WarmupCosineLR, WarmupMultiStepLR, WarmupPolyLR + +_GradientClipperInput = Union[torch.Tensor, Iterable[torch.Tensor]] +_GradientClipper = Callable[[_GradientClipperInput], None] + + +class GradientClipType(Enum): + VALUE = "value" + NORM = "norm" + + +def _create_gradient_clipper(config): + """ + Creates gradient clipping closure to clip by value or by norm, + according to the provided config. + """ + cfg = config.clone() + + def clip_grad_norm(p: _GradientClipperInput): + torch.nn.utils.clip_grad_norm_(p, cfg.CLIP_VALUE, cfg.NORM_TYPE) + + def clip_grad_value(p: _GradientClipperInput): + torch.nn.utils.clip_grad_value_(p, cfg.CLIP_VALUE) + + _GRADIENT_CLIP_TYPE_TO_CLIPPER = { + GradientClipType.VALUE: clip_grad_value, + GradientClipType.NORM: clip_grad_norm, + } + return _GRADIENT_CLIP_TYPE_TO_CLIPPER[GradientClipType(cfg.CLIP_TYPE)] + + +def _generate_optimizer_class_with_gradient_clipping(optimizer_type, gradient_clipper): + """ + Dynamically creates a new type that inherits the type of a given instance + and overrides the `step` method to add gradient clipping + """ + + def optimizer_wgc_step(self, closure=None): + for group in self.param_groups: + for p in group["params"]: + gradient_clipper(p) + super(type(self), self).step(closure) + + OptimizerWithGradientClip = type( + optimizer_type.__name__ + "WithGradientClip", + (optimizer_type,), + {"step": optimizer_wgc_step}, + ) + return OptimizerWithGradientClip + + +def maybe_add_gradient_clipping(config, optimizer): + """ + If gradient clipping is enabled through config options, wraps the existing + optimizer instance of some type OptimizerType to become an instance + of the new dynamically created class OptimizerTypeWithGradientClip + that inherits OptimizerType and overrides the `step` method to + include gradient clipping. + Args: + config: configuration options + optimizer: torch.optim.Optimizer + existing optimizer instance + Return: + optimizer: torch.optim.Optimizer + either the unmodified optimizer instance (if gradient clipping is + disabled), or the same instance with adjusted __class__ to override + the `step` method and include gradient clipping + """ + if not config.SOLVER.CLIP_GRADIENTS.ENABLED: + return optimizer + grad_clipper = _create_gradient_clipper(config.SOLVER.CLIP_GRADIENTS) + OptimizerWithGradientClip = _generate_optimizer_class_with_gradient_clipping( + type(optimizer), grad_clipper + ) + optimizer.__class__ = OptimizerWithGradientClip + return optimizer + + +def build_optimizer(config, model): + """Build an optimizer from config. + Args: + config: configuration file. + model: nn.Module, the model. + Returns: + A torch Optimizer. + Raises: + ValueError: optimizer type has unexpected value. + """ + norm_module_types = ( + torch.nn.BatchNorm1d, + torch.nn.BatchNorm2d, + torch.nn.BatchNorm3d, + torch.nn.SyncBatchNorm, + # NaiveSyncBatchNorm inherits from BatchNorm2d + torch.nn.GroupNorm, + torch.nn.InstanceNorm1d, + torch.nn.InstanceNorm2d, + torch.nn.InstanceNorm3d, + torch.nn.LayerNorm, + torch.nn.LocalResponseNorm, + ) + # A list of dict: List[Dict[str, Any]]. + params: List[Dict[str, Any]] = [] + memo: Set[torch.nn.parameter.Parameter] = set() + for module in model.modules(): + for key, value in module.named_parameters(recurse=False): + if not value.requires_grad: + continue + # Avoid duplicating parameters + if value in memo: + continue + memo.add(value) + lr = config.SOLVER.BASE_LR + weight_decay = config.SOLVER.WEIGHT_DECAY + if isinstance(module, norm_module_types): + weight_decay = config.SOLVER.WEIGHT_DECAY_NORM + elif key == "bias": + # NOTE: unlike Detectron v1, we now default BIAS_LR_FACTOR to 1.0 + # and WEIGHT_DECAY_BIAS to WEIGHT_DECAY so that bias optimizer + # hyperparameters are by default exactly the same as for regular + # weights. + lr = config.SOLVER.BASE_LR * config.SOLVER.BIAS_LR_FACTOR + weight_decay = config.SOLVER.WEIGHT_DECAY_BIAS + params += [{"params": [value], "lr": lr, "weight_decay": weight_decay}] + + if config.SOLVER.OPTIMIZER == "sgd": + optimizer = torch.optim.SGD(params, config.SOLVER.BASE_LR, momentum=config.SOLVER.MOMENTUM) + elif config.SOLVER.OPTIMIZER == "adam": + optimizer = torch.optim.Adam(params, config.SOLVER.BASE_LR, betas=config.SOLVER.ADAM_BETAS, + eps=config.SOLVER.ADAM_EPS) + else: + raise ValueError('Unknown optimizer: {}'.format(config.SOLVER.OPTIMIZER)) + optimizer = maybe_add_gradient_clipping(config, optimizer) + return optimizer + + +def build_lr_scheduler(config, optimizer): + """Build a LR scheduler from config. + Args: + config: configuration file. + optimizer: torch optimizer. + Returns: + A torch LRScheduler. + Raises: + ValueError: LRScheduler type has unexpected value. + """ + name = config.SOLVER.LR_SCHEDULER_NAME + if name == "WarmupMultiStepLR": + return WarmupMultiStepLR( + optimizer, + config.SOLVER.STEPS, + config.SOLVER.GAMMA, + warmup_factor=config.SOLVER.WARMUP_FACTOR, + warmup_iters=config.SOLVER.WARMUP_ITERS, + warmup_method=config.SOLVER.WARMUP_METHOD, + ) + elif name == "WarmupCosineLR": + return WarmupCosineLR( + optimizer, + config.TRAIN.MAX_ITER, + warmup_factor=config.SOLVER.WARMUP_FACTOR, + warmup_iters=config.SOLVER.WARMUP_ITERS, + warmup_method=config.SOLVER.WARMUP_METHOD, + ) + elif name == "WarmupPolyLR": + return WarmupPolyLR( + optimizer, + config.TRAIN.MAX_ITER, + warmup_factor=config.SOLVER.WARMUP_FACTOR, + warmup_iters=config.SOLVER.WARMUP_ITERS, + warmup_method=config.SOLVER.WARMUP_METHOD, + power=config.SOLVER.POLY_LR_POWER, + constant_ending=config.SOLVER.POLY_LR_CONSTANT_ENDING, + ) + else: + raise ValueError("Unknown LR scheduler: {}".format(name)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/lr_scheduler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/lr_scheduler.py new file mode 100644 index 000000000..27333bcf7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/lr_scheduler.py @@ -0,0 +1,162 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/solver/lr_scheduler.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import math +from bisect import bisect_right +from typing import List +import torch + +# NOTE: PyTorch's LR scheduler interface uses names that assume the LR changes +# only on epoch boundaries. We typically use iteration based schedules instead. +# As a result, "epoch" (e.g., as in self.last_epoch) should be understood to mean +# "iteration" instead. + +# FIXME: ideally this would be achieved with a CombinedLRScheduler, separating +# MultiStepLR with WarmupLR but the current LRScheduler design doesn't allow it. + + +class WarmupMultiStepLR(torch.optim.lr_scheduler._LRScheduler): + def __init__( + self, + optimizer: torch.optim.Optimizer, + milestones: List[int], + gamma: float = 0.1, + warmup_factor: float = 0.001, + warmup_iters: int = 1000, + warmup_method: str = "linear", + last_epoch: int = -1, + ): + if not list(milestones) == sorted(milestones): + raise ValueError( + "Milestones should be a list of" " increasing integers. Got {}", milestones + ) + self.milestones = milestones + self.gamma = gamma + self.warmup_factor = warmup_factor + self.warmup_iters = warmup_iters + self.warmup_method = warmup_method + super().__init__(optimizer, last_epoch) + + def get_lr(self) -> List[float]: + warmup_factor = _get_warmup_factor_at_iter( + self.warmup_method, self.last_epoch, self.warmup_iters, self.warmup_factor + ) + return [ + base_lr * warmup_factor * self.gamma ** bisect_right(self.milestones, self.last_epoch) + for base_lr in self.base_lrs + ] + + def _compute_values(self) -> List[float]: + # The new interface + return self.get_lr() + + +class WarmupCosineLR(torch.optim.lr_scheduler._LRScheduler): + def __init__( + self, + optimizer: torch.optim.Optimizer, + max_iters: int, + warmup_factor: float = 0.001, + warmup_iters: int = 1000, + warmup_method: str = "linear", + last_epoch: int = -1, + ): + self.max_iters = max_iters + self.warmup_factor = warmup_factor + self.warmup_iters = warmup_iters + self.warmup_method = warmup_method + super().__init__(optimizer, last_epoch) + + def get_lr(self) -> List[float]: + warmup_factor = _get_warmup_factor_at_iter( + self.warmup_method, self.last_epoch, self.warmup_iters, self.warmup_factor + ) + # Different definitions of half-cosine with warmup are possible. For + # simplicity we multiply the standard half-cosine schedule by the warmup + # factor. An alternative is to start the period of the cosine at warmup_iters + # instead of at 0. In the case that warmup_iters << max_iters the two are + # very close to each other. + return [ + base_lr + * warmup_factor + * 0.5 + * (1.0 + math.cos(math.pi * self.last_epoch / self.max_iters)) + for base_lr in self.base_lrs + ] + + def _compute_values(self) -> List[float]: + # The new interface + return self.get_lr() + + +class WarmupPolyLR(torch.optim.lr_scheduler._LRScheduler): + def __init__( + self, + optimizer: torch.optim.Optimizer, + max_iters: int, + warmup_factor: float = 0.001, + warmup_iters: int = 1000, + warmup_method: str = "linear", + last_epoch: int = -1, + power: float = 0.9, + constant_ending: float = 0. + ): + self.max_iters = max_iters + self.warmup_factor = warmup_factor + self.warmup_iters = warmup_iters + self.warmup_method = warmup_method + self.power = power + self.constant_ending = constant_ending + super().__init__(optimizer, last_epoch) + + def get_lr(self) -> List[float]: + warmup_factor = _get_warmup_factor_at_iter( + self.warmup_method, self.last_epoch, self.warmup_iters, self.warmup_factor + ) + if self.constant_ending > 0 and warmup_factor == 1.: + # Constant ending lr. + if math.pow((1.0 - self.last_epoch / self.max_iters), self.power) < self.constant_ending: + return [ + base_lr + * self.constant_ending + for base_lr in self.base_lrs + ] + return [ + base_lr + * warmup_factor + * math.pow((1.0 - self.last_epoch / self.max_iters), self.power) + for base_lr in self.base_lrs + ] + + def _compute_values(self) -> List[float]: + # The new interface + return self.get_lr() + + +def _get_warmup_factor_at_iter( + method: str, iter: int, warmup_iters: int, warmup_factor: float +) -> float: + """ + Return the learning rate warmup factor at a specific iteration. + See https://arxiv.org/abs/1706.02677 for more details. + Args: + method (str): warmup method; either "constant" or "linear". + iter (int): iteration at which to calculate the warmup factor. + warmup_iters (int): the number of warmup iterations. + warmup_factor (float): the base warmup factor (the meaning changes according + to the method used). + Returns: + float: the effective warmup factor at the given iteration. + """ + if iter >= warmup_iters: + return 1.0 + + if method == "constant": + return warmup_factor + elif method == "linear": + alpha = iter / warmup_iters + return warmup_factor * (1 - alpha) + alpha + else: + raise ValueError("Unknown warmup method: {}".format(method)) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/utils.py new file mode 100644 index 000000000..cfe61b36b --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/solver/utils.py @@ -0,0 +1,29 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/engine/hooks.py#L195 +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +from collections import Counter + + +def get_lr_group_id(optimizer): + """ + Returns the group id with majority of lr. + """ + # Get the correct parameter group id to access to lr info. + largest_group = max(len(g["params"]) for g in optimizer.param_groups) + if largest_group == 1: + # If all groups have one parameter, + # then find the most common initial LR, and use it for summary + lr_count = Counter([g["lr"] for g in optimizer.param_groups]) + lr = lr_count.most_common()[0][0] + for i, g in enumerate(optimizer.param_groups): + if g["lr"] == lr: + best_param_group_id = i + break + else: + for i, g in enumerate(optimizer.param_groups): + if len(g["params"]) == largest_group: + best_param_group_id = i + break + return best_param_group_id diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/__init__.py new file mode 100644 index 000000000..c2f22fd8f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/__init__.py @@ -0,0 +1,6 @@ +from .save_annotation import ( + save_annotation, save_instance_annotation, save_panoptic_annotation, save_center_image, save_heatmap_image, + save_heatmap_and_center_image, save_offset_image) +from .flow_vis import flow_compute_color +from .utils import AverageMeter +from .debug import save_debug_images diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py new file mode 100644 index 000000000..fad4cfd86 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/comm.py @@ -0,0 +1,257 @@ +# ------------------------------------------------------------------------------ +# This file contains primitives for multi-gpu communication. +# This is useful when doing distributed training. +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/comm.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import functools +import logging +import numpy as np +import pickle +import torch +import torch.distributed as dist + +_LOCAL_PROCESS_GROUP = None +""" +A torch process group which only includes processes that on the same machine as the current process. +This variable is set when processes are spawned by `launch()` in "engine/launch.py". +""" + + +def get_world_size() -> int: + if not dist.is_available(): + return 1 + if not dist.is_initialized(): + return 1 + return dist.get_world_size() + + +def get_rank() -> int: + if not dist.is_available(): + return 0 + if not dist.is_initialized(): + return 0 + return dist.get_rank() + + +def get_local_rank() -> int: + """ + Returns: + The rank of the current process within the local (per-machine) process group. + """ + if not dist.is_available(): + return 0 + if not dist.is_initialized(): + return 0 + assert _LOCAL_PROCESS_GROUP is not None + return dist.get_rank(group=_LOCAL_PROCESS_GROUP) + + +def get_local_size() -> int: + """ + Returns: + The size of the per-machine process group, + i.e. the number of processes per machine. + """ + if not dist.is_available(): + return 1 + if not dist.is_initialized(): + return 1 + return dist.get_world_size(group=_LOCAL_PROCESS_GROUP) + + +def is_main_process() -> bool: + return get_rank() == 0 + + +def synchronize(): + """ + Helper function to synchronize (barrier) among all processes when + using distributed training + """ + if not dist.is_available(): + return + if not dist.is_initialized(): + return + world_size = dist.get_world_size() + if world_size == 1: + return + dist.barrier() + + +@functools.lru_cache() +def _get_global_gloo_group(): + """ + Return a process group based on gloo backend, containing all the ranks + The result is cached. + """ + if dist.get_backend() == "nccl": + return dist.new_group(backend="gloo") + else: + return dist.group.WORLD + + +def _serialize_to_tensor(data, group): + backend = dist.get_backend(group) + assert backend in ["gloo", "nccl"] + device = torch.device("cpu" if backend == "gloo" else "cuda") + + buffer = pickle.dumps(data) + if len(buffer) > 1024 ** 3: + logger = logging.getLogger(__name__) + logger.warning( + "Rank {} trying to all-gather {:.2f} GB of data on device {}".format( + get_rank(), len(buffer) / (1024 ** 3), device + ) + ) + storage = torch.ByteStorage.from_buffer(buffer) + tensor = torch.ByteTensor(storage).to(device=device) + return tensor + + +def _pad_to_largest_tensor(tensor, group): + """ + Returns: + list[int]: size of the tensor, on each rank + Tensor: padded tensor that has the max size + """ + world_size = dist.get_world_size(group=group) + assert ( + world_size >= 1 + ), "comm.gather/all_gather must be called from ranks within the given group!" + local_size = torch.tensor([tensor.numel()], dtype=torch.int64, device=tensor.device) + size_list = [ + torch.zeros([1], dtype=torch.int64, device=tensor.device) for _ in range(world_size) + ] + dist.all_gather(size_list, local_size, group=group) + size_list = [int(size.item()) for size in size_list] + + max_size = max(size_list) + + # we pad the tensor because torch all_gather does not support + # gathering tensors of different shapes + if local_size != max_size: + padding = torch.zeros((max_size - local_size,), dtype=torch.uint8, device=tensor.device) + tensor = torch.cat((tensor, padding), dim=0) + return size_list, tensor + + +def all_gather(data, group=None): + """ + Run all_gather on arbitrary picklable data (not necessarily tensors). + Args: + data: any picklable object + group: a torch process group. By default, will use a group which + contains all ranks on gloo backend. + Returns: + list[data]: list of data gathered from each rank + """ + if get_world_size() == 1: + return [data] + if group is None: + group = _get_global_gloo_group() + if dist.get_world_size(group) == 1: + return [data] + + tensor = _serialize_to_tensor(data, group) + + size_list, tensor = _pad_to_largest_tensor(tensor, group) + max_size = max(size_list) + + # receiving Tensor from all ranks + tensor_list = [ + torch.empty((max_size,), dtype=torch.uint8, device=tensor.device) for _ in size_list + ] + dist.all_gather(tensor_list, tensor, group=group) + + data_list = [] + for size, tensor in zip(size_list, tensor_list): + buffer = tensor.cpu().numpy().tobytes()[:size] + data_list.append(pickle.loads(buffer)) + + return data_list + + +def gather(data, dst=0, group=None): + """ + Run gather on arbitrary picklable data (not necessarily tensors). + Args: + data: any picklable object + dst (int): destination rank + group: a torch process group. By default, will use a group which + contains all ranks on gloo backend. + Returns: + list[data]: on dst, a list of data gathered from each rank. Otherwise, + an empty list. + """ + if get_world_size() == 1: + return [data] + if group is None: + group = _get_global_gloo_group() + if dist.get_world_size(group=group) == 1: + return [data] + rank = dist.get_rank(group=group) + + tensor = _serialize_to_tensor(data, group) + size_list, tensor = _pad_to_largest_tensor(tensor, group) + + # receiving Tensor from all ranks + if rank == dst: + max_size = max(size_list) + tensor_list = [ + torch.empty((max_size,), dtype=torch.uint8, device=tensor.device) for _ in size_list + ] + dist.gather(tensor, tensor_list, dst=dst, group=group) + + data_list = [] + for size, tensor in zip(size_list, tensor_list): + buffer = tensor.cpu().numpy().tobytes()[:size] + data_list.append(pickle.loads(buffer)) + return data_list + else: + dist.gather(tensor, [], dst=dst, group=group) + return [] + + +def shared_random_seed(): + """ + Returns: + int: a random number that is the same across all workers. + If workers need a shared RNG, they can use this shared seed to + create one. + All workers must call this function, otherwise it will deadlock. + """ + ints = np.random.randint(2 ** 31) + all_ints = all_gather(ints) + return all_ints[0] + + +def reduce_dict(input_dict, average=True): + """ + Reduce the values in the dictionary from all processes so that process with rank + 0 has the reduced results. + Args: + input_dict (dict): inputs to be reduced. All the values must be scalar CUDA Tensor. + average (bool): whether to do average or sum + Returns: + a dict with the same keys as input_dict, after reduction. + """ + world_size = get_world_size() + if world_size < 2: + return input_dict + with torch.no_grad(): + names = [] + values = [] + # sort the keys so that they are consistent across processes + for k in sorted(input_dict.keys()): + names.append(k) + values.append(input_dict[k]) + values = torch.stack(values, dim=0) + dist.reduce(values, dst=0) + if dist.get_rank() == 0 and average: + # only main process gets accumulated, so only divide by + # world_size in this case + values /= world_size + reduced_dict = {k: v for k, v in zip(names, values)} + return reduced_dict diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py new file mode 100644 index 000000000..48d9f89a4 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py @@ -0,0 +1,196 @@ +# ------------------------------------------------------------------------------ +# Saves raw outputs and targets. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import os + +import numpy as np +import PIL.Image as img + +import torch + +from .save_annotation import label_to_color_image +from .flow_vis import flow_compute_color + + +def save_debug_images(dataset, batch_images, batch_targets, batch_outputs, out_dir=None, iteration=0, + target_keys=('semantic', 'center', 'offset', 'center_weights', 'offset_weights'), + output_keys=('semantic', 'center', 'offset'), + iteration_to_remove=-1, is_train=True): + """Saves a mini-batch of images for debugging purpose. + - image: the augmented input image + - label: the augmented labels including + - semantic: semantic segmentation label + - center: center heatmap + - offset: offset field + - instance_ignore_mask: ignore mask + - prediction: the raw output of the model (without post-processing) + - semantic: semantic segmentation label + - center: center heatmap + - offset: offset field + Args: + dataset: The Dataset. + batch_images: Tensor of shape [N, 3, H, W], a batch of input images. + batch_targets: Dict, a dict containing batch of targets. + - semantic: a Tensor of shape [N, H, W] + - center: a Tensor of shape [N, 1, H, W] + - offset: a Tensor of shape [N, 2, H, W] + - semantic_weights: a Tensor of shape [N, H, W] + - center_weights: a Tensor of shape [N, H, W] + - offset_weights: a Tensor of shape [N, H, W] + batch_outputs: Dict, a dict containing batch of outputs. + - semantic: a Tensor of shape [N, H, W] + - center: a Tensor of shape [N, 1, H, W] + - offset: a Tensor of shape [N, 2, H, W] + out_dir: String, the directory to which the results will be saved. + iteration: Integer, iteration number. + target_keys: List, target keys to save. + output_keys: List, output keys to save. + iteration_to_remove: Integer, iteration number to remove. + is_train: Boolean, save train or test debugging image. + """ + batch_size = batch_images.size(0) + map_height = batch_images.size(2) + map_width = batch_images.size(3) + + grid_image = np.zeros( + (map_height, batch_size * map_width, 3), dtype=np.uint8 + ) + + num_targets = len(target_keys) + grid_target = np.zeros( + (num_targets * map_height, batch_size * map_width, 3), dtype=np.uint8 + ) + + num_outputs = len(output_keys) + grid_output = np.zeros( + (num_outputs * map_height, batch_size * map_width, 3), dtype=np.uint8 + ) + + semantic_pred = torch.argmax(batch_outputs['semantic'].detach(), dim=1) + if 'foreground' in batch_outputs: + foreground_pred = torch.argmax(batch_outputs['foreground'].detach(), dim=1) + else: + foreground_pred = None + + for i in range(batch_size): + width_begin = map_width * i + width_end = map_width * (i + 1) + + # save images + image = dataset.reverse_transform(batch_images[i]) + grid_image[:, width_begin:width_end, :] = image + + if 'semantic' in target_keys: + # save gt semantic + gt_sem = batch_targets['semantic'][i].cpu().numpy() + gt_sem = label_to_color_image(gt_sem, dataset.create_label_colormap()) + grid_target[:map_height, width_begin:width_end, :] = gt_sem + + if 'center' in target_keys: + # save gt center + gt_ctr = batch_targets['center'][i].squeeze().cpu().numpy() + gt_ctr = gt_ctr[:, :, None] * np.array([255, 0, 0]).reshape((1, 1, 3)) + gt_ctr = gt_ctr.clip(0, 255) + # gt_ctr = 0.7 * gt_ctr + (1 - 0.3) * image + grid_target[map_height:2 * map_height, width_begin:width_end, :] = gt_ctr + + if 'offset' in target_keys: + # save gt offset + gt_off = batch_targets['offset'][i].permute(1, 2, 0).cpu().numpy() + gt_off = flow_compute_color(gt_off[:, :, 1], gt_off[:, :, 0]) + grid_target[2 * map_height:3 * map_height, width_begin:width_end, :] = gt_off + + if 'semantic_weights' in target_keys: + # save ignore mask + gt_ign = batch_targets['semantic_weights'][i].cpu().numpy() + gt_ign = gt_ign[:, :, None] / np.max(gt_ign) * 255 + gt_ign = np.tile(gt_ign, (1, 1, 3)) + grid_target[3 * map_height:4 * map_height, width_begin:width_end, :] = gt_ign + + if 'center_weights' in target_keys: + # save ignore mask + gt_ign = batch_targets['center_weights'][i].cpu().numpy() + gt_ign = gt_ign[:, :, None] * 255 + gt_ign = np.tile(gt_ign, (1, 1, 3)) + grid_target[4 * map_height:5 * map_height, width_begin:width_end, :] = gt_ign + + if 'offset_weights' in target_keys: + # save ignore mask + gt_ign = batch_targets['offset_weights'][i].cpu().numpy() + gt_ign = gt_ign[:, :, None] * 255 + gt_ign = np.tile(gt_ign, (1, 1, 3)) + grid_target[5 * map_height:6 * map_height, width_begin:width_end, :] = gt_ign + + if 'foreground' in target_keys: + # save gt foreground + gt_fg = batch_targets['foreground'][i].cpu().numpy() + gt_fg = gt_fg[:, :, None] * 255 + grid_target[6 * map_height:7 * map_height, width_begin:width_end, :] = gt_fg + + if 'semantic' in output_keys: + # save pred semantic + pred_sem = semantic_pred[i].cpu().numpy() + pred_sem = label_to_color_image(pred_sem, dataset.create_label_colormap()) + grid_output[:map_height, width_begin:width_end, :] = pred_sem + + if 'center' in output_keys: + # save pred center + pred_ctr = batch_outputs['center'][i].detach().squeeze().cpu().numpy() + pred_ctr = pred_ctr[:, :, None] * np.array([255, 0, 0]).reshape((1, 1, 3)) + pred_ctr = pred_ctr.clip(0, 255) + # pred_ctr = 0.7 * pred_ctr + (1 - 0.3) * image + grid_output[map_height:2 * map_height, width_begin:width_end, :] = pred_ctr + + if 'offset' in output_keys: + # save pred offset + pred_ctr = batch_outputs['offset'][i].detach().permute(1, 2, 0).cpu().numpy() + pred_ctr = flow_compute_color(pred_ctr[:, :, 1], pred_ctr[:, :, 0]) + grid_output[2 * map_height:3 * map_height, width_begin:width_end, :] = pred_ctr + + if 'foreground' in output_keys: + # save pred foreground + if foreground_pred is not None: + pred_fg = foreground_pred[i].cpu().numpy() + pred_fg = pred_fg[:, :, None] * 255 + grid_output[3 * map_height:4 * map_height, width_begin:width_end, :] = pred_fg + + if out_dir is not None: + if is_train: + pil_image = img.fromarray(grid_image.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_batch_images', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + pil_image = img.fromarray(grid_target.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_batch_targets', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + pil_image = img.fromarray(grid_output.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_batch_outputs', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + else: + pil_image = img.fromarray(grid_image.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_test_images', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + if grid_target.size: + pil_image = img.fromarray(grid_target.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_test_targets', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + pil_image = img.fromarray(grid_output.astype(dtype=np.uint8)) + with open('%s/%s_%d.png' % (out_dir, 'debug_test_outputs', iteration), mode='wb') as f: + pil_image.save(f, 'PNG') + + if is_train: + if iteration_to_remove >= 0: + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_images', iteration_to_remove)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_images', iteration_to_remove)) + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_targets', iteration_to_remove)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_targets', iteration_to_remove)) + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_outputs', iteration_to_remove)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_outputs', iteration_to_remove)) + # 0 is a special iter + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_images', 0)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_images', 0)) + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_targets', 0)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_targets', 0)) + if os.path.exists('%s/%s_%d.png' % (out_dir, 'debug_batch_outputs', 0)): + os.remove('%s/%s_%d.png' % (out_dir, 'debug_batch_outputs', 0)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/env.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/env.py new file mode 100644 index 000000000..b724dcf3e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/env.py @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/env.py#L15 +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import importlib +import importlib.util +import logging +import numpy as np +import os +import random +import sys +from datetime import datetime +import torch + +__all__ = ["seed_all_rng"] + + +def seed_all_rng(seed=None): + """ + Set the random seed for the RNG in torch, numpy and python. + Args: + seed (int): if None, will use a strong random seed. + """ + if seed is None: + seed = ( + os.getpid() + + int(datetime.now().strftime("%S%f")) + + int.from_bytes(os.urandom(2), "big") + ) + logger = logging.getLogger(__name__) + logger.info("Using a generated random seed {}".format(seed)) + np.random.seed(seed) + torch.set_rng_state(torch.manual_seed(seed).get_state()) + random.seed(seed) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/flow_vis.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/flow_vis.py new file mode 100644 index 000000000..6f4305d07 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/flow_vis.py @@ -0,0 +1,134 @@ +# MIT License +# +# Copyright (c) 2018 Tom Runia +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to conditions. +# +# Author: Tom Runia +# Date Created: 2018-08-03 +# Reference: https://github.com/tomrunia/OpticalFlow_Visualization + +import numpy as np + + +def make_colorwheel(): + ''' + Generates a color wheel for optical flow visualization as presented in: + Baker et al. "A Database and Evaluation Methodology for Optical Flow" (ICCV, 2007) + URL: http://vision.middlebury.edu/flow/flowEval-iccv07.pdf + According to the C++ source code of Daniel Scharstein + According to the Matlab source code of Deqing Sun + ''' + + RY = 15 + YG = 6 + GC = 4 + CB = 11 + BM = 13 + MR = 6 + + ncols = RY + YG + GC + CB + BM + MR + colorwheel = np.zeros((ncols, 3)) + col = 0 + + # RY + colorwheel[0:RY, 0] = 255 + colorwheel[0:RY, 1] = np.floor(255*np.arange(0,RY)/RY) + col = col+RY + # YG + colorwheel[col:col+YG, 0] = 255 - np.floor(255*np.arange(0,YG)/YG) + colorwheel[col:col+YG, 1] = 255 + col = col+YG + # GC + colorwheel[col:col+GC, 1] = 255 + colorwheel[col:col+GC, 2] = np.floor(255*np.arange(0,GC)/GC) + col = col+GC + # CB + colorwheel[col:col+CB, 1] = 255 - np.floor(255*np.arange(CB)/CB) + colorwheel[col:col+CB, 2] = 255 + col = col+CB + # BM + colorwheel[col:col+BM, 2] = 255 + colorwheel[col:col+BM, 0] = np.floor(255*np.arange(0,BM)/BM) + col = col+BM + # MR + colorwheel[col:col+MR, 2] = 255 - np.floor(255*np.arange(MR)/MR) + colorwheel[col:col+MR, 0] = 255 + return colorwheel + + +def flow_compute_color(u, v, convert_to_bgr=False): + ''' + Applies the flow color wheel to (possibly clipped) flow components u and v. + According to the C++ source code of Daniel Scharstein + According to the Matlab source code of Deqing Sun + :param u: np.ndarray, input horizontal flow + :param v: np.ndarray, input vertical flow + :param convert_to_bgr: bool, whether to change ordering and output BGR instead of RGB + :return: + ''' + + flow_image = np.zeros((u.shape[0], u.shape[1], 3), np.uint8) + + colorwheel = make_colorwheel() # shape [55x3] + ncols = colorwheel.shape[0] + + rad = np.sqrt(np.square(u) + np.square(v)) + a = np.arctan2(-v, -u)/np.pi + + fk = (a+1) / 2*(ncols-1) + k0 = np.floor(fk).astype(np.int32) + k1 = k0 + 1 + k1[k1 == ncols] = 0 + f = fk - k0 + + for i in range(colorwheel.shape[1]): + + tmp = colorwheel[:,i] + col0 = tmp[k0] / 255.0 + col1 = tmp[k1] / 255.0 + col = (1-f)*col0 + f*col1 + + idx = (rad <= 1) + col[idx] = 1 - rad[idx] * (1-col[idx]) + col[~idx] = col[~idx] * 0.75 # out of range? + + # Note the 2-i => BGR instead of RGB + ch_idx = 2-i if convert_to_bgr else i + flow_image[:,:,ch_idx] = np.floor(255 * col) + + return flow_image + + +def flow_to_color(flow_uv, clip_flow=None, convert_to_bgr=False): + ''' + Expects a two dimensional flow image of shape [H,W,2] + According to the C++ source code of Daniel Scharstein + According to the Matlab source code of Deqing Sun + :param flow_uv: np.ndarray of shape [H,W,2] + :param clip_flow: float, maximum clipping value for flow + :return: + ''' + + assert flow_uv.ndim == 3, 'input flow must have three dimensions' + assert flow_uv.shape[2] == 2, 'input flow must have shape [H,W,2]' + + if clip_flow is not None: + flow_uv = np.clip(flow_uv, 0, clip_flow) + + u = flow_uv[:,:,0] + v = flow_uv[:,:,1] + + rad = np.sqrt(np.square(u) + np.square(v)) + rad_max = np.max(rad) + + epsilon = 1e-5 + u = u / (rad_max + epsilon) + v = v / (rad_max + epsilon) + + return flow_compute_color(u, v, convert_to_bgr) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/logger.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/logger.py new file mode 100644 index 000000000..9d3f021d2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/logger.py @@ -0,0 +1,219 @@ +# ------------------------------------------------------------------------------ +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/logger.py +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import functools +import logging +import os +import sys +import time +from collections import Counter +from fvcore.common.file_io import PathManager +from tabulate import tabulate +from termcolor import colored + + +class _ColorfulFormatter(logging.Formatter): + def __init__(self, *args, **kwargs): + self._root_name = kwargs.pop("root_name") + "." + self._abbrev_name = kwargs.pop("abbrev_name", "") + if len(self._abbrev_name): + self._abbrev_name = self._abbrev_name + "." + super(_ColorfulFormatter, self).__init__(*args, **kwargs) + + def formatMessage(self, record): + record.name = record.name.replace(self._root_name, self._abbrev_name) + log = super(_ColorfulFormatter, self).formatMessage(record) + if record.levelno == logging.WARNING: + prefix = colored("WARNING", "red", attrs=["blink"]) + elif record.levelno == logging.ERROR or record.levelno == logging.CRITICAL: + prefix = colored("ERROR", "red", attrs=["blink", "underline"]) + else: + return log + return prefix + " " + log + + +@functools.lru_cache() # so that calling setup_logger multiple times won't add many handlers +def setup_logger( + output=None, distributed_rank=0, *, color=True, name="segmentation", abbrev_name=None +): + """ + Initialize the segmentation logger and set its verbosity level to "INFO". + Args: + output (str): a file name or a directory to save log. If None, will not save log file. + If ends with ".txt" or ".log", assumed to be a file name. + Otherwise, logs will be saved to `output/log.txt`. + name (str): the root module name of this logger + abbrev_name (str): an abbreviation of the module, to avoid long names in logs. + Set to "" to not log the root module in logs. + By default, will abbreviate "segmentation" to "seg" and leave other + modules unchanged. + Returns: + logging.Logger: a logger + """ + logger = logging.getLogger(name) + logger.setLevel(logging.DEBUG) + logger.propagate = False + + if abbrev_name is None: + abbrev_name = "seg" if name == "segmentation" else name + + plain_formatter = logging.Formatter( + "[%(asctime)s] %(name)s %(levelname)s: %(message)s", datefmt="%m/%d %H:%M:%S" + ) + # stdout logging: master only + if distributed_rank == 0: + ch = logging.StreamHandler(stream=sys.stdout) + ch.setLevel(logging.DEBUG) + if color: + formatter = _ColorfulFormatter( + colored("[%(asctime)s %(name)s]: ", "green") + "%(message)s", + datefmt="%m/%d %H:%M:%S", + root_name=name, + abbrev_name=str(abbrev_name), + ) + else: + formatter = plain_formatter + ch.setFormatter(formatter) + logger.addHandler(ch) + + # file logging: all workers + if output is not None: + if output.endswith(".txt") or output.endswith(".log"): + filename = output + else: + filename = os.path.join(output, "log.txt") + if distributed_rank > 0: + filename = filename + ".rank{}".format(distributed_rank) + # os.makedirs(os.path.dirname(filename)) + PathManager.mkdirs(os.path.dirname(filename)) + + fh = logging.StreamHandler(_cached_log_stream(filename)) + fh.setLevel(logging.DEBUG) + fh.setFormatter(plain_formatter) + logger.addHandler(fh) + + return logger + + +# cache the opened file object, so that different calls to `setup_logger` +# with the same file name can safely write to the same file. +@functools.lru_cache(maxsize=None) +def _cached_log_stream(filename): + return open(filename, "a") + + +""" +Below are some other convenient logging methods. +They are mainly adopted from +https://github.com/abseil/abseil-py/blob/master/absl/logging/__init__.py +""" + + +def _find_caller(): + """ + Returns: + str: module name of the caller + tuple: a hashable key to be used to identify different callers + """ + frame = sys._getframe(2) + while frame: + code = frame.f_code + if os.path.join("utils", "logger.") not in code.co_filename: + mod_name = frame.f_globals["__name__"] + if mod_name == "__main__": + mod_name = "segmentation" + return mod_name, (code.co_filename, frame.f_lineno, code.co_name) + frame = frame.f_back + + +_LOG_COUNTER = Counter() +_LOG_TIMER = {} + + +def log_first_n(lvl, msg, n=1, *, name=None, key="caller"): + """ + Log only for the first n times. + Args: + lvl (int): the logging level + msg (str): + n (int): + name (str): name of the logger to use. Will use the caller's module by default. + key (str or tuple[str]): the string(s) can be one of "caller" or + "message", which defines how to identify duplicated logs. + For example, if called with `n=1, key="caller"`, this function + will only log the first call from the same caller, regardless of + the message content. + If called with `n=1, key="message"`, this function will log the + same content only once, even if they are called from different places. + If called with `n=1, key=("caller", "message")`, this function + will not log only if the same caller has logged the same message before. + """ + if isinstance(key, str): + key = (key,) + assert len(key) > 0 + + caller_module, caller_key = _find_caller() + hash_key = () + if "caller" in key: + hash_key = hash_key + caller_key + if "message" in key: + hash_key = hash_key + (msg,) + + _LOG_COUNTER[hash_key] += 1 + if _LOG_COUNTER[hash_key] <= n: + logging.getLogger(name or caller_module).log(lvl, msg) + + +def log_every_n(lvl, msg, n=1, *, name=None): + """ + Log once per n times. + Args: + lvl (int): the logging level + msg (str): + n (int): + name (str): name of the logger to use. Will use the caller's module by default. + """ + caller_module, key = _find_caller() + _LOG_COUNTER[key] += 1 + if n == 1 or _LOG_COUNTER[key] % n == 1: + logging.getLogger(name or caller_module).log(lvl, msg) + + +def log_every_n_seconds(lvl, msg, n=1, *, name=None): + """ + Log no more than once per n seconds. + Args: + lvl (int): the logging level + msg (str): + n (int): + name (str): name of the logger to use. Will use the caller's module by default. + """ + caller_module, key = _find_caller() + last_logged = _LOG_TIMER.get(key, None) + current_time = time.time() + if last_logged is None or current_time - last_logged >= n: + logging.getLogger(name or caller_module).log(lvl, msg) + _LOG_TIMER[key] = current_time + + +def create_small_table(small_dict): + """ + Create a small table using the keys of small_dict as headers. This is only + suitable for small dictionaries. + Args: + small_dict (dict): a result dictionary of only a few items. + Returns: + str: the table as a string. + """ + keys, values = tuple(zip(*small_dict.items())) + table = tabulate( + [values], + headers=keys, + tablefmt="pipe", + floatfmt=".3f", + stralign="center", + numalign="center", + ) + return table \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py new file mode 100644 index 000000000..9f9823454 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/save_annotation.py @@ -0,0 +1,360 @@ +# ------------------------------------------------------------------------------ +# Saves output to png image for visualization. +# Reference: https://github.com/tensorflow/models/blob/master/research/deeplab/utils/save_annotation.py +# Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/colormap.py +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import numpy as np +import PIL.Image as img +from PIL import ImageDraw + +from .flow_vis import flow_compute_color + +# Refence: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/colormap.py#L14 +_COLORS = np.array( + [ + 0.000, 0.447, 0.741, + 0.850, 0.325, 0.098, + 0.929, 0.694, 0.125, + 0.494, 0.184, 0.556, + 0.466, 0.674, 0.188, + 0.301, 0.745, 0.933, + 0.635, 0.078, 0.184, + 0.300, 0.300, 0.300, + 0.600, 0.600, 0.600, + 1.000, 0.000, 0.000, + 1.000, 0.500, 0.000, + 0.749, 0.749, 0.000, + 0.000, 1.000, 0.000, + 0.000, 0.000, 1.000, + 0.667, 0.000, 1.000, + 0.333, 0.333, 0.000, + 0.333, 0.667, 0.000, + 0.333, 1.000, 0.000, + 0.667, 0.333, 0.000, + 0.667, 0.667, 0.000, + 0.667, 1.000, 0.000, + 1.000, 0.333, 0.000, + 1.000, 0.667, 0.000, + 1.000, 1.000, 0.000, + 0.000, 0.333, 0.500, + 0.000, 0.667, 0.500, + 0.000, 1.000, 0.500, + 0.333, 0.000, 0.500, + 0.333, 0.333, 0.500, + 0.333, 0.667, 0.500, + 0.333, 1.000, 0.500, + 0.667, 0.000, 0.500, + 0.667, 0.333, 0.500, + 0.667, 0.667, 0.500, + 0.667, 1.000, 0.500, + 1.000, 0.000, 0.500, + 1.000, 0.333, 0.500, + 1.000, 0.667, 0.500, + 1.000, 1.000, 0.500, + 0.000, 0.333, 1.000, + 0.000, 0.667, 1.000, + 0.000, 1.000, 1.000, + 0.333, 0.000, 1.000, + 0.333, 0.333, 1.000, + 0.333, 0.667, 1.000, + 0.333, 1.000, 1.000, + 0.667, 0.000, 1.000, + 0.667, 0.333, 1.000, + 0.667, 0.667, 1.000, + 0.667, 1.000, 1.000, + 1.000, 0.000, 1.000, + 1.000, 0.333, 1.000, + 1.000, 0.667, 1.000, + 0.333, 0.000, 0.000, + 0.500, 0.000, 0.000, + 0.667, 0.000, 0.000, + 0.833, 0.000, 0.000, + 1.000, 0.000, 0.000, + 0.000, 0.167, 0.000, + 0.000, 0.333, 0.000, + 0.000, 0.500, 0.000, + 0.000, 0.667, 0.000, + 0.000, 0.833, 0.000, + 0.000, 1.000, 0.000, + 0.000, 0.000, 0.167, + 0.000, 0.000, 0.333, + 0.000, 0.000, 0.500, + 0.000, 0.000, 0.667, + 0.000, 0.000, 0.833, + 0.000, 0.000, 1.000, + 0.000, 0.000, 0.000, + 0.143, 0.143, 0.143, + 0.857, 0.857, 0.857, + 1.000, 1.000, 1.000 + ] +).astype(np.float32).reshape(-1, 3) + + +def random_color(rgb=False, maximum=255): + """ + Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/colormap.py#L111 + Args: + rgb (bool): whether to return RGB colors or BGR colors. + maximum (int): either 255 or 1 + Returns: + ndarray: a vector of 3 numbers + """ + idx = np.random.randint(0, len(_COLORS)) + ret = _COLORS[idx] * maximum + if not rgb: + ret = ret[::-1] + return ret + + +def save_annotation(label, + save_dir, + filename, + add_colormap=True, + normalize_to_unit_values=False, + scale_values=False, + colormap=None, + image=None): + """Saves the given label to image on disk. + Args: + label: The numpy array to be saved. The data will be converted + to uint8 and saved as png image. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + add_colormap: Boolean, add color map to the label or not. + normalize_to_unit_values: Boolean, normalize the input values to [0, 1]. + scale_values: Boolean, scale the input values to [0, 255] for visualization. + colormap: A colormap for visualizing segmentation results. + image: merge label with image if provided + """ + # Add colormap for visualizing the prediction. + if add_colormap: + colored_label = label_to_color_image(label, colormap) + else: + colored_label = label + if normalize_to_unit_values: + min_value = np.amin(colored_label) + max_value = np.amax(colored_label) + range_value = max_value - min_value + if range_value != 0: + colored_label = (colored_label - min_value) / range_value + + if scale_values: + colored_label = 255. * colored_label + + if image is not None: + colored_label = 0.5 * colored_label + 0.5 * image + + pil_image = img.fromarray(colored_label.astype(dtype=np.uint8)) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def label_to_color_image(label, colormap=None): + """Adds color defined by the dataset colormap to the label. + Args: + label: A 2D array with integer type, storing the segmentation label. + colormap: A colormap for visualizing segmentation results. + Returns: + result: A 2D array with floating type. The element of the array + is the color indexed by the corresponding element in the input label + to the dataset color map. + Raises: + ValueError: If label is not of rank 2 or its value is larger than color + map maximum entry. + """ + if label.ndim != 2: + raise ValueError('Expect 2-D input label. Got {}'.format(label.shape)) + + if colormap is None: + raise ValueError('Expect a valid colormap.') + + return colormap[label] + + +def save_instance_annotation(label, + save_dir, + filename, + stuff_id=0, + image=None): + """Saves the given label to image on disk. + Args: + label: The numpy array to be saved. The data will be converted + to uint8 and saved as png image. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + stuff_id: Integer, id that not want to plot. + image: merge label with image if provided + """ + # Add colormap for visualizing the prediction. + ids = np.unique(label) + num_colors = len(ids) + colormap = np.zeros((num_colors, 3), dtype=np.uint8) + # Maps label to continuous value. + for i in range(num_colors): + label[label == ids[i]] = i + colormap[i, :] = random_color(rgb=True, maximum=255) + if ids[i] == stuff_id: + colormap[i, :] = np.array([0, 0, 0]) + colored_label = colormap[label] + + if image is not None: + colored_label = 0.5 * colored_label + 0.5 * image + + pil_image = img.fromarray(colored_label.astype(dtype=np.uint8)) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def save_panoptic_annotation(label, + save_dir, + filename, + label_divisor, + colormap=None, + image=None): + """Saves the given label to image on disk. + Args: + label: The numpy array to be saved. The data will be converted + to uint8 and saved as png image. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + label_divisor: An Integer, used to convert panoptic id = semantic id * label_divisor + instance_id. + colormap: A colormap for visualizing segmentation results. + image: merge label with image if provided + """ + if colormap is None: + raise ValueError('Expect a valid colormap.') + + # Add colormap to label. + colored_label = np.zeros((label.shape[0], label.shape[1], 3), dtype=np.uint8) + taken_colors = set([0, 0, 0]) + + def _random_color(base, max_dist=30): + new_color = base + np.random.randint(low=-max_dist, + high=max_dist + 1, + size=3) + return tuple(np.maximum(0, np.minimum(255, new_color))) + + for lab in np.unique(label): + mask = label == lab + base_color = colormap[lab // label_divisor] + if tuple(base_color) not in taken_colors: + taken_colors.add(tuple(base_color)) + color = base_color + else: + while True: + color = _random_color(base_color) + if color not in taken_colors: + taken_colors.add(color) + break + colored_label[mask] = color + + if image is not None: + colored_label = 0.5 * colored_label + 0.5 * image + + pil_image = img.fromarray(colored_label.astype(dtype=np.uint8)) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def save_center_image(image, + center_points, + save_dir, + filename, + radius=3): + """Saves image with center points. + Args: + image: The image. + center_points: List of tuple [(y, x)], center point coordinates. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + radius: Int, radius of the center point. + """ + pil_image = img.fromarray(image.astype(dtype=np.uint8)) + draw = ImageDraw.Draw(pil_image) + r = radius + assigned_colors = [list(random_color(rgb=True, maximum=255)) + [255] for _ in range(len(center_points))] + for i, point in enumerate(center_points): + leftUpPoint = (point[1] - r, point[0] - r) + rightDownPoint = (point[1] + r, point[0] + r) + twoPointList = [leftUpPoint, rightDownPoint] + draw.ellipse(twoPointList, fill=tuple(assigned_colors[i])) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def save_heatmap_image(image, + center_heatmap, + save_dir, + filename, + ratio=0.5): + """Saves image with heatmap. + Args: + image: The image. + center_heatmap: Ndarray, center heatmap. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + radio: Float, ratio to mix heatmap and image, out = ratio * heatmap + (1 - ratio) * image. + """ + center_heatmap = center_heatmap[:, :, None] * np.array([255, 0, 0]).reshape((1, 1, 3)) + center_heatmap = center_heatmap.clip(0, 255) + image = ratio * center_heatmap + (1 - ratio) * image + pil_image = img.fromarray(image.astype(dtype=np.uint8)) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def save_heatmap_and_center_image(image, + center_heatmap, + center_points, + save_dir, + filename, + ratio=0.5, + radius=25, + binarize_heatmap=True): + """Saves image with non-negative heatmap and center radius. + Args: + image: The image. + center_heatmap: Ndarray, center heatmap. + center_points: List of tuple [(y, x)], center point coordinates. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + radio: Float, ratio to mix heatmap and image, out = ratio * heatmap + (1 - ratio) * image. + radius: Int, radius of the center point. + """ + if binarize_heatmap: + center_heatmap = (center_heatmap[:, :, None] > 0) * np.array([255, 0, 0]).reshape((1, 1, 3)) + else: + center_heatmap = center_heatmap[:, :, None] * np.array([255, 0, 0]).reshape((1, 1, 3)) + center_heatmap = center_heatmap.clip(0, 255) + image = ratio * center_heatmap + (1 - ratio) * image + pil_image = img.fromarray(image.astype(dtype=np.uint8)) + draw = ImageDraw.Draw(pil_image) + r = radius + assigned_colors = [list(random_color(rgb=True, maximum=255)) + [255] for _ in range(len(center_points))] + for i, point in enumerate(center_points): + leftUpPoint = (point[1] - r, point[0] - r) + rightDownPoint = (point[1] + r, point[0] + r) + twoPointList = [leftUpPoint, rightDownPoint] + if binarize_heatmap: + draw.ellipse(twoPointList, outline='blue') + else: + draw.ellipse(twoPointList, fill=tuple(assigned_colors[i])) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') + + +def save_offset_image(offset, + save_dir, + filename): + """Saves image with heatmap. + Args: + image: The offset to save. + save_dir: String, the directory to which the results will be saved. + filename: String, the image filename. + """ + offset_image = flow_compute_color(offset[:, :, 1], offset[:, :, 0]) + pil_image = img.fromarray(offset_image.astype(dtype=np.uint8)) + with open('%s/%s.png' % (save_dir, filename), mode='wb') as f: + pil_image.save(f, 'PNG') diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/test_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/test_utils.py new file mode 100644 index 000000000..827781541 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/test_utils.py @@ -0,0 +1,137 @@ +# ------------------------------------------------------------------------------ +# Utility functions for multi-scale testing. +# Written by Pingjun (https://github.com/bowenc0221/panoptic-deeplab/issues/25) +# Modified by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ +import cv2 +from collections import OrderedDict + +import numpy as np +import torch +import torch.nn.functional as F + +import segmentation.data.transforms.transforms as T + + +def flip_tensor(x, dim): + """ + Flip Tensor along a dimension + """ + dim = x.dim() + dim if dim < 0 else dim + return x[tuple(slice(None, None) if i != dim + else torch.arange(x.size(i) - 1, -1, -1).long() + for i in range(x.dim()))] + + +def upsample_predictions(pred, input_shape,scale): + # Override upsample method to correctly handle `offset` + result = OrderedDict() + for key in pred.keys(): + out = F.interpolate(pred[key], size=input_shape, mode='bilinear', align_corners=True) + if 'offset' in key: #The order of second dim is (offset_y, offset_x) + out *= 1.0 / scale + result[key] = out + return result + +def get_semantic_segmentation(sem): + """ + Post-processing for semantic segmentation branch. + Arguments: + sem: A Tensor of shape [N, C, H, W], where N is the batch size, for consistent, we only + support N=1. + Returns: + A Tensor of shape [1, H, W] (to be gathered by distributed data parallel). + Raises: + ValueError, if batch size is not 1. + """ + if sem.size(0) != 1: + raise ValueError('Only supports inference for batch size = 1') + sem = sem.squeeze(0) + return torch.argmax(sem, dim=0, keepdim=True) + +def multi_scale_inference(config, model, raw_image, t_image, device): + scales = config.TEST.SCALE_LIST + flip = config.TEST.FLIP_TEST + # output_stride = 2 ** (5 - sum(config.MODEL.BACKBONE.DILATION)) + # train_crop_h, train_crop_w = config.TEST.CROP_SIZE + # scale = 1. / output_stride + # pool_h = int((float(train_crop_h) - 1.0) * scale + 1.0) + # pool_w = int((float(train_crop_w) - 1.0) * scale + 1.0) + # transforms + transforms = T.Compose( + [ + T.ToTensor(), + T.Normalize(config.DATASET.MEAN, config.DATASET.STD) + ] + ) + if flip: + flip_range = 2 + else: + flip_range = 1 + + # h,w,_ = raw_image.shape + _, _, h, w = t_image.shape + org_h_pad = (h + 31) // 32 * 32 + org_w_pad = (w + 31) // 32 * 32 + + sum_semantic_with_flip = 0 + sum_center_with_flip = 0 + sum_offset_with_flip = 0 + + for i in range(len(scales)): + image = raw_image + scale = scales[i] + raw_h = int(h * scale) + raw_w = int(w * scale) + + image = cv2.resize(image, None, fx=scale, fy=scale, interpolation=cv2.INTER_LINEAR).astype(np.int32) + nh,nw,_ = image.shape + + # pad image + new_h = (raw_h + 31) // 32 * 32 + new_w = (raw_w + 31) // 32 * 32 + input_image = np.zeros((new_h, new_w, 3), dtype=np.uint8) + input_image[:, :] = config.DATASET.MEAN + # input_image[:raw_h, :raw_w, :] = image + input_image[:nh, :nw, :] = image + + image, _ = transforms(input_image, None) + image = image.unsqueeze(0).to(device) + + + model = model.to(device) + + for flip in range(flip_range): + if flip: + image = flip_tensor(image, 3) + out_dict = model(image) + for key in out_dict.keys(): # return to raw_input shape + out_dict[key] = out_dict[key][:, :, : raw_h, : raw_w] + + if raw_h != org_h_pad or raw_w != org_w_pad: + out_dict = upsample_predictions(out_dict, (org_h_pad, org_w_pad), scale) + + # average softmax or logit? + semantic_pred = out_dict['semantic'] + # semantic_pred = F.softmax(out_dict['semantic'],dim=1) + + center_pred = out_dict['center'] + offset_pred = out_dict['offset'] + if flip: + semantic_pred = flip_tensor(semantic_pred,3) + center_pred = flip_tensor(center_pred,3) + offset_pred = flip_tensor(offset_pred,3) + offset_pred[:, 1, :, :] *= (-1) + + sum_semantic_with_flip += semantic_pred + sum_center_with_flip += center_pred + sum_offset_with_flip += offset_pred + + semantic_mean = sum_semantic_with_flip / (flip_range * len(scales)) + center_mean = sum_center_with_flip / (flip_range * len(scales)) + offset_mean = sum_offset_with_flip / (flip_range * len(scales)) + + out_dict['semantic'] = semantic_mean + out_dict['center'] = center_mean + out_dict['offset'] = offset_mean + return out_dict diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/utils.py new file mode 100644 index 000000000..14742dd58 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/segmentation/utils/utils.py @@ -0,0 +1,52 @@ +# ------------------------------------------------------------------------------ +# Utility functions. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ +import torch + + +class AverageMeter(object): + """Computes and stores the average and current value""" + def __init__(self): + self.reset() + + def reset(self): + self.val = 0 + self.avg = 0 + self.sum = 0 + self.count = 0 + + def update(self, val, n=1): + self.val = val + self.sum += val * n + self.count += n + self.avg = self.sum / self.count if self.count != 0 else 0 + + +def get_loss_info_str(loss_meter_dict): + msg = '' + for key in loss_meter_dict.keys(): + msg += '{name}: {meter.val:.3e} ({meter.avg:.3e})\t'.format( + name=key, meter=loss_meter_dict[key] + ) + + return msg + + +def to_cuda(batch, device): + if type(batch) == torch.Tensor: + batch = batch.to(device) + elif type(batch) == dict: + for key in batch.keys(): + batch[key] = to_cuda(batch[key], device) + elif type(batch) == list: + for i in range(len(batch)): + batch[i] = to_cuda(batch[i], device) + return batch + + +def get_module(model, distributed): + if distributed: + return model.module + else: + return model diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/BaseDataset.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/BaseDataset.py new file mode 100644 index 000000000..3544e6127 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/BaseDataset.py @@ -0,0 +1,161 @@ +import os +import cv2 +cv2.setNumThreads(0) +import torch +import numpy as np +from random import shuffle + +import torch.utils.data as data + + +class BaseDataset(data.Dataset): + def __init__(self, setting, split_name, preprocess=None, file_length=None): + super(BaseDataset, self).__init__() + self._split_name = split_name + self._img_path = setting['img_root'] + self._gt_path = setting['gt_root'] + self._portion = setting['portion'] if 'portion' in setting else None + self._train_source = setting['train_source'] + self._eval_source = setting['eval_source'] + self._test_source = setting['test_source'] if 'test_source' in setting else setting['eval_source'] + self._down_sampling = setting['down_sampling'] + print("using downsampling:", self._down_sampling) + self._file_names = self._get_file_names(split_name) + print("Found %d images"%len(self._file_names)) + self._file_length = file_length + self.preprocess = preprocess + + def __len__(self): + if self._file_length is not None: + return self._file_length + return len(self._file_names) + + def __getitem__(self, index): + if self._file_length is not None: + names = self._construct_new_file_names(self._file_length)[index] + else: + names = self._file_names[index] + img_path = os.path.join(self._img_path, names[0]) + gt_path = os.path.join(self._gt_path, names[1]) + item_name = names[1].split("/")[-1].split(".")[0] + + img, gt = self._fetch_data(img_path, gt_path) + img = img[:, :, ::-1] + if self.preprocess is not None: + img, gt, extra_dict = self.preprocess(img, gt) + + if self._split_name is 'train': + img = torch.from_numpy(np.ascontiguousarray(img)).float() + gt = torch.from_numpy(np.ascontiguousarray(gt)).long() + if self.preprocess is not None and extra_dict is not None: + for k, v in extra_dict.items(): + extra_dict[k] = torch.from_numpy(np.ascontiguousarray(v)) + if 'label' in k: + extra_dict[k] = extra_dict[k].long() + if 'img' in k: + extra_dict[k] = extra_dict[k].float() + + output_dict = dict(data=img, label=gt, fn=str(item_name), + n=len(self._file_names)) + if self.preprocess is not None and extra_dict is not None: + output_dict.update(**extra_dict) + + return output_dict + + def _fetch_data(self, img_path, gt_path, dtype=None): + img = self._open_image(img_path, down_sampling=self._down_sampling) + gt = self._open_image(gt_path, cv2.IMREAD_GRAYSCALE, dtype=dtype, down_sampling=self._down_sampling) + + return img, gt + + def _get_file_names(self, split_name): + assert split_name in ['train', 'val', 'test'] + source = self._train_source + if split_name == "val": + source = self._eval_source + elif split_name == 'test': + source = self._test_source + + file_names = [] + with open(source) as f: + files = f.readlines() + if self._portion is not None: + shuffle(files) + num_files = len(files) + if self._portion > 0: + split = int(np.floor(self._portion * num_files)) + files = files[:split] + elif self._portion < 0: + split = int(np.floor((1 + self._portion) * num_files)) + files = files[split:] + + for item in files: + img_name, gt_name = self._process_item_names(item) + file_names.append([img_name, gt_name]) + + return file_names + + def _construct_new_file_names(self, length): + assert isinstance(length, int) + files_len = len(self._file_names) + new_file_names = self._file_names * (length // files_len) + + rand_indices = torch.randperm(files_len).tolist() + new_indices = rand_indices[:length % files_len] + + new_file_names += [self._file_names[i] for i in new_indices] + + return new_file_names + + @staticmethod + def _process_item_names(item): + item = item.strip() + # item = item.split('\t') + item = item.split(' ') + img_name = item[0] + gt_name = item[1] + + return img_name, gt_name + + def get_length(self): + return self.__len__() + + @staticmethod + def _open_image(filepath, mode=cv2.IMREAD_COLOR, dtype=None, down_sampling=1): + # cv2: B G R + # h w c + img = np.array(cv2.imread(filepath, mode), dtype=dtype) + + if isinstance(down_sampling, int): + H, W = img.shape[:2] + if len(img.shape) == 3: + img = cv2.resize(img, (W // down_sampling, H // down_sampling), interpolation=cv2.INTER_LINEAR) + else: + img = cv2.resize(img, (W // down_sampling, H // down_sampling), interpolation=cv2.INTER_NEAREST) + assert img.shape[0] == H // down_sampling and img.shape[1] == W // down_sampling + else: + assert (isinstance(down_sampling, tuple) or isinstance(down_sampling, list)) and len(down_sampling) == 2 + if len(img.shape) == 3: + img = cv2.resize(img, (down_sampling[1], down_sampling[0]), interpolation=cv2.INTER_LINEAR) + else: + img = cv2.resize(img, (down_sampling[1], down_sampling[0]), interpolation=cv2.INTER_NEAREST) + assert img.shape[0] == down_sampling[0] and img.shape[1] == down_sampling[1] + + return img + + @classmethod + def get_class_colors(*args): + raise NotImplementedError + + @classmethod + def get_class_names(*args): + raise NotImplementedError + + +if __name__ == "__main__": + data_setting = {'img_root': '', + 'gt_root': '', + 'train_source': '', + 'eval_source': ''} + bd = BaseDataset(data_setting, 'train', None) + print(bd.get_class_names()) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/__init__.py new file mode 100644 index 000000000..a15449562 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/__init__.py @@ -0,0 +1,6 @@ +from .cityscapes import Cityscapes +from .bdd import BDD +from .coco import COCO +from .camvid import CamVid + +__all__ = ['Cityscapes', 'BDD', 'CamVid', 'COCO'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/__init__.py new file mode 100644 index 000000000..8304abb9d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/__init__.py @@ -0,0 +1,3 @@ +from .bdd import BDD + +__all__ = ['BDD'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/bdd.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/bdd.py new file mode 100644 index 000000000..959e8f13c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/bdd/bdd.py @@ -0,0 +1,41 @@ +# import numpy as np + +from datasets.BaseDataset import BaseDataset + + +class BDD(BaseDataset): + # trans_labels = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] + + @classmethod + def get_class_colors(*args): + return [[128, 64, 128], [244, 35, 232], [70, 70, 70], + [102, 102, 156], [190, 153, 153], [153, 153, 153], + [250, 170, 30], [220, 220, 0], [107, 142, 35], + [152, 251, 152], [70, 130, 180], [220, 20, 60], [255, 0, 0], + [0, 0, 142], [0, 0, 70], [0, 60, 100], [0, 80, 100], + [0, 0, 230], [119, 11, 32]] + + @classmethod + def get_class_names(*args): + # class counting(gtFine) + # 2953 2811 2934 970 1296 2949 1658 2808 2891 1654 2686 2343 1023 2832 + # 359 274 142 513 1646 + return ['road', 'sidewalk', 'building', 'wall', 'fence', 'pole', + 'traffic light', 'traffic sign', + 'vegetation', 'terrain', 'sky', 'person', 'rider', 'car', + 'truck', 'bus', 'train', 'motorcycle', 'bicycle'] + + # @classmethod + # def transform_label(cls, pred, name): + # label = np.zeros(pred.shape) + # ids = np.unique(pred) + # for id in ids: + # label[np.where(pred == id)] = cls.trans_labels[id] + + # new_name = (name.split('.')[0]).split('_')[:-1] + # new_name = '_'.join(new_name) + '.png' + + # print('Trans', name, 'to', new_name, ' ', + # np.unique(np.array(pred, np.uint8)), ' ---------> ', + # np.unique(np.array(label, np.uint8))) + # return label, new_name diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/__init__.py new file mode 100644 index 000000000..a4b01749c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/__init__.py @@ -0,0 +1,3 @@ +from .camvid import CamVid + +__all__ = ['CamVid'] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/camvid.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/camvid.py new file mode 100644 index 000000000..1b3cf161e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/camvid/camvid.py @@ -0,0 +1,17 @@ +from datasets.BaseDataset import BaseDataset + + +class CamVid(BaseDataset): + @classmethod + def get_class_colors(*args): + return [[128, 0, 0], [128, 128, 0], [128, 128, 128], [64, 0, 128], + [192, 128, 128], [128, 64, 128], [64, 64, 0], [64, 64, 128], + [192, 192, 128], [0, 0, 192], [0, 128, 192]] + + @classmethod + def get_class_names(*args): + # class counting(gtFine) + # 2953 2811 2934 970 1296 2949 1658 2808 2891 1654 2686 2343 1023 2832 + # 359 274 142 513 1646 + return ['Building', 'Tree', 'Sky', 'Car', 'Sign-Symbol', 'Road', + 'Pedestrian', 'Fence', 'Column-Pole', 'Side-Walk', 'Bicyclist', 'Void'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/__init__.py new file mode 100644 index 000000000..538cf4da0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/__init__.py @@ -0,0 +1,3 @@ +from .cityscapes import Cityscapes + +__all__ = ['Cityscapes'] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py new file mode 100644 index 000000000..47efdafcb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes.py @@ -0,0 +1,42 @@ +import numpy as np + +from datasets.BaseDataset import BaseDataset + + +class Cityscapes(BaseDataset): + trans_labels = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 31, 32, 33] + + @classmethod + def get_class_colors(*args): + return [[128, 64, 128], [244, 35, 232], [70, 70, 70], + [102, 102, 156], [190, 153, 153], [153, 153, 153], + [250, 170, 30], [220, 220, 0], [107, 142, 35], + [152, 251, 152], [70, 130, 180], [220, 20, 60], [255, 0, 0], + [0, 0, 142], [0, 0, 70], [0, 60, 100], [0, 80, 100], + [0, 0, 230], [119, 11, 32]] + + @classmethod + def get_class_names(*args): + # class counting(gtFine) + # 2953 2811 2934 970 1296 2949 1658 2808 2891 1654 2686 2343 1023 2832 + # 359 274 142 513 1646 + return ['road', 'sidewalk', 'building', 'wall', 'fence', 'pole', + 'traffic light', 'traffic sign', + 'vegetation', 'terrain', 'sky', 'person', 'rider', 'car', + 'truck', 'bus', 'train', 'motorcycle', 'bicycle'] + + @classmethod + def transform_label(cls, pred, name): + label = np.zeros(pred.shape) + ids = np.unique(pred) + for id in ids: + label[np.where(pred == id)] = cls.trans_labels[id] + + new_name = (name.split('.')[0]).split('_')[:-1] + new_name = '_'.join(new_name) + '.png' + + print('Trans', name, 'to', new_name, ' ', + np.unique(np.array(pred, np.uint8)), ' ---------> ', + np.unique(np.array(label, np.uint8))) + return label, new_name \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_test.txt b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_test.txt new file mode 100644 index 000000000..36db09eb7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_test.txt @@ -0,0 +1,1525 @@ +leftImg8bit/test/berlin/berlin_000000_000019_leftImg8bit.png gtFine/test/berlin/berlin_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000001_000019_leftImg8bit.png gtFine/test/berlin/berlin_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000002_000019_leftImg8bit.png gtFine/test/berlin/berlin_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000003_000019_leftImg8bit.png gtFine/test/berlin/berlin_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000004_000019_leftImg8bit.png gtFine/test/berlin/berlin_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000005_000019_leftImg8bit.png gtFine/test/berlin/berlin_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000006_000019_leftImg8bit.png gtFine/test/berlin/berlin_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000007_000019_leftImg8bit.png gtFine/test/berlin/berlin_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000008_000019_leftImg8bit.png gtFine/test/berlin/berlin_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000009_000019_leftImg8bit.png gtFine/test/berlin/berlin_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000010_000019_leftImg8bit.png gtFine/test/berlin/berlin_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000011_000019_leftImg8bit.png gtFine/test/berlin/berlin_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000012_000019_leftImg8bit.png gtFine/test/berlin/berlin_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000013_000019_leftImg8bit.png gtFine/test/berlin/berlin_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000014_000019_leftImg8bit.png gtFine/test/berlin/berlin_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000015_000019_leftImg8bit.png gtFine/test/berlin/berlin_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000016_000019_leftImg8bit.png gtFine/test/berlin/berlin_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000017_000019_leftImg8bit.png gtFine/test/berlin/berlin_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000018_000019_leftImg8bit.png gtFine/test/berlin/berlin_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000019_000019_leftImg8bit.png gtFine/test/berlin/berlin_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000020_000019_leftImg8bit.png gtFine/test/berlin/berlin_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000021_000019_leftImg8bit.png gtFine/test/berlin/berlin_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000022_000019_leftImg8bit.png gtFine/test/berlin/berlin_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000023_000019_leftImg8bit.png gtFine/test/berlin/berlin_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000024_000019_leftImg8bit.png gtFine/test/berlin/berlin_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000025_000019_leftImg8bit.png gtFine/test/berlin/berlin_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000026_000019_leftImg8bit.png gtFine/test/berlin/berlin_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000027_000019_leftImg8bit.png gtFine/test/berlin/berlin_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000028_000019_leftImg8bit.png gtFine/test/berlin/berlin_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000029_000019_leftImg8bit.png gtFine/test/berlin/berlin_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000030_000019_leftImg8bit.png gtFine/test/berlin/berlin_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000031_000019_leftImg8bit.png gtFine/test/berlin/berlin_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000032_000019_leftImg8bit.png gtFine/test/berlin/berlin_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000033_000019_leftImg8bit.png gtFine/test/berlin/berlin_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000034_000019_leftImg8bit.png gtFine/test/berlin/berlin_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000035_000019_leftImg8bit.png gtFine/test/berlin/berlin_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000036_000019_leftImg8bit.png gtFine/test/berlin/berlin_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000037_000019_leftImg8bit.png gtFine/test/berlin/berlin_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000038_000019_leftImg8bit.png gtFine/test/berlin/berlin_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000039_000019_leftImg8bit.png gtFine/test/berlin/berlin_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000040_000019_leftImg8bit.png gtFine/test/berlin/berlin_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000041_000019_leftImg8bit.png gtFine/test/berlin/berlin_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000042_000019_leftImg8bit.png gtFine/test/berlin/berlin_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000043_000019_leftImg8bit.png gtFine/test/berlin/berlin_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000044_000019_leftImg8bit.png gtFine/test/berlin/berlin_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000045_000019_leftImg8bit.png gtFine/test/berlin/berlin_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000046_000019_leftImg8bit.png gtFine/test/berlin/berlin_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000047_000019_leftImg8bit.png gtFine/test/berlin/berlin_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000048_000019_leftImg8bit.png gtFine/test/berlin/berlin_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000049_000019_leftImg8bit.png gtFine/test/berlin/berlin_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000050_000019_leftImg8bit.png gtFine/test/berlin/berlin_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000051_000019_leftImg8bit.png gtFine/test/berlin/berlin_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000052_000019_leftImg8bit.png gtFine/test/berlin/berlin_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000053_000019_leftImg8bit.png gtFine/test/berlin/berlin_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000054_000019_leftImg8bit.png gtFine/test/berlin/berlin_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000055_000019_leftImg8bit.png gtFine/test/berlin/berlin_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000056_000019_leftImg8bit.png gtFine/test/berlin/berlin_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000057_000019_leftImg8bit.png gtFine/test/berlin/berlin_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000058_000019_leftImg8bit.png gtFine/test/berlin/berlin_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000059_000019_leftImg8bit.png gtFine/test/berlin/berlin_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000060_000019_leftImg8bit.png gtFine/test/berlin/berlin_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000061_000019_leftImg8bit.png gtFine/test/berlin/berlin_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000062_000019_leftImg8bit.png gtFine/test/berlin/berlin_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000063_000019_leftImg8bit.png gtFine/test/berlin/berlin_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000064_000019_leftImg8bit.png gtFine/test/berlin/berlin_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000065_000019_leftImg8bit.png gtFine/test/berlin/berlin_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000066_000019_leftImg8bit.png gtFine/test/berlin/berlin_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000067_000019_leftImg8bit.png gtFine/test/berlin/berlin_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000068_000019_leftImg8bit.png gtFine/test/berlin/berlin_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000069_000019_leftImg8bit.png gtFine/test/berlin/berlin_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000070_000019_leftImg8bit.png gtFine/test/berlin/berlin_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000071_000019_leftImg8bit.png gtFine/test/berlin/berlin_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000072_000019_leftImg8bit.png gtFine/test/berlin/berlin_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000073_000019_leftImg8bit.png gtFine/test/berlin/berlin_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000074_000019_leftImg8bit.png gtFine/test/berlin/berlin_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000075_000019_leftImg8bit.png gtFine/test/berlin/berlin_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000076_000019_leftImg8bit.png gtFine/test/berlin/berlin_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000077_000019_leftImg8bit.png gtFine/test/berlin/berlin_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000078_000019_leftImg8bit.png gtFine/test/berlin/berlin_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000079_000019_leftImg8bit.png gtFine/test/berlin/berlin_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000080_000019_leftImg8bit.png gtFine/test/berlin/berlin_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000081_000019_leftImg8bit.png gtFine/test/berlin/berlin_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000082_000019_leftImg8bit.png gtFine/test/berlin/berlin_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000083_000019_leftImg8bit.png gtFine/test/berlin/berlin_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000084_000019_leftImg8bit.png gtFine/test/berlin/berlin_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000085_000019_leftImg8bit.png gtFine/test/berlin/berlin_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000086_000019_leftImg8bit.png gtFine/test/berlin/berlin_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000087_000019_leftImg8bit.png gtFine/test/berlin/berlin_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000088_000019_leftImg8bit.png gtFine/test/berlin/berlin_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000089_000019_leftImg8bit.png gtFine/test/berlin/berlin_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000090_000019_leftImg8bit.png gtFine/test/berlin/berlin_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000091_000019_leftImg8bit.png gtFine/test/berlin/berlin_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000092_000019_leftImg8bit.png gtFine/test/berlin/berlin_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000093_000019_leftImg8bit.png gtFine/test/berlin/berlin_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000094_000019_leftImg8bit.png gtFine/test/berlin/berlin_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000095_000019_leftImg8bit.png gtFine/test/berlin/berlin_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000096_000019_leftImg8bit.png gtFine/test/berlin/berlin_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000097_000019_leftImg8bit.png gtFine/test/berlin/berlin_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000098_000019_leftImg8bit.png gtFine/test/berlin/berlin_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000099_000019_leftImg8bit.png gtFine/test/berlin/berlin_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000100_000019_leftImg8bit.png gtFine/test/berlin/berlin_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000101_000019_leftImg8bit.png gtFine/test/berlin/berlin_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000102_000019_leftImg8bit.png gtFine/test/berlin/berlin_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000103_000019_leftImg8bit.png gtFine/test/berlin/berlin_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000104_000019_leftImg8bit.png gtFine/test/berlin/berlin_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000105_000019_leftImg8bit.png gtFine/test/berlin/berlin_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000106_000019_leftImg8bit.png gtFine/test/berlin/berlin_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000107_000019_leftImg8bit.png gtFine/test/berlin/berlin_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000108_000019_leftImg8bit.png gtFine/test/berlin/berlin_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000109_000019_leftImg8bit.png gtFine/test/berlin/berlin_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000110_000019_leftImg8bit.png gtFine/test/berlin/berlin_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000111_000019_leftImg8bit.png gtFine/test/berlin/berlin_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000112_000019_leftImg8bit.png gtFine/test/berlin/berlin_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000113_000019_leftImg8bit.png gtFine/test/berlin/berlin_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000114_000019_leftImg8bit.png gtFine/test/berlin/berlin_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000115_000019_leftImg8bit.png gtFine/test/berlin/berlin_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000116_000019_leftImg8bit.png gtFine/test/berlin/berlin_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000117_000019_leftImg8bit.png gtFine/test/berlin/berlin_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000118_000019_leftImg8bit.png gtFine/test/berlin/berlin_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000119_000019_leftImg8bit.png gtFine/test/berlin/berlin_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000120_000019_leftImg8bit.png gtFine/test/berlin/berlin_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000121_000019_leftImg8bit.png gtFine/test/berlin/berlin_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000122_000019_leftImg8bit.png gtFine/test/berlin/berlin_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000123_000019_leftImg8bit.png gtFine/test/berlin/berlin_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000124_000019_leftImg8bit.png gtFine/test/berlin/berlin_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000125_000019_leftImg8bit.png gtFine/test/berlin/berlin_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000126_000019_leftImg8bit.png gtFine/test/berlin/berlin_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000127_000019_leftImg8bit.png gtFine/test/berlin/berlin_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000128_000019_leftImg8bit.png gtFine/test/berlin/berlin_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000129_000019_leftImg8bit.png gtFine/test/berlin/berlin_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000130_000019_leftImg8bit.png gtFine/test/berlin/berlin_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000131_000019_leftImg8bit.png gtFine/test/berlin/berlin_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000132_000019_leftImg8bit.png gtFine/test/berlin/berlin_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000133_000019_leftImg8bit.png gtFine/test/berlin/berlin_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000134_000019_leftImg8bit.png gtFine/test/berlin/berlin_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000135_000019_leftImg8bit.png gtFine/test/berlin/berlin_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000136_000019_leftImg8bit.png gtFine/test/berlin/berlin_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000137_000019_leftImg8bit.png gtFine/test/berlin/berlin_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000138_000019_leftImg8bit.png gtFine/test/berlin/berlin_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000139_000019_leftImg8bit.png gtFine/test/berlin/berlin_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000140_000019_leftImg8bit.png gtFine/test/berlin/berlin_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000141_000019_leftImg8bit.png gtFine/test/berlin/berlin_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000142_000019_leftImg8bit.png gtFine/test/berlin/berlin_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000143_000019_leftImg8bit.png gtFine/test/berlin/berlin_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000144_000019_leftImg8bit.png gtFine/test/berlin/berlin_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000145_000019_leftImg8bit.png gtFine/test/berlin/berlin_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000146_000019_leftImg8bit.png gtFine/test/berlin/berlin_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000147_000019_leftImg8bit.png gtFine/test/berlin/berlin_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000148_000019_leftImg8bit.png gtFine/test/berlin/berlin_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000149_000019_leftImg8bit.png gtFine/test/berlin/berlin_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000150_000019_leftImg8bit.png gtFine/test/berlin/berlin_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000151_000019_leftImg8bit.png gtFine/test/berlin/berlin_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000152_000019_leftImg8bit.png gtFine/test/berlin/berlin_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000153_000019_leftImg8bit.png gtFine/test/berlin/berlin_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000154_000019_leftImg8bit.png gtFine/test/berlin/berlin_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000155_000019_leftImg8bit.png gtFine/test/berlin/berlin_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000156_000019_leftImg8bit.png gtFine/test/berlin/berlin_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000157_000019_leftImg8bit.png gtFine/test/berlin/berlin_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000158_000019_leftImg8bit.png gtFine/test/berlin/berlin_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000159_000019_leftImg8bit.png gtFine/test/berlin/berlin_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000160_000019_leftImg8bit.png gtFine/test/berlin/berlin_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000161_000019_leftImg8bit.png gtFine/test/berlin/berlin_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000162_000019_leftImg8bit.png gtFine/test/berlin/berlin_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000163_000019_leftImg8bit.png gtFine/test/berlin/berlin_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000164_000019_leftImg8bit.png gtFine/test/berlin/berlin_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000165_000019_leftImg8bit.png gtFine/test/berlin/berlin_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000166_000019_leftImg8bit.png gtFine/test/berlin/berlin_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000167_000019_leftImg8bit.png gtFine/test/berlin/berlin_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000168_000019_leftImg8bit.png gtFine/test/berlin/berlin_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000169_000019_leftImg8bit.png gtFine/test/berlin/berlin_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000170_000019_leftImg8bit.png gtFine/test/berlin/berlin_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000171_000019_leftImg8bit.png gtFine/test/berlin/berlin_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000172_000019_leftImg8bit.png gtFine/test/berlin/berlin_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000173_000019_leftImg8bit.png gtFine/test/berlin/berlin_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000174_000019_leftImg8bit.png gtFine/test/berlin/berlin_000174_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000175_000019_leftImg8bit.png gtFine/test/berlin/berlin_000175_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000176_000019_leftImg8bit.png gtFine/test/berlin/berlin_000176_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000177_000019_leftImg8bit.png gtFine/test/berlin/berlin_000177_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000178_000019_leftImg8bit.png gtFine/test/berlin/berlin_000178_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000179_000019_leftImg8bit.png gtFine/test/berlin/berlin_000179_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000180_000019_leftImg8bit.png gtFine/test/berlin/berlin_000180_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000181_000019_leftImg8bit.png gtFine/test/berlin/berlin_000181_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000182_000019_leftImg8bit.png gtFine/test/berlin/berlin_000182_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000183_000019_leftImg8bit.png gtFine/test/berlin/berlin_000183_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000184_000019_leftImg8bit.png gtFine/test/berlin/berlin_000184_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000185_000019_leftImg8bit.png gtFine/test/berlin/berlin_000185_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000186_000019_leftImg8bit.png gtFine/test/berlin/berlin_000186_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000187_000019_leftImg8bit.png gtFine/test/berlin/berlin_000187_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000188_000019_leftImg8bit.png gtFine/test/berlin/berlin_000188_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000189_000019_leftImg8bit.png gtFine/test/berlin/berlin_000189_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000190_000019_leftImg8bit.png gtFine/test/berlin/berlin_000190_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000191_000019_leftImg8bit.png gtFine/test/berlin/berlin_000191_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000192_000019_leftImg8bit.png gtFine/test/berlin/berlin_000192_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000193_000019_leftImg8bit.png gtFine/test/berlin/berlin_000193_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000194_000019_leftImg8bit.png gtFine/test/berlin/berlin_000194_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000195_000019_leftImg8bit.png gtFine/test/berlin/berlin_000195_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000196_000019_leftImg8bit.png gtFine/test/berlin/berlin_000196_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000197_000019_leftImg8bit.png gtFine/test/berlin/berlin_000197_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000198_000019_leftImg8bit.png gtFine/test/berlin/berlin_000198_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000199_000019_leftImg8bit.png gtFine/test/berlin/berlin_000199_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000200_000019_leftImg8bit.png gtFine/test/berlin/berlin_000200_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000201_000019_leftImg8bit.png gtFine/test/berlin/berlin_000201_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000202_000019_leftImg8bit.png gtFine/test/berlin/berlin_000202_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000203_000019_leftImg8bit.png gtFine/test/berlin/berlin_000203_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000204_000019_leftImg8bit.png gtFine/test/berlin/berlin_000204_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000205_000019_leftImg8bit.png gtFine/test/berlin/berlin_000205_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000206_000019_leftImg8bit.png gtFine/test/berlin/berlin_000206_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000207_000019_leftImg8bit.png gtFine/test/berlin/berlin_000207_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000208_000019_leftImg8bit.png gtFine/test/berlin/berlin_000208_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000209_000019_leftImg8bit.png gtFine/test/berlin/berlin_000209_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000210_000019_leftImg8bit.png gtFine/test/berlin/berlin_000210_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000211_000019_leftImg8bit.png gtFine/test/berlin/berlin_000211_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000212_000019_leftImg8bit.png gtFine/test/berlin/berlin_000212_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000213_000019_leftImg8bit.png gtFine/test/berlin/berlin_000213_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000214_000019_leftImg8bit.png gtFine/test/berlin/berlin_000214_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000215_000019_leftImg8bit.png gtFine/test/berlin/berlin_000215_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000216_000019_leftImg8bit.png gtFine/test/berlin/berlin_000216_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000217_000019_leftImg8bit.png gtFine/test/berlin/berlin_000217_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000218_000019_leftImg8bit.png gtFine/test/berlin/berlin_000218_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000219_000019_leftImg8bit.png gtFine/test/berlin/berlin_000219_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000220_000019_leftImg8bit.png gtFine/test/berlin/berlin_000220_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000221_000019_leftImg8bit.png gtFine/test/berlin/berlin_000221_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000222_000019_leftImg8bit.png gtFine/test/berlin/berlin_000222_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000223_000019_leftImg8bit.png gtFine/test/berlin/berlin_000223_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000224_000019_leftImg8bit.png gtFine/test/berlin/berlin_000224_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000225_000019_leftImg8bit.png gtFine/test/berlin/berlin_000225_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000226_000019_leftImg8bit.png gtFine/test/berlin/berlin_000226_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000227_000019_leftImg8bit.png gtFine/test/berlin/berlin_000227_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000228_000019_leftImg8bit.png gtFine/test/berlin/berlin_000228_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000229_000019_leftImg8bit.png gtFine/test/berlin/berlin_000229_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000230_000019_leftImg8bit.png gtFine/test/berlin/berlin_000230_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000231_000019_leftImg8bit.png gtFine/test/berlin/berlin_000231_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000232_000019_leftImg8bit.png gtFine/test/berlin/berlin_000232_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000233_000019_leftImg8bit.png gtFine/test/berlin/berlin_000233_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000234_000019_leftImg8bit.png gtFine/test/berlin/berlin_000234_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000235_000019_leftImg8bit.png gtFine/test/berlin/berlin_000235_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000236_000019_leftImg8bit.png gtFine/test/berlin/berlin_000236_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000237_000019_leftImg8bit.png gtFine/test/berlin/berlin_000237_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000238_000019_leftImg8bit.png gtFine/test/berlin/berlin_000238_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000239_000019_leftImg8bit.png gtFine/test/berlin/berlin_000239_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000240_000019_leftImg8bit.png gtFine/test/berlin/berlin_000240_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000241_000019_leftImg8bit.png gtFine/test/berlin/berlin_000241_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000242_000019_leftImg8bit.png gtFine/test/berlin/berlin_000242_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000243_000019_leftImg8bit.png gtFine/test/berlin/berlin_000243_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000244_000019_leftImg8bit.png gtFine/test/berlin/berlin_000244_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000245_000019_leftImg8bit.png gtFine/test/berlin/berlin_000245_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000246_000019_leftImg8bit.png gtFine/test/berlin/berlin_000246_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000247_000019_leftImg8bit.png gtFine/test/berlin/berlin_000247_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000248_000019_leftImg8bit.png gtFine/test/berlin/berlin_000248_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000249_000019_leftImg8bit.png gtFine/test/berlin/berlin_000249_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000250_000019_leftImg8bit.png gtFine/test/berlin/berlin_000250_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000251_000019_leftImg8bit.png gtFine/test/berlin/berlin_000251_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000252_000019_leftImg8bit.png gtFine/test/berlin/berlin_000252_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000253_000019_leftImg8bit.png gtFine/test/berlin/berlin_000253_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000254_000019_leftImg8bit.png gtFine/test/berlin/berlin_000254_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000255_000019_leftImg8bit.png gtFine/test/berlin/berlin_000255_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000256_000019_leftImg8bit.png gtFine/test/berlin/berlin_000256_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000257_000019_leftImg8bit.png gtFine/test/berlin/berlin_000257_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000258_000019_leftImg8bit.png gtFine/test/berlin/berlin_000258_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000259_000019_leftImg8bit.png gtFine/test/berlin/berlin_000259_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000260_000019_leftImg8bit.png gtFine/test/berlin/berlin_000260_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000261_000019_leftImg8bit.png gtFine/test/berlin/berlin_000261_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000262_000019_leftImg8bit.png gtFine/test/berlin/berlin_000262_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000263_000019_leftImg8bit.png gtFine/test/berlin/berlin_000263_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000264_000019_leftImg8bit.png gtFine/test/berlin/berlin_000264_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000265_000019_leftImg8bit.png gtFine/test/berlin/berlin_000265_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000266_000019_leftImg8bit.png gtFine/test/berlin/berlin_000266_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000267_000019_leftImg8bit.png gtFine/test/berlin/berlin_000267_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000268_000019_leftImg8bit.png gtFine/test/berlin/berlin_000268_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000269_000019_leftImg8bit.png gtFine/test/berlin/berlin_000269_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000270_000019_leftImg8bit.png gtFine/test/berlin/berlin_000270_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000271_000019_leftImg8bit.png gtFine/test/berlin/berlin_000271_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000272_000019_leftImg8bit.png gtFine/test/berlin/berlin_000272_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000273_000019_leftImg8bit.png gtFine/test/berlin/berlin_000273_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000274_000019_leftImg8bit.png gtFine/test/berlin/berlin_000274_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000275_000019_leftImg8bit.png gtFine/test/berlin/berlin_000275_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000276_000019_leftImg8bit.png gtFine/test/berlin/berlin_000276_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000277_000019_leftImg8bit.png gtFine/test/berlin/berlin_000277_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000278_000019_leftImg8bit.png gtFine/test/berlin/berlin_000278_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000279_000019_leftImg8bit.png gtFine/test/berlin/berlin_000279_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000280_000019_leftImg8bit.png gtFine/test/berlin/berlin_000280_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000281_000019_leftImg8bit.png gtFine/test/berlin/berlin_000281_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000282_000019_leftImg8bit.png gtFine/test/berlin/berlin_000282_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000283_000019_leftImg8bit.png gtFine/test/berlin/berlin_000283_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000284_000019_leftImg8bit.png gtFine/test/berlin/berlin_000284_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000285_000019_leftImg8bit.png gtFine/test/berlin/berlin_000285_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000286_000019_leftImg8bit.png gtFine/test/berlin/berlin_000286_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000287_000019_leftImg8bit.png gtFine/test/berlin/berlin_000287_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000288_000019_leftImg8bit.png gtFine/test/berlin/berlin_000288_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000289_000019_leftImg8bit.png gtFine/test/berlin/berlin_000289_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000290_000019_leftImg8bit.png gtFine/test/berlin/berlin_000290_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000291_000019_leftImg8bit.png gtFine/test/berlin/berlin_000291_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000292_000019_leftImg8bit.png gtFine/test/berlin/berlin_000292_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000293_000019_leftImg8bit.png gtFine/test/berlin/berlin_000293_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000294_000019_leftImg8bit.png gtFine/test/berlin/berlin_000294_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000295_000019_leftImg8bit.png gtFine/test/berlin/berlin_000295_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000296_000019_leftImg8bit.png gtFine/test/berlin/berlin_000296_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000297_000019_leftImg8bit.png gtFine/test/berlin/berlin_000297_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000298_000019_leftImg8bit.png gtFine/test/berlin/berlin_000298_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000299_000019_leftImg8bit.png gtFine/test/berlin/berlin_000299_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000300_000019_leftImg8bit.png gtFine/test/berlin/berlin_000300_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000301_000019_leftImg8bit.png gtFine/test/berlin/berlin_000301_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000302_000019_leftImg8bit.png gtFine/test/berlin/berlin_000302_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000303_000019_leftImg8bit.png gtFine/test/berlin/berlin_000303_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000304_000019_leftImg8bit.png gtFine/test/berlin/berlin_000304_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000305_000019_leftImg8bit.png gtFine/test/berlin/berlin_000305_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000306_000019_leftImg8bit.png gtFine/test/berlin/berlin_000306_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000307_000019_leftImg8bit.png gtFine/test/berlin/berlin_000307_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000308_000019_leftImg8bit.png gtFine/test/berlin/berlin_000308_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000309_000019_leftImg8bit.png gtFine/test/berlin/berlin_000309_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000310_000019_leftImg8bit.png gtFine/test/berlin/berlin_000310_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000311_000019_leftImg8bit.png gtFine/test/berlin/berlin_000311_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000312_000019_leftImg8bit.png gtFine/test/berlin/berlin_000312_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000313_000019_leftImg8bit.png gtFine/test/berlin/berlin_000313_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000314_000019_leftImg8bit.png gtFine/test/berlin/berlin_000314_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000315_000019_leftImg8bit.png gtFine/test/berlin/berlin_000315_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000316_000019_leftImg8bit.png gtFine/test/berlin/berlin_000316_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000317_000019_leftImg8bit.png gtFine/test/berlin/berlin_000317_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000318_000019_leftImg8bit.png gtFine/test/berlin/berlin_000318_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000319_000019_leftImg8bit.png gtFine/test/berlin/berlin_000319_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000320_000019_leftImg8bit.png gtFine/test/berlin/berlin_000320_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000321_000019_leftImg8bit.png gtFine/test/berlin/berlin_000321_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000322_000019_leftImg8bit.png gtFine/test/berlin/berlin_000322_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000323_000019_leftImg8bit.png gtFine/test/berlin/berlin_000323_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000324_000019_leftImg8bit.png gtFine/test/berlin/berlin_000324_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000325_000019_leftImg8bit.png gtFine/test/berlin/berlin_000325_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000326_000019_leftImg8bit.png gtFine/test/berlin/berlin_000326_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000327_000019_leftImg8bit.png gtFine/test/berlin/berlin_000327_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000328_000019_leftImg8bit.png gtFine/test/berlin/berlin_000328_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000329_000019_leftImg8bit.png gtFine/test/berlin/berlin_000329_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000330_000019_leftImg8bit.png gtFine/test/berlin/berlin_000330_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000331_000019_leftImg8bit.png gtFine/test/berlin/berlin_000331_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000332_000019_leftImg8bit.png gtFine/test/berlin/berlin_000332_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000333_000019_leftImg8bit.png gtFine/test/berlin/berlin_000333_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000334_000019_leftImg8bit.png gtFine/test/berlin/berlin_000334_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000335_000019_leftImg8bit.png gtFine/test/berlin/berlin_000335_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000336_000019_leftImg8bit.png gtFine/test/berlin/berlin_000336_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000337_000019_leftImg8bit.png gtFine/test/berlin/berlin_000337_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000338_000019_leftImg8bit.png gtFine/test/berlin/berlin_000338_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000339_000019_leftImg8bit.png gtFine/test/berlin/berlin_000339_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000340_000019_leftImg8bit.png gtFine/test/berlin/berlin_000340_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000341_000019_leftImg8bit.png gtFine/test/berlin/berlin_000341_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000342_000019_leftImg8bit.png gtFine/test/berlin/berlin_000342_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000343_000019_leftImg8bit.png gtFine/test/berlin/berlin_000343_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000344_000019_leftImg8bit.png gtFine/test/berlin/berlin_000344_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000345_000019_leftImg8bit.png gtFine/test/berlin/berlin_000345_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000346_000019_leftImg8bit.png gtFine/test/berlin/berlin_000346_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000347_000019_leftImg8bit.png gtFine/test/berlin/berlin_000347_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000348_000019_leftImg8bit.png gtFine/test/berlin/berlin_000348_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000349_000019_leftImg8bit.png gtFine/test/berlin/berlin_000349_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000350_000019_leftImg8bit.png gtFine/test/berlin/berlin_000350_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000351_000019_leftImg8bit.png gtFine/test/berlin/berlin_000351_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000352_000019_leftImg8bit.png gtFine/test/berlin/berlin_000352_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000353_000019_leftImg8bit.png gtFine/test/berlin/berlin_000353_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000354_000019_leftImg8bit.png gtFine/test/berlin/berlin_000354_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000355_000019_leftImg8bit.png gtFine/test/berlin/berlin_000355_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000356_000019_leftImg8bit.png gtFine/test/berlin/berlin_000356_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000357_000019_leftImg8bit.png gtFine/test/berlin/berlin_000357_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000358_000019_leftImg8bit.png gtFine/test/berlin/berlin_000358_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000359_000019_leftImg8bit.png gtFine/test/berlin/berlin_000359_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000360_000019_leftImg8bit.png gtFine/test/berlin/berlin_000360_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000361_000019_leftImg8bit.png gtFine/test/berlin/berlin_000361_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000362_000019_leftImg8bit.png gtFine/test/berlin/berlin_000362_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000363_000019_leftImg8bit.png gtFine/test/berlin/berlin_000363_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000364_000019_leftImg8bit.png gtFine/test/berlin/berlin_000364_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000365_000019_leftImg8bit.png gtFine/test/berlin/berlin_000365_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000366_000019_leftImg8bit.png gtFine/test/berlin/berlin_000366_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000367_000019_leftImg8bit.png gtFine/test/berlin/berlin_000367_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000368_000019_leftImg8bit.png gtFine/test/berlin/berlin_000368_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000369_000019_leftImg8bit.png gtFine/test/berlin/berlin_000369_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000370_000019_leftImg8bit.png gtFine/test/berlin/berlin_000370_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000371_000019_leftImg8bit.png gtFine/test/berlin/berlin_000371_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000372_000019_leftImg8bit.png gtFine/test/berlin/berlin_000372_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000373_000019_leftImg8bit.png gtFine/test/berlin/berlin_000373_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000374_000019_leftImg8bit.png gtFine/test/berlin/berlin_000374_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000375_000019_leftImg8bit.png gtFine/test/berlin/berlin_000375_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000376_000019_leftImg8bit.png gtFine/test/berlin/berlin_000376_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000377_000019_leftImg8bit.png gtFine/test/berlin/berlin_000377_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000378_000019_leftImg8bit.png gtFine/test/berlin/berlin_000378_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000379_000019_leftImg8bit.png gtFine/test/berlin/berlin_000379_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000380_000019_leftImg8bit.png gtFine/test/berlin/berlin_000380_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000381_000019_leftImg8bit.png gtFine/test/berlin/berlin_000381_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000382_000019_leftImg8bit.png gtFine/test/berlin/berlin_000382_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000383_000019_leftImg8bit.png gtFine/test/berlin/berlin_000383_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000384_000019_leftImg8bit.png gtFine/test/berlin/berlin_000384_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000385_000019_leftImg8bit.png gtFine/test/berlin/berlin_000385_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000386_000019_leftImg8bit.png gtFine/test/berlin/berlin_000386_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000387_000019_leftImg8bit.png gtFine/test/berlin/berlin_000387_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000388_000019_leftImg8bit.png gtFine/test/berlin/berlin_000388_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000389_000019_leftImg8bit.png gtFine/test/berlin/berlin_000389_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000390_000019_leftImg8bit.png gtFine/test/berlin/berlin_000390_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000391_000019_leftImg8bit.png gtFine/test/berlin/berlin_000391_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000392_000019_leftImg8bit.png gtFine/test/berlin/berlin_000392_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000393_000019_leftImg8bit.png gtFine/test/berlin/berlin_000393_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000394_000019_leftImg8bit.png gtFine/test/berlin/berlin_000394_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000395_000019_leftImg8bit.png gtFine/test/berlin/berlin_000395_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000396_000019_leftImg8bit.png gtFine/test/berlin/berlin_000396_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000397_000019_leftImg8bit.png gtFine/test/berlin/berlin_000397_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000398_000019_leftImg8bit.png gtFine/test/berlin/berlin_000398_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000399_000019_leftImg8bit.png gtFine/test/berlin/berlin_000399_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000400_000019_leftImg8bit.png gtFine/test/berlin/berlin_000400_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000401_000019_leftImg8bit.png gtFine/test/berlin/berlin_000401_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000402_000019_leftImg8bit.png gtFine/test/berlin/berlin_000402_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000403_000019_leftImg8bit.png gtFine/test/berlin/berlin_000403_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000404_000019_leftImg8bit.png gtFine/test/berlin/berlin_000404_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000405_000019_leftImg8bit.png gtFine/test/berlin/berlin_000405_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000406_000019_leftImg8bit.png gtFine/test/berlin/berlin_000406_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000407_000019_leftImg8bit.png gtFine/test/berlin/berlin_000407_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000408_000019_leftImg8bit.png gtFine/test/berlin/berlin_000408_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000409_000019_leftImg8bit.png gtFine/test/berlin/berlin_000409_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000410_000019_leftImg8bit.png gtFine/test/berlin/berlin_000410_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000411_000019_leftImg8bit.png gtFine/test/berlin/berlin_000411_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000412_000019_leftImg8bit.png gtFine/test/berlin/berlin_000412_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000413_000019_leftImg8bit.png gtFine/test/berlin/berlin_000413_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000414_000019_leftImg8bit.png gtFine/test/berlin/berlin_000414_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000415_000019_leftImg8bit.png gtFine/test/berlin/berlin_000415_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000416_000019_leftImg8bit.png gtFine/test/berlin/berlin_000416_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000417_000019_leftImg8bit.png gtFine/test/berlin/berlin_000417_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000418_000019_leftImg8bit.png gtFine/test/berlin/berlin_000418_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000419_000019_leftImg8bit.png gtFine/test/berlin/berlin_000419_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000420_000019_leftImg8bit.png gtFine/test/berlin/berlin_000420_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000421_000019_leftImg8bit.png gtFine/test/berlin/berlin_000421_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000422_000019_leftImg8bit.png gtFine/test/berlin/berlin_000422_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000423_000019_leftImg8bit.png gtFine/test/berlin/berlin_000423_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000424_000019_leftImg8bit.png gtFine/test/berlin/berlin_000424_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000425_000019_leftImg8bit.png gtFine/test/berlin/berlin_000425_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000426_000019_leftImg8bit.png gtFine/test/berlin/berlin_000426_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000427_000019_leftImg8bit.png gtFine/test/berlin/berlin_000427_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000428_000019_leftImg8bit.png gtFine/test/berlin/berlin_000428_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000429_000019_leftImg8bit.png gtFine/test/berlin/berlin_000429_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000430_000019_leftImg8bit.png gtFine/test/berlin/berlin_000430_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000431_000019_leftImg8bit.png gtFine/test/berlin/berlin_000431_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000432_000019_leftImg8bit.png gtFine/test/berlin/berlin_000432_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000433_000019_leftImg8bit.png gtFine/test/berlin/berlin_000433_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000434_000019_leftImg8bit.png gtFine/test/berlin/berlin_000434_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000435_000019_leftImg8bit.png gtFine/test/berlin/berlin_000435_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000436_000019_leftImg8bit.png gtFine/test/berlin/berlin_000436_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000437_000019_leftImg8bit.png gtFine/test/berlin/berlin_000437_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000438_000019_leftImg8bit.png gtFine/test/berlin/berlin_000438_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000439_000019_leftImg8bit.png gtFine/test/berlin/berlin_000439_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000440_000019_leftImg8bit.png gtFine/test/berlin/berlin_000440_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000441_000019_leftImg8bit.png gtFine/test/berlin/berlin_000441_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000442_000019_leftImg8bit.png gtFine/test/berlin/berlin_000442_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000443_000019_leftImg8bit.png gtFine/test/berlin/berlin_000443_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000444_000019_leftImg8bit.png gtFine/test/berlin/berlin_000444_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000445_000019_leftImg8bit.png gtFine/test/berlin/berlin_000445_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000446_000019_leftImg8bit.png gtFine/test/berlin/berlin_000446_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000447_000019_leftImg8bit.png gtFine/test/berlin/berlin_000447_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000448_000019_leftImg8bit.png gtFine/test/berlin/berlin_000448_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000449_000019_leftImg8bit.png gtFine/test/berlin/berlin_000449_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000450_000019_leftImg8bit.png gtFine/test/berlin/berlin_000450_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000451_000019_leftImg8bit.png gtFine/test/berlin/berlin_000451_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000452_000019_leftImg8bit.png gtFine/test/berlin/berlin_000452_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000453_000019_leftImg8bit.png gtFine/test/berlin/berlin_000453_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000454_000019_leftImg8bit.png gtFine/test/berlin/berlin_000454_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000455_000019_leftImg8bit.png gtFine/test/berlin/berlin_000455_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000456_000019_leftImg8bit.png gtFine/test/berlin/berlin_000456_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000457_000019_leftImg8bit.png gtFine/test/berlin/berlin_000457_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000458_000019_leftImg8bit.png gtFine/test/berlin/berlin_000458_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000459_000019_leftImg8bit.png gtFine/test/berlin/berlin_000459_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000460_000019_leftImg8bit.png gtFine/test/berlin/berlin_000460_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000461_000019_leftImg8bit.png gtFine/test/berlin/berlin_000461_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000462_000019_leftImg8bit.png gtFine/test/berlin/berlin_000462_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000463_000019_leftImg8bit.png gtFine/test/berlin/berlin_000463_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000464_000019_leftImg8bit.png gtFine/test/berlin/berlin_000464_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000465_000019_leftImg8bit.png gtFine/test/berlin/berlin_000465_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000466_000019_leftImg8bit.png gtFine/test/berlin/berlin_000466_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000467_000019_leftImg8bit.png gtFine/test/berlin/berlin_000467_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000468_000019_leftImg8bit.png gtFine/test/berlin/berlin_000468_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000469_000019_leftImg8bit.png gtFine/test/berlin/berlin_000469_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000470_000019_leftImg8bit.png gtFine/test/berlin/berlin_000470_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000471_000019_leftImg8bit.png gtFine/test/berlin/berlin_000471_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000472_000019_leftImg8bit.png gtFine/test/berlin/berlin_000472_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000473_000019_leftImg8bit.png gtFine/test/berlin/berlin_000473_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000474_000019_leftImg8bit.png gtFine/test/berlin/berlin_000474_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000475_000019_leftImg8bit.png gtFine/test/berlin/berlin_000475_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000476_000019_leftImg8bit.png gtFine/test/berlin/berlin_000476_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000477_000019_leftImg8bit.png gtFine/test/berlin/berlin_000477_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000478_000019_leftImg8bit.png gtFine/test/berlin/berlin_000478_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000479_000019_leftImg8bit.png gtFine/test/berlin/berlin_000479_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000480_000019_leftImg8bit.png gtFine/test/berlin/berlin_000480_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000481_000019_leftImg8bit.png gtFine/test/berlin/berlin_000481_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000482_000019_leftImg8bit.png gtFine/test/berlin/berlin_000482_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000483_000019_leftImg8bit.png gtFine/test/berlin/berlin_000483_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000484_000019_leftImg8bit.png gtFine/test/berlin/berlin_000484_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000485_000019_leftImg8bit.png gtFine/test/berlin/berlin_000485_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000486_000019_leftImg8bit.png gtFine/test/berlin/berlin_000486_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000487_000019_leftImg8bit.png gtFine/test/berlin/berlin_000487_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000488_000019_leftImg8bit.png gtFine/test/berlin/berlin_000488_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000489_000019_leftImg8bit.png gtFine/test/berlin/berlin_000489_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000490_000019_leftImg8bit.png gtFine/test/berlin/berlin_000490_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000491_000019_leftImg8bit.png gtFine/test/berlin/berlin_000491_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000492_000019_leftImg8bit.png gtFine/test/berlin/berlin_000492_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000493_000019_leftImg8bit.png gtFine/test/berlin/berlin_000493_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000494_000019_leftImg8bit.png gtFine/test/berlin/berlin_000494_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000495_000019_leftImg8bit.png gtFine/test/berlin/berlin_000495_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000496_000019_leftImg8bit.png gtFine/test/berlin/berlin_000496_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000497_000019_leftImg8bit.png gtFine/test/berlin/berlin_000497_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000498_000019_leftImg8bit.png gtFine/test/berlin/berlin_000498_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000499_000019_leftImg8bit.png gtFine/test/berlin/berlin_000499_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000500_000019_leftImg8bit.png gtFine/test/berlin/berlin_000500_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000501_000019_leftImg8bit.png gtFine/test/berlin/berlin_000501_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000502_000019_leftImg8bit.png gtFine/test/berlin/berlin_000502_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000503_000019_leftImg8bit.png gtFine/test/berlin/berlin_000503_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000504_000019_leftImg8bit.png gtFine/test/berlin/berlin_000504_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000505_000019_leftImg8bit.png gtFine/test/berlin/berlin_000505_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000506_000019_leftImg8bit.png gtFine/test/berlin/berlin_000506_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000507_000019_leftImg8bit.png gtFine/test/berlin/berlin_000507_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000508_000019_leftImg8bit.png gtFine/test/berlin/berlin_000508_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000509_000019_leftImg8bit.png gtFine/test/berlin/berlin_000509_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000510_000019_leftImg8bit.png gtFine/test/berlin/berlin_000510_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000511_000019_leftImg8bit.png gtFine/test/berlin/berlin_000511_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000512_000019_leftImg8bit.png gtFine/test/berlin/berlin_000512_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000513_000019_leftImg8bit.png gtFine/test/berlin/berlin_000513_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000514_000019_leftImg8bit.png gtFine/test/berlin/berlin_000514_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000515_000019_leftImg8bit.png gtFine/test/berlin/berlin_000515_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000516_000019_leftImg8bit.png gtFine/test/berlin/berlin_000516_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000517_000019_leftImg8bit.png gtFine/test/berlin/berlin_000517_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000518_000019_leftImg8bit.png gtFine/test/berlin/berlin_000518_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000519_000019_leftImg8bit.png gtFine/test/berlin/berlin_000519_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000520_000019_leftImg8bit.png gtFine/test/berlin/berlin_000520_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000521_000019_leftImg8bit.png gtFine/test/berlin/berlin_000521_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000522_000019_leftImg8bit.png gtFine/test/berlin/berlin_000522_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000523_000019_leftImg8bit.png gtFine/test/berlin/berlin_000523_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000524_000019_leftImg8bit.png gtFine/test/berlin/berlin_000524_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000525_000019_leftImg8bit.png gtFine/test/berlin/berlin_000525_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000526_000019_leftImg8bit.png gtFine/test/berlin/berlin_000526_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000527_000019_leftImg8bit.png gtFine/test/berlin/berlin_000527_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000528_000019_leftImg8bit.png gtFine/test/berlin/berlin_000528_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000529_000019_leftImg8bit.png gtFine/test/berlin/berlin_000529_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000530_000019_leftImg8bit.png gtFine/test/berlin/berlin_000530_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000531_000019_leftImg8bit.png gtFine/test/berlin/berlin_000531_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000532_000019_leftImg8bit.png gtFine/test/berlin/berlin_000532_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000533_000019_leftImg8bit.png gtFine/test/berlin/berlin_000533_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000534_000019_leftImg8bit.png gtFine/test/berlin/berlin_000534_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000535_000019_leftImg8bit.png gtFine/test/berlin/berlin_000535_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000536_000019_leftImg8bit.png gtFine/test/berlin/berlin_000536_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000537_000019_leftImg8bit.png gtFine/test/berlin/berlin_000537_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000538_000019_leftImg8bit.png gtFine/test/berlin/berlin_000538_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000539_000019_leftImg8bit.png gtFine/test/berlin/berlin_000539_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000540_000019_leftImg8bit.png gtFine/test/berlin/berlin_000540_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000541_000019_leftImg8bit.png gtFine/test/berlin/berlin_000541_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000542_000019_leftImg8bit.png gtFine/test/berlin/berlin_000542_000019_gtFine_labelTrainIds.png +leftImg8bit/test/berlin/berlin_000543_000019_leftImg8bit.png gtFine/test/berlin/berlin_000543_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_000321_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_000321_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_000856_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_000856_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_001011_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_001011_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_001187_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_001187_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_001505_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_001505_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_001705_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_001705_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_002308_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_002308_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_002528_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_002528_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_002735_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_002735_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_003080_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_003080_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_003406_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_003406_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_003546_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_003546_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_003731_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_003731_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_004345_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_004345_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005068_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005068_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005260_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005260_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005372_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005372_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005584_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005584_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005741_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005741_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_005942_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_005942_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_006239_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_006239_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_006603_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_006603_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_006802_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_006802_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_007030_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_007030_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_007186_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_007186_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_007545_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_007545_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_008279_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_008279_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_008581_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_008581_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_008800_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_008800_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_009728_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_009728_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_009928_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_009928_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_010156_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_010156_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_011367_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_011367_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_011831_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_011831_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_012080_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_012080_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_012584_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_012584_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_012788_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_012788_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_013570_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_013570_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_013665_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_013665_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_013814_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_013814_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_014068_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_014068_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_015301_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_015301_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_015411_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_015411_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_015587_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_015587_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_015867_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_015867_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_015942_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_015942_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_016019_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_016019_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_016718_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_016718_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_016924_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_016924_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_017051_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_017051_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_017279_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_017279_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_017438_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_017438_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_017774_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_017774_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_018102_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_018102_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_018345_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_018345_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_018644_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_018644_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_019416_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_019416_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_020757_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_020757_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_020900_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_020900_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_021221_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_021221_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_021341_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_021341_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_021381_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_021381_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_021625_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_021625_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_021826_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_021826_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_022261_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_022261_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_022835_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_022835_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_025061_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_025061_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_025426_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_025426_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_025748_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_025748_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_026053_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_026053_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_026296_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_026296_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_026550_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_026550_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_026660_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_026660_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_026823_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_026823_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_027221_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_027221_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_027586_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_027586_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_027928_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_027928_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_028046_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_028046_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_028148_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_028148_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_028414_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_028414_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_028550_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_028550_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_028747_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_028747_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_029148_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_029148_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_030038_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_030038_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_030366_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_030366_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_030958_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_030958_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_031244_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_031244_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_031510_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_031510_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_032388_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_032388_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_032766_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_032766_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_033675_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_033675_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_033770_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_033770_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_033979_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_033979_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_034705_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_034705_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_034929_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_034929_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_035223_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_035223_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_035537_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_035537_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_035879_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_035879_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_036362_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_036362_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_036732_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_036732_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_037016_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_037016_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_037159_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_037159_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_037422_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_037422_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_038924_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_038924_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_039082_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_039082_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_039221_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_039221_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_039596_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_039596_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_040035_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_040035_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_040472_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_040472_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_041014_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_041014_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_041142_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_041142_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_041223_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_041223_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_041444_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_041444_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_042403_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_042403_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_042571_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_042571_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_042717_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_042717_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_043100_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_043100_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_043389_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_043389_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_043610_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_043610_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_044085_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_044085_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_045117_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_045117_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_045232_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_045232_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_046023_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_046023_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_046212_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_046212_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_046495_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_046495_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_047542_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_047542_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_047918_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_047918_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_048227_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_048227_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_048518_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_048518_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_048754_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_048754_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_048864_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_048864_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_049313_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_049313_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_049446_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_049446_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_050021_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_050021_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_050426_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_050426_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_050586_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_050586_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_051102_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_051102_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_051223_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_051223_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_051894_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_051894_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_052155_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_052155_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_053028_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_053028_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_053384_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_053384_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_053583_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_053583_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_053779_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_053779_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_055003_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_055003_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_055145_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_055145_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056175_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056175_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056226_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056226_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056310_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056310_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056493_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056493_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056603_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056603_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_056866_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_056866_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_058374_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_058374_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_058776_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_058776_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_058934_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_058934_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059119_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059119_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059303_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059303_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059355_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059355_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059501_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059501_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059651_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059651_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059729_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059729_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059766_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059766_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_059842_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_059842_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_060786_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_060786_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_060861_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_060861_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_061094_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_061094_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_061341_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_061341_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_061975_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_061975_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_062121_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_062121_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_063427_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_063427_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_063623_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_063623_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_063939_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_063939_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_064271_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_064271_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_064583_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_064583_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_064805_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_064805_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_064910_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_064910_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_065023_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_065023_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_065154_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_065154_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_066195_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_066195_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_066405_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_066405_gtFine_labelTrainIds.png +leftImg8bit/test/bielefeld/bielefeld_000000_066495_leftImg8bit.png gtFine/test/bielefeld/bielefeld_000000_066495_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000000_000019_leftImg8bit.png gtFine/test/bonn/bonn_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000001_000019_leftImg8bit.png gtFine/test/bonn/bonn_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000002_000019_leftImg8bit.png gtFine/test/bonn/bonn_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000003_000019_leftImg8bit.png gtFine/test/bonn/bonn_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000004_000019_leftImg8bit.png gtFine/test/bonn/bonn_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000005_000019_leftImg8bit.png gtFine/test/bonn/bonn_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000006_000019_leftImg8bit.png gtFine/test/bonn/bonn_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000007_000019_leftImg8bit.png gtFine/test/bonn/bonn_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000008_000019_leftImg8bit.png gtFine/test/bonn/bonn_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000009_000019_leftImg8bit.png gtFine/test/bonn/bonn_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000010_000019_leftImg8bit.png gtFine/test/bonn/bonn_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000011_000019_leftImg8bit.png gtFine/test/bonn/bonn_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000012_000019_leftImg8bit.png gtFine/test/bonn/bonn_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000013_000019_leftImg8bit.png gtFine/test/bonn/bonn_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000014_000019_leftImg8bit.png gtFine/test/bonn/bonn_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000015_000019_leftImg8bit.png gtFine/test/bonn/bonn_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000016_000019_leftImg8bit.png gtFine/test/bonn/bonn_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000017_000019_leftImg8bit.png gtFine/test/bonn/bonn_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000018_000019_leftImg8bit.png gtFine/test/bonn/bonn_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000019_000019_leftImg8bit.png gtFine/test/bonn/bonn_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000020_000019_leftImg8bit.png gtFine/test/bonn/bonn_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000021_000019_leftImg8bit.png gtFine/test/bonn/bonn_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000022_000019_leftImg8bit.png gtFine/test/bonn/bonn_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000023_000019_leftImg8bit.png gtFine/test/bonn/bonn_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000024_000019_leftImg8bit.png gtFine/test/bonn/bonn_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000025_000019_leftImg8bit.png gtFine/test/bonn/bonn_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000026_000019_leftImg8bit.png gtFine/test/bonn/bonn_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000027_000019_leftImg8bit.png gtFine/test/bonn/bonn_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000028_000019_leftImg8bit.png gtFine/test/bonn/bonn_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000029_000019_leftImg8bit.png gtFine/test/bonn/bonn_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000030_000019_leftImg8bit.png gtFine/test/bonn/bonn_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000031_000019_leftImg8bit.png gtFine/test/bonn/bonn_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000032_000019_leftImg8bit.png gtFine/test/bonn/bonn_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000033_000019_leftImg8bit.png gtFine/test/bonn/bonn_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000034_000019_leftImg8bit.png gtFine/test/bonn/bonn_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000035_000019_leftImg8bit.png gtFine/test/bonn/bonn_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000036_000019_leftImg8bit.png gtFine/test/bonn/bonn_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000037_000019_leftImg8bit.png gtFine/test/bonn/bonn_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000038_000019_leftImg8bit.png gtFine/test/bonn/bonn_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000039_000019_leftImg8bit.png gtFine/test/bonn/bonn_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000040_000019_leftImg8bit.png gtFine/test/bonn/bonn_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000041_000019_leftImg8bit.png gtFine/test/bonn/bonn_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000042_000019_leftImg8bit.png gtFine/test/bonn/bonn_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000043_000019_leftImg8bit.png gtFine/test/bonn/bonn_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000044_000019_leftImg8bit.png gtFine/test/bonn/bonn_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/test/bonn/bonn_000045_000019_leftImg8bit.png gtFine/test/bonn/bonn_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000000_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000001_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000002_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000003_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000004_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000005_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000006_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000007_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000008_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000009_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000010_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000011_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000012_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000013_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000014_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000015_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000016_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000017_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000018_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000019_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000020_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000021_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000022_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000023_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000024_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000025_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000026_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000027_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000028_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000029_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000030_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000031_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000032_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000033_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000034_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000035_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000036_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000037_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000038_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000039_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000040_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000041_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000042_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000043_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000044_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000045_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000046_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000047_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000048_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000049_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000050_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000051_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000052_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000053_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000054_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000055_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000056_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/test/leverkusen/leverkusen_000057_000019_leftImg8bit.png gtFine/test/leverkusen/leverkusen_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_000093_leftImg8bit.png gtFine/test/mainz/mainz_000000_000093_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_000293_leftImg8bit.png gtFine/test/mainz/mainz_000000_000293_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001003_leftImg8bit.png gtFine/test/mainz/mainz_000000_001003_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001068_leftImg8bit.png gtFine/test/mainz/mainz_000000_001068_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001265_leftImg8bit.png gtFine/test/mainz/mainz_000000_001265_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001410_leftImg8bit.png gtFine/test/mainz/mainz_000000_001410_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001601_leftImg8bit.png gtFine/test/mainz/mainz_000000_001601_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_001857_leftImg8bit.png gtFine/test/mainz/mainz_000000_001857_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_002212_leftImg8bit.png gtFine/test/mainz/mainz_000000_002212_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_002353_leftImg8bit.png gtFine/test/mainz/mainz_000000_002353_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_003049_leftImg8bit.png gtFine/test/mainz/mainz_000000_003049_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_003250_leftImg8bit.png gtFine/test/mainz/mainz_000000_003250_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_003506_leftImg8bit.png gtFine/test/mainz/mainz_000000_003506_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_003619_leftImg8bit.png gtFine/test/mainz/mainz_000000_003619_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_004000_leftImg8bit.png gtFine/test/mainz/mainz_000000_004000_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_004237_leftImg8bit.png gtFine/test/mainz/mainz_000000_004237_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_004542_leftImg8bit.png gtFine/test/mainz/mainz_000000_004542_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_004740_leftImg8bit.png gtFine/test/mainz/mainz_000000_004740_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_005403_leftImg8bit.png gtFine/test/mainz/mainz_000000_005403_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_005549_leftImg8bit.png gtFine/test/mainz/mainz_000000_005549_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_005817_leftImg8bit.png gtFine/test/mainz/mainz_000000_005817_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_006141_leftImg8bit.png gtFine/test/mainz/mainz_000000_006141_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_006263_leftImg8bit.png gtFine/test/mainz/mainz_000000_006263_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_006368_leftImg8bit.png gtFine/test/mainz/mainz_000000_006368_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_006649_leftImg8bit.png gtFine/test/mainz/mainz_000000_006649_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_007415_leftImg8bit.png gtFine/test/mainz/mainz_000000_007415_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_007813_leftImg8bit.png gtFine/test/mainz/mainz_000000_007813_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_008001_leftImg8bit.png gtFine/test/mainz/mainz_000000_008001_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_008165_leftImg8bit.png gtFine/test/mainz/mainz_000000_008165_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_008509_leftImg8bit.png gtFine/test/mainz/mainz_000000_008509_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_008645_leftImg8bit.png gtFine/test/mainz/mainz_000000_008645_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_008871_leftImg8bit.png gtFine/test/mainz/mainz_000000_008871_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_009751_leftImg8bit.png gtFine/test/mainz/mainz_000000_009751_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_009985_leftImg8bit.png gtFine/test/mainz/mainz_000000_009985_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_010171_leftImg8bit.png gtFine/test/mainz/mainz_000000_010171_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_010417_leftImg8bit.png gtFine/test/mainz/mainz_000000_010417_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_010550_leftImg8bit.png gtFine/test/mainz/mainz_000000_010550_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_011339_leftImg8bit.png gtFine/test/mainz/mainz_000000_011339_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_011879_leftImg8bit.png gtFine/test/mainz/mainz_000000_011879_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_011965_leftImg8bit.png gtFine/test/mainz/mainz_000000_011965_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_012392_leftImg8bit.png gtFine/test/mainz/mainz_000000_012392_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_012737_leftImg8bit.png gtFine/test/mainz/mainz_000000_012737_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_013095_leftImg8bit.png gtFine/test/mainz/mainz_000000_013095_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_013437_leftImg8bit.png gtFine/test/mainz/mainz_000000_013437_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_013671_leftImg8bit.png gtFine/test/mainz/mainz_000000_013671_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_013960_leftImg8bit.png gtFine/test/mainz/mainz_000000_013960_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_014193_leftImg8bit.png gtFine/test/mainz/mainz_000000_014193_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_014742_leftImg8bit.png gtFine/test/mainz/mainz_000000_014742_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_015052_leftImg8bit.png gtFine/test/mainz/mainz_000000_015052_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_015170_leftImg8bit.png gtFine/test/mainz/mainz_000000_015170_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_015760_leftImg8bit.png gtFine/test/mainz/mainz_000000_015760_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_016083_leftImg8bit.png gtFine/test/mainz/mainz_000000_016083_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_016281_leftImg8bit.png gtFine/test/mainz/mainz_000000_016281_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_016612_leftImg8bit.png gtFine/test/mainz/mainz_000000_016612_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_016651_leftImg8bit.png gtFine/test/mainz/mainz_000000_016651_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_016915_leftImg8bit.png gtFine/test/mainz/mainz_000000_016915_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_017927_leftImg8bit.png gtFine/test/mainz/mainz_000000_017927_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_018249_leftImg8bit.png gtFine/test/mainz/mainz_000000_018249_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_018883_leftImg8bit.png gtFine/test/mainz/mainz_000000_018883_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_019043_leftImg8bit.png gtFine/test/mainz/mainz_000000_019043_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_019227_leftImg8bit.png gtFine/test/mainz/mainz_000000_019227_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_019439_leftImg8bit.png gtFine/test/mainz/mainz_000000_019439_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_019686_leftImg8bit.png gtFine/test/mainz/mainz_000000_019686_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_019847_leftImg8bit.png gtFine/test/mainz/mainz_000000_019847_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_020139_leftImg8bit.png gtFine/test/mainz/mainz_000000_020139_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_020415_leftImg8bit.png gtFine/test/mainz/mainz_000000_020415_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_021457_leftImg8bit.png gtFine/test/mainz/mainz_000000_021457_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_021524_leftImg8bit.png gtFine/test/mainz/mainz_000000_021524_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_021735_leftImg8bit.png gtFine/test/mainz/mainz_000000_021735_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_021833_leftImg8bit.png gtFine/test/mainz/mainz_000000_021833_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_022091_leftImg8bit.png gtFine/test/mainz/mainz_000000_022091_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000000_022417_leftImg8bit.png gtFine/test/mainz/mainz_000000_022417_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_000120_leftImg8bit.png gtFine/test/mainz/mainz_000001_000120_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_000428_leftImg8bit.png gtFine/test/mainz/mainz_000001_000428_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_001509_leftImg8bit.png gtFine/test/mainz/mainz_000001_001509_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_002033_leftImg8bit.png gtFine/test/mainz/mainz_000001_002033_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_002543_leftImg8bit.png gtFine/test/mainz/mainz_000001_002543_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_002884_leftImg8bit.png gtFine/test/mainz/mainz_000001_002884_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_003012_leftImg8bit.png gtFine/test/mainz/mainz_000001_003012_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_003624_leftImg8bit.png gtFine/test/mainz/mainz_000001_003624_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_003702_leftImg8bit.png gtFine/test/mainz/mainz_000001_003702_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_003907_leftImg8bit.png gtFine/test/mainz/mainz_000001_003907_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_004132_leftImg8bit.png gtFine/test/mainz/mainz_000001_004132_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_004219_leftImg8bit.png gtFine/test/mainz/mainz_000001_004219_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_004823_leftImg8bit.png gtFine/test/mainz/mainz_000001_004823_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005016_leftImg8bit.png gtFine/test/mainz/mainz_000001_005016_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005163_leftImg8bit.png gtFine/test/mainz/mainz_000001_005163_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005366_leftImg8bit.png gtFine/test/mainz/mainz_000001_005366_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005665_leftImg8bit.png gtFine/test/mainz/mainz_000001_005665_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005815_leftImg8bit.png gtFine/test/mainz/mainz_000001_005815_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_005911_leftImg8bit.png gtFine/test/mainz/mainz_000001_005911_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_006194_leftImg8bit.png gtFine/test/mainz/mainz_000001_006194_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_006768_leftImg8bit.png gtFine/test/mainz/mainz_000001_006768_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_007171_leftImg8bit.png gtFine/test/mainz/mainz_000001_007171_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_007460_leftImg8bit.png gtFine/test/mainz/mainz_000001_007460_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_007595_leftImg8bit.png gtFine/test/mainz/mainz_000001_007595_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_007956_leftImg8bit.png gtFine/test/mainz/mainz_000001_007956_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_008056_leftImg8bit.png gtFine/test/mainz/mainz_000001_008056_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_008264_leftImg8bit.png gtFine/test/mainz/mainz_000001_008264_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_008540_leftImg8bit.png gtFine/test/mainz/mainz_000001_008540_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_008638_leftImg8bit.png gtFine/test/mainz/mainz_000001_008638_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_008771_leftImg8bit.png gtFine/test/mainz/mainz_000001_008771_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_009152_leftImg8bit.png gtFine/test/mainz/mainz_000001_009152_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_009328_leftImg8bit.png gtFine/test/mainz/mainz_000001_009328_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_009811_leftImg8bit.png gtFine/test/mainz/mainz_000001_009811_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_009867_leftImg8bit.png gtFine/test/mainz/mainz_000001_009867_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_009996_leftImg8bit.png gtFine/test/mainz/mainz_000001_009996_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_010853_leftImg8bit.png gtFine/test/mainz/mainz_000001_010853_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_011333_leftImg8bit.png gtFine/test/mainz/mainz_000001_011333_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_011736_leftImg8bit.png gtFine/test/mainz/mainz_000001_011736_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_011785_leftImg8bit.png gtFine/test/mainz/mainz_000001_011785_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_012186_leftImg8bit.png gtFine/test/mainz/mainz_000001_012186_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_012470_leftImg8bit.png gtFine/test/mainz/mainz_000001_012470_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_012541_leftImg8bit.png gtFine/test/mainz/mainz_000001_012541_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_012644_leftImg8bit.png gtFine/test/mainz/mainz_000001_012644_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_012950_leftImg8bit.png gtFine/test/mainz/mainz_000001_012950_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_013313_leftImg8bit.png gtFine/test/mainz/mainz_000001_013313_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_014073_leftImg8bit.png gtFine/test/mainz/mainz_000001_014073_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_014469_leftImg8bit.png gtFine/test/mainz/mainz_000001_014469_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_014626_leftImg8bit.png gtFine/test/mainz/mainz_000001_014626_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_015117_leftImg8bit.png gtFine/test/mainz/mainz_000001_015117_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_015235_leftImg8bit.png gtFine/test/mainz/mainz_000001_015235_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_015508_leftImg8bit.png gtFine/test/mainz/mainz_000001_015508_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_015724_leftImg8bit.png gtFine/test/mainz/mainz_000001_015724_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_016011_leftImg8bit.png gtFine/test/mainz/mainz_000001_016011_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_016391_leftImg8bit.png gtFine/test/mainz/mainz_000001_016391_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_016931_leftImg8bit.png gtFine/test/mainz/mainz_000001_016931_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_017618_leftImg8bit.png gtFine/test/mainz/mainz_000001_017618_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_017992_leftImg8bit.png gtFine/test/mainz/mainz_000001_017992_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_018145_leftImg8bit.png gtFine/test/mainz/mainz_000001_018145_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_018329_leftImg8bit.png gtFine/test/mainz/mainz_000001_018329_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_018670_leftImg8bit.png gtFine/test/mainz/mainz_000001_018670_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_018817_leftImg8bit.png gtFine/test/mainz/mainz_000001_018817_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_019061_leftImg8bit.png gtFine/test/mainz/mainz_000001_019061_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_019286_leftImg8bit.png gtFine/test/mainz/mainz_000001_019286_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_019593_leftImg8bit.png gtFine/test/mainz/mainz_000001_019593_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_020068_leftImg8bit.png gtFine/test/mainz/mainz_000001_020068_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_020193_leftImg8bit.png gtFine/test/mainz/mainz_000001_020193_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_020484_leftImg8bit.png gtFine/test/mainz/mainz_000001_020484_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_020829_leftImg8bit.png gtFine/test/mainz/mainz_000001_020829_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_021042_leftImg8bit.png gtFine/test/mainz/mainz_000001_021042_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_021547_leftImg8bit.png gtFine/test/mainz/mainz_000001_021547_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_021892_leftImg8bit.png gtFine/test/mainz/mainz_000001_021892_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_021946_leftImg8bit.png gtFine/test/mainz/mainz_000001_021946_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_022125_leftImg8bit.png gtFine/test/mainz/mainz_000001_022125_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_022630_leftImg8bit.png gtFine/test/mainz/mainz_000001_022630_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_023439_leftImg8bit.png gtFine/test/mainz/mainz_000001_023439_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_023604_leftImg8bit.png gtFine/test/mainz/mainz_000001_023604_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_024439_leftImg8bit.png gtFine/test/mainz/mainz_000001_024439_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_024489_leftImg8bit.png gtFine/test/mainz/mainz_000001_024489_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_024718_leftImg8bit.png gtFine/test/mainz/mainz_000001_024718_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_025161_leftImg8bit.png gtFine/test/mainz/mainz_000001_025161_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_025390_leftImg8bit.png gtFine/test/mainz/mainz_000001_025390_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_025623_leftImg8bit.png gtFine/test/mainz/mainz_000001_025623_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_026209_leftImg8bit.png gtFine/test/mainz/mainz_000001_026209_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_026837_leftImg8bit.png gtFine/test/mainz/mainz_000001_026837_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_026963_leftImg8bit.png gtFine/test/mainz/mainz_000001_026963_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_027053_leftImg8bit.png gtFine/test/mainz/mainz_000001_027053_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_027124_leftImg8bit.png gtFine/test/mainz/mainz_000001_027124_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_027377_leftImg8bit.png gtFine/test/mainz/mainz_000001_027377_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_027675_leftImg8bit.png gtFine/test/mainz/mainz_000001_027675_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_027751_leftImg8bit.png gtFine/test/mainz/mainz_000001_027751_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_028111_leftImg8bit.png gtFine/test/mainz/mainz_000001_028111_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_028326_leftImg8bit.png gtFine/test/mainz/mainz_000001_028326_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_028566_leftImg8bit.png gtFine/test/mainz/mainz_000001_028566_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_028847_leftImg8bit.png gtFine/test/mainz/mainz_000001_028847_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_029293_leftImg8bit.png gtFine/test/mainz/mainz_000001_029293_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_029521_leftImg8bit.png gtFine/test/mainz/mainz_000001_029521_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_029755_leftImg8bit.png gtFine/test/mainz/mainz_000001_029755_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_029950_leftImg8bit.png gtFine/test/mainz/mainz_000001_029950_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_030417_leftImg8bit.png gtFine/test/mainz/mainz_000001_030417_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_030630_leftImg8bit.png gtFine/test/mainz/mainz_000001_030630_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_031026_leftImg8bit.png gtFine/test/mainz/mainz_000001_031026_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_031350_leftImg8bit.png gtFine/test/mainz/mainz_000001_031350_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_031697_leftImg8bit.png gtFine/test/mainz/mainz_000001_031697_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_031946_leftImg8bit.png gtFine/test/mainz/mainz_000001_031946_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032294_leftImg8bit.png gtFine/test/mainz/mainz_000001_032294_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032401_leftImg8bit.png gtFine/test/mainz/mainz_000001_032401_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032567_leftImg8bit.png gtFine/test/mainz/mainz_000001_032567_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032691_leftImg8bit.png gtFine/test/mainz/mainz_000001_032691_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032767_leftImg8bit.png gtFine/test/mainz/mainz_000001_032767_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_032911_leftImg8bit.png gtFine/test/mainz/mainz_000001_032911_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_033096_leftImg8bit.png gtFine/test/mainz/mainz_000001_033096_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_033329_leftImg8bit.png gtFine/test/mainz/mainz_000001_033329_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_033437_leftImg8bit.png gtFine/test/mainz/mainz_000001_033437_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_033603_leftImg8bit.png gtFine/test/mainz/mainz_000001_033603_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_033756_leftImg8bit.png gtFine/test/mainz/mainz_000001_033756_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_034033_leftImg8bit.png gtFine/test/mainz/mainz_000001_034033_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_034209_leftImg8bit.png gtFine/test/mainz/mainz_000001_034209_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_034394_leftImg8bit.png gtFine/test/mainz/mainz_000001_034394_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_034508_leftImg8bit.png gtFine/test/mainz/mainz_000001_034508_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_034681_leftImg8bit.png gtFine/test/mainz/mainz_000001_034681_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_035293_leftImg8bit.png gtFine/test/mainz/mainz_000001_035293_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_035585_leftImg8bit.png gtFine/test/mainz/mainz_000001_035585_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_035963_leftImg8bit.png gtFine/test/mainz/mainz_000001_035963_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_036115_leftImg8bit.png gtFine/test/mainz/mainz_000001_036115_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_036240_leftImg8bit.png gtFine/test/mainz/mainz_000001_036240_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_036412_leftImg8bit.png gtFine/test/mainz/mainz_000001_036412_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_037170_leftImg8bit.png gtFine/test/mainz/mainz_000001_037170_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_037411_leftImg8bit.png gtFine/test/mainz/mainz_000001_037411_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_037532_leftImg8bit.png gtFine/test/mainz/mainz_000001_037532_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_037736_leftImg8bit.png gtFine/test/mainz/mainz_000001_037736_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_037905_leftImg8bit.png gtFine/test/mainz/mainz_000001_037905_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_038026_leftImg8bit.png gtFine/test/mainz/mainz_000001_038026_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_038191_leftImg8bit.png gtFine/test/mainz/mainz_000001_038191_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_038347_leftImg8bit.png gtFine/test/mainz/mainz_000001_038347_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_038768_leftImg8bit.png gtFine/test/mainz/mainz_000001_038768_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_038955_leftImg8bit.png gtFine/test/mainz/mainz_000001_038955_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_039075_leftImg8bit.png gtFine/test/mainz/mainz_000001_039075_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_039470_leftImg8bit.png gtFine/test/mainz/mainz_000001_039470_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_039943_leftImg8bit.png gtFine/test/mainz/mainz_000001_039943_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_040195_leftImg8bit.png gtFine/test/mainz/mainz_000001_040195_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_040367_leftImg8bit.png gtFine/test/mainz/mainz_000001_040367_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_040839_leftImg8bit.png gtFine/test/mainz/mainz_000001_040839_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041172_leftImg8bit.png gtFine/test/mainz/mainz_000001_041172_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041284_leftImg8bit.png gtFine/test/mainz/mainz_000001_041284_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041647_leftImg8bit.png gtFine/test/mainz/mainz_000001_041647_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041797_leftImg8bit.png gtFine/test/mainz/mainz_000001_041797_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041887_leftImg8bit.png gtFine/test/mainz/mainz_000001_041887_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_041923_leftImg8bit.png gtFine/test/mainz/mainz_000001_041923_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_042121_leftImg8bit.png gtFine/test/mainz/mainz_000001_042121_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_042400_leftImg8bit.png gtFine/test/mainz/mainz_000001_042400_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_042851_leftImg8bit.png gtFine/test/mainz/mainz_000001_042851_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_043656_leftImg8bit.png gtFine/test/mainz/mainz_000001_043656_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_043886_leftImg8bit.png gtFine/test/mainz/mainz_000001_043886_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_044366_leftImg8bit.png gtFine/test/mainz/mainz_000001_044366_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_044619_leftImg8bit.png gtFine/test/mainz/mainz_000001_044619_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_045197_leftImg8bit.png gtFine/test/mainz/mainz_000001_045197_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_045385_leftImg8bit.png gtFine/test/mainz/mainz_000001_045385_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_045651_leftImg8bit.png gtFine/test/mainz/mainz_000001_045651_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_045782_leftImg8bit.png gtFine/test/mainz/mainz_000001_045782_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_046381_leftImg8bit.png gtFine/test/mainz/mainz_000001_046381_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_046981_leftImg8bit.png gtFine/test/mainz/mainz_000001_046981_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_047546_leftImg8bit.png gtFine/test/mainz/mainz_000001_047546_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_047611_leftImg8bit.png gtFine/test/mainz/mainz_000001_047611_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_047888_leftImg8bit.png gtFine/test/mainz/mainz_000001_047888_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000001_048725_leftImg8bit.png gtFine/test/mainz/mainz_000001_048725_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_000061_leftImg8bit.png gtFine/test/mainz/mainz_000002_000061_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_000181_leftImg8bit.png gtFine/test/mainz/mainz_000002_000181_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_000381_leftImg8bit.png gtFine/test/mainz/mainz_000002_000381_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_000912_leftImg8bit.png gtFine/test/mainz/mainz_000002_000912_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_001747_leftImg8bit.png gtFine/test/mainz/mainz_000002_001747_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_001871_leftImg8bit.png gtFine/test/mainz/mainz_000002_001871_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000002_002279_leftImg8bit.png gtFine/test/mainz/mainz_000002_002279_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_000043_leftImg8bit.png gtFine/test/mainz/mainz_000003_000043_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_000968_leftImg8bit.png gtFine/test/mainz/mainz_000003_000968_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_001465_leftImg8bit.png gtFine/test/mainz/mainz_000003_001465_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_001694_leftImg8bit.png gtFine/test/mainz/mainz_000003_001694_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_001899_leftImg8bit.png gtFine/test/mainz/mainz_000003_001899_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003042_leftImg8bit.png gtFine/test/mainz/mainz_000003_003042_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003455_leftImg8bit.png gtFine/test/mainz/mainz_000003_003455_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003558_leftImg8bit.png gtFine/test/mainz/mainz_000003_003558_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003711_leftImg8bit.png gtFine/test/mainz/mainz_000003_003711_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003791_leftImg8bit.png gtFine/test/mainz/mainz_000003_003791_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_003942_leftImg8bit.png gtFine/test/mainz/mainz_000003_003942_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_004144_leftImg8bit.png gtFine/test/mainz/mainz_000003_004144_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_004228_leftImg8bit.png gtFine/test/mainz/mainz_000003_004228_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_004576_leftImg8bit.png gtFine/test/mainz/mainz_000003_004576_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_004774_leftImg8bit.png gtFine/test/mainz/mainz_000003_004774_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_004883_leftImg8bit.png gtFine/test/mainz/mainz_000003_004883_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_005029_leftImg8bit.png gtFine/test/mainz/mainz_000003_005029_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_005088_leftImg8bit.png gtFine/test/mainz/mainz_000003_005088_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_005162_leftImg8bit.png gtFine/test/mainz/mainz_000003_005162_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_006478_leftImg8bit.png gtFine/test/mainz/mainz_000003_006478_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_006863_leftImg8bit.png gtFine/test/mainz/mainz_000003_006863_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_007024_leftImg8bit.png gtFine/test/mainz/mainz_000003_007024_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_007144_leftImg8bit.png gtFine/test/mainz/mainz_000003_007144_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_007255_leftImg8bit.png gtFine/test/mainz/mainz_000003_007255_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_007701_leftImg8bit.png gtFine/test/mainz/mainz_000003_007701_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_008258_leftImg8bit.png gtFine/test/mainz/mainz_000003_008258_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_008690_leftImg8bit.png gtFine/test/mainz/mainz_000003_008690_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_008876_leftImg8bit.png gtFine/test/mainz/mainz_000003_008876_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_009819_leftImg8bit.png gtFine/test/mainz/mainz_000003_009819_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_010019_leftImg8bit.png gtFine/test/mainz/mainz_000003_010019_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_010772_leftImg8bit.png gtFine/test/mainz/mainz_000003_010772_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_010880_leftImg8bit.png gtFine/test/mainz/mainz_000003_010880_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_010924_leftImg8bit.png gtFine/test/mainz/mainz_000003_010924_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_011182_leftImg8bit.png gtFine/test/mainz/mainz_000003_011182_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_011352_leftImg8bit.png gtFine/test/mainz/mainz_000003_011352_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_011949_leftImg8bit.png gtFine/test/mainz/mainz_000003_011949_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_012168_leftImg8bit.png gtFine/test/mainz/mainz_000003_012168_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_012341_leftImg8bit.png gtFine/test/mainz/mainz_000003_012341_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_012995_leftImg8bit.png gtFine/test/mainz/mainz_000003_012995_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_013348_leftImg8bit.png gtFine/test/mainz/mainz_000003_013348_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_013983_leftImg8bit.png gtFine/test/mainz/mainz_000003_013983_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_014083_leftImg8bit.png gtFine/test/mainz/mainz_000003_014083_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_014319_leftImg8bit.png gtFine/test/mainz/mainz_000003_014319_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_014457_leftImg8bit.png gtFine/test/mainz/mainz_000003_014457_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_014537_leftImg8bit.png gtFine/test/mainz/mainz_000003_014537_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_014959_leftImg8bit.png gtFine/test/mainz/mainz_000003_014959_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_015411_leftImg8bit.png gtFine/test/mainz/mainz_000003_015411_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_015649_leftImg8bit.png gtFine/test/mainz/mainz_000003_015649_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_015917_leftImg8bit.png gtFine/test/mainz/mainz_000003_015917_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_016360_leftImg8bit.png gtFine/test/mainz/mainz_000003_016360_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_016542_leftImg8bit.png gtFine/test/mainz/mainz_000003_016542_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_016708_leftImg8bit.png gtFine/test/mainz/mainz_000003_016708_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_016877_leftImg8bit.png gtFine/test/mainz/mainz_000003_016877_gtFine_labelTrainIds.png +leftImg8bit/test/mainz/mainz_000003_017171_leftImg8bit.png gtFine/test/mainz/mainz_000003_017171_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000000_000019_leftImg8bit.png gtFine/test/munich/munich_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000001_000019_leftImg8bit.png gtFine/test/munich/munich_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000002_000019_leftImg8bit.png gtFine/test/munich/munich_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000003_000019_leftImg8bit.png gtFine/test/munich/munich_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000004_000019_leftImg8bit.png gtFine/test/munich/munich_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000005_000019_leftImg8bit.png gtFine/test/munich/munich_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000006_000019_leftImg8bit.png gtFine/test/munich/munich_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000007_000019_leftImg8bit.png gtFine/test/munich/munich_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000008_000019_leftImg8bit.png gtFine/test/munich/munich_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000009_000019_leftImg8bit.png gtFine/test/munich/munich_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000010_000019_leftImg8bit.png gtFine/test/munich/munich_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000011_000019_leftImg8bit.png gtFine/test/munich/munich_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000012_000019_leftImg8bit.png gtFine/test/munich/munich_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000013_000019_leftImg8bit.png gtFine/test/munich/munich_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000014_000019_leftImg8bit.png gtFine/test/munich/munich_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000015_000019_leftImg8bit.png gtFine/test/munich/munich_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000016_000019_leftImg8bit.png gtFine/test/munich/munich_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000017_000019_leftImg8bit.png gtFine/test/munich/munich_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000018_000019_leftImg8bit.png gtFine/test/munich/munich_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000019_000019_leftImg8bit.png gtFine/test/munich/munich_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000020_000019_leftImg8bit.png gtFine/test/munich/munich_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000021_000019_leftImg8bit.png gtFine/test/munich/munich_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000022_000019_leftImg8bit.png gtFine/test/munich/munich_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000023_000019_leftImg8bit.png gtFine/test/munich/munich_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000024_000019_leftImg8bit.png gtFine/test/munich/munich_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000025_000019_leftImg8bit.png gtFine/test/munich/munich_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000026_000019_leftImg8bit.png gtFine/test/munich/munich_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000027_000019_leftImg8bit.png gtFine/test/munich/munich_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000028_000019_leftImg8bit.png gtFine/test/munich/munich_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000029_000019_leftImg8bit.png gtFine/test/munich/munich_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000030_000019_leftImg8bit.png gtFine/test/munich/munich_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000031_000019_leftImg8bit.png gtFine/test/munich/munich_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000032_000019_leftImg8bit.png gtFine/test/munich/munich_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000033_000019_leftImg8bit.png gtFine/test/munich/munich_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000034_000019_leftImg8bit.png gtFine/test/munich/munich_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000035_000019_leftImg8bit.png gtFine/test/munich/munich_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000036_000019_leftImg8bit.png gtFine/test/munich/munich_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000037_000019_leftImg8bit.png gtFine/test/munich/munich_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000038_000019_leftImg8bit.png gtFine/test/munich/munich_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000039_000019_leftImg8bit.png gtFine/test/munich/munich_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000040_000019_leftImg8bit.png gtFine/test/munich/munich_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000041_000019_leftImg8bit.png gtFine/test/munich/munich_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000042_000019_leftImg8bit.png gtFine/test/munich/munich_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000043_000019_leftImg8bit.png gtFine/test/munich/munich_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000044_000019_leftImg8bit.png gtFine/test/munich/munich_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000045_000019_leftImg8bit.png gtFine/test/munich/munich_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000046_000019_leftImg8bit.png gtFine/test/munich/munich_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000047_000019_leftImg8bit.png gtFine/test/munich/munich_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000048_000019_leftImg8bit.png gtFine/test/munich/munich_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000049_000019_leftImg8bit.png gtFine/test/munich/munich_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000050_000019_leftImg8bit.png gtFine/test/munich/munich_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000051_000019_leftImg8bit.png gtFine/test/munich/munich_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000052_000019_leftImg8bit.png gtFine/test/munich/munich_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000053_000019_leftImg8bit.png gtFine/test/munich/munich_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000054_000019_leftImg8bit.png gtFine/test/munich/munich_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000055_000019_leftImg8bit.png gtFine/test/munich/munich_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000056_000019_leftImg8bit.png gtFine/test/munich/munich_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000057_000019_leftImg8bit.png gtFine/test/munich/munich_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000058_000019_leftImg8bit.png gtFine/test/munich/munich_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000059_000019_leftImg8bit.png gtFine/test/munich/munich_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000060_000019_leftImg8bit.png gtFine/test/munich/munich_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000061_000019_leftImg8bit.png gtFine/test/munich/munich_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000062_000019_leftImg8bit.png gtFine/test/munich/munich_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000063_000019_leftImg8bit.png gtFine/test/munich/munich_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000064_000019_leftImg8bit.png gtFine/test/munich/munich_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000065_000019_leftImg8bit.png gtFine/test/munich/munich_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000066_000019_leftImg8bit.png gtFine/test/munich/munich_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000067_000019_leftImg8bit.png gtFine/test/munich/munich_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000068_000019_leftImg8bit.png gtFine/test/munich/munich_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000069_000019_leftImg8bit.png gtFine/test/munich/munich_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000070_000019_leftImg8bit.png gtFine/test/munich/munich_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000071_000019_leftImg8bit.png gtFine/test/munich/munich_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000072_000019_leftImg8bit.png gtFine/test/munich/munich_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000073_000019_leftImg8bit.png gtFine/test/munich/munich_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000074_000019_leftImg8bit.png gtFine/test/munich/munich_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000075_000019_leftImg8bit.png gtFine/test/munich/munich_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000076_000019_leftImg8bit.png gtFine/test/munich/munich_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000077_000019_leftImg8bit.png gtFine/test/munich/munich_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000078_000019_leftImg8bit.png gtFine/test/munich/munich_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000079_000019_leftImg8bit.png gtFine/test/munich/munich_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000080_000019_leftImg8bit.png gtFine/test/munich/munich_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000081_000019_leftImg8bit.png gtFine/test/munich/munich_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000082_000019_leftImg8bit.png gtFine/test/munich/munich_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000083_000019_leftImg8bit.png gtFine/test/munich/munich_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000084_000019_leftImg8bit.png gtFine/test/munich/munich_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000085_000019_leftImg8bit.png gtFine/test/munich/munich_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000086_000019_leftImg8bit.png gtFine/test/munich/munich_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000087_000019_leftImg8bit.png gtFine/test/munich/munich_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000088_000019_leftImg8bit.png gtFine/test/munich/munich_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000089_000019_leftImg8bit.png gtFine/test/munich/munich_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000090_000019_leftImg8bit.png gtFine/test/munich/munich_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000091_000019_leftImg8bit.png gtFine/test/munich/munich_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000092_000019_leftImg8bit.png gtFine/test/munich/munich_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000093_000019_leftImg8bit.png gtFine/test/munich/munich_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000094_000019_leftImg8bit.png gtFine/test/munich/munich_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000095_000019_leftImg8bit.png gtFine/test/munich/munich_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000096_000019_leftImg8bit.png gtFine/test/munich/munich_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000097_000019_leftImg8bit.png gtFine/test/munich/munich_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000098_000019_leftImg8bit.png gtFine/test/munich/munich_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000099_000019_leftImg8bit.png gtFine/test/munich/munich_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000100_000019_leftImg8bit.png gtFine/test/munich/munich_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000101_000019_leftImg8bit.png gtFine/test/munich/munich_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000102_000019_leftImg8bit.png gtFine/test/munich/munich_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000103_000019_leftImg8bit.png gtFine/test/munich/munich_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000104_000019_leftImg8bit.png gtFine/test/munich/munich_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000105_000019_leftImg8bit.png gtFine/test/munich/munich_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000106_000019_leftImg8bit.png gtFine/test/munich/munich_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000107_000019_leftImg8bit.png gtFine/test/munich/munich_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000108_000019_leftImg8bit.png gtFine/test/munich/munich_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000109_000019_leftImg8bit.png gtFine/test/munich/munich_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000110_000019_leftImg8bit.png gtFine/test/munich/munich_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000111_000019_leftImg8bit.png gtFine/test/munich/munich_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000112_000019_leftImg8bit.png gtFine/test/munich/munich_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000113_000019_leftImg8bit.png gtFine/test/munich/munich_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000114_000019_leftImg8bit.png gtFine/test/munich/munich_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000115_000019_leftImg8bit.png gtFine/test/munich/munich_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000116_000019_leftImg8bit.png gtFine/test/munich/munich_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000117_000019_leftImg8bit.png gtFine/test/munich/munich_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000118_000019_leftImg8bit.png gtFine/test/munich/munich_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000119_000019_leftImg8bit.png gtFine/test/munich/munich_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000120_000019_leftImg8bit.png gtFine/test/munich/munich_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000121_000019_leftImg8bit.png gtFine/test/munich/munich_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000122_000019_leftImg8bit.png gtFine/test/munich/munich_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000123_000019_leftImg8bit.png gtFine/test/munich/munich_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000124_000019_leftImg8bit.png gtFine/test/munich/munich_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000125_000019_leftImg8bit.png gtFine/test/munich/munich_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000126_000019_leftImg8bit.png gtFine/test/munich/munich_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000127_000019_leftImg8bit.png gtFine/test/munich/munich_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000128_000019_leftImg8bit.png gtFine/test/munich/munich_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000129_000019_leftImg8bit.png gtFine/test/munich/munich_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000130_000019_leftImg8bit.png gtFine/test/munich/munich_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000131_000019_leftImg8bit.png gtFine/test/munich/munich_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000132_000019_leftImg8bit.png gtFine/test/munich/munich_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000133_000019_leftImg8bit.png gtFine/test/munich/munich_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000134_000019_leftImg8bit.png gtFine/test/munich/munich_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000135_000019_leftImg8bit.png gtFine/test/munich/munich_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000136_000019_leftImg8bit.png gtFine/test/munich/munich_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000137_000019_leftImg8bit.png gtFine/test/munich/munich_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000138_000019_leftImg8bit.png gtFine/test/munich/munich_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000139_000019_leftImg8bit.png gtFine/test/munich/munich_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000140_000019_leftImg8bit.png gtFine/test/munich/munich_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000141_000019_leftImg8bit.png gtFine/test/munich/munich_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000142_000019_leftImg8bit.png gtFine/test/munich/munich_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000143_000019_leftImg8bit.png gtFine/test/munich/munich_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000144_000019_leftImg8bit.png gtFine/test/munich/munich_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000145_000019_leftImg8bit.png gtFine/test/munich/munich_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000146_000019_leftImg8bit.png gtFine/test/munich/munich_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000147_000019_leftImg8bit.png gtFine/test/munich/munich_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000148_000019_leftImg8bit.png gtFine/test/munich/munich_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000149_000019_leftImg8bit.png gtFine/test/munich/munich_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000150_000019_leftImg8bit.png gtFine/test/munich/munich_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000151_000019_leftImg8bit.png gtFine/test/munich/munich_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000152_000019_leftImg8bit.png gtFine/test/munich/munich_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000153_000019_leftImg8bit.png gtFine/test/munich/munich_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000154_000019_leftImg8bit.png gtFine/test/munich/munich_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000155_000019_leftImg8bit.png gtFine/test/munich/munich_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000156_000019_leftImg8bit.png gtFine/test/munich/munich_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000157_000019_leftImg8bit.png gtFine/test/munich/munich_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000158_000019_leftImg8bit.png gtFine/test/munich/munich_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000159_000019_leftImg8bit.png gtFine/test/munich/munich_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000160_000019_leftImg8bit.png gtFine/test/munich/munich_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000161_000019_leftImg8bit.png gtFine/test/munich/munich_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000162_000019_leftImg8bit.png gtFine/test/munich/munich_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000163_000019_leftImg8bit.png gtFine/test/munich/munich_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000164_000019_leftImg8bit.png gtFine/test/munich/munich_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000165_000019_leftImg8bit.png gtFine/test/munich/munich_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000166_000019_leftImg8bit.png gtFine/test/munich/munich_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000167_000019_leftImg8bit.png gtFine/test/munich/munich_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000168_000019_leftImg8bit.png gtFine/test/munich/munich_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000169_000019_leftImg8bit.png gtFine/test/munich/munich_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000170_000019_leftImg8bit.png gtFine/test/munich/munich_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000171_000019_leftImg8bit.png gtFine/test/munich/munich_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000172_000019_leftImg8bit.png gtFine/test/munich/munich_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000173_000019_leftImg8bit.png gtFine/test/munich/munich_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000174_000019_leftImg8bit.png gtFine/test/munich/munich_000174_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000175_000019_leftImg8bit.png gtFine/test/munich/munich_000175_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000176_000019_leftImg8bit.png gtFine/test/munich/munich_000176_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000177_000019_leftImg8bit.png gtFine/test/munich/munich_000177_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000178_000019_leftImg8bit.png gtFine/test/munich/munich_000178_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000179_000019_leftImg8bit.png gtFine/test/munich/munich_000179_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000180_000019_leftImg8bit.png gtFine/test/munich/munich_000180_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000181_000019_leftImg8bit.png gtFine/test/munich/munich_000181_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000182_000019_leftImg8bit.png gtFine/test/munich/munich_000182_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000183_000019_leftImg8bit.png gtFine/test/munich/munich_000183_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000184_000019_leftImg8bit.png gtFine/test/munich/munich_000184_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000185_000019_leftImg8bit.png gtFine/test/munich/munich_000185_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000186_000019_leftImg8bit.png gtFine/test/munich/munich_000186_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000187_000019_leftImg8bit.png gtFine/test/munich/munich_000187_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000188_000019_leftImg8bit.png gtFine/test/munich/munich_000188_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000189_000019_leftImg8bit.png gtFine/test/munich/munich_000189_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000190_000019_leftImg8bit.png gtFine/test/munich/munich_000190_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000191_000019_leftImg8bit.png gtFine/test/munich/munich_000191_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000192_000019_leftImg8bit.png gtFine/test/munich/munich_000192_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000193_000019_leftImg8bit.png gtFine/test/munich/munich_000193_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000194_000019_leftImg8bit.png gtFine/test/munich/munich_000194_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000195_000019_leftImg8bit.png gtFine/test/munich/munich_000195_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000196_000019_leftImg8bit.png gtFine/test/munich/munich_000196_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000197_000019_leftImg8bit.png gtFine/test/munich/munich_000197_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000198_000019_leftImg8bit.png gtFine/test/munich/munich_000198_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000199_000019_leftImg8bit.png gtFine/test/munich/munich_000199_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000200_000019_leftImg8bit.png gtFine/test/munich/munich_000200_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000201_000019_leftImg8bit.png gtFine/test/munich/munich_000201_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000202_000019_leftImg8bit.png gtFine/test/munich/munich_000202_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000203_000019_leftImg8bit.png gtFine/test/munich/munich_000203_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000204_000019_leftImg8bit.png gtFine/test/munich/munich_000204_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000205_000019_leftImg8bit.png gtFine/test/munich/munich_000205_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000206_000019_leftImg8bit.png gtFine/test/munich/munich_000206_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000207_000019_leftImg8bit.png gtFine/test/munich/munich_000207_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000208_000019_leftImg8bit.png gtFine/test/munich/munich_000208_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000209_000019_leftImg8bit.png gtFine/test/munich/munich_000209_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000210_000019_leftImg8bit.png gtFine/test/munich/munich_000210_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000211_000019_leftImg8bit.png gtFine/test/munich/munich_000211_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000212_000019_leftImg8bit.png gtFine/test/munich/munich_000212_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000213_000019_leftImg8bit.png gtFine/test/munich/munich_000213_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000214_000019_leftImg8bit.png gtFine/test/munich/munich_000214_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000215_000019_leftImg8bit.png gtFine/test/munich/munich_000215_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000216_000019_leftImg8bit.png gtFine/test/munich/munich_000216_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000217_000019_leftImg8bit.png gtFine/test/munich/munich_000217_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000218_000019_leftImg8bit.png gtFine/test/munich/munich_000218_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000219_000019_leftImg8bit.png gtFine/test/munich/munich_000219_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000220_000019_leftImg8bit.png gtFine/test/munich/munich_000220_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000221_000019_leftImg8bit.png gtFine/test/munich/munich_000221_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000222_000019_leftImg8bit.png gtFine/test/munich/munich_000222_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000223_000019_leftImg8bit.png gtFine/test/munich/munich_000223_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000224_000019_leftImg8bit.png gtFine/test/munich/munich_000224_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000225_000019_leftImg8bit.png gtFine/test/munich/munich_000225_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000226_000019_leftImg8bit.png gtFine/test/munich/munich_000226_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000227_000019_leftImg8bit.png gtFine/test/munich/munich_000227_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000228_000019_leftImg8bit.png gtFine/test/munich/munich_000228_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000229_000019_leftImg8bit.png gtFine/test/munich/munich_000229_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000230_000019_leftImg8bit.png gtFine/test/munich/munich_000230_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000231_000019_leftImg8bit.png gtFine/test/munich/munich_000231_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000232_000019_leftImg8bit.png gtFine/test/munich/munich_000232_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000233_000019_leftImg8bit.png gtFine/test/munich/munich_000233_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000234_000019_leftImg8bit.png gtFine/test/munich/munich_000234_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000235_000019_leftImg8bit.png gtFine/test/munich/munich_000235_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000236_000019_leftImg8bit.png gtFine/test/munich/munich_000236_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000237_000019_leftImg8bit.png gtFine/test/munich/munich_000237_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000238_000019_leftImg8bit.png gtFine/test/munich/munich_000238_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000239_000019_leftImg8bit.png gtFine/test/munich/munich_000239_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000240_000019_leftImg8bit.png gtFine/test/munich/munich_000240_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000241_000019_leftImg8bit.png gtFine/test/munich/munich_000241_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000242_000019_leftImg8bit.png gtFine/test/munich/munich_000242_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000243_000019_leftImg8bit.png gtFine/test/munich/munich_000243_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000244_000019_leftImg8bit.png gtFine/test/munich/munich_000244_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000245_000019_leftImg8bit.png gtFine/test/munich/munich_000245_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000246_000019_leftImg8bit.png gtFine/test/munich/munich_000246_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000247_000019_leftImg8bit.png gtFine/test/munich/munich_000247_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000248_000019_leftImg8bit.png gtFine/test/munich/munich_000248_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000249_000019_leftImg8bit.png gtFine/test/munich/munich_000249_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000250_000019_leftImg8bit.png gtFine/test/munich/munich_000250_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000251_000019_leftImg8bit.png gtFine/test/munich/munich_000251_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000252_000019_leftImg8bit.png gtFine/test/munich/munich_000252_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000253_000019_leftImg8bit.png gtFine/test/munich/munich_000253_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000254_000019_leftImg8bit.png gtFine/test/munich/munich_000254_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000255_000019_leftImg8bit.png gtFine/test/munich/munich_000255_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000256_000019_leftImg8bit.png gtFine/test/munich/munich_000256_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000257_000019_leftImg8bit.png gtFine/test/munich/munich_000257_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000258_000019_leftImg8bit.png gtFine/test/munich/munich_000258_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000259_000019_leftImg8bit.png gtFine/test/munich/munich_000259_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000260_000019_leftImg8bit.png gtFine/test/munich/munich_000260_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000261_000019_leftImg8bit.png gtFine/test/munich/munich_000261_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000262_000019_leftImg8bit.png gtFine/test/munich/munich_000262_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000263_000019_leftImg8bit.png gtFine/test/munich/munich_000263_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000264_000019_leftImg8bit.png gtFine/test/munich/munich_000264_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000265_000019_leftImg8bit.png gtFine/test/munich/munich_000265_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000266_000019_leftImg8bit.png gtFine/test/munich/munich_000266_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000267_000019_leftImg8bit.png gtFine/test/munich/munich_000267_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000268_000019_leftImg8bit.png gtFine/test/munich/munich_000268_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000269_000019_leftImg8bit.png gtFine/test/munich/munich_000269_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000270_000019_leftImg8bit.png gtFine/test/munich/munich_000270_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000271_000019_leftImg8bit.png gtFine/test/munich/munich_000271_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000272_000019_leftImg8bit.png gtFine/test/munich/munich_000272_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000273_000019_leftImg8bit.png gtFine/test/munich/munich_000273_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000274_000019_leftImg8bit.png gtFine/test/munich/munich_000274_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000275_000019_leftImg8bit.png gtFine/test/munich/munich_000275_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000276_000019_leftImg8bit.png gtFine/test/munich/munich_000276_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000277_000019_leftImg8bit.png gtFine/test/munich/munich_000277_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000278_000019_leftImg8bit.png gtFine/test/munich/munich_000278_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000279_000019_leftImg8bit.png gtFine/test/munich/munich_000279_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000280_000019_leftImg8bit.png gtFine/test/munich/munich_000280_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000281_000019_leftImg8bit.png gtFine/test/munich/munich_000281_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000282_000019_leftImg8bit.png gtFine/test/munich/munich_000282_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000283_000019_leftImg8bit.png gtFine/test/munich/munich_000283_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000284_000019_leftImg8bit.png gtFine/test/munich/munich_000284_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000285_000019_leftImg8bit.png gtFine/test/munich/munich_000285_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000286_000019_leftImg8bit.png gtFine/test/munich/munich_000286_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000287_000019_leftImg8bit.png gtFine/test/munich/munich_000287_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000288_000019_leftImg8bit.png gtFine/test/munich/munich_000288_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000289_000019_leftImg8bit.png gtFine/test/munich/munich_000289_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000290_000019_leftImg8bit.png gtFine/test/munich/munich_000290_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000291_000019_leftImg8bit.png gtFine/test/munich/munich_000291_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000292_000019_leftImg8bit.png gtFine/test/munich/munich_000292_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000293_000019_leftImg8bit.png gtFine/test/munich/munich_000293_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000294_000019_leftImg8bit.png gtFine/test/munich/munich_000294_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000295_000019_leftImg8bit.png gtFine/test/munich/munich_000295_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000296_000019_leftImg8bit.png gtFine/test/munich/munich_000296_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000297_000019_leftImg8bit.png gtFine/test/munich/munich_000297_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000298_000019_leftImg8bit.png gtFine/test/munich/munich_000298_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000299_000019_leftImg8bit.png gtFine/test/munich/munich_000299_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000300_000019_leftImg8bit.png gtFine/test/munich/munich_000300_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000301_000019_leftImg8bit.png gtFine/test/munich/munich_000301_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000302_000019_leftImg8bit.png gtFine/test/munich/munich_000302_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000303_000019_leftImg8bit.png gtFine/test/munich/munich_000303_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000304_000019_leftImg8bit.png gtFine/test/munich/munich_000304_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000305_000019_leftImg8bit.png gtFine/test/munich/munich_000305_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000306_000019_leftImg8bit.png gtFine/test/munich/munich_000306_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000307_000019_leftImg8bit.png gtFine/test/munich/munich_000307_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000308_000019_leftImg8bit.png gtFine/test/munich/munich_000308_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000309_000019_leftImg8bit.png gtFine/test/munich/munich_000309_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000310_000019_leftImg8bit.png gtFine/test/munich/munich_000310_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000311_000019_leftImg8bit.png gtFine/test/munich/munich_000311_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000312_000019_leftImg8bit.png gtFine/test/munich/munich_000312_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000313_000019_leftImg8bit.png gtFine/test/munich/munich_000313_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000314_000019_leftImg8bit.png gtFine/test/munich/munich_000314_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000315_000019_leftImg8bit.png gtFine/test/munich/munich_000315_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000316_000019_leftImg8bit.png gtFine/test/munich/munich_000316_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000317_000019_leftImg8bit.png gtFine/test/munich/munich_000317_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000318_000019_leftImg8bit.png gtFine/test/munich/munich_000318_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000319_000019_leftImg8bit.png gtFine/test/munich/munich_000319_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000320_000019_leftImg8bit.png gtFine/test/munich/munich_000320_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000321_000019_leftImg8bit.png gtFine/test/munich/munich_000321_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000322_000019_leftImg8bit.png gtFine/test/munich/munich_000322_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000323_000019_leftImg8bit.png gtFine/test/munich/munich_000323_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000324_000019_leftImg8bit.png gtFine/test/munich/munich_000324_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000325_000019_leftImg8bit.png gtFine/test/munich/munich_000325_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000326_000019_leftImg8bit.png gtFine/test/munich/munich_000326_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000327_000019_leftImg8bit.png gtFine/test/munich/munich_000327_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000328_000019_leftImg8bit.png gtFine/test/munich/munich_000328_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000329_000019_leftImg8bit.png gtFine/test/munich/munich_000329_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000330_000019_leftImg8bit.png gtFine/test/munich/munich_000330_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000331_000019_leftImg8bit.png gtFine/test/munich/munich_000331_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000332_000019_leftImg8bit.png gtFine/test/munich/munich_000332_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000333_000019_leftImg8bit.png gtFine/test/munich/munich_000333_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000334_000019_leftImg8bit.png gtFine/test/munich/munich_000334_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000335_000019_leftImg8bit.png gtFine/test/munich/munich_000335_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000336_000019_leftImg8bit.png gtFine/test/munich/munich_000336_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000337_000019_leftImg8bit.png gtFine/test/munich/munich_000337_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000338_000019_leftImg8bit.png gtFine/test/munich/munich_000338_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000339_000019_leftImg8bit.png gtFine/test/munich/munich_000339_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000340_000019_leftImg8bit.png gtFine/test/munich/munich_000340_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000341_000019_leftImg8bit.png gtFine/test/munich/munich_000341_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000342_000019_leftImg8bit.png gtFine/test/munich/munich_000342_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000343_000019_leftImg8bit.png gtFine/test/munich/munich_000343_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000344_000019_leftImg8bit.png gtFine/test/munich/munich_000344_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000345_000019_leftImg8bit.png gtFine/test/munich/munich_000345_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000346_000019_leftImg8bit.png gtFine/test/munich/munich_000346_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000347_000019_leftImg8bit.png gtFine/test/munich/munich_000347_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000348_000019_leftImg8bit.png gtFine/test/munich/munich_000348_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000349_000019_leftImg8bit.png gtFine/test/munich/munich_000349_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000350_000019_leftImg8bit.png gtFine/test/munich/munich_000350_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000351_000019_leftImg8bit.png gtFine/test/munich/munich_000351_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000352_000019_leftImg8bit.png gtFine/test/munich/munich_000352_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000353_000019_leftImg8bit.png gtFine/test/munich/munich_000353_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000354_000019_leftImg8bit.png gtFine/test/munich/munich_000354_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000355_000019_leftImg8bit.png gtFine/test/munich/munich_000355_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000356_000019_leftImg8bit.png gtFine/test/munich/munich_000356_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000357_000019_leftImg8bit.png gtFine/test/munich/munich_000357_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000358_000019_leftImg8bit.png gtFine/test/munich/munich_000358_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000359_000019_leftImg8bit.png gtFine/test/munich/munich_000359_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000360_000019_leftImg8bit.png gtFine/test/munich/munich_000360_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000361_000019_leftImg8bit.png gtFine/test/munich/munich_000361_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000362_000019_leftImg8bit.png gtFine/test/munich/munich_000362_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000363_000019_leftImg8bit.png gtFine/test/munich/munich_000363_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000364_000019_leftImg8bit.png gtFine/test/munich/munich_000364_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000365_000019_leftImg8bit.png gtFine/test/munich/munich_000365_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000366_000019_leftImg8bit.png gtFine/test/munich/munich_000366_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000367_000019_leftImg8bit.png gtFine/test/munich/munich_000367_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000368_000019_leftImg8bit.png gtFine/test/munich/munich_000368_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000369_000019_leftImg8bit.png gtFine/test/munich/munich_000369_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000370_000019_leftImg8bit.png gtFine/test/munich/munich_000370_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000371_000019_leftImg8bit.png gtFine/test/munich/munich_000371_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000372_000019_leftImg8bit.png gtFine/test/munich/munich_000372_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000373_000019_leftImg8bit.png gtFine/test/munich/munich_000373_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000374_000019_leftImg8bit.png gtFine/test/munich/munich_000374_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000375_000019_leftImg8bit.png gtFine/test/munich/munich_000375_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000376_000019_leftImg8bit.png gtFine/test/munich/munich_000376_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000377_000019_leftImg8bit.png gtFine/test/munich/munich_000377_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000378_000019_leftImg8bit.png gtFine/test/munich/munich_000378_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000379_000019_leftImg8bit.png gtFine/test/munich/munich_000379_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000380_000019_leftImg8bit.png gtFine/test/munich/munich_000380_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000381_000019_leftImg8bit.png gtFine/test/munich/munich_000381_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000382_000019_leftImg8bit.png gtFine/test/munich/munich_000382_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000383_000019_leftImg8bit.png gtFine/test/munich/munich_000383_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000384_000019_leftImg8bit.png gtFine/test/munich/munich_000384_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000385_000019_leftImg8bit.png gtFine/test/munich/munich_000385_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000386_000019_leftImg8bit.png gtFine/test/munich/munich_000386_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000387_000019_leftImg8bit.png gtFine/test/munich/munich_000387_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000388_000019_leftImg8bit.png gtFine/test/munich/munich_000388_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000389_000019_leftImg8bit.png gtFine/test/munich/munich_000389_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000390_000019_leftImg8bit.png gtFine/test/munich/munich_000390_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000391_000019_leftImg8bit.png gtFine/test/munich/munich_000391_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000392_000019_leftImg8bit.png gtFine/test/munich/munich_000392_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000393_000019_leftImg8bit.png gtFine/test/munich/munich_000393_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000394_000019_leftImg8bit.png gtFine/test/munich/munich_000394_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000395_000019_leftImg8bit.png gtFine/test/munich/munich_000395_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000396_000019_leftImg8bit.png gtFine/test/munich/munich_000396_000019_gtFine_labelTrainIds.png +leftImg8bit/test/munich/munich_000397_000019_leftImg8bit.png gtFine/test/munich/munich_000397_000019_gtFine_labelTrainIds.png diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_train_fine.txt b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_train_fine.txt new file mode 100644 index 000000000..1e7045a2c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_train_fine.txt @@ -0,0 +1,2975 @@ +leftImg8bit/train/aachen/aachen_000000_000019_leftImg8bit.png gtFine/train/aachen/aachen_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000001_000019_leftImg8bit.png gtFine/train/aachen/aachen_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000002_000019_leftImg8bit.png gtFine/train/aachen/aachen_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000003_000019_leftImg8bit.png gtFine/train/aachen/aachen_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000004_000019_leftImg8bit.png gtFine/train/aachen/aachen_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000005_000019_leftImg8bit.png gtFine/train/aachen/aachen_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000006_000019_leftImg8bit.png gtFine/train/aachen/aachen_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000007_000019_leftImg8bit.png gtFine/train/aachen/aachen_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000008_000019_leftImg8bit.png gtFine/train/aachen/aachen_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000009_000019_leftImg8bit.png gtFine/train/aachen/aachen_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000010_000019_leftImg8bit.png gtFine/train/aachen/aachen_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000011_000019_leftImg8bit.png gtFine/train/aachen/aachen_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000012_000019_leftImg8bit.png gtFine/train/aachen/aachen_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000013_000019_leftImg8bit.png gtFine/train/aachen/aachen_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000014_000019_leftImg8bit.png gtFine/train/aachen/aachen_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000015_000019_leftImg8bit.png gtFine/train/aachen/aachen_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000016_000019_leftImg8bit.png gtFine/train/aachen/aachen_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000017_000019_leftImg8bit.png gtFine/train/aachen/aachen_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000018_000019_leftImg8bit.png gtFine/train/aachen/aachen_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000019_000019_leftImg8bit.png gtFine/train/aachen/aachen_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000020_000019_leftImg8bit.png gtFine/train/aachen/aachen_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000021_000019_leftImg8bit.png gtFine/train/aachen/aachen_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000022_000019_leftImg8bit.png gtFine/train/aachen/aachen_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000023_000019_leftImg8bit.png gtFine/train/aachen/aachen_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000024_000019_leftImg8bit.png gtFine/train/aachen/aachen_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000025_000019_leftImg8bit.png gtFine/train/aachen/aachen_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000026_000019_leftImg8bit.png gtFine/train/aachen/aachen_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000027_000019_leftImg8bit.png gtFine/train/aachen/aachen_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000028_000019_leftImg8bit.png gtFine/train/aachen/aachen_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000029_000019_leftImg8bit.png gtFine/train/aachen/aachen_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000030_000019_leftImg8bit.png gtFine/train/aachen/aachen_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000031_000019_leftImg8bit.png gtFine/train/aachen/aachen_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000032_000019_leftImg8bit.png gtFine/train/aachen/aachen_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000033_000019_leftImg8bit.png gtFine/train/aachen/aachen_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000034_000019_leftImg8bit.png gtFine/train/aachen/aachen_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000035_000019_leftImg8bit.png gtFine/train/aachen/aachen_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000036_000019_leftImg8bit.png gtFine/train/aachen/aachen_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000037_000019_leftImg8bit.png gtFine/train/aachen/aachen_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000038_000019_leftImg8bit.png gtFine/train/aachen/aachen_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000039_000019_leftImg8bit.png gtFine/train/aachen/aachen_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000040_000019_leftImg8bit.png gtFine/train/aachen/aachen_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000041_000019_leftImg8bit.png gtFine/train/aachen/aachen_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000042_000019_leftImg8bit.png gtFine/train/aachen/aachen_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000043_000019_leftImg8bit.png gtFine/train/aachen/aachen_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000044_000019_leftImg8bit.png gtFine/train/aachen/aachen_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000045_000019_leftImg8bit.png gtFine/train/aachen/aachen_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000046_000019_leftImg8bit.png gtFine/train/aachen/aachen_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000047_000019_leftImg8bit.png gtFine/train/aachen/aachen_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000048_000019_leftImg8bit.png gtFine/train/aachen/aachen_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000049_000019_leftImg8bit.png gtFine/train/aachen/aachen_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000050_000019_leftImg8bit.png gtFine/train/aachen/aachen_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000051_000019_leftImg8bit.png gtFine/train/aachen/aachen_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000052_000019_leftImg8bit.png gtFine/train/aachen/aachen_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000053_000019_leftImg8bit.png gtFine/train/aachen/aachen_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000054_000019_leftImg8bit.png gtFine/train/aachen/aachen_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000055_000019_leftImg8bit.png gtFine/train/aachen/aachen_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000056_000019_leftImg8bit.png gtFine/train/aachen/aachen_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000057_000019_leftImg8bit.png gtFine/train/aachen/aachen_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000058_000019_leftImg8bit.png gtFine/train/aachen/aachen_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000059_000019_leftImg8bit.png gtFine/train/aachen/aachen_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000060_000019_leftImg8bit.png gtFine/train/aachen/aachen_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000061_000019_leftImg8bit.png gtFine/train/aachen/aachen_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000062_000019_leftImg8bit.png gtFine/train/aachen/aachen_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000063_000019_leftImg8bit.png gtFine/train/aachen/aachen_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000064_000019_leftImg8bit.png gtFine/train/aachen/aachen_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000065_000019_leftImg8bit.png gtFine/train/aachen/aachen_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000066_000019_leftImg8bit.png gtFine/train/aachen/aachen_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000067_000019_leftImg8bit.png gtFine/train/aachen/aachen_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000068_000019_leftImg8bit.png gtFine/train/aachen/aachen_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000069_000019_leftImg8bit.png gtFine/train/aachen/aachen_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000070_000019_leftImg8bit.png gtFine/train/aachen/aachen_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000071_000019_leftImg8bit.png gtFine/train/aachen/aachen_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000072_000019_leftImg8bit.png gtFine/train/aachen/aachen_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000073_000019_leftImg8bit.png gtFine/train/aachen/aachen_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000074_000019_leftImg8bit.png gtFine/train/aachen/aachen_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000075_000019_leftImg8bit.png gtFine/train/aachen/aachen_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000076_000019_leftImg8bit.png gtFine/train/aachen/aachen_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000077_000019_leftImg8bit.png gtFine/train/aachen/aachen_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000078_000019_leftImg8bit.png gtFine/train/aachen/aachen_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000079_000019_leftImg8bit.png gtFine/train/aachen/aachen_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000080_000019_leftImg8bit.png gtFine/train/aachen/aachen_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000081_000019_leftImg8bit.png gtFine/train/aachen/aachen_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000082_000019_leftImg8bit.png gtFine/train/aachen/aachen_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000083_000019_leftImg8bit.png gtFine/train/aachen/aachen_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000084_000019_leftImg8bit.png gtFine/train/aachen/aachen_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000085_000019_leftImg8bit.png gtFine/train/aachen/aachen_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000086_000019_leftImg8bit.png gtFine/train/aachen/aachen_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000087_000019_leftImg8bit.png gtFine/train/aachen/aachen_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000088_000019_leftImg8bit.png gtFine/train/aachen/aachen_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000089_000019_leftImg8bit.png gtFine/train/aachen/aachen_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000090_000019_leftImg8bit.png gtFine/train/aachen/aachen_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000091_000019_leftImg8bit.png gtFine/train/aachen/aachen_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000092_000019_leftImg8bit.png gtFine/train/aachen/aachen_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000093_000019_leftImg8bit.png gtFine/train/aachen/aachen_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000094_000019_leftImg8bit.png gtFine/train/aachen/aachen_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000095_000019_leftImg8bit.png gtFine/train/aachen/aachen_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000096_000019_leftImg8bit.png gtFine/train/aachen/aachen_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000097_000019_leftImg8bit.png gtFine/train/aachen/aachen_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000098_000019_leftImg8bit.png gtFine/train/aachen/aachen_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000099_000019_leftImg8bit.png gtFine/train/aachen/aachen_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000100_000019_leftImg8bit.png gtFine/train/aachen/aachen_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000101_000019_leftImg8bit.png gtFine/train/aachen/aachen_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000102_000019_leftImg8bit.png gtFine/train/aachen/aachen_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000103_000019_leftImg8bit.png gtFine/train/aachen/aachen_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000104_000019_leftImg8bit.png gtFine/train/aachen/aachen_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000105_000019_leftImg8bit.png gtFine/train/aachen/aachen_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000106_000019_leftImg8bit.png gtFine/train/aachen/aachen_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000107_000019_leftImg8bit.png gtFine/train/aachen/aachen_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000108_000019_leftImg8bit.png gtFine/train/aachen/aachen_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000109_000019_leftImg8bit.png gtFine/train/aachen/aachen_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000110_000019_leftImg8bit.png gtFine/train/aachen/aachen_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000111_000019_leftImg8bit.png gtFine/train/aachen/aachen_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000112_000019_leftImg8bit.png gtFine/train/aachen/aachen_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000113_000019_leftImg8bit.png gtFine/train/aachen/aachen_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000114_000019_leftImg8bit.png gtFine/train/aachen/aachen_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000115_000019_leftImg8bit.png gtFine/train/aachen/aachen_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000116_000019_leftImg8bit.png gtFine/train/aachen/aachen_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000117_000019_leftImg8bit.png gtFine/train/aachen/aachen_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000118_000019_leftImg8bit.png gtFine/train/aachen/aachen_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000119_000019_leftImg8bit.png gtFine/train/aachen/aachen_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000120_000019_leftImg8bit.png gtFine/train/aachen/aachen_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000121_000019_leftImg8bit.png gtFine/train/aachen/aachen_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000122_000019_leftImg8bit.png gtFine/train/aachen/aachen_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000123_000019_leftImg8bit.png gtFine/train/aachen/aachen_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000124_000019_leftImg8bit.png gtFine/train/aachen/aachen_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000125_000019_leftImg8bit.png gtFine/train/aachen/aachen_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000126_000019_leftImg8bit.png gtFine/train/aachen/aachen_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000127_000019_leftImg8bit.png gtFine/train/aachen/aachen_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000128_000019_leftImg8bit.png gtFine/train/aachen/aachen_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000129_000019_leftImg8bit.png gtFine/train/aachen/aachen_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000130_000019_leftImg8bit.png gtFine/train/aachen/aachen_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000131_000019_leftImg8bit.png gtFine/train/aachen/aachen_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000132_000019_leftImg8bit.png gtFine/train/aachen/aachen_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000133_000019_leftImg8bit.png gtFine/train/aachen/aachen_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000134_000019_leftImg8bit.png gtFine/train/aachen/aachen_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000135_000019_leftImg8bit.png gtFine/train/aachen/aachen_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000136_000019_leftImg8bit.png gtFine/train/aachen/aachen_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000137_000019_leftImg8bit.png gtFine/train/aachen/aachen_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000138_000019_leftImg8bit.png gtFine/train/aachen/aachen_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000139_000019_leftImg8bit.png gtFine/train/aachen/aachen_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000140_000019_leftImg8bit.png gtFine/train/aachen/aachen_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000141_000019_leftImg8bit.png gtFine/train/aachen/aachen_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000142_000019_leftImg8bit.png gtFine/train/aachen/aachen_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000143_000019_leftImg8bit.png gtFine/train/aachen/aachen_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000144_000019_leftImg8bit.png gtFine/train/aachen/aachen_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000145_000019_leftImg8bit.png gtFine/train/aachen/aachen_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000146_000019_leftImg8bit.png gtFine/train/aachen/aachen_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000147_000019_leftImg8bit.png gtFine/train/aachen/aachen_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000148_000019_leftImg8bit.png gtFine/train/aachen/aachen_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000149_000019_leftImg8bit.png gtFine/train/aachen/aachen_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000150_000019_leftImg8bit.png gtFine/train/aachen/aachen_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000151_000019_leftImg8bit.png gtFine/train/aachen/aachen_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000152_000019_leftImg8bit.png gtFine/train/aachen/aachen_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000153_000019_leftImg8bit.png gtFine/train/aachen/aachen_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000154_000019_leftImg8bit.png gtFine/train/aachen/aachen_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000155_000019_leftImg8bit.png gtFine/train/aachen/aachen_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000156_000019_leftImg8bit.png gtFine/train/aachen/aachen_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000157_000019_leftImg8bit.png gtFine/train/aachen/aachen_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000158_000019_leftImg8bit.png gtFine/train/aachen/aachen_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000159_000019_leftImg8bit.png gtFine/train/aachen/aachen_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000160_000019_leftImg8bit.png gtFine/train/aachen/aachen_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000161_000019_leftImg8bit.png gtFine/train/aachen/aachen_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000162_000019_leftImg8bit.png gtFine/train/aachen/aachen_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000163_000019_leftImg8bit.png gtFine/train/aachen/aachen_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000164_000019_leftImg8bit.png gtFine/train/aachen/aachen_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000165_000019_leftImg8bit.png gtFine/train/aachen/aachen_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000166_000019_leftImg8bit.png gtFine/train/aachen/aachen_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000167_000019_leftImg8bit.png gtFine/train/aachen/aachen_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000168_000019_leftImg8bit.png gtFine/train/aachen/aachen_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000169_000019_leftImg8bit.png gtFine/train/aachen/aachen_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000170_000019_leftImg8bit.png gtFine/train/aachen/aachen_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000171_000019_leftImg8bit.png gtFine/train/aachen/aachen_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000172_000019_leftImg8bit.png gtFine/train/aachen/aachen_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/train/aachen/aachen_000173_000019_leftImg8bit.png gtFine/train/aachen/aachen_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_000313_leftImg8bit.png gtFine/train/bochum/bochum_000000_000313_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_000600_leftImg8bit.png gtFine/train/bochum/bochum_000000_000600_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_000885_leftImg8bit.png gtFine/train/bochum/bochum_000000_000885_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_001097_leftImg8bit.png gtFine/train/bochum/bochum_000000_001097_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_001519_leftImg8bit.png gtFine/train/bochum/bochum_000000_001519_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_001828_leftImg8bit.png gtFine/train/bochum/bochum_000000_001828_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_002293_leftImg8bit.png gtFine/train/bochum/bochum_000000_002293_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_002562_leftImg8bit.png gtFine/train/bochum/bochum_000000_002562_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_003005_leftImg8bit.png gtFine/train/bochum/bochum_000000_003005_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_003245_leftImg8bit.png gtFine/train/bochum/bochum_000000_003245_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_003674_leftImg8bit.png gtFine/train/bochum/bochum_000000_003674_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_004032_leftImg8bit.png gtFine/train/bochum/bochum_000000_004032_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_004229_leftImg8bit.png gtFine/train/bochum/bochum_000000_004229_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_004748_leftImg8bit.png gtFine/train/bochum/bochum_000000_004748_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_005537_leftImg8bit.png gtFine/train/bochum/bochum_000000_005537_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_005936_leftImg8bit.png gtFine/train/bochum/bochum_000000_005936_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_006026_leftImg8bit.png gtFine/train/bochum/bochum_000000_006026_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_006484_leftImg8bit.png gtFine/train/bochum/bochum_000000_006484_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_006746_leftImg8bit.png gtFine/train/bochum/bochum_000000_006746_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_007150_leftImg8bit.png gtFine/train/bochum/bochum_000000_007150_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_007651_leftImg8bit.png gtFine/train/bochum/bochum_000000_007651_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_007950_leftImg8bit.png gtFine/train/bochum/bochum_000000_007950_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_008162_leftImg8bit.png gtFine/train/bochum/bochum_000000_008162_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_008448_leftImg8bit.png gtFine/train/bochum/bochum_000000_008448_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_008804_leftImg8bit.png gtFine/train/bochum/bochum_000000_008804_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_009554_leftImg8bit.png gtFine/train/bochum/bochum_000000_009554_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_009951_leftImg8bit.png gtFine/train/bochum/bochum_000000_009951_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_010562_leftImg8bit.png gtFine/train/bochum/bochum_000000_010562_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_010700_leftImg8bit.png gtFine/train/bochum/bochum_000000_010700_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_011255_leftImg8bit.png gtFine/train/bochum/bochum_000000_011255_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_011711_leftImg8bit.png gtFine/train/bochum/bochum_000000_011711_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_013209_leftImg8bit.png gtFine/train/bochum/bochum_000000_013209_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_013705_leftImg8bit.png gtFine/train/bochum/bochum_000000_013705_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_014332_leftImg8bit.png gtFine/train/bochum/bochum_000000_014332_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_014658_leftImg8bit.png gtFine/train/bochum/bochum_000000_014658_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_014803_leftImg8bit.png gtFine/train/bochum/bochum_000000_014803_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_015038_leftImg8bit.png gtFine/train/bochum/bochum_000000_015038_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_015321_leftImg8bit.png gtFine/train/bochum/bochum_000000_015321_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_015645_leftImg8bit.png gtFine/train/bochum/bochum_000000_015645_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_015880_leftImg8bit.png gtFine/train/bochum/bochum_000000_015880_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_016125_leftImg8bit.png gtFine/train/bochum/bochum_000000_016125_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_016260_leftImg8bit.png gtFine/train/bochum/bochum_000000_016260_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_016591_leftImg8bit.png gtFine/train/bochum/bochum_000000_016591_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_016758_leftImg8bit.png gtFine/train/bochum/bochum_000000_016758_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_017216_leftImg8bit.png gtFine/train/bochum/bochum_000000_017216_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_017453_leftImg8bit.png gtFine/train/bochum/bochum_000000_017453_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_018195_leftImg8bit.png gtFine/train/bochum/bochum_000000_018195_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_019188_leftImg8bit.png gtFine/train/bochum/bochum_000000_019188_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_020673_leftImg8bit.png gtFine/train/bochum/bochum_000000_020673_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_020776_leftImg8bit.png gtFine/train/bochum/bochum_000000_020776_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_020899_leftImg8bit.png gtFine/train/bochum/bochum_000000_020899_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_021070_leftImg8bit.png gtFine/train/bochum/bochum_000000_021070_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_021325_leftImg8bit.png gtFine/train/bochum/bochum_000000_021325_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_021393_leftImg8bit.png gtFine/train/bochum/bochum_000000_021393_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_021479_leftImg8bit.png gtFine/train/bochum/bochum_000000_021479_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_021606_leftImg8bit.png gtFine/train/bochum/bochum_000000_021606_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_022210_leftImg8bit.png gtFine/train/bochum/bochum_000000_022210_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_022414_leftImg8bit.png gtFine/train/bochum/bochum_000000_022414_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_023040_leftImg8bit.png gtFine/train/bochum/bochum_000000_023040_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_023174_leftImg8bit.png gtFine/train/bochum/bochum_000000_023174_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_023435_leftImg8bit.png gtFine/train/bochum/bochum_000000_023435_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_023648_leftImg8bit.png gtFine/train/bochum/bochum_000000_023648_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_024196_leftImg8bit.png gtFine/train/bochum/bochum_000000_024196_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_024343_leftImg8bit.png gtFine/train/bochum/bochum_000000_024343_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_024524_leftImg8bit.png gtFine/train/bochum/bochum_000000_024524_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_024717_leftImg8bit.png gtFine/train/bochum/bochum_000000_024717_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_024855_leftImg8bit.png gtFine/train/bochum/bochum_000000_024855_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_025746_leftImg8bit.png gtFine/train/bochum/bochum_000000_025746_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_025833_leftImg8bit.png gtFine/train/bochum/bochum_000000_025833_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_026056_leftImg8bit.png gtFine/train/bochum/bochum_000000_026056_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_026634_leftImg8bit.png gtFine/train/bochum/bochum_000000_026634_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_027057_leftImg8bit.png gtFine/train/bochum/bochum_000000_027057_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_027699_leftImg8bit.png gtFine/train/bochum/bochum_000000_027699_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_027951_leftImg8bit.png gtFine/train/bochum/bochum_000000_027951_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_028297_leftImg8bit.png gtFine/train/bochum/bochum_000000_028297_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_028764_leftImg8bit.png gtFine/train/bochum/bochum_000000_028764_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_029203_leftImg8bit.png gtFine/train/bochum/bochum_000000_029203_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_029721_leftImg8bit.png gtFine/train/bochum/bochum_000000_029721_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_030913_leftImg8bit.png gtFine/train/bochum/bochum_000000_030913_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_031152_leftImg8bit.png gtFine/train/bochum/bochum_000000_031152_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_031477_leftImg8bit.png gtFine/train/bochum/bochum_000000_031477_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_031687_leftImg8bit.png gtFine/train/bochum/bochum_000000_031687_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_031922_leftImg8bit.png gtFine/train/bochum/bochum_000000_031922_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_032169_leftImg8bit.png gtFine/train/bochum/bochum_000000_032169_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_033056_leftImg8bit.png gtFine/train/bochum/bochum_000000_033056_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_033331_leftImg8bit.png gtFine/train/bochum/bochum_000000_033331_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_033531_leftImg8bit.png gtFine/train/bochum/bochum_000000_033531_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_033714_leftImg8bit.png gtFine/train/bochum/bochum_000000_033714_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_034936_leftImg8bit.png gtFine/train/bochum/bochum_000000_034936_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_035958_leftImg8bit.png gtFine/train/bochum/bochum_000000_035958_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_036606_leftImg8bit.png gtFine/train/bochum/bochum_000000_036606_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_037039_leftImg8bit.png gtFine/train/bochum/bochum_000000_037039_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_037223_leftImg8bit.png gtFine/train/bochum/bochum_000000_037223_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_037829_leftImg8bit.png gtFine/train/bochum/bochum_000000_037829_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_038022_leftImg8bit.png gtFine/train/bochum/bochum_000000_038022_gtFine_labelTrainIds.png +leftImg8bit/train/bochum/bochum_000000_038150_leftImg8bit.png gtFine/train/bochum/bochum_000000_038150_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000000_000019_leftImg8bit.png gtFine/train/bremen/bremen_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000001_000019_leftImg8bit.png gtFine/train/bremen/bremen_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000002_000019_leftImg8bit.png gtFine/train/bremen/bremen_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000003_000019_leftImg8bit.png gtFine/train/bremen/bremen_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000004_000019_leftImg8bit.png gtFine/train/bremen/bremen_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000005_000019_leftImg8bit.png gtFine/train/bremen/bremen_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000006_000019_leftImg8bit.png gtFine/train/bremen/bremen_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000007_000019_leftImg8bit.png gtFine/train/bremen/bremen_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000008_000019_leftImg8bit.png gtFine/train/bremen/bremen_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000009_000019_leftImg8bit.png gtFine/train/bremen/bremen_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000010_000019_leftImg8bit.png gtFine/train/bremen/bremen_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000011_000019_leftImg8bit.png gtFine/train/bremen/bremen_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000012_000019_leftImg8bit.png gtFine/train/bremen/bremen_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000013_000019_leftImg8bit.png gtFine/train/bremen/bremen_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000014_000019_leftImg8bit.png gtFine/train/bremen/bremen_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000015_000019_leftImg8bit.png gtFine/train/bremen/bremen_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000016_000019_leftImg8bit.png gtFine/train/bremen/bremen_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000017_000019_leftImg8bit.png gtFine/train/bremen/bremen_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000018_000019_leftImg8bit.png gtFine/train/bremen/bremen_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000019_000019_leftImg8bit.png gtFine/train/bremen/bremen_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000020_000019_leftImg8bit.png gtFine/train/bremen/bremen_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000021_000019_leftImg8bit.png gtFine/train/bremen/bremen_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000022_000019_leftImg8bit.png gtFine/train/bremen/bremen_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000023_000019_leftImg8bit.png gtFine/train/bremen/bremen_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000024_000019_leftImg8bit.png gtFine/train/bremen/bremen_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000025_000019_leftImg8bit.png gtFine/train/bremen/bremen_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000026_000019_leftImg8bit.png gtFine/train/bremen/bremen_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000027_000019_leftImg8bit.png gtFine/train/bremen/bremen_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000028_000019_leftImg8bit.png gtFine/train/bremen/bremen_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000029_000019_leftImg8bit.png gtFine/train/bremen/bremen_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000030_000019_leftImg8bit.png gtFine/train/bremen/bremen_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000031_000019_leftImg8bit.png gtFine/train/bremen/bremen_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000032_000019_leftImg8bit.png gtFine/train/bremen/bremen_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000033_000019_leftImg8bit.png gtFine/train/bremen/bremen_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000034_000019_leftImg8bit.png gtFine/train/bremen/bremen_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000035_000019_leftImg8bit.png gtFine/train/bremen/bremen_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000036_000019_leftImg8bit.png gtFine/train/bremen/bremen_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000037_000019_leftImg8bit.png gtFine/train/bremen/bremen_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000038_000019_leftImg8bit.png gtFine/train/bremen/bremen_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000039_000019_leftImg8bit.png gtFine/train/bremen/bremen_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000040_000019_leftImg8bit.png gtFine/train/bremen/bremen_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000041_000019_leftImg8bit.png gtFine/train/bremen/bremen_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000042_000019_leftImg8bit.png gtFine/train/bremen/bremen_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000043_000019_leftImg8bit.png gtFine/train/bremen/bremen_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000044_000019_leftImg8bit.png gtFine/train/bremen/bremen_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000045_000019_leftImg8bit.png gtFine/train/bremen/bremen_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000046_000019_leftImg8bit.png gtFine/train/bremen/bremen_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000047_000019_leftImg8bit.png gtFine/train/bremen/bremen_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000048_000019_leftImg8bit.png gtFine/train/bremen/bremen_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000049_000019_leftImg8bit.png gtFine/train/bremen/bremen_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000050_000019_leftImg8bit.png gtFine/train/bremen/bremen_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000051_000019_leftImg8bit.png gtFine/train/bremen/bremen_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000052_000019_leftImg8bit.png gtFine/train/bremen/bremen_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000053_000019_leftImg8bit.png gtFine/train/bremen/bremen_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000054_000019_leftImg8bit.png gtFine/train/bremen/bremen_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000055_000019_leftImg8bit.png gtFine/train/bremen/bremen_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000056_000019_leftImg8bit.png gtFine/train/bremen/bremen_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000057_000019_leftImg8bit.png gtFine/train/bremen/bremen_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000058_000019_leftImg8bit.png gtFine/train/bremen/bremen_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000059_000019_leftImg8bit.png gtFine/train/bremen/bremen_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000060_000019_leftImg8bit.png gtFine/train/bremen/bremen_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000061_000019_leftImg8bit.png gtFine/train/bremen/bremen_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000062_000019_leftImg8bit.png gtFine/train/bremen/bremen_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000063_000019_leftImg8bit.png gtFine/train/bremen/bremen_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000064_000019_leftImg8bit.png gtFine/train/bremen/bremen_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000065_000019_leftImg8bit.png gtFine/train/bremen/bremen_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000066_000019_leftImg8bit.png gtFine/train/bremen/bremen_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000067_000019_leftImg8bit.png gtFine/train/bremen/bremen_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000068_000019_leftImg8bit.png gtFine/train/bremen/bremen_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000069_000019_leftImg8bit.png gtFine/train/bremen/bremen_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000070_000019_leftImg8bit.png gtFine/train/bremen/bremen_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000071_000019_leftImg8bit.png gtFine/train/bremen/bremen_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000072_000019_leftImg8bit.png gtFine/train/bremen/bremen_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000073_000019_leftImg8bit.png gtFine/train/bremen/bremen_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000074_000019_leftImg8bit.png gtFine/train/bremen/bremen_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000075_000019_leftImg8bit.png gtFine/train/bremen/bremen_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000076_000019_leftImg8bit.png gtFine/train/bremen/bremen_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000077_000019_leftImg8bit.png gtFine/train/bremen/bremen_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000078_000019_leftImg8bit.png gtFine/train/bremen/bremen_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000079_000019_leftImg8bit.png gtFine/train/bremen/bremen_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000080_000019_leftImg8bit.png gtFine/train/bremen/bremen_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000081_000019_leftImg8bit.png gtFine/train/bremen/bremen_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000082_000019_leftImg8bit.png gtFine/train/bremen/bremen_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000083_000019_leftImg8bit.png gtFine/train/bremen/bremen_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000084_000019_leftImg8bit.png gtFine/train/bremen/bremen_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000085_000019_leftImg8bit.png gtFine/train/bremen/bremen_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000086_000019_leftImg8bit.png gtFine/train/bremen/bremen_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000087_000019_leftImg8bit.png gtFine/train/bremen/bremen_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000088_000019_leftImg8bit.png gtFine/train/bremen/bremen_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000089_000019_leftImg8bit.png gtFine/train/bremen/bremen_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000090_000019_leftImg8bit.png gtFine/train/bremen/bremen_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000091_000019_leftImg8bit.png gtFine/train/bremen/bremen_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000092_000019_leftImg8bit.png gtFine/train/bremen/bremen_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000093_000019_leftImg8bit.png gtFine/train/bremen/bremen_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000094_000019_leftImg8bit.png gtFine/train/bremen/bremen_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000095_000019_leftImg8bit.png gtFine/train/bremen/bremen_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000096_000019_leftImg8bit.png gtFine/train/bremen/bremen_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000097_000019_leftImg8bit.png gtFine/train/bremen/bremen_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000098_000019_leftImg8bit.png gtFine/train/bremen/bremen_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000099_000019_leftImg8bit.png gtFine/train/bremen/bremen_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000100_000019_leftImg8bit.png gtFine/train/bremen/bremen_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000101_000019_leftImg8bit.png gtFine/train/bremen/bremen_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000102_000019_leftImg8bit.png gtFine/train/bremen/bremen_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000103_000019_leftImg8bit.png gtFine/train/bremen/bremen_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000104_000019_leftImg8bit.png gtFine/train/bremen/bremen_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000105_000019_leftImg8bit.png gtFine/train/bremen/bremen_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000106_000019_leftImg8bit.png gtFine/train/bremen/bremen_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000107_000019_leftImg8bit.png gtFine/train/bremen/bremen_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000108_000019_leftImg8bit.png gtFine/train/bremen/bremen_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000109_000019_leftImg8bit.png gtFine/train/bremen/bremen_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000110_000019_leftImg8bit.png gtFine/train/bremen/bremen_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000111_000019_leftImg8bit.png gtFine/train/bremen/bremen_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000112_000019_leftImg8bit.png gtFine/train/bremen/bremen_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000113_000019_leftImg8bit.png gtFine/train/bremen/bremen_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000114_000019_leftImg8bit.png gtFine/train/bremen/bremen_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000115_000019_leftImg8bit.png gtFine/train/bremen/bremen_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000116_000019_leftImg8bit.png gtFine/train/bremen/bremen_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000117_000019_leftImg8bit.png gtFine/train/bremen/bremen_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000118_000019_leftImg8bit.png gtFine/train/bremen/bremen_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000119_000019_leftImg8bit.png gtFine/train/bremen/bremen_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000120_000019_leftImg8bit.png gtFine/train/bremen/bremen_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000121_000019_leftImg8bit.png gtFine/train/bremen/bremen_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000122_000019_leftImg8bit.png gtFine/train/bremen/bremen_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000123_000019_leftImg8bit.png gtFine/train/bremen/bremen_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000124_000019_leftImg8bit.png gtFine/train/bremen/bremen_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000125_000019_leftImg8bit.png gtFine/train/bremen/bremen_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000126_000019_leftImg8bit.png gtFine/train/bremen/bremen_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000127_000019_leftImg8bit.png gtFine/train/bremen/bremen_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000128_000019_leftImg8bit.png gtFine/train/bremen/bremen_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000129_000019_leftImg8bit.png gtFine/train/bremen/bremen_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000130_000019_leftImg8bit.png gtFine/train/bremen/bremen_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000131_000019_leftImg8bit.png gtFine/train/bremen/bremen_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000132_000019_leftImg8bit.png gtFine/train/bremen/bremen_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000133_000019_leftImg8bit.png gtFine/train/bremen/bremen_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000134_000019_leftImg8bit.png gtFine/train/bremen/bremen_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000135_000019_leftImg8bit.png gtFine/train/bremen/bremen_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000136_000019_leftImg8bit.png gtFine/train/bremen/bremen_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000137_000019_leftImg8bit.png gtFine/train/bremen/bremen_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000138_000019_leftImg8bit.png gtFine/train/bremen/bremen_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000139_000019_leftImg8bit.png gtFine/train/bremen/bremen_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000140_000019_leftImg8bit.png gtFine/train/bremen/bremen_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000141_000019_leftImg8bit.png gtFine/train/bremen/bremen_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000142_000019_leftImg8bit.png gtFine/train/bremen/bremen_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000143_000019_leftImg8bit.png gtFine/train/bremen/bremen_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000144_000019_leftImg8bit.png gtFine/train/bremen/bremen_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000145_000019_leftImg8bit.png gtFine/train/bremen/bremen_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000146_000019_leftImg8bit.png gtFine/train/bremen/bremen_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000147_000019_leftImg8bit.png gtFine/train/bremen/bremen_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000148_000019_leftImg8bit.png gtFine/train/bremen/bremen_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000149_000019_leftImg8bit.png gtFine/train/bremen/bremen_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000150_000019_leftImg8bit.png gtFine/train/bremen/bremen_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000151_000019_leftImg8bit.png gtFine/train/bremen/bremen_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000152_000019_leftImg8bit.png gtFine/train/bremen/bremen_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000153_000019_leftImg8bit.png gtFine/train/bremen/bremen_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000154_000019_leftImg8bit.png gtFine/train/bremen/bremen_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000155_000019_leftImg8bit.png gtFine/train/bremen/bremen_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000156_000019_leftImg8bit.png gtFine/train/bremen/bremen_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000157_000019_leftImg8bit.png gtFine/train/bremen/bremen_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000158_000019_leftImg8bit.png gtFine/train/bremen/bremen_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000159_000019_leftImg8bit.png gtFine/train/bremen/bremen_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000160_000019_leftImg8bit.png gtFine/train/bremen/bremen_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000161_000019_leftImg8bit.png gtFine/train/bremen/bremen_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000162_000019_leftImg8bit.png gtFine/train/bremen/bremen_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000163_000019_leftImg8bit.png gtFine/train/bremen/bremen_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000164_000019_leftImg8bit.png gtFine/train/bremen/bremen_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000165_000019_leftImg8bit.png gtFine/train/bremen/bremen_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000166_000019_leftImg8bit.png gtFine/train/bremen/bremen_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000167_000019_leftImg8bit.png gtFine/train/bremen/bremen_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000168_000019_leftImg8bit.png gtFine/train/bremen/bremen_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000169_000019_leftImg8bit.png gtFine/train/bremen/bremen_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000170_000019_leftImg8bit.png gtFine/train/bremen/bremen_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000171_000019_leftImg8bit.png gtFine/train/bremen/bremen_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000172_000019_leftImg8bit.png gtFine/train/bremen/bremen_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000173_000019_leftImg8bit.png gtFine/train/bremen/bremen_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000174_000019_leftImg8bit.png gtFine/train/bremen/bremen_000174_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000175_000019_leftImg8bit.png gtFine/train/bremen/bremen_000175_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000176_000019_leftImg8bit.png gtFine/train/bremen/bremen_000176_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000177_000019_leftImg8bit.png gtFine/train/bremen/bremen_000177_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000178_000019_leftImg8bit.png gtFine/train/bremen/bremen_000178_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000179_000019_leftImg8bit.png gtFine/train/bremen/bremen_000179_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000180_000019_leftImg8bit.png gtFine/train/bremen/bremen_000180_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000181_000019_leftImg8bit.png gtFine/train/bremen/bremen_000181_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000182_000019_leftImg8bit.png gtFine/train/bremen/bremen_000182_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000183_000019_leftImg8bit.png gtFine/train/bremen/bremen_000183_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000184_000019_leftImg8bit.png gtFine/train/bremen/bremen_000184_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000185_000019_leftImg8bit.png gtFine/train/bremen/bremen_000185_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000186_000019_leftImg8bit.png gtFine/train/bremen/bremen_000186_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000187_000019_leftImg8bit.png gtFine/train/bremen/bremen_000187_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000188_000019_leftImg8bit.png gtFine/train/bremen/bremen_000188_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000189_000019_leftImg8bit.png gtFine/train/bremen/bremen_000189_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000190_000019_leftImg8bit.png gtFine/train/bremen/bremen_000190_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000191_000019_leftImg8bit.png gtFine/train/bremen/bremen_000191_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000192_000019_leftImg8bit.png gtFine/train/bremen/bremen_000192_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000193_000019_leftImg8bit.png gtFine/train/bremen/bremen_000193_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000194_000019_leftImg8bit.png gtFine/train/bremen/bremen_000194_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000195_000019_leftImg8bit.png gtFine/train/bremen/bremen_000195_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000196_000019_leftImg8bit.png gtFine/train/bremen/bremen_000196_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000197_000019_leftImg8bit.png gtFine/train/bremen/bremen_000197_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000198_000019_leftImg8bit.png gtFine/train/bremen/bremen_000198_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000199_000019_leftImg8bit.png gtFine/train/bremen/bremen_000199_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000200_000019_leftImg8bit.png gtFine/train/bremen/bremen_000200_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000201_000019_leftImg8bit.png gtFine/train/bremen/bremen_000201_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000202_000019_leftImg8bit.png gtFine/train/bremen/bremen_000202_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000203_000019_leftImg8bit.png gtFine/train/bremen/bremen_000203_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000204_000019_leftImg8bit.png gtFine/train/bremen/bremen_000204_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000205_000019_leftImg8bit.png gtFine/train/bremen/bremen_000205_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000206_000019_leftImg8bit.png gtFine/train/bremen/bremen_000206_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000207_000019_leftImg8bit.png gtFine/train/bremen/bremen_000207_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000208_000019_leftImg8bit.png gtFine/train/bremen/bremen_000208_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000209_000019_leftImg8bit.png gtFine/train/bremen/bremen_000209_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000210_000019_leftImg8bit.png gtFine/train/bremen/bremen_000210_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000211_000019_leftImg8bit.png gtFine/train/bremen/bremen_000211_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000212_000019_leftImg8bit.png gtFine/train/bremen/bremen_000212_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000213_000019_leftImg8bit.png gtFine/train/bremen/bremen_000213_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000214_000019_leftImg8bit.png gtFine/train/bremen/bremen_000214_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000215_000019_leftImg8bit.png gtFine/train/bremen/bremen_000215_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000216_000019_leftImg8bit.png gtFine/train/bremen/bremen_000216_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000217_000019_leftImg8bit.png gtFine/train/bremen/bremen_000217_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000218_000019_leftImg8bit.png gtFine/train/bremen/bremen_000218_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000219_000019_leftImg8bit.png gtFine/train/bremen/bremen_000219_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000220_000019_leftImg8bit.png gtFine/train/bremen/bremen_000220_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000221_000019_leftImg8bit.png gtFine/train/bremen/bremen_000221_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000222_000019_leftImg8bit.png gtFine/train/bremen/bremen_000222_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000223_000019_leftImg8bit.png gtFine/train/bremen/bremen_000223_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000224_000019_leftImg8bit.png gtFine/train/bremen/bremen_000224_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000225_000019_leftImg8bit.png gtFine/train/bremen/bremen_000225_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000226_000019_leftImg8bit.png gtFine/train/bremen/bremen_000226_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000227_000019_leftImg8bit.png gtFine/train/bremen/bremen_000227_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000228_000019_leftImg8bit.png gtFine/train/bremen/bremen_000228_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000229_000019_leftImg8bit.png gtFine/train/bremen/bremen_000229_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000230_000019_leftImg8bit.png gtFine/train/bremen/bremen_000230_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000231_000019_leftImg8bit.png gtFine/train/bremen/bremen_000231_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000232_000019_leftImg8bit.png gtFine/train/bremen/bremen_000232_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000233_000019_leftImg8bit.png gtFine/train/bremen/bremen_000233_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000234_000019_leftImg8bit.png gtFine/train/bremen/bremen_000234_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000235_000019_leftImg8bit.png gtFine/train/bremen/bremen_000235_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000236_000019_leftImg8bit.png gtFine/train/bremen/bremen_000236_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000237_000019_leftImg8bit.png gtFine/train/bremen/bremen_000237_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000238_000019_leftImg8bit.png gtFine/train/bremen/bremen_000238_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000239_000019_leftImg8bit.png gtFine/train/bremen/bremen_000239_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000240_000019_leftImg8bit.png gtFine/train/bremen/bremen_000240_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000241_000019_leftImg8bit.png gtFine/train/bremen/bremen_000241_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000242_000019_leftImg8bit.png gtFine/train/bremen/bremen_000242_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000243_000019_leftImg8bit.png gtFine/train/bremen/bremen_000243_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000244_000019_leftImg8bit.png gtFine/train/bremen/bremen_000244_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000245_000019_leftImg8bit.png gtFine/train/bremen/bremen_000245_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000246_000019_leftImg8bit.png gtFine/train/bremen/bremen_000246_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000247_000019_leftImg8bit.png gtFine/train/bremen/bremen_000247_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000248_000019_leftImg8bit.png gtFine/train/bremen/bremen_000248_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000249_000019_leftImg8bit.png gtFine/train/bremen/bremen_000249_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000250_000019_leftImg8bit.png gtFine/train/bremen/bremen_000250_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000251_000019_leftImg8bit.png gtFine/train/bremen/bremen_000251_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000252_000019_leftImg8bit.png gtFine/train/bremen/bremen_000252_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000253_000019_leftImg8bit.png gtFine/train/bremen/bremen_000253_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000254_000019_leftImg8bit.png gtFine/train/bremen/bremen_000254_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000255_000019_leftImg8bit.png gtFine/train/bremen/bremen_000255_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000256_000019_leftImg8bit.png gtFine/train/bremen/bremen_000256_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000257_000019_leftImg8bit.png gtFine/train/bremen/bremen_000257_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000258_000019_leftImg8bit.png gtFine/train/bremen/bremen_000258_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000259_000019_leftImg8bit.png gtFine/train/bremen/bremen_000259_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000260_000019_leftImg8bit.png gtFine/train/bremen/bremen_000260_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000261_000019_leftImg8bit.png gtFine/train/bremen/bremen_000261_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000262_000019_leftImg8bit.png gtFine/train/bremen/bremen_000262_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000263_000019_leftImg8bit.png gtFine/train/bremen/bremen_000263_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000264_000019_leftImg8bit.png gtFine/train/bremen/bremen_000264_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000265_000019_leftImg8bit.png gtFine/train/bremen/bremen_000265_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000266_000019_leftImg8bit.png gtFine/train/bremen/bremen_000266_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000267_000019_leftImg8bit.png gtFine/train/bremen/bremen_000267_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000268_000019_leftImg8bit.png gtFine/train/bremen/bremen_000268_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000269_000019_leftImg8bit.png gtFine/train/bremen/bremen_000269_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000270_000019_leftImg8bit.png gtFine/train/bremen/bremen_000270_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000271_000019_leftImg8bit.png gtFine/train/bremen/bremen_000271_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000272_000019_leftImg8bit.png gtFine/train/bremen/bremen_000272_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000273_000019_leftImg8bit.png gtFine/train/bremen/bremen_000273_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000274_000019_leftImg8bit.png gtFine/train/bremen/bremen_000274_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000275_000019_leftImg8bit.png gtFine/train/bremen/bremen_000275_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000276_000019_leftImg8bit.png gtFine/train/bremen/bremen_000276_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000277_000019_leftImg8bit.png gtFine/train/bremen/bremen_000277_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000278_000019_leftImg8bit.png gtFine/train/bremen/bremen_000278_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000279_000019_leftImg8bit.png gtFine/train/bremen/bremen_000279_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000280_000019_leftImg8bit.png gtFine/train/bremen/bremen_000280_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000281_000019_leftImg8bit.png gtFine/train/bremen/bremen_000281_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000282_000019_leftImg8bit.png gtFine/train/bremen/bremen_000282_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000283_000019_leftImg8bit.png gtFine/train/bremen/bremen_000283_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000284_000019_leftImg8bit.png gtFine/train/bremen/bremen_000284_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000285_000019_leftImg8bit.png gtFine/train/bremen/bremen_000285_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000286_000019_leftImg8bit.png gtFine/train/bremen/bremen_000286_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000287_000019_leftImg8bit.png gtFine/train/bremen/bremen_000287_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000288_000019_leftImg8bit.png gtFine/train/bremen/bremen_000288_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000289_000019_leftImg8bit.png gtFine/train/bremen/bremen_000289_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000290_000019_leftImg8bit.png gtFine/train/bremen/bremen_000290_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000291_000019_leftImg8bit.png gtFine/train/bremen/bremen_000291_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000292_000019_leftImg8bit.png gtFine/train/bremen/bremen_000292_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000293_000019_leftImg8bit.png gtFine/train/bremen/bremen_000293_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000294_000019_leftImg8bit.png gtFine/train/bremen/bremen_000294_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000295_000019_leftImg8bit.png gtFine/train/bremen/bremen_000295_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000296_000019_leftImg8bit.png gtFine/train/bremen/bremen_000296_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000297_000019_leftImg8bit.png gtFine/train/bremen/bremen_000297_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000298_000019_leftImg8bit.png gtFine/train/bremen/bremen_000298_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000299_000019_leftImg8bit.png gtFine/train/bremen/bremen_000299_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000300_000019_leftImg8bit.png gtFine/train/bremen/bremen_000300_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000301_000019_leftImg8bit.png gtFine/train/bremen/bremen_000301_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000302_000019_leftImg8bit.png gtFine/train/bremen/bremen_000302_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000303_000019_leftImg8bit.png gtFine/train/bremen/bremen_000303_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000304_000019_leftImg8bit.png gtFine/train/bremen/bremen_000304_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000305_000019_leftImg8bit.png gtFine/train/bremen/bremen_000305_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000306_000019_leftImg8bit.png gtFine/train/bremen/bremen_000306_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000307_000019_leftImg8bit.png gtFine/train/bremen/bremen_000307_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000308_000019_leftImg8bit.png gtFine/train/bremen/bremen_000308_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000309_000019_leftImg8bit.png gtFine/train/bremen/bremen_000309_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000310_000019_leftImg8bit.png gtFine/train/bremen/bremen_000310_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000311_000019_leftImg8bit.png gtFine/train/bremen/bremen_000311_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000312_000019_leftImg8bit.png gtFine/train/bremen/bremen_000312_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000313_000019_leftImg8bit.png gtFine/train/bremen/bremen_000313_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000314_000019_leftImg8bit.png gtFine/train/bremen/bremen_000314_000019_gtFine_labelTrainIds.png +leftImg8bit/train/bremen/bremen_000315_000019_leftImg8bit.png gtFine/train/bremen/bremen_000315_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000000_000019_leftImg8bit.png gtFine/train/cologne/cologne_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000001_000019_leftImg8bit.png gtFine/train/cologne/cologne_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000002_000019_leftImg8bit.png gtFine/train/cologne/cologne_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000003_000019_leftImg8bit.png gtFine/train/cologne/cologne_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000004_000019_leftImg8bit.png gtFine/train/cologne/cologne_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000005_000019_leftImg8bit.png gtFine/train/cologne/cologne_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000006_000019_leftImg8bit.png gtFine/train/cologne/cologne_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000007_000019_leftImg8bit.png gtFine/train/cologne/cologne_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000008_000019_leftImg8bit.png gtFine/train/cologne/cologne_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000009_000019_leftImg8bit.png gtFine/train/cologne/cologne_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000010_000019_leftImg8bit.png gtFine/train/cologne/cologne_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000011_000019_leftImg8bit.png gtFine/train/cologne/cologne_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000012_000019_leftImg8bit.png gtFine/train/cologne/cologne_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000013_000019_leftImg8bit.png gtFine/train/cologne/cologne_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000014_000019_leftImg8bit.png gtFine/train/cologne/cologne_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000015_000019_leftImg8bit.png gtFine/train/cologne/cologne_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000016_000019_leftImg8bit.png gtFine/train/cologne/cologne_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000017_000019_leftImg8bit.png gtFine/train/cologne/cologne_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000018_000019_leftImg8bit.png gtFine/train/cologne/cologne_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000019_000019_leftImg8bit.png gtFine/train/cologne/cologne_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000020_000019_leftImg8bit.png gtFine/train/cologne/cologne_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000021_000019_leftImg8bit.png gtFine/train/cologne/cologne_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000022_000019_leftImg8bit.png gtFine/train/cologne/cologne_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000023_000019_leftImg8bit.png gtFine/train/cologne/cologne_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000024_000019_leftImg8bit.png gtFine/train/cologne/cologne_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000025_000019_leftImg8bit.png gtFine/train/cologne/cologne_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000026_000019_leftImg8bit.png gtFine/train/cologne/cologne_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000027_000019_leftImg8bit.png gtFine/train/cologne/cologne_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000028_000019_leftImg8bit.png gtFine/train/cologne/cologne_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000029_000019_leftImg8bit.png gtFine/train/cologne/cologne_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000030_000019_leftImg8bit.png gtFine/train/cologne/cologne_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000031_000019_leftImg8bit.png gtFine/train/cologne/cologne_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000032_000019_leftImg8bit.png gtFine/train/cologne/cologne_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000033_000019_leftImg8bit.png gtFine/train/cologne/cologne_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000034_000019_leftImg8bit.png gtFine/train/cologne/cologne_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000035_000019_leftImg8bit.png gtFine/train/cologne/cologne_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000036_000019_leftImg8bit.png gtFine/train/cologne/cologne_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000037_000019_leftImg8bit.png gtFine/train/cologne/cologne_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000038_000019_leftImg8bit.png gtFine/train/cologne/cologne_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000039_000019_leftImg8bit.png gtFine/train/cologne/cologne_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000040_000019_leftImg8bit.png gtFine/train/cologne/cologne_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000041_000019_leftImg8bit.png gtFine/train/cologne/cologne_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000042_000019_leftImg8bit.png gtFine/train/cologne/cologne_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000043_000019_leftImg8bit.png gtFine/train/cologne/cologne_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000044_000019_leftImg8bit.png gtFine/train/cologne/cologne_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000045_000019_leftImg8bit.png gtFine/train/cologne/cologne_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000046_000019_leftImg8bit.png gtFine/train/cologne/cologne_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000047_000019_leftImg8bit.png gtFine/train/cologne/cologne_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000048_000019_leftImg8bit.png gtFine/train/cologne/cologne_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000049_000019_leftImg8bit.png gtFine/train/cologne/cologne_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000050_000019_leftImg8bit.png gtFine/train/cologne/cologne_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000051_000019_leftImg8bit.png gtFine/train/cologne/cologne_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000052_000019_leftImg8bit.png gtFine/train/cologne/cologne_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000053_000019_leftImg8bit.png gtFine/train/cologne/cologne_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000054_000019_leftImg8bit.png gtFine/train/cologne/cologne_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000055_000019_leftImg8bit.png gtFine/train/cologne/cologne_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000056_000019_leftImg8bit.png gtFine/train/cologne/cologne_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000057_000019_leftImg8bit.png gtFine/train/cologne/cologne_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000058_000019_leftImg8bit.png gtFine/train/cologne/cologne_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000059_000019_leftImg8bit.png gtFine/train/cologne/cologne_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000060_000019_leftImg8bit.png gtFine/train/cologne/cologne_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000061_000019_leftImg8bit.png gtFine/train/cologne/cologne_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000062_000019_leftImg8bit.png gtFine/train/cologne/cologne_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000063_000019_leftImg8bit.png gtFine/train/cologne/cologne_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000064_000019_leftImg8bit.png gtFine/train/cologne/cologne_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000065_000019_leftImg8bit.png gtFine/train/cologne/cologne_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000066_000019_leftImg8bit.png gtFine/train/cologne/cologne_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000067_000019_leftImg8bit.png gtFine/train/cologne/cologne_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000068_000019_leftImg8bit.png gtFine/train/cologne/cologne_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000069_000019_leftImg8bit.png gtFine/train/cologne/cologne_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000070_000019_leftImg8bit.png gtFine/train/cologne/cologne_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000071_000019_leftImg8bit.png gtFine/train/cologne/cologne_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000072_000019_leftImg8bit.png gtFine/train/cologne/cologne_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000073_000019_leftImg8bit.png gtFine/train/cologne/cologne_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000074_000019_leftImg8bit.png gtFine/train/cologne/cologne_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000075_000019_leftImg8bit.png gtFine/train/cologne/cologne_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000076_000019_leftImg8bit.png gtFine/train/cologne/cologne_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000077_000019_leftImg8bit.png gtFine/train/cologne/cologne_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000078_000019_leftImg8bit.png gtFine/train/cologne/cologne_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000079_000019_leftImg8bit.png gtFine/train/cologne/cologne_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000080_000019_leftImg8bit.png gtFine/train/cologne/cologne_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000081_000019_leftImg8bit.png gtFine/train/cologne/cologne_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000082_000019_leftImg8bit.png gtFine/train/cologne/cologne_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000083_000019_leftImg8bit.png gtFine/train/cologne/cologne_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000084_000019_leftImg8bit.png gtFine/train/cologne/cologne_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000085_000019_leftImg8bit.png gtFine/train/cologne/cologne_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000086_000019_leftImg8bit.png gtFine/train/cologne/cologne_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000087_000019_leftImg8bit.png gtFine/train/cologne/cologne_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000088_000019_leftImg8bit.png gtFine/train/cologne/cologne_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000089_000019_leftImg8bit.png gtFine/train/cologne/cologne_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000090_000019_leftImg8bit.png gtFine/train/cologne/cologne_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000091_000019_leftImg8bit.png gtFine/train/cologne/cologne_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000092_000019_leftImg8bit.png gtFine/train/cologne/cologne_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000093_000019_leftImg8bit.png gtFine/train/cologne/cologne_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000094_000019_leftImg8bit.png gtFine/train/cologne/cologne_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000095_000019_leftImg8bit.png gtFine/train/cologne/cologne_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000096_000019_leftImg8bit.png gtFine/train/cologne/cologne_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000097_000019_leftImg8bit.png gtFine/train/cologne/cologne_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000098_000019_leftImg8bit.png gtFine/train/cologne/cologne_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000099_000019_leftImg8bit.png gtFine/train/cologne/cologne_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000100_000019_leftImg8bit.png gtFine/train/cologne/cologne_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000101_000019_leftImg8bit.png gtFine/train/cologne/cologne_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000102_000019_leftImg8bit.png gtFine/train/cologne/cologne_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000103_000019_leftImg8bit.png gtFine/train/cologne/cologne_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000104_000019_leftImg8bit.png gtFine/train/cologne/cologne_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000105_000019_leftImg8bit.png gtFine/train/cologne/cologne_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000106_000019_leftImg8bit.png gtFine/train/cologne/cologne_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000107_000019_leftImg8bit.png gtFine/train/cologne/cologne_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000108_000019_leftImg8bit.png gtFine/train/cologne/cologne_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000109_000019_leftImg8bit.png gtFine/train/cologne/cologne_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000110_000019_leftImg8bit.png gtFine/train/cologne/cologne_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000111_000019_leftImg8bit.png gtFine/train/cologne/cologne_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000112_000019_leftImg8bit.png gtFine/train/cologne/cologne_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000113_000019_leftImg8bit.png gtFine/train/cologne/cologne_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000114_000019_leftImg8bit.png gtFine/train/cologne/cologne_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000115_000019_leftImg8bit.png gtFine/train/cologne/cologne_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000116_000019_leftImg8bit.png gtFine/train/cologne/cologne_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000117_000019_leftImg8bit.png gtFine/train/cologne/cologne_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000118_000019_leftImg8bit.png gtFine/train/cologne/cologne_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000119_000019_leftImg8bit.png gtFine/train/cologne/cologne_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000120_000019_leftImg8bit.png gtFine/train/cologne/cologne_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000121_000019_leftImg8bit.png gtFine/train/cologne/cologne_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000122_000019_leftImg8bit.png gtFine/train/cologne/cologne_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000123_000019_leftImg8bit.png gtFine/train/cologne/cologne_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000124_000019_leftImg8bit.png gtFine/train/cologne/cologne_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000125_000019_leftImg8bit.png gtFine/train/cologne/cologne_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000126_000019_leftImg8bit.png gtFine/train/cologne/cologne_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000127_000019_leftImg8bit.png gtFine/train/cologne/cologne_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000128_000019_leftImg8bit.png gtFine/train/cologne/cologne_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000129_000019_leftImg8bit.png gtFine/train/cologne/cologne_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000130_000019_leftImg8bit.png gtFine/train/cologne/cologne_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000131_000019_leftImg8bit.png gtFine/train/cologne/cologne_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000132_000019_leftImg8bit.png gtFine/train/cologne/cologne_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000133_000019_leftImg8bit.png gtFine/train/cologne/cologne_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000134_000019_leftImg8bit.png gtFine/train/cologne/cologne_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000135_000019_leftImg8bit.png gtFine/train/cologne/cologne_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000136_000019_leftImg8bit.png gtFine/train/cologne/cologne_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000137_000019_leftImg8bit.png gtFine/train/cologne/cologne_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000138_000019_leftImg8bit.png gtFine/train/cologne/cologne_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000139_000019_leftImg8bit.png gtFine/train/cologne/cologne_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000140_000019_leftImg8bit.png gtFine/train/cologne/cologne_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000141_000019_leftImg8bit.png gtFine/train/cologne/cologne_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000142_000019_leftImg8bit.png gtFine/train/cologne/cologne_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000143_000019_leftImg8bit.png gtFine/train/cologne/cologne_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000144_000019_leftImg8bit.png gtFine/train/cologne/cologne_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000145_000019_leftImg8bit.png gtFine/train/cologne/cologne_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000146_000019_leftImg8bit.png gtFine/train/cologne/cologne_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000147_000019_leftImg8bit.png gtFine/train/cologne/cologne_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000148_000019_leftImg8bit.png gtFine/train/cologne/cologne_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000149_000019_leftImg8bit.png gtFine/train/cologne/cologne_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000150_000019_leftImg8bit.png gtFine/train/cologne/cologne_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000151_000019_leftImg8bit.png gtFine/train/cologne/cologne_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000152_000019_leftImg8bit.png gtFine/train/cologne/cologne_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/train/cologne/cologne_000153_000019_leftImg8bit.png gtFine/train/cologne/cologne_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000000_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000001_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000002_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000003_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000004_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000005_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000006_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000007_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000008_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000009_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000010_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000011_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000012_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000013_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000014_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000015_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000016_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000017_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000018_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000019_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000020_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000021_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000022_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000023_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000024_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000025_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000026_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000027_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000028_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000029_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000030_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000031_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000032_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000033_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000034_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000035_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000036_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000037_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000038_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000039_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000040_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000041_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000042_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000043_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000044_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000045_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000046_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000047_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000048_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000049_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000050_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000051_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000052_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000053_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000054_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000055_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000056_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000057_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000058_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000059_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000060_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000061_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000062_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000063_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000064_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000065_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000066_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000067_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000068_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000069_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000070_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000071_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000072_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000073_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000074_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000075_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000076_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000077_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000078_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000079_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000080_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000081_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000082_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000083_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/darmstadt/darmstadt_000084_000019_leftImg8bit.png gtFine/train/darmstadt/darmstadt_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000000_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000001_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000002_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000003_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000004_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000005_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000006_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000007_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000008_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000009_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000010_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000011_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000012_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000013_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000014_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000015_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000016_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000017_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000018_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000019_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000020_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000021_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000022_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000023_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000024_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000025_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000026_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000027_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000028_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000029_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000030_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000031_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000032_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000033_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000034_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000035_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000036_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000037_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000038_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000039_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000040_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000041_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000042_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000043_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000044_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000045_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000046_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000047_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000048_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000049_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000050_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000051_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000052_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000053_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000054_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000055_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000056_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000057_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000058_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000059_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000060_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000061_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000062_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000063_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000064_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000065_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000066_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000067_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000068_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000069_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000070_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000071_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000072_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000073_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000074_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000075_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000076_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000077_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000078_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000079_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000080_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000081_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000082_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000083_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000084_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000085_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000086_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000087_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000088_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000089_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000090_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000091_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000092_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000093_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000094_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000095_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000096_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000097_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000098_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000099_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000100_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000101_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000102_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000103_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000104_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000105_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000106_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000107_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000108_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000109_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000110_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000111_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000112_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000113_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000114_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000115_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000116_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000117_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000118_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000119_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000120_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000121_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000122_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000123_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000124_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000125_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000126_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000127_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000128_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000129_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000130_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000131_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000132_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000133_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000134_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000135_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000136_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000137_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000138_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000139_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000140_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000141_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000142_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000143_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000144_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000145_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000146_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000147_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000148_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000149_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000150_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000151_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000152_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000153_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000154_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000155_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000156_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000157_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000158_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000159_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000160_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000161_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000162_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000163_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000164_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000165_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000166_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000167_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000168_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000169_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000170_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000171_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000172_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000173_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000174_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000174_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000175_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000175_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000176_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000176_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000177_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000177_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000178_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000178_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000179_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000179_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000180_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000180_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000181_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000181_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000182_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000182_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000183_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000183_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000184_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000184_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000185_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000185_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000186_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000186_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000187_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000187_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000188_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000188_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000189_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000189_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000190_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000190_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000191_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000191_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000192_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000192_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000193_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000193_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000194_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000194_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000195_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000195_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000196_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000196_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000197_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000197_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000198_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000198_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000199_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000199_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000200_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000200_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000201_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000201_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000202_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000202_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000203_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000203_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000204_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000204_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000205_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000205_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000206_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000206_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000207_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000207_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000208_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000208_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000209_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000209_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000210_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000210_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000211_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000211_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000212_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000212_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000213_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000213_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000214_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000214_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000215_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000215_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000216_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000216_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000217_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000217_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000218_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000218_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000219_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000219_000019_gtFine_labelTrainIds.png +leftImg8bit/train/dusseldorf/dusseldorf_000220_000019_leftImg8bit.png gtFine/train/dusseldorf/dusseldorf_000220_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000000_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000001_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000002_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000003_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000004_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000005_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000006_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000007_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000008_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000009_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000010_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000011_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000012_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000013_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000014_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000015_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000016_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000017_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000018_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000019_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000020_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000021_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000022_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000023_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000024_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000025_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000026_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000027_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000028_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000029_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000030_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000031_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000032_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000033_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000034_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000035_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000036_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000037_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000038_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000039_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000040_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000041_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000042_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000043_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000044_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000045_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000046_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000047_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000048_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000049_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000050_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000051_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000052_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000053_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000054_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000055_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000056_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000057_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000058_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000059_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000060_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000061_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000062_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000063_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000064_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000065_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000066_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000067_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000068_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000069_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000070_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000071_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000072_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000073_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000074_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000075_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000076_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000077_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000078_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000079_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000080_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000081_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000082_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000083_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000084_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000085_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000086_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000087_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000088_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000089_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000090_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000091_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000092_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000093_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000094_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000095_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000096_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000097_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000098_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000099_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000100_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000101_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000102_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000103_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000104_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000105_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000106_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000107_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/erfurt/erfurt_000108_000019_leftImg8bit.png gtFine/train/erfurt/erfurt_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_000042_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_000042_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_000629_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_000629_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_001106_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_001106_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_001613_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_001613_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_002095_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_002095_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_002338_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_002338_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_003488_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_003488_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_003904_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_003904_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_004985_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_004985_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_005639_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_005639_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_006192_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_006192_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_006322_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_006322_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_007737_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_007737_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_008221_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_008221_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_008494_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_008494_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_011641_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_011641_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_013577_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_013577_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_014030_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_014030_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_014940_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_014940_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_015350_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_015350_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_016447_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_016447_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_016691_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_016691_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_016928_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_016928_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_018592_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_018592_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_018878_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_018878_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_019373_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_019373_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_019760_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_019760_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_019892_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_019892_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_020211_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_020211_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_020563_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_020563_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_021353_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_021353_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_021961_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_021961_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_022524_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_022524_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_023472_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_023472_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_024251_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_024251_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_025802_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_025802_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_025986_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_025986_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_026675_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_026675_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_027304_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_027304_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_027857_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_027857_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_028056_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_028056_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_028439_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_028439_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_028608_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_028608_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_029144_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_029144_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_029378_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_029378_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_029676_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_029676_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_030279_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_030279_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_030953_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_030953_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_031971_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_031971_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_032266_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_032266_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_032460_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_032460_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_032719_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_032719_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_032906_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_032906_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_033506_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_033506_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_034049_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_034049_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_035568_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_035568_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_036003_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_036003_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_036427_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_036427_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_036527_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_036527_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_037036_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_037036_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_037161_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_037161_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_037279_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_037279_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_037741_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_037741_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_038446_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_038446_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_038511_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_038511_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_038729_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_038729_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_038915_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_038915_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_039264_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_039264_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_039420_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_039420_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_039546_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_039546_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_040021_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_040021_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_041667_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_041667_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_042505_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_042505_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_042885_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_042885_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_043944_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_043944_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_044251_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_044251_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_044400_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_044400_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_044747_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_044747_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_044996_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_044996_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_045437_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_045437_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_045704_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_045704_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_045908_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_045908_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_046078_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_046078_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_046510_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_046510_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_046566_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_046566_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_046619_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_046619_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_046872_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_046872_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_047057_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_047057_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_047108_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_047108_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_047157_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_047157_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_047220_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_047220_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_047390_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_047390_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_048138_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_048138_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_048494_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_048494_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_048750_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_048750_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_048960_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_048960_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_049558_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_049558_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_050160_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_050160_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_051855_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_051855_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_052122_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_052122_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_052904_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_052904_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_053086_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_053086_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_053486_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_053486_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_053563_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_053563_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_053776_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_053776_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_053886_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_053886_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_054029_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_054029_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_054220_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_054220_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_054555_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_054555_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_054850_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_054850_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_055039_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_055039_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_055414_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_055414_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_055894_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_055894_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_056229_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_056229_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_056508_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_056508_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_057487_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_057487_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_057678_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_057678_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_057816_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_057816_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_058591_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_058591_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_059339_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_059339_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_059720_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_059720_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_060215_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_060215_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_060586_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_060586_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_060907_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_060907_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_061048_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_061048_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_061468_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_061468_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_061790_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_061790_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_062039_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_062039_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_062371_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_062371_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_062710_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_062710_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_062964_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_062964_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_063403_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_063403_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_063698_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_063698_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_064269_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_064269_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_064825_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_064825_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_065055_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_065055_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_065604_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_065604_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_065843_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_065843_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_065983_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_065983_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_066424_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_066424_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_066706_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_066706_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_066988_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_066988_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_067223_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_067223_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_067338_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_067338_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_067587_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_067587_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_067799_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_067799_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_068693_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_068693_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_068916_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_068916_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_069096_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_069096_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_069177_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_069177_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_069289_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_069289_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_069417_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_069417_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_070334_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_070334_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_070444_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_070444_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_071016_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_071016_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_071150_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_071150_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_071675_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_071675_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_071942_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_071942_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073314_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073314_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073389_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073389_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073549_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073549_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073672_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073672_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073758_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073758_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_073999_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_073999_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_074139_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_074139_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_074267_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_074267_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_074425_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_074425_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_074545_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_074545_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_074694_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_074694_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_076392_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_076392_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_076966_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_076966_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_077144_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_077144_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_077642_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_077642_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_077756_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_077756_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_077927_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_077927_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_078407_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_078407_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_078579_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_078579_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_078842_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_078842_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_079376_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_079376_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_079657_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_079657_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_080169_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_080169_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_080438_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_080438_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_080674_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_080674_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_080878_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_080878_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_081299_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_081299_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_082187_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_082187_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_082301_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_082301_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_083586_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_083586_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_083696_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_083696_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_084746_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_084746_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_084865_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_084865_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_085073_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_085073_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_085321_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_085321_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_085413_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_085413_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_085645_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_085645_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_085982_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_085982_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_086499_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_086499_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_086636_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_086636_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_087216_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_087216_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_087822_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_087822_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088054_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088054_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088197_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088197_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088627_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088627_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088783_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088783_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088939_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088939_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_088983_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_088983_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_089491_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_089491_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_089696_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_089696_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_090398_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_090398_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_090742_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_090742_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_091038_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_091038_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_091155_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_091155_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_091900_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_091900_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_092476_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_092476_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_092850_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_092850_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_093325_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_093325_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_093572_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_093572_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_093787_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_093787_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_094185_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_094185_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_094717_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_094717_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_095561_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_095561_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_096063_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_096063_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_096624_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_096624_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_097086_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_097086_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_097447_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_097447_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_098061_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_098061_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_098400_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_098400_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_098616_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_098616_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_098862_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_098862_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_099109_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_099109_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_099368_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_099368_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_099902_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_099902_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_100300_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_100300_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_101724_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_101724_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_102379_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_102379_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_102574_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_102574_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_103075_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_103075_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_103186_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_103186_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_103367_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_103367_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_103541_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_103541_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_103856_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_103856_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_104428_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_104428_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_104857_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_104857_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_105123_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_105123_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_105296_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_105296_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_105464_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_105464_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_105724_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_105724_gtFine_labelTrainIds.png +leftImg8bit/train/hamburg/hamburg_000000_106102_leftImg8bit.png gtFine/train/hamburg/hamburg_000000_106102_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_000164_leftImg8bit.png gtFine/train/hanover/hanover_000000_000164_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_000381_leftImg8bit.png gtFine/train/hanover/hanover_000000_000381_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_000712_leftImg8bit.png gtFine/train/hanover/hanover_000000_000712_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_001173_leftImg8bit.png gtFine/train/hanover/hanover_000000_001173_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_001620_leftImg8bit.png gtFine/train/hanover/hanover_000000_001620_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_002140_leftImg8bit.png gtFine/train/hanover/hanover_000000_002140_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_002357_leftImg8bit.png gtFine/train/hanover/hanover_000000_002357_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_002458_leftImg8bit.png gtFine/train/hanover/hanover_000000_002458_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_003224_leftImg8bit.png gtFine/train/hanover/hanover_000000_003224_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_003411_leftImg8bit.png gtFine/train/hanover/hanover_000000_003411_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_003853_leftImg8bit.png gtFine/train/hanover/hanover_000000_003853_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_004230_leftImg8bit.png gtFine/train/hanover/hanover_000000_004230_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_004646_leftImg8bit.png gtFine/train/hanover/hanover_000000_004646_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_004752_leftImg8bit.png gtFine/train/hanover/hanover_000000_004752_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_005175_leftImg8bit.png gtFine/train/hanover/hanover_000000_005175_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_005288_leftImg8bit.png gtFine/train/hanover/hanover_000000_005288_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_005599_leftImg8bit.png gtFine/train/hanover/hanover_000000_005599_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_005732_leftImg8bit.png gtFine/train/hanover/hanover_000000_005732_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_005970_leftImg8bit.png gtFine/train/hanover/hanover_000000_005970_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_006355_leftImg8bit.png gtFine/train/hanover/hanover_000000_006355_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_006922_leftImg8bit.png gtFine/train/hanover/hanover_000000_006922_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_007342_leftImg8bit.png gtFine/train/hanover/hanover_000000_007342_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_007780_leftImg8bit.png gtFine/train/hanover/hanover_000000_007780_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_007897_leftImg8bit.png gtFine/train/hanover/hanover_000000_007897_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_008017_leftImg8bit.png gtFine/train/hanover/hanover_000000_008017_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_008200_leftImg8bit.png gtFine/train/hanover/hanover_000000_008200_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_009004_leftImg8bit.png gtFine/train/hanover/hanover_000000_009004_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_009128_leftImg8bit.png gtFine/train/hanover/hanover_000000_009128_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_009420_leftImg8bit.png gtFine/train/hanover/hanover_000000_009420_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_010403_leftImg8bit.png gtFine/train/hanover/hanover_000000_010403_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_010553_leftImg8bit.png gtFine/train/hanover/hanover_000000_010553_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_011170_leftImg8bit.png gtFine/train/hanover/hanover_000000_011170_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_011471_leftImg8bit.png gtFine/train/hanover/hanover_000000_011471_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_011971_leftImg8bit.png gtFine/train/hanover/hanover_000000_011971_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_012347_leftImg8bit.png gtFine/train/hanover/hanover_000000_012347_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_012675_leftImg8bit.png gtFine/train/hanover/hanover_000000_012675_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_013094_leftImg8bit.png gtFine/train/hanover/hanover_000000_013094_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_013205_leftImg8bit.png gtFine/train/hanover/hanover_000000_013205_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_013814_leftImg8bit.png gtFine/train/hanover/hanover_000000_013814_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_014319_leftImg8bit.png gtFine/train/hanover/hanover_000000_014319_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_014537_leftImg8bit.png gtFine/train/hanover/hanover_000000_014537_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_014713_leftImg8bit.png gtFine/train/hanover/hanover_000000_014713_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_014919_leftImg8bit.png gtFine/train/hanover/hanover_000000_014919_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_015587_leftImg8bit.png gtFine/train/hanover/hanover_000000_015587_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_015849_leftImg8bit.png gtFine/train/hanover/hanover_000000_015849_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_016038_leftImg8bit.png gtFine/train/hanover/hanover_000000_016038_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_016558_leftImg8bit.png gtFine/train/hanover/hanover_000000_016558_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_017041_leftImg8bit.png gtFine/train/hanover/hanover_000000_017041_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_018213_leftImg8bit.png gtFine/train/hanover/hanover_000000_018213_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_018546_leftImg8bit.png gtFine/train/hanover/hanover_000000_018546_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_018800_leftImg8bit.png gtFine/train/hanover/hanover_000000_018800_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_019116_leftImg8bit.png gtFine/train/hanover/hanover_000000_019116_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_019282_leftImg8bit.png gtFine/train/hanover/hanover_000000_019282_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_019456_leftImg8bit.png gtFine/train/hanover/hanover_000000_019456_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_019672_leftImg8bit.png gtFine/train/hanover/hanover_000000_019672_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_019938_leftImg8bit.png gtFine/train/hanover/hanover_000000_019938_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_020089_leftImg8bit.png gtFine/train/hanover/hanover_000000_020089_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_020655_leftImg8bit.png gtFine/train/hanover/hanover_000000_020655_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_021337_leftImg8bit.png gtFine/train/hanover/hanover_000000_021337_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_022645_leftImg8bit.png gtFine/train/hanover/hanover_000000_022645_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_023239_leftImg8bit.png gtFine/train/hanover/hanover_000000_023239_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_023276_leftImg8bit.png gtFine/train/hanover/hanover_000000_023276_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_023614_leftImg8bit.png gtFine/train/hanover/hanover_000000_023614_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_023881_leftImg8bit.png gtFine/train/hanover/hanover_000000_023881_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_023975_leftImg8bit.png gtFine/train/hanover/hanover_000000_023975_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_024136_leftImg8bit.png gtFine/train/hanover/hanover_000000_024136_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_024276_leftImg8bit.png gtFine/train/hanover/hanover_000000_024276_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_024441_leftImg8bit.png gtFine/train/hanover/hanover_000000_024441_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_024719_leftImg8bit.png gtFine/train/hanover/hanover_000000_024719_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_024989_leftImg8bit.png gtFine/train/hanover/hanover_000000_024989_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_025335_leftImg8bit.png gtFine/train/hanover/hanover_000000_025335_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_025437_leftImg8bit.png gtFine/train/hanover/hanover_000000_025437_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_026014_leftImg8bit.png gtFine/train/hanover/hanover_000000_026014_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_026183_leftImg8bit.png gtFine/train/hanover/hanover_000000_026183_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_026356_leftImg8bit.png gtFine/train/hanover/hanover_000000_026356_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_026743_leftImg8bit.png gtFine/train/hanover/hanover_000000_026743_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_026804_leftImg8bit.png gtFine/train/hanover/hanover_000000_026804_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027007_leftImg8bit.png gtFine/train/hanover/hanover_000000_027007_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027282_leftImg8bit.png gtFine/train/hanover/hanover_000000_027282_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027390_leftImg8bit.png gtFine/train/hanover/hanover_000000_027390_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027481_leftImg8bit.png gtFine/train/hanover/hanover_000000_027481_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027561_leftImg8bit.png gtFine/train/hanover/hanover_000000_027561_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027650_leftImg8bit.png gtFine/train/hanover/hanover_000000_027650_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027766_leftImg8bit.png gtFine/train/hanover/hanover_000000_027766_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_027998_leftImg8bit.png gtFine/train/hanover/hanover_000000_027998_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_028202_leftImg8bit.png gtFine/train/hanover/hanover_000000_028202_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_028460_leftImg8bit.png gtFine/train/hanover/hanover_000000_028460_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_029043_leftImg8bit.png gtFine/train/hanover/hanover_000000_029043_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_029325_leftImg8bit.png gtFine/train/hanover/hanover_000000_029325_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_029404_leftImg8bit.png gtFine/train/hanover/hanover_000000_029404_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_029455_leftImg8bit.png gtFine/train/hanover/hanover_000000_029455_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_029769_leftImg8bit.png gtFine/train/hanover/hanover_000000_029769_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_030276_leftImg8bit.png gtFine/train/hanover/hanover_000000_030276_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_030346_leftImg8bit.png gtFine/train/hanover/hanover_000000_030346_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_030546_leftImg8bit.png gtFine/train/hanover/hanover_000000_030546_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_030781_leftImg8bit.png gtFine/train/hanover/hanover_000000_030781_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_030889_leftImg8bit.png gtFine/train/hanover/hanover_000000_030889_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_031144_leftImg8bit.png gtFine/train/hanover/hanover_000000_031144_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_031856_leftImg8bit.png gtFine/train/hanover/hanover_000000_031856_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_032210_leftImg8bit.png gtFine/train/hanover/hanover_000000_032210_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_032351_leftImg8bit.png gtFine/train/hanover/hanover_000000_032351_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_032559_leftImg8bit.png gtFine/train/hanover/hanover_000000_032559_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_032681_leftImg8bit.png gtFine/train/hanover/hanover_000000_032681_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_033457_leftImg8bit.png gtFine/train/hanover/hanover_000000_033457_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034015_leftImg8bit.png gtFine/train/hanover/hanover_000000_034015_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034141_leftImg8bit.png gtFine/train/hanover/hanover_000000_034141_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034347_leftImg8bit.png gtFine/train/hanover/hanover_000000_034347_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034560_leftImg8bit.png gtFine/train/hanover/hanover_000000_034560_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034720_leftImg8bit.png gtFine/train/hanover/hanover_000000_034720_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_034935_leftImg8bit.png gtFine/train/hanover/hanover_000000_034935_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_035491_leftImg8bit.png gtFine/train/hanover/hanover_000000_035491_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_035606_leftImg8bit.png gtFine/train/hanover/hanover_000000_035606_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_035768_leftImg8bit.png gtFine/train/hanover/hanover_000000_035768_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_036051_leftImg8bit.png gtFine/train/hanover/hanover_000000_036051_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_036562_leftImg8bit.png gtFine/train/hanover/hanover_000000_036562_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_037039_leftImg8bit.png gtFine/train/hanover/hanover_000000_037039_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_037298_leftImg8bit.png gtFine/train/hanover/hanover_000000_037298_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_037516_leftImg8bit.png gtFine/train/hanover/hanover_000000_037516_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_038773_leftImg8bit.png gtFine/train/hanover/hanover_000000_038773_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_038855_leftImg8bit.png gtFine/train/hanover/hanover_000000_038855_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_038927_leftImg8bit.png gtFine/train/hanover/hanover_000000_038927_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_039021_leftImg8bit.png gtFine/train/hanover/hanover_000000_039021_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_039470_leftImg8bit.png gtFine/train/hanover/hanover_000000_039470_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040051_leftImg8bit.png gtFine/train/hanover/hanover_000000_040051_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040133_leftImg8bit.png gtFine/train/hanover/hanover_000000_040133_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040221_leftImg8bit.png gtFine/train/hanover/hanover_000000_040221_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040294_leftImg8bit.png gtFine/train/hanover/hanover_000000_040294_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040456_leftImg8bit.png gtFine/train/hanover/hanover_000000_040456_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_040793_leftImg8bit.png gtFine/train/hanover/hanover_000000_040793_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_041232_leftImg8bit.png gtFine/train/hanover/hanover_000000_041232_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_041493_leftImg8bit.png gtFine/train/hanover/hanover_000000_041493_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_041610_leftImg8bit.png gtFine/train/hanover/hanover_000000_041610_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_042255_leftImg8bit.png gtFine/train/hanover/hanover_000000_042255_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_042382_leftImg8bit.png gtFine/train/hanover/hanover_000000_042382_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_042581_leftImg8bit.png gtFine/train/hanover/hanover_000000_042581_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_042770_leftImg8bit.png gtFine/train/hanover/hanover_000000_042770_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_042992_leftImg8bit.png gtFine/train/hanover/hanover_000000_042992_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_043102_leftImg8bit.png gtFine/train/hanover/hanover_000000_043102_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_043236_leftImg8bit.png gtFine/train/hanover/hanover_000000_043236_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_043550_leftImg8bit.png gtFine/train/hanover/hanover_000000_043550_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_043653_leftImg8bit.png gtFine/train/hanover/hanover_000000_043653_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_043822_leftImg8bit.png gtFine/train/hanover/hanover_000000_043822_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_044085_leftImg8bit.png gtFine/train/hanover/hanover_000000_044085_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_044195_leftImg8bit.png gtFine/train/hanover/hanover_000000_044195_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_044344_leftImg8bit.png gtFine/train/hanover/hanover_000000_044344_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_044622_leftImg8bit.png gtFine/train/hanover/hanover_000000_044622_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_045004_leftImg8bit.png gtFine/train/hanover/hanover_000000_045004_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_045188_leftImg8bit.png gtFine/train/hanover/hanover_000000_045188_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_045446_leftImg8bit.png gtFine/train/hanover/hanover_000000_045446_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_045657_leftImg8bit.png gtFine/train/hanover/hanover_000000_045657_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_045841_leftImg8bit.png gtFine/train/hanover/hanover_000000_045841_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046200_leftImg8bit.png gtFine/train/hanover/hanover_000000_046200_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046398_leftImg8bit.png gtFine/train/hanover/hanover_000000_046398_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046572_leftImg8bit.png gtFine/train/hanover/hanover_000000_046572_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046646_leftImg8bit.png gtFine/train/hanover/hanover_000000_046646_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046732_leftImg8bit.png gtFine/train/hanover/hanover_000000_046732_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_046954_leftImg8bit.png gtFine/train/hanover/hanover_000000_046954_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_047499_leftImg8bit.png gtFine/train/hanover/hanover_000000_047499_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_047629_leftImg8bit.png gtFine/train/hanover/hanover_000000_047629_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_047870_leftImg8bit.png gtFine/train/hanover/hanover_000000_047870_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_048274_leftImg8bit.png gtFine/train/hanover/hanover_000000_048274_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_048379_leftImg8bit.png gtFine/train/hanover/hanover_000000_048379_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_048508_leftImg8bit.png gtFine/train/hanover/hanover_000000_048508_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_048765_leftImg8bit.png gtFine/train/hanover/hanover_000000_048765_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_049005_leftImg8bit.png gtFine/train/hanover/hanover_000000_049005_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_049269_leftImg8bit.png gtFine/train/hanover/hanover_000000_049269_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_049465_leftImg8bit.png gtFine/train/hanover/hanover_000000_049465_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_050228_leftImg8bit.png gtFine/train/hanover/hanover_000000_050228_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_050398_leftImg8bit.png gtFine/train/hanover/hanover_000000_050398_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_051059_leftImg8bit.png gtFine/train/hanover/hanover_000000_051059_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_051152_leftImg8bit.png gtFine/train/hanover/hanover_000000_051152_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_051271_leftImg8bit.png gtFine/train/hanover/hanover_000000_051271_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_051536_leftImg8bit.png gtFine/train/hanover/hanover_000000_051536_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_051842_leftImg8bit.png gtFine/train/hanover/hanover_000000_051842_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_052013_leftImg8bit.png gtFine/train/hanover/hanover_000000_052013_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_052512_leftImg8bit.png gtFine/train/hanover/hanover_000000_052512_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_052649_leftImg8bit.png gtFine/train/hanover/hanover_000000_052649_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_052729_leftImg8bit.png gtFine/train/hanover/hanover_000000_052729_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_052887_leftImg8bit.png gtFine/train/hanover/hanover_000000_052887_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_053027_leftImg8bit.png gtFine/train/hanover/hanover_000000_053027_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_053437_leftImg8bit.png gtFine/train/hanover/hanover_000000_053437_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_053604_leftImg8bit.png gtFine/train/hanover/hanover_000000_053604_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_054276_leftImg8bit.png gtFine/train/hanover/hanover_000000_054276_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_054965_leftImg8bit.png gtFine/train/hanover/hanover_000000_054965_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_055124_leftImg8bit.png gtFine/train/hanover/hanover_000000_055124_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_055592_leftImg8bit.png gtFine/train/hanover/hanover_000000_055592_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_055800_leftImg8bit.png gtFine/train/hanover/hanover_000000_055800_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_055937_leftImg8bit.png gtFine/train/hanover/hanover_000000_055937_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_056142_leftImg8bit.png gtFine/train/hanover/hanover_000000_056142_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_056361_leftImg8bit.png gtFine/train/hanover/hanover_000000_056361_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_056457_leftImg8bit.png gtFine/train/hanover/hanover_000000_056457_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_056601_leftImg8bit.png gtFine/train/hanover/hanover_000000_056601_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_056800_leftImg8bit.png gtFine/train/hanover/hanover_000000_056800_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_057532_leftImg8bit.png gtFine/train/hanover/hanover_000000_057532_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_057710_leftImg8bit.png gtFine/train/hanover/hanover_000000_057710_gtFine_labelTrainIds.png +leftImg8bit/train/hanover/hanover_000000_058189_leftImg8bit.png gtFine/train/hanover/hanover_000000_058189_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000000_000019_leftImg8bit.png gtFine/train/jena/jena_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000001_000019_leftImg8bit.png gtFine/train/jena/jena_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000002_000019_leftImg8bit.png gtFine/train/jena/jena_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000003_000019_leftImg8bit.png gtFine/train/jena/jena_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000004_000019_leftImg8bit.png gtFine/train/jena/jena_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000005_000019_leftImg8bit.png gtFine/train/jena/jena_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000006_000019_leftImg8bit.png gtFine/train/jena/jena_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000007_000019_leftImg8bit.png gtFine/train/jena/jena_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000008_000019_leftImg8bit.png gtFine/train/jena/jena_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000009_000019_leftImg8bit.png gtFine/train/jena/jena_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000010_000019_leftImg8bit.png gtFine/train/jena/jena_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000011_000019_leftImg8bit.png gtFine/train/jena/jena_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000012_000019_leftImg8bit.png gtFine/train/jena/jena_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000013_000019_leftImg8bit.png gtFine/train/jena/jena_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000014_000019_leftImg8bit.png gtFine/train/jena/jena_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000015_000019_leftImg8bit.png gtFine/train/jena/jena_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000016_000019_leftImg8bit.png gtFine/train/jena/jena_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000017_000019_leftImg8bit.png gtFine/train/jena/jena_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000018_000019_leftImg8bit.png gtFine/train/jena/jena_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000019_000019_leftImg8bit.png gtFine/train/jena/jena_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000020_000019_leftImg8bit.png gtFine/train/jena/jena_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000021_000019_leftImg8bit.png gtFine/train/jena/jena_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000022_000019_leftImg8bit.png gtFine/train/jena/jena_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000023_000019_leftImg8bit.png gtFine/train/jena/jena_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000024_000019_leftImg8bit.png gtFine/train/jena/jena_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000025_000019_leftImg8bit.png gtFine/train/jena/jena_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000026_000019_leftImg8bit.png gtFine/train/jena/jena_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000027_000019_leftImg8bit.png gtFine/train/jena/jena_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000028_000019_leftImg8bit.png gtFine/train/jena/jena_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000029_000019_leftImg8bit.png gtFine/train/jena/jena_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000030_000019_leftImg8bit.png gtFine/train/jena/jena_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000031_000019_leftImg8bit.png gtFine/train/jena/jena_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000032_000019_leftImg8bit.png gtFine/train/jena/jena_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000033_000019_leftImg8bit.png gtFine/train/jena/jena_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000034_000019_leftImg8bit.png gtFine/train/jena/jena_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000035_000019_leftImg8bit.png gtFine/train/jena/jena_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000036_000019_leftImg8bit.png gtFine/train/jena/jena_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000037_000019_leftImg8bit.png gtFine/train/jena/jena_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000038_000019_leftImg8bit.png gtFine/train/jena/jena_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000039_000019_leftImg8bit.png gtFine/train/jena/jena_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000040_000019_leftImg8bit.png gtFine/train/jena/jena_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000041_000019_leftImg8bit.png gtFine/train/jena/jena_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000042_000019_leftImg8bit.png gtFine/train/jena/jena_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000043_000019_leftImg8bit.png gtFine/train/jena/jena_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000044_000019_leftImg8bit.png gtFine/train/jena/jena_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000045_000019_leftImg8bit.png gtFine/train/jena/jena_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000046_000019_leftImg8bit.png gtFine/train/jena/jena_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000047_000019_leftImg8bit.png gtFine/train/jena/jena_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000048_000019_leftImg8bit.png gtFine/train/jena/jena_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000049_000019_leftImg8bit.png gtFine/train/jena/jena_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000050_000019_leftImg8bit.png gtFine/train/jena/jena_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000051_000019_leftImg8bit.png gtFine/train/jena/jena_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000052_000019_leftImg8bit.png gtFine/train/jena/jena_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000053_000019_leftImg8bit.png gtFine/train/jena/jena_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000054_000019_leftImg8bit.png gtFine/train/jena/jena_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000055_000019_leftImg8bit.png gtFine/train/jena/jena_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000056_000019_leftImg8bit.png gtFine/train/jena/jena_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000057_000019_leftImg8bit.png gtFine/train/jena/jena_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000058_000019_leftImg8bit.png gtFine/train/jena/jena_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000059_000019_leftImg8bit.png gtFine/train/jena/jena_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000060_000019_leftImg8bit.png gtFine/train/jena/jena_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000061_000019_leftImg8bit.png gtFine/train/jena/jena_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000062_000019_leftImg8bit.png gtFine/train/jena/jena_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000063_000019_leftImg8bit.png gtFine/train/jena/jena_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000064_000019_leftImg8bit.png gtFine/train/jena/jena_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000065_000019_leftImg8bit.png gtFine/train/jena/jena_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000066_000019_leftImg8bit.png gtFine/train/jena/jena_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000067_000019_leftImg8bit.png gtFine/train/jena/jena_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000068_000019_leftImg8bit.png gtFine/train/jena/jena_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000069_000019_leftImg8bit.png gtFine/train/jena/jena_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000070_000019_leftImg8bit.png gtFine/train/jena/jena_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000071_000019_leftImg8bit.png gtFine/train/jena/jena_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000072_000019_leftImg8bit.png gtFine/train/jena/jena_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000073_000019_leftImg8bit.png gtFine/train/jena/jena_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000074_000019_leftImg8bit.png gtFine/train/jena/jena_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000075_000019_leftImg8bit.png gtFine/train/jena/jena_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000076_000019_leftImg8bit.png gtFine/train/jena/jena_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000077_000019_leftImg8bit.png gtFine/train/jena/jena_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000078_000019_leftImg8bit.png gtFine/train/jena/jena_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000079_000019_leftImg8bit.png gtFine/train/jena/jena_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000080_000019_leftImg8bit.png gtFine/train/jena/jena_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000081_000019_leftImg8bit.png gtFine/train/jena/jena_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000082_000019_leftImg8bit.png gtFine/train/jena/jena_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000083_000019_leftImg8bit.png gtFine/train/jena/jena_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000084_000019_leftImg8bit.png gtFine/train/jena/jena_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000085_000019_leftImg8bit.png gtFine/train/jena/jena_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000086_000019_leftImg8bit.png gtFine/train/jena/jena_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000087_000019_leftImg8bit.png gtFine/train/jena/jena_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000088_000019_leftImg8bit.png gtFine/train/jena/jena_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000089_000019_leftImg8bit.png gtFine/train/jena/jena_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000090_000019_leftImg8bit.png gtFine/train/jena/jena_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000091_000019_leftImg8bit.png gtFine/train/jena/jena_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000092_000019_leftImg8bit.png gtFine/train/jena/jena_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000093_000019_leftImg8bit.png gtFine/train/jena/jena_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000094_000019_leftImg8bit.png gtFine/train/jena/jena_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000095_000019_leftImg8bit.png gtFine/train/jena/jena_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000096_000019_leftImg8bit.png gtFine/train/jena/jena_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000097_000019_leftImg8bit.png gtFine/train/jena/jena_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000098_000019_leftImg8bit.png gtFine/train/jena/jena_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000099_000019_leftImg8bit.png gtFine/train/jena/jena_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000100_000019_leftImg8bit.png gtFine/train/jena/jena_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000101_000019_leftImg8bit.png gtFine/train/jena/jena_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000102_000019_leftImg8bit.png gtFine/train/jena/jena_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000103_000019_leftImg8bit.png gtFine/train/jena/jena_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000104_000019_leftImg8bit.png gtFine/train/jena/jena_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000105_000019_leftImg8bit.png gtFine/train/jena/jena_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000106_000019_leftImg8bit.png gtFine/train/jena/jena_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000107_000019_leftImg8bit.png gtFine/train/jena/jena_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000108_000019_leftImg8bit.png gtFine/train/jena/jena_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000109_000019_leftImg8bit.png gtFine/train/jena/jena_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000110_000019_leftImg8bit.png gtFine/train/jena/jena_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000111_000019_leftImg8bit.png gtFine/train/jena/jena_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000112_000019_leftImg8bit.png gtFine/train/jena/jena_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000113_000019_leftImg8bit.png gtFine/train/jena/jena_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000114_000019_leftImg8bit.png gtFine/train/jena/jena_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000115_000019_leftImg8bit.png gtFine/train/jena/jena_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000116_000019_leftImg8bit.png gtFine/train/jena/jena_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000117_000019_leftImg8bit.png gtFine/train/jena/jena_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/jena/jena_000118_000019_leftImg8bit.png gtFine/train/jena/jena_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_000108_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_000108_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_000316_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_000316_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_000442_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_000442_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_000926_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_000926_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_001566_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_001566_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_001908_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_001908_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_002083_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_002083_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_003096_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_003096_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_003707_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_003707_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_003937_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_003937_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_004447_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_004447_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_004608_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_004608_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_005252_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_005252_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_005503_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_005503_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_006274_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_006274_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_006686_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_006686_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_007325_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_007325_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_008239_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_008239_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_008305_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_008305_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_008584_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_008584_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_009404_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_009404_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_009574_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_009574_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_009926_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_009926_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_010160_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_010160_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_010329_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_010329_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_010653_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_010653_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_011483_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_011483_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_011655_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_011655_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_012353_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_012353_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_012505_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_012505_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_013139_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_013139_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_013257_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_013257_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_013766_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_013766_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_014146_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_014146_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_014673_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_014673_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_014886_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_014886_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_015116_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_015116_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_015494_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_015494_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_015687_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_015687_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_015868_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_015868_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_016342_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_016342_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_016863_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_016863_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_017042_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_017042_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_017342_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_017342_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_017489_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_017489_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_018004_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_018004_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_018514_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_018514_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_018747_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_018747_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_018866_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_018866_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_019125_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_019125_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_019697_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_019697_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_019791_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_019791_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_020033_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_020033_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_020334_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_020334_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_020624_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_020624_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_020873_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_020873_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_020933_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_020933_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_021000_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_021000_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_021222_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_021222_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_021553_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_021553_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_021814_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_021814_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_022162_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_022162_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_023143_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_023143_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_023338_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_023338_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_023510_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_023510_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_023698_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_023698_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_024276_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_024276_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_024362_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_024362_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_024604_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_024604_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_024921_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_024921_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_025434_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_025434_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_025812_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_025812_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_026269_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_026269_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_026580_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_026580_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_026919_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_026919_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_027075_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_027075_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_027596_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_027596_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_027954_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_027954_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_028378_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_028378_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_028638_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_028638_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_029050_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_029050_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_029704_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_029704_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_030111_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_030111_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_030221_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_030221_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_030400_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_030400_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_030560_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_030560_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_030701_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_030701_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_031257_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_031257_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_032390_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_032390_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_032614_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_032614_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_032845_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_032845_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_033478_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_033478_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_034156_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_034156_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_034231_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_034231_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_034389_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_034389_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_034686_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_034686_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_035124_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_035124_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_035398_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_035398_gtFine_labelTrainIds.png +leftImg8bit/train/krefeld/krefeld_000000_036299_leftImg8bit.png gtFine/train/krefeld/krefeld_000000_036299_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_000076_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_000076_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_000383_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_000383_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_001068_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_001068_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_001294_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_001294_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_002255_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_002255_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_002478_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_002478_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_002972_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_002972_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_003442_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_003442_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_004580_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_004580_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_005138_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_005138_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_005686_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_005686_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_005876_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_005876_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_006169_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_006169_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_006518_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_006518_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_007098_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_007098_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_007695_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_007695_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_007851_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_007851_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_009191_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_009191_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_009615_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_009615_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_009690_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_009690_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_009930_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_009930_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_010280_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_010280_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_010505_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_010505_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_010733_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_010733_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_010860_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_010860_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_011383_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_011383_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_012376_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_012376_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_012672_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_012672_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_013228_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_013228_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_013352_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_013352_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_014685_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_014685_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_015126_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_015126_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_015561_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_015561_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_015685_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_015685_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_015928_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_015928_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_017950_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_017950_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_018114_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_018114_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_018294_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_018294_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_018445_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_018445_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_018575_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_018575_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_018720_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_018720_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_019142_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_019142_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_019500_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_019500_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_019682_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_019682_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_019901_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_019901_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_020303_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_020303_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_020596_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_020596_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_020856_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_020856_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_021104_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_021104_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_021663_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_021663_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_022361_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_022361_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_022748_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_022748_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_023052_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_023052_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_023375_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_023375_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_023489_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_023489_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_023856_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_023856_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_024243_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_024243_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_024637_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_024637_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_024964_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_024964_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_025215_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_025215_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_026006_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_026006_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_026305_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_026305_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_026602_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_026602_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_026908_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_026908_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_027628_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_027628_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_028216_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_028216_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_028563_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_028563_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_028883_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_028883_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_029240_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_029240_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_029526_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_029526_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_030010_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_030010_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_030662_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_030662_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_031005_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_031005_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_031360_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_031360_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_031623_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_031623_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_032540_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_032540_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_033454_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_033454_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_033683_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_033683_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_034302_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_034302_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_034621_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_034621_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_034930_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_034930_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_035083_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_035083_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_035364_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_035364_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_035650_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_035650_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_035718_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_035718_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000000_036139_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000000_036139_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_000054_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_000054_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_000168_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_000168_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_000537_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_000537_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_000876_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_000876_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_001531_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_001531_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_001936_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_001936_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_002229_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_002229_gtFine_labelTrainIds.png +leftImg8bit/train/monchengladbach/monchengladbach_000001_002353_leftImg8bit.png gtFine/train/monchengladbach/monchengladbach_000001_002353_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_000065_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_000065_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_000295_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_000295_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_000751_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_000751_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_001278_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_001278_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_002183_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_002183_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_002553_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_002553_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_003632_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_003632_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_003846_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_003846_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_004112_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_004112_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_004248_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_004248_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_004383_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_004383_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_004660_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_004660_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_004951_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_004951_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_005249_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_005249_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_005912_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_005912_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_005995_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_005995_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_006106_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_006106_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_006264_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_006264_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_006483_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_006483_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_006621_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_006621_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_006995_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_006995_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_007441_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_007441_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_007727_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_007727_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_007813_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_007813_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_008603_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_008603_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_008677_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_008677_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_008784_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_008784_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_009110_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_009110_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_009619_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_009619_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_010049_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_010049_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_010372_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_010372_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_010816_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_010816_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_011225_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_011225_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_011880_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_011880_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_012070_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_012070_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_012934_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_012934_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013223_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013223_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013322_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013322_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013574_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013574_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013654_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013654_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013863_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013863_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_013944_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_013944_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014066_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014066_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014101_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014101_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014235_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014235_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014416_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014416_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014503_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014503_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014584_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014584_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014743_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014743_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_014931_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_014931_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_015131_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_015131_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_015506_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_015506_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_015602_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_015602_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_015764_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_015764_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_016024_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_016024_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_016247_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_016247_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_016311_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_016311_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_016436_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_016436_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017044_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017044_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017081_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017081_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017159_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017159_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017283_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017283_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017450_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017450_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017593_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017593_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_017761_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_017761_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_018153_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_018153_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_018358_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_018358_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_018616_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_018616_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_018874_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_018874_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_019050_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_019050_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_019229_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_019229_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_019355_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_019355_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_019617_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_019617_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_019891_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_019891_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_020432_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_020432_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_020653_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_020653_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_021231_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_021231_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_021651_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_021651_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_022067_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_022067_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_022489_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_022489_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_023064_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_023064_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_023694_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_023694_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_023854_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_023854_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_024179_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_024179_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_024945_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_024945_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025089_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025089_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025268_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025268_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025351_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025351_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025491_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025491_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025772_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025772_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_025907_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_025907_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026316_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026316_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026575_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026575_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026611_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026611_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026741_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026741_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026882_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026882_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_026998_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_026998_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_027156_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_027156_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_027233_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_027233_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_027771_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_027771_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_028240_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_028240_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_028556_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_028556_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_028628_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_028628_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_028822_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_028822_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_028912_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_028912_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029020_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029020_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029051_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029051_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029179_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029179_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029281_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029281_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029339_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029339_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029400_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029400_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029481_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029481_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029577_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029577_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029729_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029729_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029839_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029839_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_029915_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_029915_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030017_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030017_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030122_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030122_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030324_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030324_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030435_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030435_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030706_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030706_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_030941_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_030941_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_031067_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_031067_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_031223_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_031223_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_031323_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_031323_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_031602_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_031602_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_032186_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_032186_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_032346_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_032346_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_032962_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_032962_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_033062_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_033062_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_033129_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_033129_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_033425_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_033425_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_033747_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_033747_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_033838_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_033838_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_034040_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_034040_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_034097_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_034097_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_034387_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_034387_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_034652_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_034652_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_035008_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_035008_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_035255_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_035255_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_035571_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_035571_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_035713_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_035713_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_035942_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_035942_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000000_036016_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000000_036016_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_000113_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_000113_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_000508_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_000508_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_000710_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_000710_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_000778_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_000778_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_001072_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_001072_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_001449_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_001449_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_001722_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_001722_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_001901_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_001901_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002081_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002081_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002216_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002216_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002354_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002354_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002519_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002519_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002644_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002644_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_002949_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_002949_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_003159_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_003159_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_003489_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_003489_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_003676_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_003676_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_003991_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_003991_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_004106_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_004106_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_004260_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_004260_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_004745_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_004745_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_004983_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_004983_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_005219_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_005219_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_005289_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_005289_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_005666_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_005666_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_005876_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_005876_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_006153_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_006153_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_006386_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_006386_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_006562_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_006562_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_006916_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_006916_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_007148_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_007148_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_007524_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_007524_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_007657_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_007657_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_007864_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_007864_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_008310_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_008310_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_008576_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_008576_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_008771_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_008771_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009097_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009097_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009246_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009246_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009333_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009333_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009471_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009471_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009618_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009618_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_009795_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_009795_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_010162_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_010162_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_010445_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_010445_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_010640_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_010640_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_010755_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_010755_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_011617_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_011617_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_011775_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_011775_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_011990_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_011990_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_012956_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_012956_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_013266_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_013266_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_013767_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_013767_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_013914_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_013914_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_014033_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_014033_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_014258_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_014258_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_014629_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_014629_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_015220_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_015220_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_015605_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_015605_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_015974_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_015974_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_016253_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_016253_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_016376_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_016376_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_016481_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_016481_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_016681_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_016681_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_017469_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_017469_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_017540_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_017540_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_017675_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_017675_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_017844_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_017844_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_018155_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_018155_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_018432_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_018432_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_018742_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_018742_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_018872_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_018872_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_019247_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_019247_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_019698_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_019698_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_020904_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_020904_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_020956_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_020956_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_021951_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_021951_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_022151_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_022151_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_022363_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_022363_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_022560_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_022560_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_022836_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_022836_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_023271_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_023271_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_023515_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_023515_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_024152_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_024152_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_024379_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_024379_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_024701_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_024701_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_025426_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_025426_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_025833_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_025833_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_026106_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_026106_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_026355_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_026355_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_026606_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_026606_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_026856_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_026856_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_027097_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_027097_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_028379_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_028379_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_028852_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_028852_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_029178_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_029178_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_029696_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_029696_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_029980_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_029980_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030120_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030120_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030269_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030269_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030539_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030539_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030725_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030725_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030839_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030839_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_030997_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_030997_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031116_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031116_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031272_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031272_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031427_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031427_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031582_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031582_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031683_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031683_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_031976_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_031976_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_032315_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_032315_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_032660_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_032660_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_033027_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_033027_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_033448_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_033448_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_033925_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_033925_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_034375_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_034375_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_034494_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_034494_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_034633_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_034633_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_034923_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_034923_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_035276_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_035276_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_035562_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_035562_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_035689_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_035689_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_036232_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_036232_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_036480_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_036480_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_036697_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_036697_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_036937_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_036937_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_037090_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_037090_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_037645_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_037645_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_037776_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_037776_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_037906_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_037906_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_038281_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_038281_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039114_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039114_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039231_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039231_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039374_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039374_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039446_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039446_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039558_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039558_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_039703_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_039703_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_040564_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_040564_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_040620_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_040620_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_040761_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_040761_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_040981_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_040981_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_041215_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_041215_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_042235_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_042235_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_042309_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_042309_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_042434_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_042434_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_042558_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_042558_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_042869_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_042869_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_043080_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_043080_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_043748_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_043748_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_043886_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_043886_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_044219_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_044219_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_045135_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_045135_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_045481_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_045481_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_045880_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_045880_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_046324_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_046324_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_047336_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_047336_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_047619_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_047619_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_047702_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_047702_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_047755_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_047755_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_047955_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_047955_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_048121_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_048121_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_048605_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_048605_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_049143_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_049143_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_049399_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_049399_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_049776_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_049776_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_049977_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_049977_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_050098_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_050098_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051134_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051134_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051317_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051317_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051448_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051448_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051574_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051574_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051661_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051661_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051877_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051877_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_051934_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_051934_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052050_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052050_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052198_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052198_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052297_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052297_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052430_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052430_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052497_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052497_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052544_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052544_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052840_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052840_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_052979_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_052979_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_053222_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_053222_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_053579_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_053579_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_053976_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_053976_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_054275_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_054275_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_054639_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_054639_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_055273_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_055273_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_055698_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_055698_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_055860_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_055860_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_055934_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_055934_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_056142_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_056142_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_056330_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_056330_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_056857_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_056857_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_057129_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_057129_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_057191_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_057191_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_057517_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_057517_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_057811_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_057811_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_057930_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_057930_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_058105_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_058105_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_058373_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_058373_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_058954_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_058954_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_059433_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_059433_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_059675_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_059675_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_059914_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_059914_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_060061_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_060061_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_060173_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_060173_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_060821_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_060821_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_061285_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_061285_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_061384_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_061384_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_061472_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_061472_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_061685_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_061685_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_062362_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_062362_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_062542_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_062542_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_062691_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_062691_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_063385_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_063385_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_063808_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_063808_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_064224_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_064224_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_064393_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_064393_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_065214_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_065214_gtFine_labelTrainIds.png +leftImg8bit/train/strasbourg/strasbourg_000001_065572_leftImg8bit.png gtFine/train/strasbourg/strasbourg_000001_065572_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000000_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000001_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000002_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000003_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000004_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000005_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000006_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000007_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000008_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000009_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000010_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000011_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000012_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000013_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000014_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000015_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000016_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000017_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000018_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000019_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000020_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000021_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000022_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000023_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000024_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000025_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000026_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000027_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000028_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000029_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000030_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000031_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000032_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000033_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000034_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000035_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000036_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000037_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000038_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000039_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000040_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000041_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000042_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000043_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000044_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000045_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000046_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000047_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000048_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000049_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000050_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000051_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000052_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000053_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000054_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000055_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000056_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000057_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000058_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000059_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000060_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000061_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000062_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000063_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000064_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000065_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000066_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000067_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000068_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000069_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000070_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000071_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000072_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000073_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000074_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000075_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000076_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000077_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000078_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000079_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000080_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000081_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000082_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000083_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000084_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000085_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000086_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000087_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000088_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000089_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000090_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000091_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000092_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000093_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000094_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000095_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000096_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000097_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000098_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000099_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000100_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000101_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000102_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000103_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000104_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000105_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000106_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000107_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000108_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000109_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000110_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000111_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000112_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000113_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000114_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000115_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000116_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000117_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000118_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000119_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000120_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000121_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000122_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000123_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000124_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000125_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000126_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000127_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000128_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000129_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000130_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000131_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000132_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000133_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000134_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000135_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000136_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000137_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000138_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000139_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000140_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000141_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000142_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000143_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000144_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000145_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000146_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000147_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000148_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000149_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000150_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000151_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000152_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000153_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000154_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000155_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000156_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000157_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000158_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000159_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000160_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000161_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000162_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000163_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000164_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000165_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000166_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000167_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000168_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000169_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000170_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000171_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000172_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000173_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000173_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000174_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000174_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000175_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000175_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000176_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000176_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000177_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000177_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000178_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000178_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000179_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000179_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000180_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000180_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000181_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000181_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000182_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000182_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000183_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000183_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000184_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000184_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000185_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000185_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000186_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000186_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000187_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000187_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000188_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000188_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000189_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000189_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000190_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000190_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000191_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000191_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000192_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000192_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000193_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000193_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000194_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000194_000019_gtFine_labelTrainIds.png +leftImg8bit/train/stuttgart/stuttgart_000195_000019_leftImg8bit.png gtFine/train/stuttgart/stuttgart_000195_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000000_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000001_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000002_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000003_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000004_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000005_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000006_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000007_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000008_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000009_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000010_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000011_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000012_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000013_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000014_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000015_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000016_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000017_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000018_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000019_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000020_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000021_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000022_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000023_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000024_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000025_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000026_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000027_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000028_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000029_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000030_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000031_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000032_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000033_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000034_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000035_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000036_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000037_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000038_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000039_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000040_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000041_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000042_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000043_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000044_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000045_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000046_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000047_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000048_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000049_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000050_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000051_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000052_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000053_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000054_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000055_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000056_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000057_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000058_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000059_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000060_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000061_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000062_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000063_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000064_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000065_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000066_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000067_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000068_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000069_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000070_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000071_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000072_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000073_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000074_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000075_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000076_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000077_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000078_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000079_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000080_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000081_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000082_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000083_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000084_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000085_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000086_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000087_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000088_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000089_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000090_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000091_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000092_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000093_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000094_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000095_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000096_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000097_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000098_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000099_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000100_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000101_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000102_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000103_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000104_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000105_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000106_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000107_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000108_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000109_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000110_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000111_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000112_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000113_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000114_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000115_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000116_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000117_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000118_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000119_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000120_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000121_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000122_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000123_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000124_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000125_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000126_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000127_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000128_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000129_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000130_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000131_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000132_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000133_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000134_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000135_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000136_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000137_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000138_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000139_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000140_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000141_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000142_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/train/tubingen/tubingen_000143_000019_leftImg8bit.png gtFine/train/tubingen/tubingen_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000000_000019_leftImg8bit.png gtFine/train/ulm/ulm_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000001_000019_leftImg8bit.png gtFine/train/ulm/ulm_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000002_000019_leftImg8bit.png gtFine/train/ulm/ulm_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000003_000019_leftImg8bit.png gtFine/train/ulm/ulm_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000004_000019_leftImg8bit.png gtFine/train/ulm/ulm_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000005_000019_leftImg8bit.png gtFine/train/ulm/ulm_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000006_000019_leftImg8bit.png gtFine/train/ulm/ulm_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000007_000019_leftImg8bit.png gtFine/train/ulm/ulm_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000008_000019_leftImg8bit.png gtFine/train/ulm/ulm_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000009_000019_leftImg8bit.png gtFine/train/ulm/ulm_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000010_000019_leftImg8bit.png gtFine/train/ulm/ulm_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000011_000019_leftImg8bit.png gtFine/train/ulm/ulm_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000012_000019_leftImg8bit.png gtFine/train/ulm/ulm_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000013_000019_leftImg8bit.png gtFine/train/ulm/ulm_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000014_000019_leftImg8bit.png gtFine/train/ulm/ulm_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000015_000019_leftImg8bit.png gtFine/train/ulm/ulm_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000016_000019_leftImg8bit.png gtFine/train/ulm/ulm_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000017_000019_leftImg8bit.png gtFine/train/ulm/ulm_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000018_000019_leftImg8bit.png gtFine/train/ulm/ulm_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000019_000019_leftImg8bit.png gtFine/train/ulm/ulm_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000020_000019_leftImg8bit.png gtFine/train/ulm/ulm_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000021_000019_leftImg8bit.png gtFine/train/ulm/ulm_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000022_000019_leftImg8bit.png gtFine/train/ulm/ulm_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000023_000019_leftImg8bit.png gtFine/train/ulm/ulm_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000024_000019_leftImg8bit.png gtFine/train/ulm/ulm_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000025_000019_leftImg8bit.png gtFine/train/ulm/ulm_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000026_000019_leftImg8bit.png gtFine/train/ulm/ulm_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000027_000019_leftImg8bit.png gtFine/train/ulm/ulm_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000028_000019_leftImg8bit.png gtFine/train/ulm/ulm_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000029_000019_leftImg8bit.png gtFine/train/ulm/ulm_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000030_000019_leftImg8bit.png gtFine/train/ulm/ulm_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000031_000019_leftImg8bit.png gtFine/train/ulm/ulm_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000032_000019_leftImg8bit.png gtFine/train/ulm/ulm_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000033_000019_leftImg8bit.png gtFine/train/ulm/ulm_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000034_000019_leftImg8bit.png gtFine/train/ulm/ulm_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000035_000019_leftImg8bit.png gtFine/train/ulm/ulm_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000036_000019_leftImg8bit.png gtFine/train/ulm/ulm_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000037_000019_leftImg8bit.png gtFine/train/ulm/ulm_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000038_000019_leftImg8bit.png gtFine/train/ulm/ulm_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000039_000019_leftImg8bit.png gtFine/train/ulm/ulm_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000040_000019_leftImg8bit.png gtFine/train/ulm/ulm_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000041_000019_leftImg8bit.png gtFine/train/ulm/ulm_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000042_000019_leftImg8bit.png gtFine/train/ulm/ulm_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000043_000019_leftImg8bit.png gtFine/train/ulm/ulm_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000044_000019_leftImg8bit.png gtFine/train/ulm/ulm_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000045_000019_leftImg8bit.png gtFine/train/ulm/ulm_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000046_000019_leftImg8bit.png gtFine/train/ulm/ulm_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000047_000019_leftImg8bit.png gtFine/train/ulm/ulm_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000048_000019_leftImg8bit.png gtFine/train/ulm/ulm_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000049_000019_leftImg8bit.png gtFine/train/ulm/ulm_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000050_000019_leftImg8bit.png gtFine/train/ulm/ulm_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000051_000019_leftImg8bit.png gtFine/train/ulm/ulm_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000052_000019_leftImg8bit.png gtFine/train/ulm/ulm_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000053_000019_leftImg8bit.png gtFine/train/ulm/ulm_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000054_000019_leftImg8bit.png gtFine/train/ulm/ulm_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000055_000019_leftImg8bit.png gtFine/train/ulm/ulm_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000056_000019_leftImg8bit.png gtFine/train/ulm/ulm_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000057_000019_leftImg8bit.png gtFine/train/ulm/ulm_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000058_000019_leftImg8bit.png gtFine/train/ulm/ulm_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000059_000019_leftImg8bit.png gtFine/train/ulm/ulm_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000060_000019_leftImg8bit.png gtFine/train/ulm/ulm_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000061_000019_leftImg8bit.png gtFine/train/ulm/ulm_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000062_000019_leftImg8bit.png gtFine/train/ulm/ulm_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000063_000019_leftImg8bit.png gtFine/train/ulm/ulm_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000064_000019_leftImg8bit.png gtFine/train/ulm/ulm_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000065_000019_leftImg8bit.png gtFine/train/ulm/ulm_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000066_000019_leftImg8bit.png gtFine/train/ulm/ulm_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000067_000019_leftImg8bit.png gtFine/train/ulm/ulm_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000068_000019_leftImg8bit.png gtFine/train/ulm/ulm_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000069_000019_leftImg8bit.png gtFine/train/ulm/ulm_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000070_000019_leftImg8bit.png gtFine/train/ulm/ulm_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000071_000019_leftImg8bit.png gtFine/train/ulm/ulm_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000072_000019_leftImg8bit.png gtFine/train/ulm/ulm_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000073_000019_leftImg8bit.png gtFine/train/ulm/ulm_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000074_000019_leftImg8bit.png gtFine/train/ulm/ulm_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000075_000019_leftImg8bit.png gtFine/train/ulm/ulm_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000076_000019_leftImg8bit.png gtFine/train/ulm/ulm_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000077_000019_leftImg8bit.png gtFine/train/ulm/ulm_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000078_000019_leftImg8bit.png gtFine/train/ulm/ulm_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000079_000019_leftImg8bit.png gtFine/train/ulm/ulm_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000080_000019_leftImg8bit.png gtFine/train/ulm/ulm_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000081_000019_leftImg8bit.png gtFine/train/ulm/ulm_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000082_000019_leftImg8bit.png gtFine/train/ulm/ulm_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000083_000019_leftImg8bit.png gtFine/train/ulm/ulm_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000084_000019_leftImg8bit.png gtFine/train/ulm/ulm_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000085_000019_leftImg8bit.png gtFine/train/ulm/ulm_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000086_000019_leftImg8bit.png gtFine/train/ulm/ulm_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000087_000019_leftImg8bit.png gtFine/train/ulm/ulm_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000088_000019_leftImg8bit.png gtFine/train/ulm/ulm_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000089_000019_leftImg8bit.png gtFine/train/ulm/ulm_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000090_000019_leftImg8bit.png gtFine/train/ulm/ulm_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000091_000019_leftImg8bit.png gtFine/train/ulm/ulm_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000092_000019_leftImg8bit.png gtFine/train/ulm/ulm_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000093_000019_leftImg8bit.png gtFine/train/ulm/ulm_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/ulm/ulm_000094_000019_leftImg8bit.png gtFine/train/ulm/ulm_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000000_000019_leftImg8bit.png gtFine/train/weimar/weimar_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000001_000019_leftImg8bit.png gtFine/train/weimar/weimar_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000002_000019_leftImg8bit.png gtFine/train/weimar/weimar_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000003_000019_leftImg8bit.png gtFine/train/weimar/weimar_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000004_000019_leftImg8bit.png gtFine/train/weimar/weimar_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000005_000019_leftImg8bit.png gtFine/train/weimar/weimar_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000006_000019_leftImg8bit.png gtFine/train/weimar/weimar_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000007_000019_leftImg8bit.png gtFine/train/weimar/weimar_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000008_000019_leftImg8bit.png gtFine/train/weimar/weimar_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000009_000019_leftImg8bit.png gtFine/train/weimar/weimar_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000010_000019_leftImg8bit.png gtFine/train/weimar/weimar_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000011_000019_leftImg8bit.png gtFine/train/weimar/weimar_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000012_000019_leftImg8bit.png gtFine/train/weimar/weimar_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000013_000019_leftImg8bit.png gtFine/train/weimar/weimar_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000014_000019_leftImg8bit.png gtFine/train/weimar/weimar_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000015_000019_leftImg8bit.png gtFine/train/weimar/weimar_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000016_000019_leftImg8bit.png gtFine/train/weimar/weimar_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000017_000019_leftImg8bit.png gtFine/train/weimar/weimar_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000018_000019_leftImg8bit.png gtFine/train/weimar/weimar_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000019_000019_leftImg8bit.png gtFine/train/weimar/weimar_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000020_000019_leftImg8bit.png gtFine/train/weimar/weimar_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000021_000019_leftImg8bit.png gtFine/train/weimar/weimar_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000022_000019_leftImg8bit.png gtFine/train/weimar/weimar_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000023_000019_leftImg8bit.png gtFine/train/weimar/weimar_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000024_000019_leftImg8bit.png gtFine/train/weimar/weimar_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000025_000019_leftImg8bit.png gtFine/train/weimar/weimar_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000026_000019_leftImg8bit.png gtFine/train/weimar/weimar_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000027_000019_leftImg8bit.png gtFine/train/weimar/weimar_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000028_000019_leftImg8bit.png gtFine/train/weimar/weimar_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000029_000019_leftImg8bit.png gtFine/train/weimar/weimar_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000030_000019_leftImg8bit.png gtFine/train/weimar/weimar_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000031_000019_leftImg8bit.png gtFine/train/weimar/weimar_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000032_000019_leftImg8bit.png gtFine/train/weimar/weimar_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000033_000019_leftImg8bit.png gtFine/train/weimar/weimar_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000034_000019_leftImg8bit.png gtFine/train/weimar/weimar_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000035_000019_leftImg8bit.png gtFine/train/weimar/weimar_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000036_000019_leftImg8bit.png gtFine/train/weimar/weimar_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000037_000019_leftImg8bit.png gtFine/train/weimar/weimar_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000038_000019_leftImg8bit.png gtFine/train/weimar/weimar_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000039_000019_leftImg8bit.png gtFine/train/weimar/weimar_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000040_000019_leftImg8bit.png gtFine/train/weimar/weimar_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000041_000019_leftImg8bit.png gtFine/train/weimar/weimar_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000042_000019_leftImg8bit.png gtFine/train/weimar/weimar_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000043_000019_leftImg8bit.png gtFine/train/weimar/weimar_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000044_000019_leftImg8bit.png gtFine/train/weimar/weimar_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000045_000019_leftImg8bit.png gtFine/train/weimar/weimar_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000046_000019_leftImg8bit.png gtFine/train/weimar/weimar_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000047_000019_leftImg8bit.png gtFine/train/weimar/weimar_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000048_000019_leftImg8bit.png gtFine/train/weimar/weimar_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000049_000019_leftImg8bit.png gtFine/train/weimar/weimar_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000050_000019_leftImg8bit.png gtFine/train/weimar/weimar_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000051_000019_leftImg8bit.png gtFine/train/weimar/weimar_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000052_000019_leftImg8bit.png gtFine/train/weimar/weimar_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000053_000019_leftImg8bit.png gtFine/train/weimar/weimar_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000054_000019_leftImg8bit.png gtFine/train/weimar/weimar_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000055_000019_leftImg8bit.png gtFine/train/weimar/weimar_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000056_000019_leftImg8bit.png gtFine/train/weimar/weimar_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000057_000019_leftImg8bit.png gtFine/train/weimar/weimar_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000058_000019_leftImg8bit.png gtFine/train/weimar/weimar_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000059_000019_leftImg8bit.png gtFine/train/weimar/weimar_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000060_000019_leftImg8bit.png gtFine/train/weimar/weimar_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000061_000019_leftImg8bit.png gtFine/train/weimar/weimar_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000062_000019_leftImg8bit.png gtFine/train/weimar/weimar_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000063_000019_leftImg8bit.png gtFine/train/weimar/weimar_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000064_000019_leftImg8bit.png gtFine/train/weimar/weimar_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000065_000019_leftImg8bit.png gtFine/train/weimar/weimar_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000066_000019_leftImg8bit.png gtFine/train/weimar/weimar_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000067_000019_leftImg8bit.png gtFine/train/weimar/weimar_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000068_000019_leftImg8bit.png gtFine/train/weimar/weimar_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000069_000019_leftImg8bit.png gtFine/train/weimar/weimar_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000070_000019_leftImg8bit.png gtFine/train/weimar/weimar_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000071_000019_leftImg8bit.png gtFine/train/weimar/weimar_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000072_000019_leftImg8bit.png gtFine/train/weimar/weimar_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000073_000019_leftImg8bit.png gtFine/train/weimar/weimar_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000074_000019_leftImg8bit.png gtFine/train/weimar/weimar_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000075_000019_leftImg8bit.png gtFine/train/weimar/weimar_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000076_000019_leftImg8bit.png gtFine/train/weimar/weimar_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000077_000019_leftImg8bit.png gtFine/train/weimar/weimar_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000078_000019_leftImg8bit.png gtFine/train/weimar/weimar_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000079_000019_leftImg8bit.png gtFine/train/weimar/weimar_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000080_000019_leftImg8bit.png gtFine/train/weimar/weimar_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000081_000019_leftImg8bit.png gtFine/train/weimar/weimar_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000082_000019_leftImg8bit.png gtFine/train/weimar/weimar_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000083_000019_leftImg8bit.png gtFine/train/weimar/weimar_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000084_000019_leftImg8bit.png gtFine/train/weimar/weimar_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000085_000019_leftImg8bit.png gtFine/train/weimar/weimar_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000086_000019_leftImg8bit.png gtFine/train/weimar/weimar_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000087_000019_leftImg8bit.png gtFine/train/weimar/weimar_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000088_000019_leftImg8bit.png gtFine/train/weimar/weimar_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000089_000019_leftImg8bit.png gtFine/train/weimar/weimar_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000090_000019_leftImg8bit.png gtFine/train/weimar/weimar_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000091_000019_leftImg8bit.png gtFine/train/weimar/weimar_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000092_000019_leftImg8bit.png gtFine/train/weimar/weimar_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000093_000019_leftImg8bit.png gtFine/train/weimar/weimar_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000094_000019_leftImg8bit.png gtFine/train/weimar/weimar_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000095_000019_leftImg8bit.png gtFine/train/weimar/weimar_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000096_000019_leftImg8bit.png gtFine/train/weimar/weimar_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000097_000019_leftImg8bit.png gtFine/train/weimar/weimar_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000098_000019_leftImg8bit.png gtFine/train/weimar/weimar_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000099_000019_leftImg8bit.png gtFine/train/weimar/weimar_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000100_000019_leftImg8bit.png gtFine/train/weimar/weimar_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000101_000019_leftImg8bit.png gtFine/train/weimar/weimar_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000102_000019_leftImg8bit.png gtFine/train/weimar/weimar_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000103_000019_leftImg8bit.png gtFine/train/weimar/weimar_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000104_000019_leftImg8bit.png gtFine/train/weimar/weimar_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000105_000019_leftImg8bit.png gtFine/train/weimar/weimar_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000106_000019_leftImg8bit.png gtFine/train/weimar/weimar_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000107_000019_leftImg8bit.png gtFine/train/weimar/weimar_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000108_000019_leftImg8bit.png gtFine/train/weimar/weimar_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000109_000019_leftImg8bit.png gtFine/train/weimar/weimar_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000110_000019_leftImg8bit.png gtFine/train/weimar/weimar_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000111_000019_leftImg8bit.png gtFine/train/weimar/weimar_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000112_000019_leftImg8bit.png gtFine/train/weimar/weimar_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000113_000019_leftImg8bit.png gtFine/train/weimar/weimar_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000114_000019_leftImg8bit.png gtFine/train/weimar/weimar_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000115_000019_leftImg8bit.png gtFine/train/weimar/weimar_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000116_000019_leftImg8bit.png gtFine/train/weimar/weimar_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000117_000019_leftImg8bit.png gtFine/train/weimar/weimar_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000118_000019_leftImg8bit.png gtFine/train/weimar/weimar_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000119_000019_leftImg8bit.png gtFine/train/weimar/weimar_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000120_000019_leftImg8bit.png gtFine/train/weimar/weimar_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000121_000019_leftImg8bit.png gtFine/train/weimar/weimar_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000122_000019_leftImg8bit.png gtFine/train/weimar/weimar_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000123_000019_leftImg8bit.png gtFine/train/weimar/weimar_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000124_000019_leftImg8bit.png gtFine/train/weimar/weimar_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000125_000019_leftImg8bit.png gtFine/train/weimar/weimar_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000126_000019_leftImg8bit.png gtFine/train/weimar/weimar_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000127_000019_leftImg8bit.png gtFine/train/weimar/weimar_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000128_000019_leftImg8bit.png gtFine/train/weimar/weimar_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000129_000019_leftImg8bit.png gtFine/train/weimar/weimar_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000130_000019_leftImg8bit.png gtFine/train/weimar/weimar_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000131_000019_leftImg8bit.png gtFine/train/weimar/weimar_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000132_000019_leftImg8bit.png gtFine/train/weimar/weimar_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000133_000019_leftImg8bit.png gtFine/train/weimar/weimar_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000134_000019_leftImg8bit.png gtFine/train/weimar/weimar_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000135_000019_leftImg8bit.png gtFine/train/weimar/weimar_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000136_000019_leftImg8bit.png gtFine/train/weimar/weimar_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000137_000019_leftImg8bit.png gtFine/train/weimar/weimar_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000138_000019_leftImg8bit.png gtFine/train/weimar/weimar_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000139_000019_leftImg8bit.png gtFine/train/weimar/weimar_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000140_000019_leftImg8bit.png gtFine/train/weimar/weimar_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/train/weimar/weimar_000141_000019_leftImg8bit.png gtFine/train/weimar/weimar_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000000_000019_leftImg8bit.png gtFine/train/zurich/zurich_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000001_000019_leftImg8bit.png gtFine/train/zurich/zurich_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000002_000019_leftImg8bit.png gtFine/train/zurich/zurich_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000003_000019_leftImg8bit.png gtFine/train/zurich/zurich_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000004_000019_leftImg8bit.png gtFine/train/zurich/zurich_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000005_000019_leftImg8bit.png gtFine/train/zurich/zurich_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000006_000019_leftImg8bit.png gtFine/train/zurich/zurich_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000007_000019_leftImg8bit.png gtFine/train/zurich/zurich_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000008_000019_leftImg8bit.png gtFine/train/zurich/zurich_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000009_000019_leftImg8bit.png gtFine/train/zurich/zurich_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000010_000019_leftImg8bit.png gtFine/train/zurich/zurich_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000011_000019_leftImg8bit.png gtFine/train/zurich/zurich_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000012_000019_leftImg8bit.png gtFine/train/zurich/zurich_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000013_000019_leftImg8bit.png gtFine/train/zurich/zurich_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000014_000019_leftImg8bit.png gtFine/train/zurich/zurich_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000015_000019_leftImg8bit.png gtFine/train/zurich/zurich_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000016_000019_leftImg8bit.png gtFine/train/zurich/zurich_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000017_000019_leftImg8bit.png gtFine/train/zurich/zurich_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000018_000019_leftImg8bit.png gtFine/train/zurich/zurich_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000019_000019_leftImg8bit.png gtFine/train/zurich/zurich_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000020_000019_leftImg8bit.png gtFine/train/zurich/zurich_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000021_000019_leftImg8bit.png gtFine/train/zurich/zurich_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000022_000019_leftImg8bit.png gtFine/train/zurich/zurich_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000023_000019_leftImg8bit.png gtFine/train/zurich/zurich_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000024_000019_leftImg8bit.png gtFine/train/zurich/zurich_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000025_000019_leftImg8bit.png gtFine/train/zurich/zurich_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000026_000019_leftImg8bit.png gtFine/train/zurich/zurich_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000027_000019_leftImg8bit.png gtFine/train/zurich/zurich_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000028_000019_leftImg8bit.png gtFine/train/zurich/zurich_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000029_000019_leftImg8bit.png gtFine/train/zurich/zurich_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000030_000019_leftImg8bit.png gtFine/train/zurich/zurich_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000031_000019_leftImg8bit.png gtFine/train/zurich/zurich_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000032_000019_leftImg8bit.png gtFine/train/zurich/zurich_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000033_000019_leftImg8bit.png gtFine/train/zurich/zurich_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000034_000019_leftImg8bit.png gtFine/train/zurich/zurich_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000035_000019_leftImg8bit.png gtFine/train/zurich/zurich_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000036_000019_leftImg8bit.png gtFine/train/zurich/zurich_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000037_000019_leftImg8bit.png gtFine/train/zurich/zurich_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000038_000019_leftImg8bit.png gtFine/train/zurich/zurich_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000039_000019_leftImg8bit.png gtFine/train/zurich/zurich_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000040_000019_leftImg8bit.png gtFine/train/zurich/zurich_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000041_000019_leftImg8bit.png gtFine/train/zurich/zurich_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000042_000019_leftImg8bit.png gtFine/train/zurich/zurich_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000043_000019_leftImg8bit.png gtFine/train/zurich/zurich_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000044_000019_leftImg8bit.png gtFine/train/zurich/zurich_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000045_000019_leftImg8bit.png gtFine/train/zurich/zurich_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000046_000019_leftImg8bit.png gtFine/train/zurich/zurich_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000047_000019_leftImg8bit.png gtFine/train/zurich/zurich_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000048_000019_leftImg8bit.png gtFine/train/zurich/zurich_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000049_000019_leftImg8bit.png gtFine/train/zurich/zurich_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000050_000019_leftImg8bit.png gtFine/train/zurich/zurich_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000051_000019_leftImg8bit.png gtFine/train/zurich/zurich_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000052_000019_leftImg8bit.png gtFine/train/zurich/zurich_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000053_000019_leftImg8bit.png gtFine/train/zurich/zurich_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000054_000019_leftImg8bit.png gtFine/train/zurich/zurich_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000055_000019_leftImg8bit.png gtFine/train/zurich/zurich_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000056_000019_leftImg8bit.png gtFine/train/zurich/zurich_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000057_000019_leftImg8bit.png gtFine/train/zurich/zurich_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000058_000019_leftImg8bit.png gtFine/train/zurich/zurich_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000059_000019_leftImg8bit.png gtFine/train/zurich/zurich_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000060_000019_leftImg8bit.png gtFine/train/zurich/zurich_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000061_000019_leftImg8bit.png gtFine/train/zurich/zurich_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000062_000019_leftImg8bit.png gtFine/train/zurich/zurich_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000063_000019_leftImg8bit.png gtFine/train/zurich/zurich_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000064_000019_leftImg8bit.png gtFine/train/zurich/zurich_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000065_000019_leftImg8bit.png gtFine/train/zurich/zurich_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000066_000019_leftImg8bit.png gtFine/train/zurich/zurich_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000067_000019_leftImg8bit.png gtFine/train/zurich/zurich_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000068_000019_leftImg8bit.png gtFine/train/zurich/zurich_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000069_000019_leftImg8bit.png gtFine/train/zurich/zurich_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000070_000019_leftImg8bit.png gtFine/train/zurich/zurich_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000071_000019_leftImg8bit.png gtFine/train/zurich/zurich_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000072_000019_leftImg8bit.png gtFine/train/zurich/zurich_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000073_000019_leftImg8bit.png gtFine/train/zurich/zurich_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000074_000019_leftImg8bit.png gtFine/train/zurich/zurich_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000075_000019_leftImg8bit.png gtFine/train/zurich/zurich_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000076_000019_leftImg8bit.png gtFine/train/zurich/zurich_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000077_000019_leftImg8bit.png gtFine/train/zurich/zurich_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000078_000019_leftImg8bit.png gtFine/train/zurich/zurich_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000079_000019_leftImg8bit.png gtFine/train/zurich/zurich_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000080_000019_leftImg8bit.png gtFine/train/zurich/zurich_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000081_000019_leftImg8bit.png gtFine/train/zurich/zurich_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000082_000019_leftImg8bit.png gtFine/train/zurich/zurich_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000083_000019_leftImg8bit.png gtFine/train/zurich/zurich_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000084_000019_leftImg8bit.png gtFine/train/zurich/zurich_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000085_000019_leftImg8bit.png gtFine/train/zurich/zurich_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000086_000019_leftImg8bit.png gtFine/train/zurich/zurich_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000087_000019_leftImg8bit.png gtFine/train/zurich/zurich_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000088_000019_leftImg8bit.png gtFine/train/zurich/zurich_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000089_000019_leftImg8bit.png gtFine/train/zurich/zurich_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000090_000019_leftImg8bit.png gtFine/train/zurich/zurich_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000091_000019_leftImg8bit.png gtFine/train/zurich/zurich_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000092_000019_leftImg8bit.png gtFine/train/zurich/zurich_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000093_000019_leftImg8bit.png gtFine/train/zurich/zurich_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000094_000019_leftImg8bit.png gtFine/train/zurich/zurich_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000095_000019_leftImg8bit.png gtFine/train/zurich/zurich_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000096_000019_leftImg8bit.png gtFine/train/zurich/zurich_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000097_000019_leftImg8bit.png gtFine/train/zurich/zurich_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000098_000019_leftImg8bit.png gtFine/train/zurich/zurich_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000099_000019_leftImg8bit.png gtFine/train/zurich/zurich_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000100_000019_leftImg8bit.png gtFine/train/zurich/zurich_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000101_000019_leftImg8bit.png gtFine/train/zurich/zurich_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000102_000019_leftImg8bit.png gtFine/train/zurich/zurich_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000103_000019_leftImg8bit.png gtFine/train/zurich/zurich_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000104_000019_leftImg8bit.png gtFine/train/zurich/zurich_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000105_000019_leftImg8bit.png gtFine/train/zurich/zurich_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000106_000019_leftImg8bit.png gtFine/train/zurich/zurich_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000107_000019_leftImg8bit.png gtFine/train/zurich/zurich_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000108_000019_leftImg8bit.png gtFine/train/zurich/zurich_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000109_000019_leftImg8bit.png gtFine/train/zurich/zurich_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000110_000019_leftImg8bit.png gtFine/train/zurich/zurich_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000111_000019_leftImg8bit.png gtFine/train/zurich/zurich_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000112_000019_leftImg8bit.png gtFine/train/zurich/zurich_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000113_000019_leftImg8bit.png gtFine/train/zurich/zurich_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000114_000019_leftImg8bit.png gtFine/train/zurich/zurich_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000115_000019_leftImg8bit.png gtFine/train/zurich/zurich_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000116_000019_leftImg8bit.png gtFine/train/zurich/zurich_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000117_000019_leftImg8bit.png gtFine/train/zurich/zurich_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000118_000019_leftImg8bit.png gtFine/train/zurich/zurich_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000119_000019_leftImg8bit.png gtFine/train/zurich/zurich_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000120_000019_leftImg8bit.png gtFine/train/zurich/zurich_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/train/zurich/zurich_000121_000019_leftImg8bit.png gtFine/train/zurich/zurich_000121_000019_gtFine_labelTrainIds.png diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_val_fine.txt b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_val_fine.txt new file mode 100644 index 000000000..70f192bbb --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/cityscapes/cityscapes_val_fine.txt @@ -0,0 +1,500 @@ +leftImg8bit/val/frankfurt/frankfurt_000000_000294_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_000294_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_000576_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_000576_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_001016_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_001016_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_001236_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_001236_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_001751_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_001751_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_002196_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_002196_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_002963_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_002963_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_003025_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_003025_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_003357_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_003357_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_003920_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_003920_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_004617_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_004617_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_005543_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_005543_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_005898_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_005898_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_006589_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_006589_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_007365_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_007365_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_008206_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_008206_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_008451_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_008451_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_009291_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_009291_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_009561_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_009561_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_009688_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_009688_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_009969_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_009969_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_010351_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_010351_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_010763_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_010763_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_011007_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_011007_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_011074_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_011074_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_011461_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_011461_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_011810_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_011810_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_012009_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_012009_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_012121_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_012121_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_012868_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_012868_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_013067_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_013067_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_013240_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_013240_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_013382_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_013382_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_013942_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_013942_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_014480_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_014480_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_015389_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_015389_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_015676_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_015676_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_016005_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_016005_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_016286_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_016286_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_017228_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_017228_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_017476_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_017476_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_018797_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_018797_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_019607_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_019607_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_020215_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_020215_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_020321_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_020321_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_020880_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_020880_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_021667_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_021667_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_021879_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_021879_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_022254_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_022254_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000000_022797_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000000_022797_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_000538_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_000538_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_001464_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_001464_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_002512_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_002512_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_002646_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_002646_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_002759_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_002759_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_003056_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_003056_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_003588_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_003588_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_004327_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_004327_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_004736_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_004736_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_004859_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_004859_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_005184_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_005184_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_005410_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_005410_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_005703_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_005703_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_005898_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_005898_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_007285_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_007285_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_007407_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_007407_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_007622_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_007622_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_007857_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_007857_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_007973_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_007973_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_008200_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_008200_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_008688_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_008688_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_009058_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_009058_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_009504_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_009504_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_009854_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_009854_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_010156_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_010156_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_010444_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_010444_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_010600_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_010600_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_010830_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_010830_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_011162_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_011162_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_011715_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_011715_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_011835_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_011835_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_012038_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_012038_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_012519_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_012519_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_012699_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_012699_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_012738_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_012738_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_012870_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_012870_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_013016_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_013016_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_013496_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_013496_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_013710_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_013710_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_014221_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_014221_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_014406_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_014406_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_014565_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_014565_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_014741_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_014741_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_015091_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_015091_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_015328_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_015328_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_015768_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_015768_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_016029_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_016029_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_016273_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_016273_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_016462_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_016462_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_017101_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_017101_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_017459_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_017459_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_017842_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_017842_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_018113_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_018113_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_019698_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_019698_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_019854_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_019854_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_019969_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_019969_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_020046_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_020046_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_020287_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_020287_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_020693_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_020693_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_021406_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_021406_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_021825_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_021825_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_023235_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_023235_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_023369_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_023369_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_023769_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_023769_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_024927_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_024927_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_025512_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_025512_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_025713_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_025713_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_025921_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_025921_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_027325_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_027325_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_028232_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_028232_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_028335_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_028335_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_028590_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_028590_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_028854_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_028854_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_029086_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_029086_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_029236_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_029236_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_029600_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_029600_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_030067_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_030067_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_030310_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_030310_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_030669_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_030669_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_031266_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_031266_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_031416_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_031416_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_032018_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_032018_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_032556_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_032556_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_032711_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_032711_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_032942_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_032942_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_033655_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_033655_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_034047_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_034047_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_034816_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_034816_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_035144_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_035144_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_035864_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_035864_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_037705_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_037705_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_038245_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_038245_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_038418_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_038418_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_038645_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_038645_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_038844_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_038844_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_039895_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_039895_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_040575_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_040575_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_040732_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_040732_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_041074_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_041074_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_041354_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_041354_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_041517_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_041517_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_041664_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_041664_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_042098_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_042098_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_042384_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_042384_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_042733_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_042733_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_043395_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_043395_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_043564_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_043564_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_044227_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_044227_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_044413_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_044413_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_044525_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_044525_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_044658_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_044658_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_044787_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_044787_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_046126_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_046126_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_046272_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_046272_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_046504_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_046504_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_046779_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_046779_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_047178_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_047178_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_047552_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_047552_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_048196_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_048196_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_048355_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_048355_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_048654_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_048654_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_049078_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_049078_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_049209_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_049209_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_049298_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_049298_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_049698_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_049698_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_049770_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_049770_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_050149_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_050149_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_050686_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_050686_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_051516_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_051516_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_051737_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_051737_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_051807_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_051807_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_052120_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_052120_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_052594_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_052594_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_053102_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_053102_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_054077_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_054077_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_054219_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_054219_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_054415_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_054415_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_054640_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_054640_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_054884_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_054884_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055062_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055062_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055172_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055172_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055306_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055306_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055387_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055387_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055538_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055538_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055603_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055603_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_055709_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_055709_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_056580_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_056580_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_057181_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_057181_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_057478_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_057478_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_057954_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_057954_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_058057_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_058057_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_058176_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_058176_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_058504_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_058504_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_058914_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_058914_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_059119_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_059119_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_059642_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_059642_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_059789_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_059789_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_060135_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_060135_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_060422_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_060422_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_060545_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_060545_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_060906_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_060906_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_061682_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_061682_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_061763_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_061763_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062016_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062016_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062250_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062250_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062396_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062396_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062509_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062509_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062653_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062653_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_062793_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_062793_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_063045_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_063045_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_064130_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_064130_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_064305_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_064305_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_064651_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_064651_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_064798_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_064798_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_064925_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_064925_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_065160_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_065160_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_065617_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_065617_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_065850_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_065850_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_066092_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_066092_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_066438_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_066438_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_066574_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_066574_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_066832_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_066832_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_067092_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_067092_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_067178_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_067178_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_067295_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_067295_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_067474_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_067474_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_067735_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_067735_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_068063_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_068063_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_068208_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_068208_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_068682_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_068682_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_068772_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_068772_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_069633_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_069633_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_070099_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_070099_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_071288_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_071288_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_071781_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_071781_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_072155_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_072155_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_072295_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_072295_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_073088_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_073088_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_073243_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_073243_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_073464_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_073464_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_073911_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_073911_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_075296_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_075296_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_075984_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_075984_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_076502_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_076502_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_077092_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_077092_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_077233_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_077233_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_077434_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_077434_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_078803_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_078803_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_079206_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_079206_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_080091_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_080091_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_080391_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_080391_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_080830_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_080830_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_082087_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_082087_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_082466_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_082466_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_083029_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_083029_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_083199_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_083199_gtFine_labelTrainIds.png +leftImg8bit/val/frankfurt/frankfurt_000001_083852_leftImg8bit.png gtFine/val/frankfurt/frankfurt_000001_083852_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000000_000019_leftImg8bit.png gtFine/val/lindau/lindau_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000001_000019_leftImg8bit.png gtFine/val/lindau/lindau_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000002_000019_leftImg8bit.png gtFine/val/lindau/lindau_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000003_000019_leftImg8bit.png gtFine/val/lindau/lindau_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000004_000019_leftImg8bit.png gtFine/val/lindau/lindau_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000005_000019_leftImg8bit.png gtFine/val/lindau/lindau_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000006_000019_leftImg8bit.png gtFine/val/lindau/lindau_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000007_000019_leftImg8bit.png gtFine/val/lindau/lindau_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000008_000019_leftImg8bit.png gtFine/val/lindau/lindau_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000009_000019_leftImg8bit.png gtFine/val/lindau/lindau_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000010_000019_leftImg8bit.png gtFine/val/lindau/lindau_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000011_000019_leftImg8bit.png gtFine/val/lindau/lindau_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000012_000019_leftImg8bit.png gtFine/val/lindau/lindau_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000013_000019_leftImg8bit.png gtFine/val/lindau/lindau_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000014_000019_leftImg8bit.png gtFine/val/lindau/lindau_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000015_000019_leftImg8bit.png gtFine/val/lindau/lindau_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000016_000019_leftImg8bit.png gtFine/val/lindau/lindau_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000017_000019_leftImg8bit.png gtFine/val/lindau/lindau_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000018_000019_leftImg8bit.png gtFine/val/lindau/lindau_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000019_000019_leftImg8bit.png gtFine/val/lindau/lindau_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000020_000019_leftImg8bit.png gtFine/val/lindau/lindau_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000021_000019_leftImg8bit.png gtFine/val/lindau/lindau_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000022_000019_leftImg8bit.png gtFine/val/lindau/lindau_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000023_000019_leftImg8bit.png gtFine/val/lindau/lindau_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000024_000019_leftImg8bit.png gtFine/val/lindau/lindau_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000025_000019_leftImg8bit.png gtFine/val/lindau/lindau_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000026_000019_leftImg8bit.png gtFine/val/lindau/lindau_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000027_000019_leftImg8bit.png gtFine/val/lindau/lindau_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000028_000019_leftImg8bit.png gtFine/val/lindau/lindau_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000029_000019_leftImg8bit.png gtFine/val/lindau/lindau_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000030_000019_leftImg8bit.png gtFine/val/lindau/lindau_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000031_000019_leftImg8bit.png gtFine/val/lindau/lindau_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000032_000019_leftImg8bit.png gtFine/val/lindau/lindau_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000033_000019_leftImg8bit.png gtFine/val/lindau/lindau_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000034_000019_leftImg8bit.png gtFine/val/lindau/lindau_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000035_000019_leftImg8bit.png gtFine/val/lindau/lindau_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000036_000019_leftImg8bit.png gtFine/val/lindau/lindau_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000037_000019_leftImg8bit.png gtFine/val/lindau/lindau_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000038_000019_leftImg8bit.png gtFine/val/lindau/lindau_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000039_000019_leftImg8bit.png gtFine/val/lindau/lindau_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000040_000019_leftImg8bit.png gtFine/val/lindau/lindau_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000041_000019_leftImg8bit.png gtFine/val/lindau/lindau_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000042_000019_leftImg8bit.png gtFine/val/lindau/lindau_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000043_000019_leftImg8bit.png gtFine/val/lindau/lindau_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000044_000019_leftImg8bit.png gtFine/val/lindau/lindau_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000045_000019_leftImg8bit.png gtFine/val/lindau/lindau_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000046_000019_leftImg8bit.png gtFine/val/lindau/lindau_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000047_000019_leftImg8bit.png gtFine/val/lindau/lindau_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000048_000019_leftImg8bit.png gtFine/val/lindau/lindau_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000049_000019_leftImg8bit.png gtFine/val/lindau/lindau_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000050_000019_leftImg8bit.png gtFine/val/lindau/lindau_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000051_000019_leftImg8bit.png gtFine/val/lindau/lindau_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000052_000019_leftImg8bit.png gtFine/val/lindau/lindau_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000053_000019_leftImg8bit.png gtFine/val/lindau/lindau_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000054_000019_leftImg8bit.png gtFine/val/lindau/lindau_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000055_000019_leftImg8bit.png gtFine/val/lindau/lindau_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000056_000019_leftImg8bit.png gtFine/val/lindau/lindau_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000057_000019_leftImg8bit.png gtFine/val/lindau/lindau_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/val/lindau/lindau_000058_000019_leftImg8bit.png gtFine/val/lindau/lindau_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000000_000019_leftImg8bit.png gtFine/val/munster/munster_000000_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000001_000019_leftImg8bit.png gtFine/val/munster/munster_000001_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000002_000019_leftImg8bit.png gtFine/val/munster/munster_000002_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000003_000019_leftImg8bit.png gtFine/val/munster/munster_000003_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000004_000019_leftImg8bit.png gtFine/val/munster/munster_000004_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000005_000019_leftImg8bit.png gtFine/val/munster/munster_000005_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000006_000019_leftImg8bit.png gtFine/val/munster/munster_000006_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000007_000019_leftImg8bit.png gtFine/val/munster/munster_000007_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000008_000019_leftImg8bit.png gtFine/val/munster/munster_000008_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000009_000019_leftImg8bit.png gtFine/val/munster/munster_000009_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000010_000019_leftImg8bit.png gtFine/val/munster/munster_000010_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000011_000019_leftImg8bit.png gtFine/val/munster/munster_000011_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000012_000019_leftImg8bit.png gtFine/val/munster/munster_000012_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000013_000019_leftImg8bit.png gtFine/val/munster/munster_000013_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000014_000019_leftImg8bit.png gtFine/val/munster/munster_000014_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000015_000019_leftImg8bit.png gtFine/val/munster/munster_000015_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000016_000019_leftImg8bit.png gtFine/val/munster/munster_000016_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000017_000019_leftImg8bit.png gtFine/val/munster/munster_000017_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000018_000019_leftImg8bit.png gtFine/val/munster/munster_000018_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000019_000019_leftImg8bit.png gtFine/val/munster/munster_000019_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000020_000019_leftImg8bit.png gtFine/val/munster/munster_000020_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000021_000019_leftImg8bit.png gtFine/val/munster/munster_000021_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000022_000019_leftImg8bit.png gtFine/val/munster/munster_000022_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000023_000019_leftImg8bit.png gtFine/val/munster/munster_000023_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000024_000019_leftImg8bit.png gtFine/val/munster/munster_000024_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000025_000019_leftImg8bit.png gtFine/val/munster/munster_000025_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000026_000019_leftImg8bit.png gtFine/val/munster/munster_000026_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000027_000019_leftImg8bit.png gtFine/val/munster/munster_000027_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000028_000019_leftImg8bit.png gtFine/val/munster/munster_000028_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000029_000019_leftImg8bit.png gtFine/val/munster/munster_000029_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000030_000019_leftImg8bit.png gtFine/val/munster/munster_000030_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000031_000019_leftImg8bit.png gtFine/val/munster/munster_000031_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000032_000019_leftImg8bit.png gtFine/val/munster/munster_000032_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000033_000019_leftImg8bit.png gtFine/val/munster/munster_000033_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000034_000019_leftImg8bit.png gtFine/val/munster/munster_000034_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000035_000019_leftImg8bit.png gtFine/val/munster/munster_000035_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000036_000019_leftImg8bit.png gtFine/val/munster/munster_000036_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000037_000019_leftImg8bit.png gtFine/val/munster/munster_000037_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000038_000019_leftImg8bit.png gtFine/val/munster/munster_000038_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000039_000019_leftImg8bit.png gtFine/val/munster/munster_000039_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000040_000019_leftImg8bit.png gtFine/val/munster/munster_000040_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000041_000019_leftImg8bit.png gtFine/val/munster/munster_000041_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000042_000019_leftImg8bit.png gtFine/val/munster/munster_000042_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000043_000019_leftImg8bit.png gtFine/val/munster/munster_000043_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000044_000019_leftImg8bit.png gtFine/val/munster/munster_000044_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000045_000019_leftImg8bit.png gtFine/val/munster/munster_000045_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000046_000019_leftImg8bit.png gtFine/val/munster/munster_000046_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000047_000019_leftImg8bit.png gtFine/val/munster/munster_000047_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000048_000019_leftImg8bit.png gtFine/val/munster/munster_000048_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000049_000019_leftImg8bit.png gtFine/val/munster/munster_000049_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000050_000019_leftImg8bit.png gtFine/val/munster/munster_000050_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000051_000019_leftImg8bit.png gtFine/val/munster/munster_000051_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000052_000019_leftImg8bit.png gtFine/val/munster/munster_000052_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000053_000019_leftImg8bit.png gtFine/val/munster/munster_000053_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000054_000019_leftImg8bit.png gtFine/val/munster/munster_000054_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000055_000019_leftImg8bit.png gtFine/val/munster/munster_000055_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000056_000019_leftImg8bit.png gtFine/val/munster/munster_000056_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000057_000019_leftImg8bit.png gtFine/val/munster/munster_000057_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000058_000019_leftImg8bit.png gtFine/val/munster/munster_000058_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000059_000019_leftImg8bit.png gtFine/val/munster/munster_000059_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000060_000019_leftImg8bit.png gtFine/val/munster/munster_000060_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000061_000019_leftImg8bit.png gtFine/val/munster/munster_000061_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000062_000019_leftImg8bit.png gtFine/val/munster/munster_000062_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000063_000019_leftImg8bit.png gtFine/val/munster/munster_000063_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000064_000019_leftImg8bit.png gtFine/val/munster/munster_000064_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000065_000019_leftImg8bit.png gtFine/val/munster/munster_000065_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000066_000019_leftImg8bit.png gtFine/val/munster/munster_000066_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000067_000019_leftImg8bit.png gtFine/val/munster/munster_000067_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000068_000019_leftImg8bit.png gtFine/val/munster/munster_000068_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000069_000019_leftImg8bit.png gtFine/val/munster/munster_000069_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000070_000019_leftImg8bit.png gtFine/val/munster/munster_000070_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000071_000019_leftImg8bit.png gtFine/val/munster/munster_000071_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000072_000019_leftImg8bit.png gtFine/val/munster/munster_000072_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000073_000019_leftImg8bit.png gtFine/val/munster/munster_000073_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000074_000019_leftImg8bit.png gtFine/val/munster/munster_000074_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000075_000019_leftImg8bit.png gtFine/val/munster/munster_000075_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000076_000019_leftImg8bit.png gtFine/val/munster/munster_000076_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000077_000019_leftImg8bit.png gtFine/val/munster/munster_000077_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000078_000019_leftImg8bit.png gtFine/val/munster/munster_000078_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000079_000019_leftImg8bit.png gtFine/val/munster/munster_000079_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000080_000019_leftImg8bit.png gtFine/val/munster/munster_000080_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000081_000019_leftImg8bit.png gtFine/val/munster/munster_000081_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000082_000019_leftImg8bit.png gtFine/val/munster/munster_000082_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000083_000019_leftImg8bit.png gtFine/val/munster/munster_000083_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000084_000019_leftImg8bit.png gtFine/val/munster/munster_000084_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000085_000019_leftImg8bit.png gtFine/val/munster/munster_000085_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000086_000019_leftImg8bit.png gtFine/val/munster/munster_000086_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000087_000019_leftImg8bit.png gtFine/val/munster/munster_000087_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000088_000019_leftImg8bit.png gtFine/val/munster/munster_000088_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000089_000019_leftImg8bit.png gtFine/val/munster/munster_000089_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000090_000019_leftImg8bit.png gtFine/val/munster/munster_000090_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000091_000019_leftImg8bit.png gtFine/val/munster/munster_000091_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000092_000019_leftImg8bit.png gtFine/val/munster/munster_000092_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000093_000019_leftImg8bit.png gtFine/val/munster/munster_000093_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000094_000019_leftImg8bit.png gtFine/val/munster/munster_000094_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000095_000019_leftImg8bit.png gtFine/val/munster/munster_000095_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000096_000019_leftImg8bit.png gtFine/val/munster/munster_000096_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000097_000019_leftImg8bit.png gtFine/val/munster/munster_000097_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000098_000019_leftImg8bit.png gtFine/val/munster/munster_000098_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000099_000019_leftImg8bit.png gtFine/val/munster/munster_000099_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000100_000019_leftImg8bit.png gtFine/val/munster/munster_000100_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000101_000019_leftImg8bit.png gtFine/val/munster/munster_000101_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000102_000019_leftImg8bit.png gtFine/val/munster/munster_000102_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000103_000019_leftImg8bit.png gtFine/val/munster/munster_000103_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000104_000019_leftImg8bit.png gtFine/val/munster/munster_000104_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000105_000019_leftImg8bit.png gtFine/val/munster/munster_000105_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000106_000019_leftImg8bit.png gtFine/val/munster/munster_000106_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000107_000019_leftImg8bit.png gtFine/val/munster/munster_000107_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000108_000019_leftImg8bit.png gtFine/val/munster/munster_000108_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000109_000019_leftImg8bit.png gtFine/val/munster/munster_000109_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000110_000019_leftImg8bit.png gtFine/val/munster/munster_000110_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000111_000019_leftImg8bit.png gtFine/val/munster/munster_000111_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000112_000019_leftImg8bit.png gtFine/val/munster/munster_000112_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000113_000019_leftImg8bit.png gtFine/val/munster/munster_000113_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000114_000019_leftImg8bit.png gtFine/val/munster/munster_000114_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000115_000019_leftImg8bit.png gtFine/val/munster/munster_000115_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000116_000019_leftImg8bit.png gtFine/val/munster/munster_000116_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000117_000019_leftImg8bit.png gtFine/val/munster/munster_000117_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000118_000019_leftImg8bit.png gtFine/val/munster/munster_000118_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000119_000019_leftImg8bit.png gtFine/val/munster/munster_000119_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000120_000019_leftImg8bit.png gtFine/val/munster/munster_000120_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000121_000019_leftImg8bit.png gtFine/val/munster/munster_000121_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000122_000019_leftImg8bit.png gtFine/val/munster/munster_000122_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000123_000019_leftImg8bit.png gtFine/val/munster/munster_000123_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000124_000019_leftImg8bit.png gtFine/val/munster/munster_000124_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000125_000019_leftImg8bit.png gtFine/val/munster/munster_000125_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000126_000019_leftImg8bit.png gtFine/val/munster/munster_000126_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000127_000019_leftImg8bit.png gtFine/val/munster/munster_000127_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000128_000019_leftImg8bit.png gtFine/val/munster/munster_000128_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000129_000019_leftImg8bit.png gtFine/val/munster/munster_000129_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000130_000019_leftImg8bit.png gtFine/val/munster/munster_000130_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000131_000019_leftImg8bit.png gtFine/val/munster/munster_000131_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000132_000019_leftImg8bit.png gtFine/val/munster/munster_000132_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000133_000019_leftImg8bit.png gtFine/val/munster/munster_000133_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000134_000019_leftImg8bit.png gtFine/val/munster/munster_000134_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000135_000019_leftImg8bit.png gtFine/val/munster/munster_000135_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000136_000019_leftImg8bit.png gtFine/val/munster/munster_000136_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000137_000019_leftImg8bit.png gtFine/val/munster/munster_000137_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000138_000019_leftImg8bit.png gtFine/val/munster/munster_000138_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000139_000019_leftImg8bit.png gtFine/val/munster/munster_000139_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000140_000019_leftImg8bit.png gtFine/val/munster/munster_000140_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000141_000019_leftImg8bit.png gtFine/val/munster/munster_000141_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000142_000019_leftImg8bit.png gtFine/val/munster/munster_000142_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000143_000019_leftImg8bit.png gtFine/val/munster/munster_000143_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000144_000019_leftImg8bit.png gtFine/val/munster/munster_000144_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000145_000019_leftImg8bit.png gtFine/val/munster/munster_000145_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000146_000019_leftImg8bit.png gtFine/val/munster/munster_000146_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000147_000019_leftImg8bit.png gtFine/val/munster/munster_000147_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000148_000019_leftImg8bit.png gtFine/val/munster/munster_000148_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000149_000019_leftImg8bit.png gtFine/val/munster/munster_000149_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000150_000019_leftImg8bit.png gtFine/val/munster/munster_000150_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000151_000019_leftImg8bit.png gtFine/val/munster/munster_000151_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000152_000019_leftImg8bit.png gtFine/val/munster/munster_000152_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000153_000019_leftImg8bit.png gtFine/val/munster/munster_000153_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000154_000019_leftImg8bit.png gtFine/val/munster/munster_000154_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000155_000019_leftImg8bit.png gtFine/val/munster/munster_000155_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000156_000019_leftImg8bit.png gtFine/val/munster/munster_000156_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000157_000019_leftImg8bit.png gtFine/val/munster/munster_000157_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000158_000019_leftImg8bit.png gtFine/val/munster/munster_000158_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000159_000019_leftImg8bit.png gtFine/val/munster/munster_000159_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000160_000019_leftImg8bit.png gtFine/val/munster/munster_000160_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000161_000019_leftImg8bit.png gtFine/val/munster/munster_000161_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000162_000019_leftImg8bit.png gtFine/val/munster/munster_000162_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000163_000019_leftImg8bit.png gtFine/val/munster/munster_000163_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000164_000019_leftImg8bit.png gtFine/val/munster/munster_000164_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000165_000019_leftImg8bit.png gtFine/val/munster/munster_000165_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000166_000019_leftImg8bit.png gtFine/val/munster/munster_000166_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000167_000019_leftImg8bit.png gtFine/val/munster/munster_000167_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000168_000019_leftImg8bit.png gtFine/val/munster/munster_000168_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000169_000019_leftImg8bit.png gtFine/val/munster/munster_000169_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000170_000019_leftImg8bit.png gtFine/val/munster/munster_000170_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000171_000019_leftImg8bit.png gtFine/val/munster/munster_000171_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000172_000019_leftImg8bit.png gtFine/val/munster/munster_000172_000019_gtFine_labelTrainIds.png +leftImg8bit/val/munster/munster_000173_000019_leftImg8bit.png gtFine/val/munster/munster_000173_000019_gtFine_labelTrainIds.png diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/__init__.py new file mode 100644 index 000000000..15671ae80 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/__init__.py @@ -0,0 +1,3 @@ +from .coco import COCO + +__all__ = ['COCO'] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/coco.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/coco.py new file mode 100644 index 000000000..914cc7e4e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/datasets/coco/coco.py @@ -0,0 +1,160 @@ +# import numpy as np + +from datasets.BaseDataset import BaseDataset + +COCO_CATEGORIES = [ + {"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"}, + {"color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"}, + {"color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"}, + {"color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"}, + {"color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"}, + {"color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"}, + {"color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"}, + {"color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"}, + {"color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"}, + {"color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"}, + {"color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"}, + {"color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"}, + {"color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"}, + {"color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"}, + {"color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"}, + {"color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"}, + {"color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"}, + {"color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"}, + {"color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"}, + {"color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"}, + {"color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"}, + {"color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"}, + {"color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"}, + {"color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"}, + {"color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"}, + {"color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"}, + {"color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"}, + {"color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"}, + {"color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"}, + {"color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"}, + {"color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"}, + {"color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"}, + {"color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"}, + {"color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"}, + {"color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"}, + {"color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"}, + {"color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"}, + {"color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"}, + {"color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"}, + {"color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"}, + {"color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"}, + {"color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"}, + {"color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"}, + {"color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"}, + {"color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"}, + {"color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"}, + {"color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"}, + {"color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"}, + {"color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"}, + {"color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"}, + {"color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"}, + {"color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"}, + {"color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"}, + {"color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"}, + {"color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"}, + {"color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"}, + {"color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"}, + {"color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"}, + {"color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"}, + {"color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"}, + {"color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"}, + {"color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"}, + {"color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"}, + {"color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"}, + {"color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"}, + {"color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"}, + {"color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"}, + {"color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"}, + {"color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"}, + {"color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"}, + {"color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"}, + {"color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"}, + {"color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"}, + {"color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"}, + {"color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"}, + {"color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"}, + {"color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"}, + {"color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"}, + {"color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"}, + {"color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"}, + {"color": [255, 255, 128], "isthing": 0, "id": 92, "name": "banner"}, + {"color": [147, 211, 203], "isthing": 0, "id": 93, "name": "blanket"}, + {"color": [150, 100, 100], "isthing": 0, "id": 95, "name": "bridge"}, + {"color": [168, 171, 172], "isthing": 0, "id": 100, "name": "cardboard"}, + {"color": [146, 112, 198], "isthing": 0, "id": 107, "name": "counter"}, + {"color": [210, 170, 100], "isthing": 0, "id": 109, "name": "curtain"}, + {"color": [92, 136, 89], "isthing": 0, "id": 112, "name": "door-stuff"}, + {"color": [218, 88, 184], "isthing": 0, "id": 118, "name": "floor-wood"}, + {"color": [241, 129, 0], "isthing": 0, "id": 119, "name": "flower"}, + {"color": [217, 17, 255], "isthing": 0, "id": 122, "name": "fruit"}, + {"color": [124, 74, 181], "isthing": 0, "id": 125, "name": "gravel"}, + {"color": [70, 70, 70], "isthing": 0, "id": 128, "name": "house"}, + {"color": [255, 228, 255], "isthing": 0, "id": 130, "name": "light"}, + {"color": [154, 208, 0], "isthing": 0, "id": 133, "name": "mirror-stuff"}, + {"color": [193, 0, 92], "isthing": 0, "id": 138, "name": "net"}, + {"color": [76, 91, 113], "isthing": 0, "id": 141, "name": "pillow"}, + {"color": [255, 180, 195], "isthing": 0, "id": 144, "name": "platform"}, + {"color": [106, 154, 176], "isthing": 0, "id": 145, "name": "playingfield"}, + {"color": [230, 150, 140], "isthing": 0, "id": 147, "name": "railroad"}, + {"color": [60, 143, 255], "isthing": 0, "id": 148, "name": "river"}, + {"color": [128, 64, 128], "isthing": 0, "id": 149, "name": "road"}, + {"color": [92, 82, 55], "isthing": 0, "id": 151, "name": "roof"}, + {"color": [254, 212, 124], "isthing": 0, "id": 154, "name": "sand"}, + {"color": [73, 77, 174], "isthing": 0, "id": 155, "name": "sea"}, + {"color": [255, 160, 98], "isthing": 0, "id": 156, "name": "shelf"}, + {"color": [255, 255, 255], "isthing": 0, "id": 159, "name": "snow"}, + {"color": [104, 84, 109], "isthing": 0, "id": 161, "name": "stairs"}, + {"color": [169, 164, 131], "isthing": 0, "id": 166, "name": "tent"}, + {"color": [225, 199, 255], "isthing": 0, "id": 168, "name": "towel"}, + {"color": [137, 54, 74], "isthing": 0, "id": 171, "name": "wall-brick"}, + {"color": [135, 158, 223], "isthing": 0, "id": 175, "name": "wall-stone"}, + {"color": [7, 246, 231], "isthing": 0, "id": 176, "name": "wall-tile"}, + {"color": [107, 255, 200], "isthing": 0, "id": 177, "name": "wall-wood"}, + {"color": [58, 41, 149], "isthing": 0, "id": 178, "name": "water-other"}, + {"color": [183, 121, 142], "isthing": 0, "id": 180, "name": "window-blind"}, + {"color": [255, 73, 97], "isthing": 0, "id": 181, "name": "window-other"}, + {"color": [107, 142, 35], "isthing": 0, "id": 184, "name": "tree-merged"}, + {"color": [190, 153, 153], "isthing": 0, "id": 185, "name": "fence-merged"}, + {"color": [146, 139, 141], "isthing": 0, "id": 186, "name": "ceiling-merged"}, + {"color": [70, 130, 180], "isthing": 0, "id": 187, "name": "sky-other-merged"}, + {"color": [134, 199, 156], "isthing": 0, "id": 188, "name": "cabinet-merged"}, + {"color": [209, 226, 140], "isthing": 0, "id": 189, "name": "table-merged"}, + {"color": [96, 36, 108], "isthing": 0, "id": 190, "name": "floor-other-merged"}, + {"color": [96, 96, 96], "isthing": 0, "id": 191, "name": "pavement-merged"}, + {"color": [64, 170, 64], "isthing": 0, "id": 192, "name": "mountain-merged"}, + {"color": [152, 251, 152], "isthing": 0, "id": 193, "name": "grass-merged"}, + {"color": [208, 229, 228], "isthing": 0, "id": 194, "name": "dirt-merged"}, + {"color": [206, 186, 171], "isthing": 0, "id": 195, "name": "paper-merged"}, + {"color": [152, 161, 64], "isthing": 0, "id": 196, "name": "food-other-merged"}, + {"color": [116, 112, 0], "isthing": 0, "id": 197, "name": "building-other-merged"}, + {"color": [0, 114, 143], "isthing": 0, "id": 198, "name": "rock-merged"}, + {"color": [102, 102, 156], "isthing": 0, "id": 199, "name": "wall-other-merged"}, + {"color": [250, 141, 255], "isthing": 0, "id": 200, "name": "rug-merged"}, +] + +COCO_COLORS = [] +COCO_NAMES = [] + +for item in COCO_CATEGORIES: + COCO_COLORS.append(item["color"]) + COCO_NAMES.append(item["name"]) + +class COCO(BaseDataset): + # trans_labels = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] + + @classmethod + def get_class_colors(*args): + return COCO_COLORS + + @classmethod + def get_class_names(*args): + # class counting(gtFine) + # 2953 2811 2934 970 1296 2949 1658 2808 2891 1654 2686 2343 1023 2832 + # 359 274 142 513 1646 + return COCO_NAMES diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/evaluator.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/evaluator.py new file mode 100644 index 000000000..ae7282764 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/evaluator.py @@ -0,0 +1,339 @@ +import os +import cv2 +import numpy as np +import time +from tqdm import tqdm + +import torch +import torch.multiprocessing as mp + +from engine.logger import get_logger +from utils.pyt_utils import load_model, link_file, ensure_dir +from utils.img_utils import pad_image_to_shape, normalize + +logger = get_logger() + + +class Evaluator(object): + def __init__(self, dataset, class_num, image_mean, image_std, network, + multi_scales, is_flip, devices=0, out_idx=0, threds=5, config=None, logger=None, + verbose=False, save_path=None, show_image=False, show_prediction=False): + self.dataset = dataset + self.ndata = self.dataset.get_length() + self.class_num = class_num + self.image_mean = image_mean + self.image_std = image_std + self.multi_scales = multi_scales + self.is_flip = is_flip + self.network = network + self.devices = devices + if type(self.devices) == int: self.devices = [self.devices] + self.out_idx = out_idx + self.threds = threds + self.config = config + self.logger = logger + + self.context = mp.get_context('spawn') + self.val_func = None + self.results_queue = self.context.Queue(self.ndata) + + self.verbose = verbose + self.save_path = save_path + if save_path is not None: + ensure_dir(save_path) + self.show_image = show_image + self.show_prediction = show_prediction + + def run(self, model_path, model_indice, log_file, log_file_link): + """There are four evaluation modes: + 1.only eval a .pth model: -e *.pth + 2.only eval a certain epoch: -e epoch + 3.eval all epochs in a given section: -e start_epoch-end_epoch + 4.eval all epochs from a certain started epoch: -e start_epoch- + """ + if '.pth' in model_indice: + models = [model_indice, ] + elif "-" in model_indice: + start_epoch = int(model_indice.split("-")[0]) + end_epoch = model_indice.split("-")[1] + + models = os.listdir(model_path) + models.remove("epoch-last.pth") + sorted_models = [None] * len(models) + model_idx = [0] * len(models) + + for idx, m in enumerate(models): + num = m.split(".")[0].split("-")[1] + model_idx[idx] = num + sorted_models[idx] = m + model_idx = np.array([int(i) for i in model_idx]) + + down_bound = model_idx >= start_epoch + up_bound = [True] * len(sorted_models) + if end_epoch: + end_epoch = int(end_epoch) + assert start_epoch < end_epoch + up_bound = model_idx <= end_epoch + bound = up_bound * down_bound + model_slice = np.array(sorted_models)[bound] + models = [os.path.join(model_path, model) for model in + model_slice] + else: + models = [os.path.join(model_path, + 'epoch-%s.pth' % model_indice), ] + + results = open(log_file, 'a') + link_file(log_file, log_file_link) + + for model in models: + logger.info("Load Model: %s" % model) + self.val_func = load_model(self.network, model) + result_line, mIoU = self.multi_process_evaluation() + + results.write('Model: ' + model + '\n') + results.write(result_line) + results.write('\n') + results.flush() + + results.close() + + def run_online(self): + """ + eval during training + """ + self.val_func = self.network + result_line, mIoU = self.single_process_evaluation() + return result_line, mIoU + + def single_process_evaluation(self): + all_results = [] + from pdb import set_trace as bp + with torch.no_grad(): + for idx in tqdm(range(self.ndata)): + dd = self.dataset[idx] + results_dict = self.func_per_iteration(dd, self.devices[0], iter=idx) + all_results.append(results_dict) + _, _mIoU = self.compute_metric([results_dict]) + result_line, mIoU = self.compute_metric(all_results) + return result_line, mIoU + + def run_online_multiprocess(self): + """ + eval during training + """ + self.val_func = self.network + result_line, mIoU = self.multi_process_single_gpu_evaluation() + return result_line, mIoU + + def multi_process_single_gpu_evaluation(self): + # start_eval_time = time.perf_counter() + stride = int(np.ceil(self.ndata / self.threds)) + + # start multi-process on single-gpu + procs = [] + for d in range(self.threds): + e_record = min((d + 1) * stride, self.ndata) + shred_list = list(range(d * stride, e_record)) + device = self.devices[0] + logger.info('Thread %d handle %d data.' % (d, len(shred_list))) + p = self.context.Process(target=self.worker, args=(shred_list, device)) + procs.append(p) + + for p in procs: + p.start() + + all_results = [] + for _ in tqdm(range(self.ndata)): + t = self.results_queue.get() + all_results.append(t) + if self.verbose: + self.compute_metric(all_results) + + for p in procs: + p.join() + + result_line, mIoU = self.compute_metric(all_results) + # logger.info('Evaluation Elapsed Time: %.2fs' % (time.perf_counter() - start_eval_time)) + return result_line, mIoU + + def multi_process_evaluation(self): + start_eval_time = time.perf_counter() + nr_devices = len(self.devices) + stride = int(np.ceil(self.ndata / nr_devices)) + + # start multi-process on multi-gpu + procs = [] + for d in range(nr_devices): + e_record = min((d + 1) * stride, self.ndata) + shred_list = list(range(d * stride, e_record)) + device = self.devices[d] + logger.info('GPU %s handle %d data.' % (device, len(shred_list))) + p = self.context.Process(target=self.worker, args=(shred_list, device)) + procs.append(p) + + for p in procs: + p.start() + + all_results = [] + for _ in tqdm(range(self.ndata)): + t = self.results_queue.get() + all_results.append(t) + if self.verbose: + self.compute_metric(all_results) + + for p in procs: + p.join() + + result_line, mIoU = self.compute_metric(all_results) + logger.info('Evaluation Elapsed Time: %.2fs' % (time.perf_counter() - start_eval_time)) + return result_line, mIoU + + def worker(self, shred_list, device): + # start_load_time = time.time() + # logger.info('Load Model on Device %d: %.2fs' % (device, time.time() - start_load_time)) + for idx in shred_list: + dd = self.dataset[idx] + results_dict = self.func_per_iteration(dd, device, iter=idx) + self.results_queue.put(results_dict) + + def func_per_iteration(self, data, device, iter=None): + raise NotImplementedError + + def compute_metric(self, results): + raise NotImplementedError + + # evaluate the whole image at once + def whole_eval(self, img, output_size, input_size=None, device=None): + if input_size is not None: + img, margin = self.process_image(img, input_size) + else: + img = self.process_image(img, input_size) + + pred = self.val_func_process(img, device) + if input_size is not None: + pred = pred[:, margin[0]:(pred.shape[1] - margin[1]), + margin[2]:(pred.shape[2] - margin[3])] + pred = pred.permute(1, 2, 0) + pred = pred.cpu().numpy() + if output_size is not None: + pred = cv2.resize(pred, + (output_size[1], output_size[0]), + interpolation=cv2.INTER_LINEAR) + + pred = pred.argmax(2) + + return pred + + # slide the window to evaluate the image + def sliding_eval(self, img, crop_size, stride_rate, device=None): + ori_rows, ori_cols, c = img.shape + processed_pred = np.zeros((ori_rows, ori_cols, self.class_num)) + + for s in self.multi_scales: + img_scale = cv2.resize(img, None, fx=s, fy=s, + interpolation=cv2.INTER_LINEAR) + new_rows, new_cols, _ = img_scale.shape + processed_pred += self.scale_process(img_scale, + (ori_rows, ori_cols), + crop_size, stride_rate, device) + + pred = processed_pred.argmax(2) + + return pred + + def scale_process(self, img, ori_shape, crop_size, stride_rate, + device=None): + new_rows, new_cols, c = img.shape + long_size = new_cols if new_cols > new_rows else new_rows + + if long_size <= crop_size: + input_data, margin = self.process_image(img, crop_size) + score = self.val_func_process(input_data, device) + score = score[:, margin[0]:(score.shape[1] - margin[1]), + margin[2]:(score.shape[2] - margin[3])] + else: + stride = int(np.ceil(crop_size * stride_rate)) + img_pad, margin = pad_image_to_shape(img, crop_size, + cv2.BORDER_CONSTANT, value=0) + + pad_rows = img_pad.shape[0] + pad_cols = img_pad.shape[1] + r_grid = int(np.ceil((pad_rows - crop_size) / stride)) + 1 + c_grid = int(np.ceil((pad_cols - crop_size) / stride)) + 1 + data_scale = torch.zeros(self.class_num, pad_rows, pad_cols).cuda( + device) + count_scale = torch.zeros(self.class_num, pad_rows, pad_cols).cuda( + device) + + for grid_yidx in range(r_grid): + for grid_xidx in range(c_grid): + s_x = grid_xidx * stride + s_y = grid_yidx * stride + e_x = min(s_x + crop_size, pad_cols) + e_y = min(s_y + crop_size, pad_rows) + s_x = e_x - crop_size + s_y = e_y - crop_size + img_sub = img_pad[s_y:e_y, s_x: e_x, :] + count_scale[:, s_y: e_y, s_x: e_x] += 1 + + input_data, tmargin = self.process_image(img_sub, crop_size) + temp_score = self.val_func_process(input_data, device) + temp_score = temp_score[:, + tmargin[0]:(temp_score.shape[1] - tmargin[1]), + tmargin[2]:(temp_score.shape[2] - tmargin[3])] + data_scale[:, s_y: e_y, s_x: e_x] += temp_score + # score = data_scale / count_scale + score = data_scale + score = score[:, margin[0]:(score.shape[1] - margin[1]), + margin[2]:(score.shape[2] - margin[3])] + + score = score.permute(1, 2, 0) + data_output = cv2.resize(score.cpu().numpy(), + (ori_shape[1], ori_shape[0]), + interpolation=cv2.INTER_LINEAR) + + return data_output + + def val_func_process(self, input_data, device=None): + input_data = np.ascontiguousarray(input_data[None, :, :, :], dtype=np.float32) + input_data = torch.FloatTensor(input_data).cuda(device) + + with torch.cuda.device(input_data.get_device()): + self.val_func.eval() + self.val_func.to(input_data.get_device()) + with torch.no_grad(): + score = self.val_func(input_data) + if (isinstance(score, tuple) or isinstance(score, list)) and len(score) > 1: + score = score[self.out_idx] + score = score[0] # a single image pass, ignore batch dim + + if self.is_flip: + input_data = input_data.flip(-1) + score_flip = self.val_func(input_data) + score_flip = score_flip[0] + score += score_flip.flip(-1) + score = torch.exp(score) + # score = score.data + + return score + + def process_image(self, img, crop_size=None): + p_img = img + + if img.shape[2] < 3: + im_b = p_img + im_g = p_img + im_r = p_img + p_img = np.concatenate((im_b, im_g, im_r), axis=2) + + p_img = normalize(p_img, self.image_mean, self.image_std) + + if crop_size is not None: + p_img, margin = pad_image_to_shape(p_img, crop_size, cv2.BORDER_CONSTANT, value=0) + p_img = p_img.transpose(2, 0, 1) + + return p_img, margin + + p_img = p_img.transpose(2, 0, 1) + + return p_img diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/logger.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/logger.py new file mode 100644 index 000000000..10d8f2e47 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/logger.py @@ -0,0 +1,90 @@ +import os +import sys +import logging + +_default_level_name = os.getenv('ENGINE_LOGGING_LEVEL', 'INFO') +_default_level = logging.getLevelName(_default_level_name.upper()) + + +class LogFormatter(logging.Formatter): + log_fout = None + date_full = '[%(asctime)s %(lineno)d@%(filename)s:%(name)s] ' + date = '%(asctime)s ' + msg = '%(message)s' + + def format(self, record): + if record.levelno == logging.DEBUG: + mcl, mtxt = self._color_dbg, 'DBG' + elif record.levelno == logging.WARNING: + mcl, mtxt = self._color_warn, 'WRN' + elif record.levelno == logging.ERROR: + mcl, mtxt = self._color_err, 'ERR' + else: + mcl, mtxt = self._color_normal, '' + + if mtxt: + mtxt += ' ' + + if self.log_fout: + self.__set_fmt(self.date_full + mtxt + self.msg) + formatted = super(LogFormatter, self).format(record) + # self.log_fout.write(formatted) + # self.log_fout.write('\n') + # self.log_fout.flush() + return formatted + + self.__set_fmt(self._color_date(self.date) + mcl(mtxt + self.msg)) + formatted = super(LogFormatter, self).format(record) + + return formatted + + if sys.version_info.major < 3: + def __set_fmt(self, fmt): + self._fmt = fmt + else: + def __set_fmt(self, fmt): + self._style._fmt = fmt + + @staticmethod + def _color_dbg(msg): + return '\x1b[36m{}\x1b[0m'.format(msg) + + @staticmethod + def _color_warn(msg): + return '\x1b[1;31m{}\x1b[0m'.format(msg) + + @staticmethod + def _color_err(msg): + return '\x1b[1;4;31m{}\x1b[0m'.format(msg) + + @staticmethod + def _color_omitted(msg): + return '\x1b[35m{}\x1b[0m'.format(msg) + + @staticmethod + def _color_normal(msg): + return msg + + @staticmethod + def _color_date(msg): + return '\x1b[32m{}\x1b[0m'.format(msg) + + +def get_logger(log_dir=None, log_file=None, formatter=LogFormatter): + logger = logging.getLogger() + logger.setLevel(_default_level) + del logger.handlers[:] + + if log_dir and log_file: + if not os.path.isdir(log_dir): os.makedirs(log_dir) + LogFormatter.log_fout = True + file_handler = logging.FileHandler(log_file, mode='a') + file_handler.setLevel(logging.INFO) + file_handler.setFormatter(formatter) + logger.addHandler(file_handler) + + stream_handler = logging.StreamHandler() + stream_handler.setFormatter(formatter(datefmt='%d %H:%M:%S')) + stream_handler.setLevel(0) + logger.addHandler(stream_handler) + return logger diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/tester.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/tester.py new file mode 100644 index 000000000..5b800110a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/engine/tester.py @@ -0,0 +1,312 @@ +import os +import os.path as osp +import cv2 +import numpy as np +import time +from tqdm import tqdm + +import torch +import torch.nn.functional as F +import torch.multiprocessing as mp + +from engine.logger import get_logger +from utils.pyt_utils import load_model, link_file, ensure_dir +from utils.img_utils import pad_image_to_shape, normalize + +logger = get_logger() + + +class Tester(object): + def __init__(self, dataset, class_num, image_mean, image_std, network, + multi_scales, is_flip, devices=0, out_idx=0, threds=3, config=None, logger=None, + verbose=False, save_path=None, show_prediction=False): + self.dataset = dataset + self.ndata = self.dataset.get_length() + self.class_num = class_num + self.image_mean = image_mean + self.image_std = image_std + self.multi_scales = multi_scales + self.is_flip = is_flip + self.network = network + self.devices = devices + if type(self.devices) == int: self.devices = [self.devices] + self.out_idx = out_idx + self.threds = threds + self.config = config + self.logger = logger + + self.context = mp.get_context('spawn') + self.val_func = None + self.results_queue = self.context.Queue(self.ndata) + + self.verbose = verbose + self.save_path = save_path + if save_path is not None: + ensure_dir(save_path) + self.show_prediction = show_prediction + + def run(self, model_path, model_indice, log_file, log_file_link): + """There are four evaluation modes: + 1.only eval a .pth model: -e *.pth + 2.only eval a certain epoch: -e epoch + 3.eval all epochs in a given section: -e start_epoch-end_epoch + 4.eval all epochs from a certain started epoch: -e start_epoch- + """ + if '.pth' in model_indice: + models = [model_indice, ] + elif "-" in model_indice: + start_epoch = int(model_indice.split("-")[0]) + end_epoch = model_indice.split("-")[1] + + models = os.listdir(model_path) + models.remove("epoch-last.pth") + sorted_models = [None] * len(models) + model_idx = [0] * len(models) + + for idx, m in enumerate(models): + num = m.split(".")[0].split("-")[1] + model_idx[idx] = num + sorted_models[idx] = m + model_idx = np.array([int(i) for i in model_idx]) + + down_bound = model_idx >= start_epoch + up_bound = [True] * len(sorted_models) + if end_epoch: + end_epoch = int(end_epoch) + assert start_epoch < end_epoch + up_bound = model_idx <= end_epoch + bound = up_bound * down_bound + model_slice = np.array(sorted_models)[bound] + models = [os.path.join(model_path, model) for model in + model_slice] + else: + models = [os.path.join(model_path, + 'epoch-%s.pth' % model_indice), ] + + results = open(log_file, 'a') + link_file(log_file, log_file_link) + + for model in models: + logger.info("Load Model: %s" % model) + self.val_func = load_model(self.network, model) + result_line, mIoU = self.multi_process_evaluation() + + results.write('Model: ' + model + '\n') + results.write(result_line) + results.write('\n') + results.flush() + + results.close() + + def run_online(self): + """ + eval during training + """ + self.val_func = self.network + self.single_process_evaluation() + + def single_process_evaluation(self): + with torch.no_grad(): + for idx in tqdm(range(self.ndata)): + dd = self.dataset[idx] + self.func_per_iteration(dd, self.devices[0], iter=idx) + + def run_online_multiprocess(self): + """ + eval during training + """ + self.val_func = self.network + self.multi_process_single_gpu_evaluation() + + def multi_process_single_gpu_evaluation(self): + # start_eval_time = time.perf_counter() + stride = int(np.ceil(self.ndata / self.threds)) + + # start multi-process on single-gpu + procs = [] + for d in range(self.threds): + e_record = min((d + 1) * stride, self.ndata) + shred_list = list(range(d * stride, e_record)) + device = self.devices[0] + logger.info('Thread %d handle %d data.' % (d, len(shred_list))) + p = self.context.Process(target=self.worker, args=(shred_list, device)) + procs.append(p) + + for p in procs: + p.start() + + for p in procs: + p.join() + + + def multi_process_evaluation(self): + start_eval_time = time.perf_counter() + nr_devices = len(self.devices) + stride = int(np.ceil(self.ndata / nr_devices)) + + # start multi-process on multi-gpu + procs = [] + for d in range(nr_devices): + e_record = min((d + 1) * stride, self.ndata) + shred_list = list(range(d * stride, e_record)) + device = self.devices[d] + logger.info('GPU %s handle %d data.' % (device, len(shred_list))) + p = self.context.Process(target=self.worker, args=(shred_list, device)) + procs.append(p) + + for p in procs: + p.start() + + for p in procs: + p.join() + + + def worker(self, shred_list, device): + start_load_time = time.time() + # logger.info('Load Model on Device %d: %.2fs' % (device, time.time() - start_load_time)) + for idx in shred_list: + dd = self.dataset[idx] + results_dict = self.func_per_iteration(dd, device, iter=idx) + self.results_queue.put(results_dict) + + def func_per_iteration(self, data, device, iter=None): + raise NotImplementedError + + def compute_metric(self, results): + raise NotImplementedError + + # evaluate the whole image at once + def whole_eval(self, img, output_size, input_size=None, device=None): + if input_size is not None: + img, margin = self.process_image(img, input_size) + else: + img = self.process_image(img, input_size) + + pred = self.val_func_process(img, device) + if input_size is not None: + pred = pred[:, margin[0]:(pred.shape[1] - margin[1]), + margin[2]:(pred.shape[2] - margin[3])] + pred = pred.permute(1, 2, 0) + pred = pred.cpu().numpy() + if output_size is not None: + pred = cv2.resize(pred, + (output_size[1], output_size[0]), + interpolation=cv2.INTER_LINEAR) + + pred = pred.argmax(2) + + return pred + + # slide the window to evaluate the image + def sliding_eval(self, img, crop_size, stride_rate, device=None): + ori_rows, ori_cols, c = img.shape + processed_pred = np.zeros((ori_rows, ori_cols, self.class_num)) + + for s in self.multi_scales: + img_scale = cv2.resize(img, None, fx=s, fy=s, + interpolation=cv2.INTER_LINEAR) + new_rows, new_cols, _ = img_scale.shape + processed_pred += self.scale_process(img_scale, + (ori_rows, ori_cols), + crop_size, stride_rate, device) + + pred = processed_pred.argmax(2) + + return pred + + def scale_process(self, img, ori_shape, crop_size, stride_rate, + device=None): + new_rows, new_cols, c = img.shape + long_size = new_cols if new_cols > new_rows else new_rows + + if long_size <= crop_size: + input_data, margin = self.process_image(img, crop_size) + score = self.val_func_process(input_data, device) + score = score[:, margin[0]:(score.shape[1] - margin[1]), + margin[2]:(score.shape[2] - margin[3])] + else: + stride = int(np.ceil(crop_size * stride_rate)) + img_pad, margin = pad_image_to_shape(img, crop_size, + cv2.BORDER_CONSTANT, value=0) + + pad_rows = img_pad.shape[0] + pad_cols = img_pad.shape[1] + r_grid = int(np.ceil((pad_rows - crop_size) / stride)) + 1 + c_grid = int(np.ceil((pad_cols - crop_size) / stride)) + 1 + data_scale = torch.zeros(self.class_num, pad_rows, pad_cols).cuda( + device) + count_scale = torch.zeros(self.class_num, pad_rows, pad_cols).cuda( + device) + + for grid_yidx in range(r_grid): + for grid_xidx in range(c_grid): + s_x = grid_xidx * stride + s_y = grid_yidx * stride + e_x = min(s_x + crop_size, pad_cols) + e_y = min(s_y + crop_size, pad_rows) + s_x = e_x - crop_size + s_y = e_y - crop_size + img_sub = img_pad[s_y:e_y, s_x: e_x, :] + count_scale[:, s_y: e_y, s_x: e_x] += 1 + + input_data, tmargin = self.process_image(img_sub, crop_size) + temp_score = self.val_func_process(input_data, device) + temp_score = temp_score[:, + tmargin[0]:(temp_score.shape[1] - tmargin[1]), + tmargin[2]:(temp_score.shape[2] - tmargin[3])] + data_scale[:, s_y: e_y, s_x: e_x] += temp_score + # score = data_scale / count_scale + score = data_scale + score = score[:, margin[0]:(score.shape[1] - margin[1]), + margin[2]:(score.shape[2] - margin[3])] + + score = score.permute(1, 2, 0) + data_output = cv2.resize(score.cpu().numpy(), + (ori_shape[1], ori_shape[0]), + interpolation=cv2.INTER_LINEAR) + + return data_output + + def val_func_process(self, input_data, device=None): + input_data = np.ascontiguousarray(input_data[None, :, :, :], dtype=np.float32) + input_data = torch.FloatTensor(input_data).cuda(device) + + with torch.cuda.device(input_data.get_device()): + self.val_func.eval() + self.val_func.to(input_data.get_device()) + with torch.no_grad(): + score = self.val_func(input_data) + if (isinstance(score, tuple) or isinstance(score, list)) and len(score) > 1: + score = score[self.out_idx] + score = score[0] # a single image pass, ignore batch dim + + if self.is_flip: + input_data = input_data.flip(-1) + score_flip = self.val_func(input_data) + score_flip = score_flip[0] + score += score_flip.flip(-1) + score = torch.exp(score) + # score = score.data + + return score + + def process_image(self, img, crop_size=None): + p_img = img + + if img.shape[2] < 3: + im_b = p_img + im_g = p_img + im_r = p_img + p_img = np.concatenate((im_b, im_g, im_r), axis=2) + + p_img = normalize(p_img, self.image_mean, self.image_std) + + if crop_size is not None: + p_img, margin = pad_image_to_shape(p_img, crop_size, cv2.BORDER_CONSTANT, value=0) + p_img = p_img.transpose(2, 0, 1) + + return p_img, margin + + p_img = p_img.transpose(2, 0, 1) + + return p_img diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/loss_opr.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/loss_opr.py new file mode 100644 index 000000000..455b75852 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/loss_opr.py @@ -0,0 +1,199 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F + +from engine.logger import get_logger + +logger = get_logger() + +L1Loss = nn.L1Loss +MSELoss = nn.MSELoss +CrossEntropyLoss = nn.CrossEntropyLoss + +class SigmoidFocalLoss(nn.Module): + def __init__(self, ignore_label, gamma=2.0, alpha=0.25, + reduction='mean'): + super(SigmoidFocalLoss, self).__init__() + self.ignore_label = ignore_label + self.gamma = gamma + self.alpha = alpha + self.reduction = reduction + + def forward(self, pred, target): + b, h, w = target.size() + pred = pred.view(b, -1, 1) + pred_sigmoid = pred.sigmoid() + target = target.view(b, -1).float() + mask = (target.ne(self.ignore_label)).float() + target = mask * target + onehot = target.view(b, -1, 1) + + max_val = (-pred_sigmoid).clamp(min=0) + + pos_part = (1 - pred_sigmoid) ** self.gamma * ( + pred_sigmoid - pred_sigmoid * onehot) + neg_part = pred_sigmoid ** self.gamma * (max_val + ( + (-max_val).exp() + (-pred_sigmoid - max_val).exp()).log()) + + loss = -(self.alpha * pos_part + (1 - self.alpha) * neg_part).sum( + dim=-1) * mask + if self.reduction == 'mean': + loss = loss.mean() + + return loss + + +class ProbOhemCrossEntropy2d(nn.Module): + def __init__(self, ignore_label, reduction='mean', thresh=0.6, min_kept=256, + down_ratio=1, use_weight=False): + super(ProbOhemCrossEntropy2d, self).__init__() + self.ignore_label = ignore_label + self.thresh = float(thresh) + self.min_kept = int(min_kept) + self.down_ratio = down_ratio + if use_weight: + weight = torch.FloatTensor( + [0.8373, 0.918, 0.866, 1.0345, 1.0166, 0.9969, 0.9754, 1.0489, + 0.8786, 1.0023, 0.9539, 0.9843, 1.1116, 0.9037, 1.0865, 1.0955, + 1.0865, 1.1529, 1.0507]).cuda() + self.criterion = torch.nn.CrossEntropyLoss(reduction=reduction, + weight=weight, + ignore_index=ignore_label) + else: + self.criterion = torch.nn.CrossEntropyLoss(reduction=reduction, + ignore_index=ignore_label) + + def forward(self, pred, target): + b, c, h, w = pred.size() + target = target.view(-1) + valid_mask = target.ne(self.ignore_label) + target = target * valid_mask.long() + num_valid = valid_mask.sum() + + prob = F.softmax(pred, dim=1) + prob = (prob.transpose(0, 1)).reshape(c, -1) + + if self.min_kept > num_valid: + logger.info('Labels: {}'.format(num_valid)) + elif num_valid > 0: + prob = prob.masked_fill_(~valid_mask, 1) + mask_prob = prob[ + target, torch.arange(len(target), dtype=torch.long)] + threshold = self.thresh + if self.min_kept > 0: + index = mask_prob.argsort() + threshold_index = index[min(len(index), self.min_kept) - 1] + if mask_prob[threshold_index] > self.thresh: + threshold = mask_prob[threshold_index] + kept_mask = mask_prob.le(threshold) + target = target * kept_mask.long() + valid_mask = valid_mask * kept_mask + # logger.info('Valid Mask: {}'.format(valid_mask.sum())) + + target = target.masked_fill_(~valid_mask, self.ignore_label) + target = target.view(b, h, w) + + return self.criterion(pred, target) + +class RegularCE(nn.Module): + """ + Regular cross entropy loss for semantic segmentation, support pixel-wise loss weight. + Arguments: + ignore_label: Integer, label to ignore. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, weight=None): + super(RegularCE, self).__init__() + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + mask = labels.contiguous().view(-1) != self.ignore_label + + pixel_losses = pixel_losses[mask] + return pixel_losses.mean() + + +class OhemCE(nn.Module): + """ + Online hard example mining with cross entropy loss, for semantic segmentation. + This is widely used in PyTorch semantic segmentation frameworks. + Reference: https://github.com/HRNet/HRNet-Semantic-Segmentation/blob/1b3ae72f6025bde4ea404305d502abea3c2f5266/lib/core/criterion.py#L29 + Arguments: + ignore_label: Integer, label to ignore. + threshold: Float, threshold for softmax score (of gt class), only predictions with softmax score + below this threshold will be kept. + min_kept: Integer, minimum number of pixels to be kept, it is used to adjust the + threshold value to avoid number of examples being too small. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, threshold=0.7, + min_kept=100000, weight=None): + super(OhemCE, self).__init__() + self.threshold = threshold + self.min_kept = max(1, min_kept) + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + predictions = F.softmax(logits, dim=1) + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + mask = labels.contiguous().view(-1) != self.ignore_label + + tmp_labels = labels.clone() + tmp_labels[tmp_labels == self.ignore_label] = 0 + # Get the score for gt class at each pixel location. + predictions = predictions.gather(1, tmp_labels.unsqueeze(1)) + predictions, indices = predictions.contiguous().view(-1, )[mask].contiguous().sort() + min_value = predictions[min(self.min_kept, predictions.numel() - 1)] + threshold = max(min_value, self.threshold) + + pixel_losses = pixel_losses[mask][indices] + pixel_losses = pixel_losses[predictions < threshold] + return pixel_losses.mean() + + +class DeepLabCE(nn.Module): + """ + Hard pixel mining mining with cross entropy loss, for semantic segmentation. + This is used in TensorFlow DeepLab frameworks. + Reference: https://github.com/tensorflow/models/blob/bd488858d610e44df69da6f89277e9de8a03722c/research/deeplab/utils/train_utils.py#L33 + Arguments: + ignore_label: Integer, label to ignore. + top_k_percent_pixels: Float, the value lies in [0.0, 1.0]. When its value < 1.0, only compute the loss for + the top k percent pixels (e.g., the top 20% pixels). This is useful for hard pixel mining. + weight: Tensor, a manual rescaling weight given to each class. + """ + def __init__(self, ignore_label=-1, top_k_percent_pixels=1.0, weight=None): + super(DeepLabCE, self).__init__() + self.top_k_percent_pixels = top_k_percent_pixels + self.ignore_label = ignore_label + self.criterion = nn.CrossEntropyLoss(weight=weight, + ignore_index=ignore_label, + reduction='none') + + def forward(self, logits, labels, **kwargs): + if 'semantic_weights' in kwargs: + pixel_losses = self.criterion(logits, labels) * kwargs['semantic_weights'] + pixel_losses = pixel_losses.contiguous().view(-1) + else: + pixel_losses = self.criterion(logits, labels).contiguous().view(-1) + if self.top_k_percent_pixels == 1.0: + return pixel_losses.mean() + + top_k_pixels = int(self.top_k_percent_pixels * pixel_losses.numel()) + pixel_losses, _ = torch.topk(pixel_losses, top_k_pixels) + return pixel_losses.mean() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py new file mode 100644 index 000000000..503c3cf8d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/seg_opr/metric.py @@ -0,0 +1,87 @@ +import numpy as np + +np.seterr(divide='ignore', invalid='ignore') + + +# voc cityscapes metric +def hist_info(n_cl, pred, gt): + assert (pred.shape == gt.shape) + k = (gt >= 0) & (gt < n_cl) + labeled = np.sum(k) + correct = np.sum((pred[k] == gt[k])) + + return np.bincount(n_cl * gt[k].astype(int) + pred[k].astype(int), + minlength=n_cl ** 2).reshape(n_cl, + n_cl), labeled, correct + + +def compute_score(hist, correct, labeled): + iu = np.diag(hist) / (hist.sum(1) + hist.sum(0) - np.diag(hist)) + mean_IU = np.nanmean(iu) + mean_IU_no_back = np.nanmean(iu[1:]) + # freq = hist.sum(1) / hist.sum() + # freq_IU = (iu[freq > 0] * freq[freq > 0]).sum() + mean_pixel_acc = correct / labeled + + return iu, mean_IU, mean_IU_no_back, mean_pixel_acc + + +# ade metric +def meanIoU(area_intersection, area_union): + iou = 1.0 * np.sum(area_intersection, axis=1) / np.sum(area_union, axis=1) + meaniou = np.nanmean(iou) + meaniou_no_back = np.nanmean(iou[1:]) + + return iou, meaniou, meaniou_no_back + + +def intersectionAndUnion(imPred, imLab, numClass): + # Remove classes from unlabeled pixels in gt image. + # We should not penalize detections in unlabeled portions of the image. + imPred = np.asarray(imPred).copy() + imLab = np.asarray(imLab).copy() + + imPred += 1 + imLab += 1 + # Remove classes from unlabeled pixels in gt image. + # We should not penalize detections in unlabeled portions of the image. + imPred = imPred * (imLab > 0) + + # imPred = imPred * (imLab >= 0) + + # Compute area intersection: + intersection = imPred * (imPred == imLab) + (area_intersection, _) = np.histogram(intersection, bins=numClass, + range=(1, numClass)) + + # Compute area union: + (area_pred, _) = np.histogram(imPred, bins=numClass, range=(1, numClass)) + (area_lab, _) = np.histogram(imLab, bins=numClass, range=(1, numClass)) + area_union = area_pred + area_lab - area_intersection + + return area_intersection, area_union + + +def mean_pixel_accuracy(pixel_correct, pixel_labeled): + mean_pixel_accuracy = 1.0 * np.sum(pixel_correct) / ( + np.spacing(1) + np.sum(pixel_labeled)) + + return mean_pixel_accuracy + + +def pixelAccuracy(imPred, imLab): + # Remove classes from unlabeled pixels in gt image. + # We should not penalize detections in unlabeled portions of the image. + pixel_labeled = np.sum(imLab >= 0) + pixel_correct = np.sum((imPred == imLab) * (imLab >= 0)) + pixel_accuracy = 1.0 * pixel_correct / pixel_labeled + + return pixel_accuracy, pixel_correct, pixel_labeled + + +def accuracy(preds, label): + valid = (label >= 0) + acc_sum = (valid * (preds == label)).sum() + valid_sum = valid.sum() + acc = float(acc_sum) / (valid_sum + 1e-10) + return acc, valid_sum diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/__init__.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/cal_model.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/cal_model.py new file mode 100644 index 000000000..27ec3628c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/cal_model.py @@ -0,0 +1,216 @@ +from __future__ import division +import os +import sys +import time +import glob +import json +import logging +import argparse +from tqdm import tqdm + +import torch +import torch.nn as nn +import torch.utils +import torch.nn.functional as F +import torch.optim as optim +import torch.distributed as dist +from tensorboardX import SummaryWriter + +import numpy as np +from thop import profile +from ptflops import get_model_complexity_info + +from config_train import config +# if config.is_eval: +# config.save = '../OUTPUT/eval-{}-{}'.format(config.save, time.strftime("%Y%m%d-%H%M%S")) +# else: +# config.save = '../OUTPUT/train-{}-{}'.format(config.save, time.strftime("%Y%m%d-%H%M%S")) +from dataloader import get_train_loader, CyclicIterator +from datasets import Cityscapes + +import dataloaders +from utils.init_func import init_weight +from utils.lr_scheduler import Iter_LR_Scheduler +from seg_opr.loss_opr import ProbOhemCrossEntropy2d +from eval import SegEvaluator +from test import SegTester + +from utils.darts_utils import create_exp_dir, save, plot_op, plot_path_width, objective_acc_lat +from utils.dist_utils import reduce_tensor, ModelEma +from model_seg import Network_Multi_Path_Infer_SPOS as Network +import seg_metrics + +import yaml +import timm +from timm.optim import create_optimizer +from utils.pyt_utils import AverageMeter, to_cuda, get_loss_info_str, compute_hist, compute_hist_np, load_pretrain + +def adjust_learning_rate(base_lr, power, optimizer, epoch, total_epoch): + for param_group in optimizer.param_groups: + param_group['lr'] = param_group['lr'] * power + + +# The first arg parser parses out only the --config argument, this argument is used to +# load a yaml file containing key-values that override the defaults for the main parser below +config_parser = parser = argparse.ArgumentParser(description='Training Config', add_help=False) +parser.add_argument('-c', '--config', default='../configs/auto2/sz512drop0.2.yaml', type=str, metavar='FILE', + help='YAML config file specifying default arguments') + +parser = argparse.ArgumentParser(description='PyTorch Training') +parser.add_argument('--det2_cfg', type=str, default='configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml', help='') +parser.add_argument('--save', type=str, default='../OUTPUT/train', help='') +parser.add_argument("--local_rank", default=0, type=int) +parser.add_argument("--world_size", default=1, type=int) +parser.add_argument("--eval_height", default=1025, type=int, help='train height') +parser.add_argument("--eval_width", default=2049, type=int, help='train width') +parser.add_argument("--test_epoch", default=250, type=int, help='Epochs for test') +parser.add_argument("--batch_size", default=12, type=int, help='batch size') +parser.add_argument("--Fch", default=12, type=int, help='Fch') +parser.add_argument('--stem_head_width', type=float, default=1.0, help='base learning rate') +parser.add_argument('--resume', type=str, default='../OUTPUT/train/', help='resume') + +## new retrain ### +parser.add_argument('--sched', default='step', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "step"') +parser.add_argument('--epochs', type=int, default=4000, help='num of training epochs') +parser.add_argument('--dataset', type=str, default='cityscapes', help='pascal or cityscapes') +parser.add_argument('--base_lr', type=float, default=0.05, help='base learning rate') +parser.add_argument('--warmup_start_lr', type=float, default=5e-6, help='warm up learning rate') +parser.add_argument('--lr-step', type=float, default=None) +parser.add_argument('--warmup-iters', type=int, default=1000) +parser.add_argument('--min-lr', type=float, default=None) +parser.add_argument('--crop_size', type=int, default=769, help='image crop size') +parser.add_argument('--resize', type=int, default=769, help='image crop size') +parser.add_argument("--image_height", default=513, type=int, help='train height') +parser.add_argument("--image_width", default=1025, type=int, help='train width') +parser.add_argument('--workers', type=int, default=4, help='number of data loading workers') +parser.add_argument('--dist', type=bool, default=True) +parser.add_argument('--autodeeplab', type=str, default='train_seg') +parser.add_argument('--max-iteration', default=1000000, type=bool) +parser.add_argument('--mode', default='poly', type=str, help='how lr decline') +parser.add_argument('--train_mode', type=str, default='iter', choices=['iter', 'epoch']) + +parser.add_argument("--data_path", default='/home/t-hongyuanyu/data/cityscapes', type=str, help='If specified, replace config.load_path') +parser.add_argument("--load_path", default='', type=str, help='If specified, replace config.load_path') +parser.add_argument("--json_file", default='jsons/0.json', type=str, help='model_arch') +parser.add_argument("--seed", default=12345, type=int, help="random seed") +parser.add_argument('--sync_bn', action='store_false', + help='Enable NVIDIA Apex or Torch synchronized BatchNorm.') +parser.add_argument('--random_sample', action='store_true', + help='Random sample path.') +parser.add_argument('--drop_path_prob', type=float, default=0.0, help='drop path prob') + +# Optimizer parameters +parser.add_argument('--opt', default='sgd', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "sgd"') +parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') +parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') +parser.add_argument('--weight-decay', type=float, default=0.0001, + help='weight decay (default: 0.0001)') + +# Model Exponential Moving Average +parser.add_argument('--model-ema', action='store_true', default=False, + help='Enable tracking moving average of model weights') +parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, + help='Force ema to be tracked on CPU, rank=0 node only. Disables EMA validation.') +parser.add_argument('--model-ema-decay', type=float, default=0.9998, + help='decay factor for model weights moving average (default: 0.9998)') + +# train val +parser.add_argument('--ignore', type=int, default=255, help='semantic ignore') +parser.add_argument('--eval_flip', action='store_true', default=False, + help='semantic eval flip') + + +class NpEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, np.integer): + return int(obj) + elif isinstance(obj, np.floating): + return float(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + else: + return super(NpEncoder, self).default(obj) + +def _parse_args(): + # Do we have a config file to parse? + args_config, remaining = config_parser.parse_known_args() + if args_config.config: + with open(args_config.config, 'r') as f: + cfg = yaml.safe_load(f) + parser.set_defaults(**cfg) + + # The main arg parser parses the rest of the args, the usual + # defaults will have been overridden if config file specified. + args = parser.parse_args(remaining) + + # Cache the args as a text string to save them in the output dir later + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + return args, args_text + +def main(): + args, args_text = _parse_args() + + + if args.load_path: + config.load_path = args.load_path + + config.batch_size = args.batch_size + config.image_height = args.image_height + config.image_width = args.image_width + config.eval_height = args.eval_height + config.eval_width = args.eval_width + config.Fch = args.Fch + config.dataset_path = args.data_path + config.save = args.save + + # preparation ################ + np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.cuda.manual_seed_all(args.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + + model_files = glob.glob("Search/1paths/*.json") + glob.glob("Search/2paths/*.json") + glob.glob("Search/3paths/*.json") + + for model_file in model_files: + + with open(model_file, 'r') as f: + # dict_a = json.loads(f, cls=NpEncoder) + model_dict = json.loads(f.read()) + + model = Network( + model_dict["ops"], model_dict["paths"], model_dict["downs"], model_dict["widths"], model_dict["lasts"], + num_classes=config.num_classes, layers=config.layers, Fch=config.Fch, width_mult_list=config.width_mult_list, stem_head_width=(args.stem_head_width, args.stem_head_width)) + + if args.local_rank == 0: + print("net: " + str(model)) + # with torch.cuda.device(0): + # macs, params = get_model_complexity_info(model, (3, 1024, 2048), as_strings=True, + # print_per_layer_stat=True, verbose=True) + # logging.info('{:<30} {:<8}'.format('Computational complexity: ', macs)) + # logging.info('{:<30} {:<8}'.format('Number of parameters: ', params)) + + flops, params = profile(model, inputs=(torch.randn(1, 3, 1024, 2048),), verbose=False) + flops = flops / 1e9 + params = params / 1e6 + model_dict['flops'] = flops + model_dict['params'] = params + print("params = %fMB, FLOPs = %fGB", params, flops) + + with open(model_file, 'w') as f: + json.dump(model_dict, f, cls=NpEncoder) + + +if __name__ == '__main__': + main() + #launch( + # main, + # 2, + # num_machines=1, + # machine_rank=0, + # dist_url='auto', + #) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/darts_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/darts_utils.py new file mode 100644 index 000000000..7973d27d7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/darts_utils.py @@ -0,0 +1,352 @@ +import os +import math +import numpy as np +import torch +import shutil +from torch.autograd import Variable +import time +from tqdm import tqdm +from genotypes import PRIMITIVES +import matplotlib +# Force matplotlib to not use any Xwindows backend. +matplotlib.use('Agg') +from matplotlib import pyplot as plt +from pdb import set_trace as bp +import warnings + + +class AvgrageMeter(object): + + def __init__(self): + self.reset() + + def reset(self): + self.avg = 0 + self.sum = 0 + self.cnt = 0 + + def update(self, val, n=1): + self.sum += val * n + self.cnt += n + self.avg = self.sum / self.cnt + + +class Cutout(object): + def __init__(self, length): + self.length = length + + def __call__(self, img): + h, w = img.size(1), img.size(2) + mask = np.ones((h, w), np.float32) + y = np.random.randint(h) + x = np.random.randint(w) + + y1 = np.clip(y - self.length // 2, 0, h) + y2 = np.clip(y + self.length // 2, 0, h) + x1 = np.clip(x - self.length // 2, 0, w) + x2 = np.clip(x + self.length // 2, 0, w) + + mask[y1: y2, x1: x2] = 0. + mask = torch.from_numpy(mask) + mask = mask.expand_as(img) + img *= mask + return img + + +def count_parameters_in_MB(model): + return np.sum(np.prod(v.size()) for name, v in model.named_parameters() if "auxiliary" not in name)/1e6 + + +def save_checkpoint(state, is_best, save): + filename = os.path.join(save, 'checkpoint.pth.tar') + torch.save(state, filename) + if is_best: + best_filename = os.path.join(save, 'model_best.pth.tar') + shutil.copyfile(filename, best_filename) + + +def save(model, model_path): + torch.save(model.state_dict(), model_path) + + +def load(model, model_path): + model.load_state_dict(torch.load(model_path)) + + +def drop_path(x, drop_prob): + if drop_prob > 0.: + keep_prob = 1.-drop_prob + mask = Variable(torch.cuda.FloatTensor(x.size(0), 1, 1, 1).bernoulli_(keep_prob)) + x.div_(keep_prob) + x.mul_(mask) + return x + + +def create_exp_dir(path, scripts_to_save=None): + if not os.path.exists(path): + # os.mkdir(path) + os.makedirs(path, exist_ok=True) + print('Experiment dir : {}'.format(path)) + + if scripts_to_save is not None: + # os.mkdir(os.path.join(path, 'scripts')) + os.makedirs(os.path.join(path, 'scripts'), exist_ok=True) + for script in scripts_to_save: + dst_file = os.path.join(path, 'scripts', os.path.basename(script)) + shutil.copyfile(script, dst_file) + +########################## TensorRT speed_test ################################# +try: + import tensorrt as trt + import pycuda.driver as cuda + import pycuda.autoinit + + MAX_BATCH_SIZE = 1 + MAX_WORKSPACE_SIZE = 1 << 30 + + TRT_LOGGER = trt.Logger(trt.Logger.WARNING) + DTYPE = trt.float32 + + # Model + INPUT_NAME = 'input' + OUTPUT_NAME = 'output' + + def allocate_buffers(engine): + h_input = cuda.pagelocked_empty(trt.volume(engine.get_binding_shape(0)), dtype=trt.nptype(DTYPE)) + h_output = cuda.pagelocked_empty(trt.volume(engine.get_binding_shape(1)), dtype=trt.nptype(DTYPE)) + d_input = cuda.mem_alloc(h_input.nbytes) + d_output = cuda.mem_alloc(h_output.nbytes) + return h_input, d_input, h_output, d_output + + + def build_engine(model_file): + with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.OnnxParser(network, TRT_LOGGER) as parser: + builder.max_workspace_size = MAX_WORKSPACE_SIZE + builder.max_batch_size = MAX_BATCH_SIZE + + with open(model_file, 'rb') as model: + parser.parse(model.read()) + last_layer = network.get_layer(network.num_layers - 1) + network.mark_output(last_layer.get_output(0)) + return builder.build_cuda_engine(network) + + + def load_input(input_size, host_buffer): + assert len(input_size) == 4 + b, c, h, w = input_size + dtype = trt.nptype(DTYPE) + img_array = np.random.randn(c, h, w).astype(dtype).ravel() + np.copyto(host_buffer, img_array) + + + def do_inference(context, h_input, d_input, h_output, d_output, iterations=None): + # Transfer input data to the GPU. + cuda.memcpy_htod(d_input, h_input) + # warm-up + for _ in range(10): + context.execute(batch_size=1, bindings=[int(d_input), int(d_output)]) + # test proper iterations + if iterations is None: + elapsed_time = 0 + iterations = 100 + while elapsed_time < 1: + t_start = time.time() + for _ in range(iterations): + context.execute(batch_size=1, bindings=[int(d_input), int(d_output)]) + elapsed_time = time.time() - t_start + iterations *= 2 + FPS = iterations / elapsed_time + iterations = int(FPS * 3) + # Run inference. + t_start = time.time() + for _ in tqdm(range(iterations)): + context.execute(batch_size=1, bindings=[int(d_input), int(d_output)]) + elapsed_time = time.time() - t_start + latency = elapsed_time / iterations * 1000 + return latency + + + def compute_latency_ms_tensorrt(model, input_size, iterations=None): + model = model.cuda() + model.eval() + _, c, h, w = input_size + dummy_input = torch.randn(1, c, h, w, device='cuda') + torch.onnx.export(model, dummy_input, "model.onnx", verbose=False, input_names=["input"], output_names=["output"]) + with build_engine("model.onnx") as engine: + h_input, d_input, h_output, d_output = allocate_buffers(engine) + load_input(input_size, h_input) + with engine.create_execution_context() as context: + latency = do_inference(context, h_input, d_input, h_output, d_output, iterations=iterations) + # FPS = 1000 / latency (in ms) + return latency +except: + warnings.warn("TensorRT (or pycuda) is not installed. compute_latency_ms_tensorrt() cannot be used.") +######################################################################### + +def compute_latency_ms_pytorch(model, input_size, iterations=None, device=None): + torch.backends.cudnn.enabled = True + torch.backends.cudnn.benchmark = True + + model.eval() + model = model.cuda() + + input = torch.randn(*input_size).cuda() + + with torch.no_grad(): + for _ in range(10): + model(input) + + if iterations is None: + elapsed_time = 0 + iterations = 100 + while elapsed_time < 1: + torch.cuda.synchronize() + torch.cuda.synchronize() + t_start = time.time() + for _ in range(iterations): + model(input) + torch.cuda.synchronize() + torch.cuda.synchronize() + elapsed_time = time.time() - t_start + iterations *= 2 + FPS = iterations / elapsed_time + iterations = int(FPS * 6) + + print('=========Speed Testing=========') + torch.cuda.synchronize() + torch.cuda.synchronize() + t_start = time.time() + for _ in tqdm(range(iterations)): + model(input) + torch.cuda.synchronize() + torch.cuda.synchronize() + elapsed_time = time.time() - t_start + latency = elapsed_time / iterations * 1000 + torch.cuda.empty_cache() + # FPS = 1000 / latency (in ms) + return latency + + +def plot_path(lasts, paths=[]): + ''' + paths: list of path0~path2 + ''' + assert len(paths) > 0 + path0 = paths[0] + path1 = paths[1] if len(paths) > 1 else [] + path2 = paths[2] if len(paths) > 2 else [] + + if path0[-1] != lasts[0]: path0.append(lasts[0]) + if len(path1) != 0 and path1[-1] != lasts[1]: path1.append(lasts[1]) + if len(path2) != 0 and path2[-1] != lasts[2]: path2.append(lasts[2]) + x_len = max(len(path0), len(path1), len(path2)) + f, ax = plt.subplots(figsize=(x_len, 3)) + ax.plot(np.arange(len(path0)), 2 - np.array(path0), label='1/32', lw=2.5, color='#000000', linestyle='-')#, marker='o', markeredgecolor='r', markerfacecolor='r') + ax.plot(np.arange(len(path1)), 2 - np.array(path1) - 0.08, lw=1.8, label='1/16', color='#313131', linestyle='--')#, marker='^', markeredgecolor='b', markerfacecolor='b') + ax.plot(np.arange(len(path2)), 2 - np.array(path2) - 0.16, lw=1.2, label='1/8', color='#5a5858', linestyle='-.')#, marker='s', markeredgecolor='m', markerfacecolor='m') + plt.xticks(np.arange(x_len), list(range(1, x_len+1))) + plt.yticks(np.array([0, 1, 2]), ["1/32", "1/16", "1/8"]) + plt.ylabel("Scale", fontsize=17) + plt.xlabel("Layer", fontsize=17) + for tick in ax.xaxis.get_major_ticks(): + tick.label.set_fontsize(14) + for tick in ax.yaxis.get_major_ticks(): + tick.label.set_fontsize(14) + f.tight_layout() + plt.legend(prop={'size': 14}, loc=3) + return f + + +def plot_path_width(lasts, paths=[], widths=[]): + ''' + paths: list of path0~path2 + ''' + assert len(paths) > 0 and len(widths) > 0 + path0 = paths[0] + path1 = paths[1] if len(paths) > 1 else [] + path2 = paths[2] if len(paths) > 2 else [] + width0 = widths[0] + width1 = widths[1] if len(widths) > 1 else [] + width2 = widths[2] if len(widths) > 2 else [] + + # just for visualization purpose + if path0[-1] != lasts[0]: path0.append(lasts[0]) + if len(path1) != 0 and path1[-1] != lasts[1]: path1.append(lasts[1]) + if len(path2) != 0 and path2[-1] != lasts[2]: path2.append(lasts[2]) + line_updown = -0.07 + annotation_updown = 0.05; annotation_down_scale = 1.7 + x_len = max(len(path0), len(path1), len(path2)) + f, ax = plt.subplots(figsize=(x_len, 3)) + + assert len(path0) == len(width0) + 1 or len(path0) + len(width0) == 0, "path0 %d, width0 %d"%(len(path0), len(width0)) + assert len(path1) == len(width1) + 1 or len(path1) + len(width1) == 0, "path1 %d, width1 %d"%(len(path1), len(width1)) + assert len(path2) == len(width2) + 1 or len(path2) + len(width2) == 0, "path2 %d, width2 %d"%(len(path2), len(width2)) + + ax.plot(np.arange(len(path0)), 2 - np.array(path0), label='1/32', lw=2.5, color='#000000', linestyle='-') + ax.plot(np.arange(len(path1)), 2 - np.array(path1) + line_updown, lw=1.8, label='1/16', color='#313131', linestyle='--') + ax.plot(np.arange(len(path2)), 2 - np.array(path2) + line_updown*2, lw=1.2, label='1/8', color='#5a5858', linestyle='-.') + + annotations = {} # (idx, scale, width, down): ((x, y), width) + for idx, width in enumerate(width2): + annotations[(idx, path2[idx], width, path2[idx+1]-path2[idx])] = ((0.35 + idx, 2 - path2[idx] + line_updown*2 + annotation_updown - (path2[idx+1]-path2[idx])/annotation_down_scale), width) + for idx, width in enumerate(width1): + annotations[(idx, path1[idx], width, path1[idx+1]-path1[idx])] = ((0.35 + idx, 2 - path1[idx] + line_updown + annotation_updown - (path1[idx+1]-path1[idx])/annotation_down_scale), width) + for idx, width in enumerate(width0): + annotations[(idx, path0[idx], width, path0[idx+1]-path0[idx])] = ((0.35 + idx, 2 - path0[idx] + annotation_updown - (path0[idx+1]-path0[idx])/annotation_down_scale), width) + for k, v in annotations.items(): + plt.annotate("%.2f"%v[1], v[0], fontsize=12, color='red') + + plt.xticks(np.arange(x_len), list(range(1, x_len+1))) + plt.yticks(np.array([0, 1, 2]), ["1/32", "1/16", "1/8"]) + plt.ylim([-0.4, 2.5]) + plt.ylabel("Scale", fontsize=17) + plt.xlabel("Layer", fontsize=17) + for tick in ax.xaxis.get_major_ticks(): + tick.label.set_fontsize(14) + for tick in ax.yaxis.get_major_ticks(): + tick.label.set_fontsize(14) + f.tight_layout() + plt.legend(prop={'size': 14}, loc=3) + return f + +def plot_op(ops, path, width=[], head_width=None, F_base=16): + assert len(width) == 0 or len(width) == len(ops) - 1 + table_vals = [] + scales = {0: "1/8", 1: "1/16", 2: "1/32"}; base_scale = 3 + for idx, op in enumerate(ops): + scale = path[idx] + if len(width) > 0: + if idx < len(width): + ch = int(F_base*2**(scale+base_scale)*width[idx]) + else: + ch = int(F_base*2**(scale+base_scale)*head_width) + else: + ch = F_base*2**(scale+base_scale) + row = [idx+1, PRIMITIVES[op], scales[scale], ch] + table_vals.append(row) + + # Based on http://stackoverflow.com/a/8531491/190597 (Andrey Sobolev) + col_labels = ['Stage', 'Operator', 'Scale', '#Channel_out'] + plt.tight_layout() + fig = plt.figure(figsize=(3,3)) + ax = fig.add_subplot(111, frame_on=False) + ax.xaxis.set_visible(False) # hide the x axis + ax.yaxis.set_visible(False) # hide the y axis + + table = plt.table(cellText=table_vals, + colWidths=[0.22, 0.6, 0.25, 0.5], + colLabels=col_labels, + cellLoc='center', + loc='center') + table.auto_set_font_size(False) + table.set_fontsize(20) + table.scale(2, 2) + + return fig + +def objective_acc_lat(acc, lat, lat_target=8.3, alpha=-0.07, beta=-0.07): + if lat <= lat_target: + w = alpha + else: + w = beta + return acc * math.pow(lat / lat_target, w) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py new file mode 100644 index 000000000..d96ac9ad7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/dist_utils.py @@ -0,0 +1,81 @@ +""" Common distribution utilities +Hacked by Hongyuan Yu +""" + +from copy import deepcopy + +import torch +from torch import distributed as dist + +import logging +from collections import OrderedDict + + +_logger = logging.getLogger(__name__) + +def reduce_tensor(tensor, n): + rt = tensor.clone() + dist.all_reduce(rt, op=dist.ReduceOp.SUM) + rt /= n + return rt + +class ModelEma: + """ Model Exponential Moving Average + Keep a moving average of everything in the model state_dict (parameters and buffers). + This is intended to allow functionality like + https://www.tensorflow.org/api_docs/python/tf/train/ExponentialMovingAverage + A smoothed version of the weights is necessary for some training schemes to perform well. + E.g. Google's hyper-params for training MNASNet, MobileNet-V3, EfficientNet, etc that use + RMSprop with a short 2.4-3 epoch decay period and slow LR decay rate of .96-.99 requires EMA + smoothing of weights to match results. Pay attention to the decay constant you are using + relative to your update count per epoch. + To keep EMA from using GPU resources, set device='cpu'. This will save a bit of memory but + disable validation of the EMA weights. Validation will have to be done manually in a separate + process, or after the training stops converging. + This class is sensitive where it is initialized in the sequence of model init, + GPU assignment and distributed training wrappers. + I've tested with the sequence in my own train.py for torch.DataParallel, apex.DDP, and single-GPU. + """ + def __init__(self, model, decay=0.9999, device='', resume=''): + # make a copy of the model for accumulating moving average of weights + self.ema = deepcopy(model) + self.ema.eval() + self.decay = decay + self.device = device # perform ema on different device from model if set + if device: + self.ema.to(device=device) + self.ema_has_module = hasattr(self.ema, 'module') + if resume: + self._load_checkpoint(resume) + for p in self.ema.parameters(): + p.requires_grad_(False) + + def _load_checkpoint(self, checkpoint_path): + checkpoint = torch.load(checkpoint_path, map_location='cpu') + assert isinstance(checkpoint, dict) + if 'state_dict_ema' in checkpoint: + new_state_dict = OrderedDict() + for k, v in checkpoint['state_dict_ema'].items(): + # ema model may have been wrapped by DataParallel, and need module prefix + if self.ema_has_module: + name = 'module.' + k if not k.startswith('module') else k + else: + name = k + new_state_dict[name] = v + self.ema.load_state_dict(new_state_dict) + _logger.info("Loaded state_dict_ema") + else: + _logger.warning("Failed to find state_dict_ema, starting from loaded model weights") + + def update(self, model): + # correct a mismatch in state dict keys + needs_module = hasattr(model, 'module') and not self.ema_has_module + with torch.no_grad(): + msd = model.state_dict() + for k, ema_v in self.ema.state_dict().items(): + if needs_module: + k = 'module.' + k + model_v = msd[k].detach() + if self.device: + model_v = model_v.to(device=self.device) + ema_v.copy_(ema_v * self.decay + (1. - self.decay) * model_v) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py new file mode 100644 index 000000000..eed8effd5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py @@ -0,0 +1,75 @@ +from collections import namedtuple + +Genotype = namedtuple('Genotype', 'normal normal_concat reduce reduce_concat') + +PRIMITIVES = [ + 'skip', + 'conv', + 'conv_di', + 'conv_2x', + 'conv_2x_di', +] + +NASNet = Genotype( + normal = [ + ('sep_conv_5x5', 1), + ('sep_conv_3x3', 0), + ('sep_conv_5x5', 0), + ('sep_conv_3x3', 0), + ('avg_pool_3x3', 1), + ('skip_connect', 0), + ('avg_pool_3x3', 0), + ('avg_pool_3x3', 0), + ('sep_conv_3x3', 1), + ('skip_connect', 1), + ], + normal_concat = [2, 3, 4, 5, 6], + reduce = [ + ('sep_conv_5x5', 1), + ('sep_conv_7x7', 0), + ('max_pool_3x3', 1), + ('sep_conv_7x7', 0), + ('avg_pool_3x3', 1), + ('sep_conv_5x5', 0), + ('skip_connect', 3), + ('avg_pool_3x3', 2), + ('sep_conv_3x3', 2), + ('max_pool_3x3', 1), + ], + reduce_concat = [4, 5, 6], +) + +AmoebaNet = Genotype( + normal = [ + ('avg_pool_3x3', 0), + ('max_pool_3x3', 1), + ('sep_conv_3x3', 0), + ('sep_conv_5x5', 2), + ('sep_conv_3x3', 0), + ('avg_pool_3x3', 3), + ('sep_conv_3x3', 1), + ('skip_connect', 1), + ('skip_connect', 0), + ('avg_pool_3x3', 1), + ], + normal_concat = [4, 5, 6], + reduce = [ + ('avg_pool_3x3', 0), + ('sep_conv_3x3', 1), + ('max_pool_3x3', 0), + ('sep_conv_7x7', 2), + ('sep_conv_7x7', 0), + ('avg_pool_3x3', 1), + ('max_pool_3x3', 0), + ('max_pool_3x3', 1), + ('conv_7x1_1x7', 0), + ('sep_conv_3x3', 5), + ], + reduce_concat = [3, 4, 6] +) + +DARTS_V1 = Genotype(normal=[('sep_conv_3x3', 1), ('sep_conv_3x3', 0), ('skip_connect', 0), ('sep_conv_3x3', 1), ('skip_connect', 0), ('sep_conv_3x3', 1), ('sep_conv_3x3', 0), ('skip_connect', 2)], normal_concat=[2, 3, 4, 5], reduce=[('max_pool_3x3', 0), ('max_pool_3x3', 1), ('skip_connect', 2), ('max_pool_3x3', 0), ('max_pool_3x3', 0), ('skip_connect', 2), ('skip_connect', 2), ('avg_pool_3x3', 0)], reduce_concat=[2, 3, 4, 5]) +DARTS_V2 = Genotype(normal=[('sep_conv_3x3', 0), ('sep_conv_3x3', 1), ('sep_conv_3x3', 0), ('sep_conv_3x3', 1), ('sep_conv_3x3', 1), ('skip_connect', 0), ('skip_connect', 0), ('dil_conv_3x3', 2)], normal_concat=[2, 3, 4, 5], reduce=[('max_pool_3x3', 0), ('max_pool_3x3', 1), ('skip_connect', 2), ('max_pool_3x3', 1), ('max_pool_3x3', 0), ('skip_connect', 2), ('skip_connect', 2), ('max_pool_3x3', 1)], reduce_concat=[2, 3, 4, 5]) + +DARTS = DARTS_V2 + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/img_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/img_utils.py new file mode 100644 index 000000000..95e3608c0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/img_utils.py @@ -0,0 +1,185 @@ +import cv2 +import numpy as np +import numbers +import random +import collections + + +def get_2dshape(shape, *, zero=True): + if not isinstance(shape, collections.Iterable): + shape = int(shape) + shape = (shape, shape) + else: + h, w = map(int, shape) + shape = (h, w) + if zero: + minv = 0 + else: + minv = 1 + + assert min(shape) >= minv, 'invalid shape: {}'.format(shape) + return shape + + +def random_crop_pad_to_shape(img, crop_pos, crop_size, pad_label_value): + h, w = img.shape[:2] + start_crop_h, start_crop_w = crop_pos + assert ((start_crop_h < h) and (start_crop_h >= 0)) + assert ((start_crop_w < w) and (start_crop_w >= 0)) + + crop_size = get_2dshape(crop_size) + crop_h, crop_w = crop_size + + img_crop = img[start_crop_h:start_crop_h + crop_h, + start_crop_w:start_crop_w + crop_w, ...] + + img_, margin = pad_image_to_shape(img_crop, crop_size, cv2.BORDER_CONSTANT, + pad_label_value) + + return img_, margin + + +def generate_random_crop_pos(ori_size, crop_size): + ori_size = get_2dshape(ori_size) + h, w = ori_size + + crop_size = get_2dshape(crop_size) + crop_h, crop_w = crop_size + + pos_h, pos_w = 0, 0 + + if h > crop_h: + pos_h = random.randint(0, h - crop_h + 1) + + if w > crop_w: + pos_w = random.randint(0, w - crop_w + 1) + + return pos_h, pos_w + + +def pad_image_to_shape(img, shape, border_mode, value): + margin = np.zeros(4, np.uint32) + shape = get_2dshape(shape) + pad_height = shape[0] - img.shape[0] if shape[0] - img.shape[0] > 0 else 0 + pad_width = shape[1] - img.shape[1] if shape[1] - img.shape[1] > 0 else 0 + + margin[0] = pad_height // 2 + margin[1] = pad_height // 2 + pad_height % 2 + margin[2] = pad_width // 2 + margin[3] = pad_width // 2 + pad_width % 2 + + img = cv2.copyMakeBorder(img, margin[0], margin[1], margin[2], margin[3], + border_mode, value=value) + + return img, margin + + +def pad_image_size_to_multiples_of(img, multiple, pad_value): + h, w = img.shape[:2] + d = multiple + + def canonicalize(s): + v = s // d + return (v + (v * d != s)) * d + + th, tw = map(canonicalize, (h, w)) + + return pad_image_to_shape(img, (th, tw), cv2.BORDER_CONSTANT, pad_value) + + +def resize_ensure_shortest_edge(img, edge_length, + interpolation_mode=cv2.INTER_LINEAR): + assert isinstance(edge_length, int) and edge_length > 0, edge_length + h, w = img.shape[:2] + if h < w: + ratio = float(edge_length) / h + th, tw = edge_length, max(1, int(ratio * w)) + else: + ratio = float(edge_length) / w + th, tw = max(1, int(ratio * h)), edge_length + img = cv2.resize(img, (tw, th), interpolation_mode) + + return img + + +def random_scale(img, gt, scales): + scale = random.choice(scales) + sh = int(img.shape[0] * scale) + sw = int(img.shape[1] * scale) + img = cv2.resize(img, (sw, sh), interpolation=cv2.INTER_LINEAR) + gt = cv2.resize(gt, (sw, sh), interpolation=cv2.INTER_NEAREST) + + return img, gt, scale + + +def random_scale_with_length(img, gt, length): + size = random.choice(length) + sh = size + sw = size + img = cv2.resize(img, (sw, sh), interpolation=cv2.INTER_LINEAR) + gt = cv2.resize(gt, (sw, sh), interpolation=cv2.INTER_NEAREST) + + return img, gt, size + + +def random_mirror(img, gt): + if random.random() >= 0.5: + img = cv2.flip(img, 1) + gt = cv2.flip(gt, 1) + + return img, gt, + + +def random_rotation(img, gt): + angle = random.random() * 20 - 10 + h, w = img.shape[:2] + rotation_matrix = cv2.getRotationMatrix2D((w / 2, h / 2), angle, 1) + img = cv2.warpAffine(img, rotation_matrix, (w, h), flags=cv2.INTER_LINEAR) + gt = cv2.warpAffine(gt, rotation_matrix, (w, h), flags=cv2.INTER_NEAREST) + + return img, gt + + +def random_gaussian_blur(img): + gauss_size = random.choice([1, 3, 5, 7]) + if gauss_size > 1: + # do the gaussian blur + img = cv2.GaussianBlur(img, (gauss_size, gauss_size), 0) + + return img + + +def center_crop(img, shape): + h, w = shape[0], shape[1] + y = (img.shape[0] - h) // 2 + x = (img.shape[1] - w) // 2 + return img[y:y + h, x:x + w] + + +def random_crop(img, gt, size): + if isinstance(size, numbers.Number): + size = (int(size), int(size)) + + h, w = img.shape[:2] + crop_h, crop_w = size[0], size[1] + + if h > crop_h: + x = random.randint(0, h - crop_h + 1) + img = img[x:x + crop_h, :, :] + gt = gt[x:x + crop_h, :] + + if w > crop_w: + x = random.randint(0, w - crop_w + 1) + img = img[:, x:x + crop_w, :] + gt = gt[:, x:x + crop_w] + + return img, gt + + +def normalize(img, mean, std): + # pytorch pretrained model need the input range: 0-1 + img = img.astype(np.float32) / 255.0 + img = img - mean + img = img / std + + return img diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/init_func.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/init_func.py new file mode 100644 index 000000000..e2bae28aa --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/init_func.py @@ -0,0 +1,67 @@ +import numpy as np +import json +import torch +import torch.nn as nn + + +def __init_weight(feature, conv_init, norm_layer, bn_eps, bn_momentum, + **kwargs): + for name, m in feature.named_modules(): + if isinstance(m, (nn.Conv2d, nn.Conv3d)): + conv_init(m.weight, **kwargs) + elif isinstance(m, norm_layer): + m.eps = bn_eps + m.momentum = bn_momentum + nn.init.constant_(m.weight, 1) + nn.init.constant_(m.bias, 0) + +def init_weights(m): + if type(m) == nn.Linear: + torch.nn.init.xavier_uniform(m.weight) + m.bias.data.fill_(0.01) + +def init_weight(module_list, conv_init, norm_layer, bn_eps, bn_momentum, + **kwargs): + if isinstance(module_list, list): + for feature in module_list: + __init_weight(feature, conv_init, norm_layer, bn_eps, bn_momentum, + **kwargs) + else: + __init_weight(module_list, conv_init, norm_layer, bn_eps, bn_momentum, + **kwargs) + + +def group_weight(weight_group, module, norm_layer, lr): + group_decay = [] + group_no_decay = [] + for m in module.modules(): + if isinstance(m, nn.Linear): + group_decay.append(m.weight) + if m.bias is not None: + group_no_decay.append(m.bias) + elif isinstance(m, (nn.Conv2d, nn.Conv3d)): + group_decay.append(m.weight) + if m.bias is not None: + group_no_decay.append(m.bias) + elif isinstance(m, norm_layer) or isinstance(m, nn.GroupNorm): + if m.weight is not None: + group_no_decay.append(m.weight) + if m.bias is not None: + group_no_decay.append(m.bias) + + assert len(list(module.parameters())) == len(group_decay) + len( + group_no_decay) + weight_group.append(dict(params=group_decay, lr=lr)) + weight_group.append(dict(params=group_no_decay, weight_decay=.0, lr=lr)) + return weight_group + +class NpEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, np.integer): + return int(obj) + elif isinstance(obj, np.floating): + return float(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + else: + return super(NpEncoder, self).default(obj) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/lr_scheduler.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/lr_scheduler.py new file mode 100644 index 000000000..ba6b3e3dd --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/lr_scheduler.py @@ -0,0 +1,56 @@ +import math + + +class Iter_LR_Scheduler(object): + """Learning Rate Scheduler + Step mode: ``lr = baselr * 0.1 ^ {floor(epoch-1 / lr_step)}`` + Cosine mode: ``lr = baselr * 0.5 * (1 + cos(iter/maxiter))`` + Poly mode: ``lr = baselr * (1 - iter/maxiter) ^ 0.9`` + Args: + args: + :attr:`args.lr_scheduler` lr scheduler mode (`cos`, `poly`), + :attr:`args.lr` base learning rate, :attr:`args.epochs` number of epochs, + :attr:`args.lr_step` + iters_per_epoch: number of iterations per epoch + """ + + def __init__(self, args, max_iteration, iters_per_epoch): + self.mode = args.mode + print('Using {} LR Scheduler!'.format(self.mode)) + self.lr = args.base_lr + self.lr_step = args.lr_step + self.iters_per_epoch = iters_per_epoch + self.max_iteration = max_iteration + self.epoch = -1 + self.warmup_iters = args.warmup_iters + self.min_lr = args.min_lr if args.min_lr is not None else 0 + self.warmup_start_lr = args.warmup_start_lr + self.warmup_factor = (self.lr / args.warmup_start_lr) ** (1. / args.warmup_iters) + + def __call__(self, optimizer, iteration): + if self.warmup_iters > 0 and iteration < self.warmup_iters: + lr = self.warmup_start_lr * (self.warmup_factor ** iteration) + elif self.mode == 'cos': + lr = 0.5 * self.lr * (1 + math.cos(1.0 * iteration / self.max_iteration * math.pi)) + elif self.mode == 'poly': + lr = self.lr * pow((1 - (iteration - self.warmup_iters) / (self.max_iteration - self.warmup_iters)), 0.9) + elif self.mode == 'step': # TODO: Fix the step mode + print('Warning! Now the step decline lr exists some issue') + if not self.lr_step: + raise NotImplementedError + epoch = iteration // self.iters_per_epoch + lr = self.lr * (0.1 ** (epoch // self.lr_step)) + else: + raise NotImplemented + # warm up lr schedule + if iteration == self.warmup_iters: + print('==> warmup done, start to implement poly lr strategy') + if (not iteration % self.iters_per_epoch) and (iteration // self.iters_per_epoch > self.epoch): + epoch = iteration // self.iters_per_epoch + print('\n=>Epoches %i, learning rate = %.4f' % (epoch, lr)) + self.epoch = epoch + + optimizer.param_groups[0]['lr'] = max(lr, self.min_lr) + + def get_lr(self, optimizer): + return optimizer.param_groups[0]['lr'] \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py new file mode 100644 index 000000000..ee235e30c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/metrics.py @@ -0,0 +1,46 @@ +import numpy as np + + +class Evaluator(object): + def __init__(self, num_class): + self.num_class = num_class + self.confusion_matrix = np.zeros((self.num_class,)*2) + + def Pixel_Accuracy(self): + Acc = np.diag(self.confusion_matrix).sum() / self.confusion_matrix.sum() + return Acc + + def Pixel_Accuracy_Class(self): + Acc = np.diag(self.confusion_matrix) / self.confusion_matrix.sum(axis=1) + Acc = np.nanmean(Acc) + return Acc + + def Mean_Intersection_over_Union(self): + MIoU = np.diag(self.confusion_matrix) / ( + np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) - + np.diag(self.confusion_matrix)) + MIoU = np.nanmean(MIoU) + return MIoU + + def Frequency_Weighted_Intersection_over_Union(self): + freq = np.sum(self.confusion_matrix, axis=1) / np.sum(self.confusion_matrix) + iu = np.diag(self.confusion_matrix) / ( + np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) - + np.diag(self.confusion_matrix)) + + FWIoU = (freq[freq > 0] * iu[freq > 0]).sum() + return FWIoU + + def _generate_matrix(self, gt_image, pre_image): + mask = (gt_image >= 0) & (gt_image < self.num_class) + label = self.num_class * gt_image[mask].astype('int') + pre_image[mask] + count = np.bincount(label, minlength=self.num_class**2) + confusion_matrix = count.reshape(self.num_class, self.num_class) + return confusion_matrix + + def add_batch(self, gt_image, pre_image): + assert gt_image.shape == pre_image.shape + self.confusion_matrix += self._generate_matrix(gt_image, pre_image) + + def reset(self): + self.confusion_matrix = np.zeros((self.num_class,) * 2) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/pyt_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/pyt_utils.py new file mode 100644 index 000000000..a5487b965 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/pyt_utils.py @@ -0,0 +1,291 @@ +# encoding: utf-8 +import os +import time +import numpy as np +import numba +import argparse +from collections import OrderedDict + +import torch +import torch.distributed as dist + +from engine.logger import get_logger + +logger = get_logger() +EPS = 1e-10 + +model_urls = { + 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', + 'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth', + 'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth', + 'resnet101': 'https://download.pytorch.org/models/resnet101-5d3b4d8f.pth', + 'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth', +} + +class AverageMeter(object): + """Computes and stores the average and current value""" + def __init__(self): + self.reset() + + def reset(self): + self.val = 0 + self.avg = 0 + self.sum = 0 + self.count = 0 + + def update(self, val, n=1): + self.val = val + self.sum += val * n + self.count += n + self.avg = self.sum / self.count if self.count != 0 else 0 + +def to_cuda(batch, device): + if type(batch) == torch.Tensor: + batch = batch.cuda(non_blocking=True) + elif type(batch) == dict: + for key in batch.keys(): + batch[key] = to_cuda(batch[key], device) + elif type(batch) == list: + for i in range(len(batch)): + batch[i] = to_cuda(batch[i], device) + return batch + +def get_loss_info_str(loss_meter_dict): + msg = '' + for key in loss_meter_dict.keys(): + msg += '{name}: {meter.val:.3e} ({meter.avg:.3e})\t'.format( + name=key, meter=loss_meter_dict[key] + ) + + return msg + +def reduce_tensor(tensor, dst=0, op=dist.ReduceOp.SUM, world_size=1): + tensor = tensor.clone() + dist.reduce(tensor, dst, op) + if dist.get_rank() == dst: + tensor.div_(world_size) + + return tensor + +def all_reduce_tensor(tensor, op=dist.ReduceOp.SUM, world_size=1): + tensor = tensor.clone() + dist.all_reduce(tensor, op) + tensor.div_(world_size) + + return tensor + + +def load_model(model, model_file, is_restore=False): + t_start = time.time() + if isinstance(model_file, str): + state_dict = torch.load(model_file) + if 'model' in state_dict.keys(): + state_dict = state_dict['model'] + else: + state_dict = model_file + t_ioend = time.time() + + if is_restore: + new_state_dict = OrderedDict() + for k, v in state_dict.items(): + name = 'module.' + k + new_state_dict[name] = v + state_dict = new_state_dict + + model.load_state_dict(state_dict, strict=False) + ckpt_keys = set(state_dict.keys()) + own_keys = set(model.state_dict().keys()) + missing_keys = own_keys - ckpt_keys + unexpected_keys = ckpt_keys - own_keys + + if len(missing_keys) > 0: + logger.warning('Missing key(s) in state_dict: {}'.format( + ', '.join('{}'.format(k) for k in missing_keys))) + + if len(unexpected_keys) > 0: + logger.warning('Unexpected key(s) in state_dict: {}'.format( + ', '.join('{}'.format(k) for k in unexpected_keys))) + + del state_dict + t_end = time.time() + logger.info( + "Load model, Time usage:\n\tIO: {}, initialize parameters: {}".format( + t_ioend - t_start, t_end - t_ioend)) + + return model + + +def parse_devices(input_devices): + if input_devices.endswith('*'): + devices = list(range(torch.cuda.device_count())) + return devices + + devices = [] + for d in input_devices.split(','): + if '-' in d: + start_device, end_device = d.split('-')[0], d.split('-')[1] + assert start_device != '' + assert end_device != '' + start_device, end_device = int(start_device), int(end_device) + assert start_device < end_device + assert end_device < torch.cuda.device_count() + for sd in range(start_device, end_device + 1): + devices.append(sd) + else: + device = int(d) + assert device < torch.cuda.device_count() + devices.append(device) + + logger.info('using devices {}'.format( + ', '.join([str(d) for d in devices]))) + + return devices + + +def extant_file(x): + """ + 'Type' for argparse - checks that file exists but does not open. + """ + if not os.path.exists(x): + # Argparse uses the ArgumentTypeError to give a rejection message like: + # error: argument input: x does not exist + raise argparse.ArgumentTypeError("{0} does not exist".format(x)) + return x + + +def link_file(src, target): + if os.path.isdir(target) or os.path.isfile(target): + os.remove(target) + os.system('ln -s {} {}'.format(src, target)) + + +def ensure_dir(path): + if not os.path.isdir(path): + os.makedirs(path) + + +def _dbg_interactive(var, value): + from IPython import embed + embed() + + +def check_keys(model, pretrained_state_dict): + ckpt_keys = set(pretrained_state_dict.keys()) + model_keys = set(model.state_dict().keys()) + used_pretrained_keys = model_keys & ckpt_keys + unused_pretrained_keys = ckpt_keys - model_keys + missing_keys = model_keys - ckpt_keys + + print('missing keys:{}'.format(missing_keys)) + print('unused checkpoint keys:{}'.format(unused_pretrained_keys)) + # print('used keys:{}'.format(used_pretrained_keys)) + assert len(used_pretrained_keys) > 0, 'load NONE from pretrained checkpoint' + return True + +def remove_prefix(state_dict, prefix): + ''' + Old style model is stored with all names of parameters share common prefix 'module.' + ''' + print('remove prefix \'{}\''.format(prefix)) + f = lambda x: x.split(prefix, 1)[-1] if x.startswith(prefix) else x + return {f(key): value for key, value in state_dict.items()} + +def load_pretrain(model, pretrained_path): + print('load pretrained model from {}'.format(pretrained_path)) + + device = torch.cuda.current_device() + pretrained_dict = torch.load(pretrained_path, map_location=lambda storage, loc: storage.cuda(device)) + + if "state_dict" in pretrained_dict.keys(): + pretrained_dict = remove_prefix(pretrained_dict['state_dict'], 'module.') + else: + pretrained_dict = remove_prefix(pretrained_dict, 'module.') + check_keys(model, pretrained_dict) + model.load_state_dict(pretrained_dict, strict=False) + return model + +def nanmean(x): + """Computes the arithmetic mean ignoring any NaNs.""" + return torch.mean(x[x == x]) + +# computes confusion matrix +def _fast_hist(true, pred, num_classes): + mask = (true >= 0) & (true < num_classes) + hist = torch.bincount( + num_classes * true[mask] + pred[mask], + minlength=num_classes ** 2, + ).reshape(num_classes, num_classes).float() + return hist + +def compute_hist(pred, lb, n_classes, ignore_label): + n_classes = n_classes + keep = torch.logical_not(lb == ignore_label) + merge = pred[keep] * n_classes + lb[keep] + hist = torch.bincount(merge, minlength=n_classes ** 2) + hist = hist.reshape((n_classes, n_classes)).float() + return hist + +@numba.jit +def compute_hist_np(pred, lb, n_classes, ignore_label): + n_classes = n_classes + keep = np.logical_not(lb == ignore_label) + merge = pred[keep] * n_classes + lb[keep] + hist = np.bincount(merge, minlength=n_classes ** 2) + hist = hist.reshape((n_classes, n_classes)) + return hist + +# computes IoU based on confusion matrix +def jaccard_index(hist): + """Computes the Jaccard index, a.k.a the Intersection over Union (IoU). + Args: + hist: confusion matrix. + Returns: + avg_jacc: the average per-class jaccard index. + """ + A_inter_B = torch.diag(hist) + A = hist.sum(dim=1) + B = hist.sum(dim=0) + jaccard = A_inter_B / (A + B - A_inter_B + EPS) + avg_jacc = nanmean(jaccard) #the mean of jaccard without NaNs + return avg_jacc, jaccard + +def check_keys(model, pretrained_state_dict): + ckpt_keys = set(pretrained_state_dict.keys()) + model_keys = set(model.state_dict().keys()) + used_pretrained_keys = model_keys & ckpt_keys + unused_pretrained_keys = ckpt_keys - model_keys + missing_keys = model_keys - ckpt_keys + + print('missing keys:{}'.format(missing_keys)) + print('unused checkpoint keys:{}'.format(unused_pretrained_keys)) + # print('used keys:{}'.format(used_pretrained_keys)) + assert len(used_pretrained_keys) > 0, 'load NONE from pretrained checkpoint' + return True + +def remove_prefix(state_dict, prefix): + ''' + Old style model is stored with all names of parameters share common prefix 'module.' + ''' + print('remove prefix \'{}\''.format(prefix)) + f = lambda x: x.split(prefix, 1)[-1] if x.startswith(prefix) else x + return {f(key): value for key, value in state_dict.items()} + +def load_pretrain(model, pretrained_path): + print('load pretrained model from {}'.format(pretrained_path)) + + device = torch.cuda.current_device() + pretrained_dict = torch.load(pretrained_path, map_location=lambda storage, loc: storage.cuda(device)) + if "state_dict" in pretrained_dict.keys(): + pretrained_dict = remove_prefix(pretrained_dict['state_dict'], 'module.') + # new_dict = {} + # for k in pretrained_dict.keys(): + # if "heads" in k: + # continue + # else: + # new_dict[k] = pretrained_dict[k] + # pretrained_dict = new_dict + else: + pretrained_dict = remove_prefix(pretrained_dict, 'module.') + check_keys(model, pretrained_dict) + model.load_state_dict(pretrained_dict, strict=False) + return model \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/visualize.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/visualize.py new file mode 100644 index 000000000..08eed2557 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/utils/visualize.py @@ -0,0 +1,89 @@ +import numpy as np +import cv2 +import scipy.io as sio + + +def set_img_color(colors, background, img, gt, show255=False, weight_foreground=0.55): + origin = np.array(img) + for i in range(len(colors)): + if i != background: + img[np.where(gt == i)] = colors[i] + if show255: + img[np.where(gt == 255)] = 0 + cv2.addWeighted(img, weight_foreground, origin, (1 - weight_foreground), 0, img) + return img + + +def show_prediction(colors, background, img, pred, weight_foreground=1): + im = np.array(img, np.uint8) + set_img_color(colors, background, im, pred, weight_foreground=weight_foreground) + final = np.array(im) + return final + + +def show_img(colors, background, img, clean, gt, *pds): + im1 = np.array(img, np.uint8) + # set_img_color(colors, background, im1, clean) + final = np.array(im1) + # the pivot black bar + pivot = np.zeros((im1.shape[0], 15, 3), dtype=np.uint8) + for pd in pds: + im = np.array(img, np.uint8) + # pd[np.where(gt == 255)] = 255 + set_img_color(colors, background, im, pd) + final = np.column_stack((final, pivot)) + final = np.column_stack((final, im)) + + im = np.array(img, np.uint8) + set_img_color(colors, background, im, gt, True) + final = np.column_stack((final, pivot)) + final = np.column_stack((final, im)) + return final + + +def get_colors(class_num): + colors = [] + for i in range(class_num): + colors.append((np.random.random((1, 3)) * 255).tolist()[0]) + + return colors + + +def get_ade_colors(): + colors = sio.loadmat('./color150.mat')['colors'] + colors = colors[:, ::-1, ] + colors = np.array(colors).astype(int).tolist() + colors.insert(0, [0, 0, 0]) + + return colors + + +def print_iou(iu, mean_pixel_acc, class_names=None, show_no_back=False, + no_print=False): + n = iu.size + lines = [] + for i in range(n): + if class_names is None: + cls = 'Class %d:' % (i + 1) + else: + cls = '%d %s' % (i + 1, class_names[i]) + lines.append('%-8s\t%.3f%%' % (cls, iu[i] * 100)) + mean_IU = np.nanmean(iu) + # mean_IU_no_back = np.nanmean(iu[1:]) + mean_IU_no_back = np.nanmean(iu[:-1]) + if show_no_back: + lines.append( + '---------------------------- %-8s\t%.3f%%\t%-8s\t%.3f%%\t%-8s\t%.3f%%' % ( + 'mean_IU', mean_IU * 100, 'mean_IU_no_back', + mean_IU_no_back * 100, + 'mean_pixel_ACC', mean_pixel_acc * 100)) + else: + print(mean_pixel_acc) + lines.append( + '---------------------------- %-8s\t%.3f%%\t%-8s\t%.3f%%' % ( + 'mean_IU', mean_IU * 100, 'mean_pixel_ACC', + mean_pixel_acc * 100)) + line = "\n".join(lines) + if not no_print: + print(line) + return line diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/panoptic_coco_categories.json b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/panoptic_coco_categories.json new file mode 100644 index 000000000..673a19e5c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/panoptic_coco_categories.json @@ -0,0 +1 @@ +[{"supercategory": "person", "color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"}, {"supercategory": "vehicle", "color": [119, 11, 32], "isthing": 1, "id": 2, "name": "bicycle"}, {"supercategory": "vehicle", "color": [0, 0, 142], "isthing": 1, "id": 3, "name": "car"}, {"supercategory": "vehicle", "color": [0, 0, 230], "isthing": 1, "id": 4, "name": "motorcycle"}, {"supercategory": "vehicle", "color": [106, 0, 228], "isthing": 1, "id": 5, "name": "airplane"}, {"supercategory": "vehicle", "color": [0, 60, 100], "isthing": 1, "id": 6, "name": "bus"}, {"supercategory": "vehicle", "color": [0, 80, 100], "isthing": 1, "id": 7, "name": "train"}, {"supercategory": "vehicle", "color": [0, 0, 70], "isthing": 1, "id": 8, "name": "truck"}, {"supercategory": "vehicle", "color": [0, 0, 192], "isthing": 1, "id": 9, "name": "boat"}, {"supercategory": "outdoor", "color": [250, 170, 30], "isthing": 1, "id": 10, "name": "traffic light"}, {"supercategory": "outdoor", "color": [100, 170, 30], "isthing": 1, "id": 11, "name": "fire hydrant"}, {"supercategory": "outdoor", "color": [220, 220, 0], "isthing": 1, "id": 13, "name": "stop sign"}, {"supercategory": "outdoor", "color": [175, 116, 175], "isthing": 1, "id": 14, "name": "parking meter"}, {"supercategory": "outdoor", "color": [250, 0, 30], "isthing": 1, "id": 15, "name": "bench"}, {"supercategory": "animal", "color": [165, 42, 42], "isthing": 1, "id": 16, "name": "bird"}, {"supercategory": "animal", "color": [255, 77, 255], "isthing": 1, "id": 17, "name": "cat"}, {"supercategory": "animal", "color": [0, 226, 252], "isthing": 1, "id": 18, "name": "dog"}, {"supercategory": "animal", "color": [182, 182, 255], "isthing": 1, "id": 19, "name": "horse"}, {"supercategory": "animal", "color": [0, 82, 0], "isthing": 1, "id": 20, "name": "sheep"}, {"supercategory": "animal", "color": [120, 166, 157], "isthing": 1, "id": 21, "name": "cow"}, {"supercategory": "animal", "color": [110, 76, 0], "isthing": 1, "id": 22, "name": "elephant"}, {"supercategory": "animal", "color": [174, 57, 255], "isthing": 1, "id": 23, "name": "bear"}, {"supercategory": "animal", "color": [199, 100, 0], "isthing": 1, "id": 24, "name": "zebra"}, {"supercategory": "animal", "color": [72, 0, 118], "isthing": 1, "id": 25, "name": "giraffe"}, {"supercategory": "accessory", "color": [255, 179, 240], "isthing": 1, "id": 27, "name": "backpack"}, {"supercategory": "accessory", "color": [0, 125, 92], "isthing": 1, "id": 28, "name": "umbrella"}, {"supercategory": "accessory", "color": [209, 0, 151], "isthing": 1, "id": 31, "name": "handbag"}, {"supercategory": "accessory", "color": [188, 208, 182], "isthing": 1, "id": 32, "name": "tie"}, {"supercategory": "accessory", "color": [0, 220, 176], "isthing": 1, "id": 33, "name": "suitcase"}, {"supercategory": "sports", "color": [255, 99, 164], "isthing": 1, "id": 34, "name": "frisbee"}, {"supercategory": "sports", "color": [92, 0, 73], "isthing": 1, "id": 35, "name": "skis"}, {"supercategory": "sports", "color": [133, 129, 255], "isthing": 1, "id": 36, "name": "snowboard"}, {"supercategory": "sports", "color": [78, 180, 255], "isthing": 1, "id": 37, "name": "sports ball"}, {"supercategory": "sports", "color": [0, 228, 0], "isthing": 1, "id": 38, "name": "kite"}, {"supercategory": "sports", "color": [174, 255, 243], "isthing": 1, "id": 39, "name": "baseball bat"}, {"supercategory": "sports", "color": [45, 89, 255], "isthing": 1, "id": 40, "name": "baseball glove"}, {"supercategory": "sports", "color": [134, 134, 103], "isthing": 1, "id": 41, "name": "skateboard"}, {"supercategory": "sports", "color": [145, 148, 174], "isthing": 1, "id": 42, "name": "surfboard"}, {"supercategory": "sports", "color": [255, 208, 186], "isthing": 1, "id": 43, "name": "tennis racket"}, {"supercategory": "kitchen", "color": [197, 226, 255], "isthing": 1, "id": 44, "name": "bottle"}, {"supercategory": "kitchen", "color": [171, 134, 1], "isthing": 1, "id": 46, "name": "wine glass"}, {"supercategory": "kitchen", "color": [109, 63, 54], "isthing": 1, "id": 47, "name": "cup"}, {"supercategory": "kitchen", "color": [207, 138, 255], "isthing": 1, "id": 48, "name": "fork"}, {"supercategory": "kitchen", "color": [151, 0, 95], "isthing": 1, "id": 49, "name": "knife"}, {"supercategory": "kitchen", "color": [9, 80, 61], "isthing": 1, "id": 50, "name": "spoon"}, {"supercategory": "kitchen", "color": [84, 105, 51], "isthing": 1, "id": 51, "name": "bowl"}, {"supercategory": "food", "color": [74, 65, 105], "isthing": 1, "id": 52, "name": "banana"}, {"supercategory": "food", "color": [166, 196, 102], "isthing": 1, "id": 53, "name": "apple"}, {"supercategory": "food", "color": [208, 195, 210], "isthing": 1, "id": 54, "name": "sandwich"}, {"supercategory": "food", "color": [255, 109, 65], "isthing": 1, "id": 55, "name": "orange"}, {"supercategory": "food", "color": [0, 143, 149], "isthing": 1, "id": 56, "name": "broccoli"}, {"supercategory": "food", "color": [179, 0, 194], "isthing": 1, "id": 57, "name": "carrot"}, {"supercategory": "food", "color": [209, 99, 106], "isthing": 1, "id": 58, "name": "hot dog"}, {"supercategory": "food", "color": [5, 121, 0], "isthing": 1, "id": 59, "name": "pizza"}, {"supercategory": "food", "color": [227, 255, 205], "isthing": 1, "id": 60, "name": "donut"}, {"supercategory": "food", "color": [147, 186, 208], "isthing": 1, "id": 61, "name": "cake"}, {"supercategory": "furniture", "color": [153, 69, 1], "isthing": 1, "id": 62, "name": "chair"}, {"supercategory": "furniture", "color": [3, 95, 161], "isthing": 1, "id": 63, "name": "couch"}, {"supercategory": "furniture", "color": [163, 255, 0], "isthing": 1, "id": 64, "name": "potted plant"}, {"supercategory": "furniture", "color": [119, 0, 170], "isthing": 1, "id": 65, "name": "bed"}, {"supercategory": "furniture", "color": [0, 182, 199], "isthing": 1, "id": 67, "name": "dining table"}, {"supercategory": "furniture", "color": [0, 165, 120], "isthing": 1, "id": 70, "name": "toilet"}, {"supercategory": "electronic", "color": [183, 130, 88], "isthing": 1, "id": 72, "name": "tv"}, {"supercategory": "electronic", "color": [95, 32, 0], "isthing": 1, "id": 73, "name": "laptop"}, {"supercategory": "electronic", "color": [130, 114, 135], "isthing": 1, "id": 74, "name": "mouse"}, {"supercategory": "electronic", "color": [110, 129, 133], "isthing": 1, "id": 75, "name": "remote"}, {"supercategory": "electronic", "color": [166, 74, 118], "isthing": 1, "id": 76, "name": "keyboard"}, {"supercategory": "electronic", "color": [219, 142, 185], "isthing": 1, "id": 77, "name": "cell phone"}, {"supercategory": "appliance", "color": [79, 210, 114], "isthing": 1, "id": 78, "name": "microwave"}, {"supercategory": "appliance", "color": [178, 90, 62], "isthing": 1, "id": 79, "name": "oven"}, {"supercategory": "appliance", "color": [65, 70, 15], "isthing": 1, "id": 80, "name": "toaster"}, {"supercategory": "appliance", "color": [127, 167, 115], "isthing": 1, "id": 81, "name": "sink"}, {"supercategory": "appliance", "color": [59, 105, 106], "isthing": 1, "id": 82, "name": "refrigerator"}, {"supercategory": "indoor", "color": [142, 108, 45], "isthing": 1, "id": 84, "name": "book"}, {"supercategory": "indoor", "color": [196, 172, 0], "isthing": 1, "id": 85, "name": "clock"}, {"supercategory": "indoor", "color": [95, 54, 80], "isthing": 1, "id": 86, "name": "vase"}, {"supercategory": "indoor", "color": [128, 76, 255], "isthing": 1, "id": 87, "name": "scissors"}, {"supercategory": "indoor", "color": [201, 57, 1], "isthing": 1, "id": 88, "name": "teddy bear"}, {"supercategory": "indoor", "color": [246, 0, 122], "isthing": 1, "id": 89, "name": "hair drier"}, {"supercategory": "indoor", "color": [191, 162, 208], "isthing": 1, "id": 90, "name": "toothbrush"}, {"supercategory": "textile", "color": [255, 255, 128], "isthing": 0, "id": 92, "name": "banner"}, {"supercategory": "textile", "color": [147, 211, 203], "isthing": 0, "id": 93, "name": "blanket"}, {"supercategory": "building", "color": [150, 100, 100], "isthing": 0, "id": 95, "name": "bridge"}, {"supercategory": "raw-material", "color": [168, 171, 172], "isthing": 0, "id": 100, "name": "cardboard"}, {"supercategory": "furniture-stuff", "color": [146, 112, 198], "isthing": 0, "id": 107, "name": "counter"}, {"supercategory": "textile", "color": [210, 170, 100], "isthing": 0, "id": 109, "name": "curtain"}, {"supercategory": "furniture-stuff", "color": [92, 136, 89], "isthing": 0, "id": 112, "name": "door-stuff"}, {"supercategory": "floor", "color": [218, 88, 184], "isthing": 0, "id": 118, "name": "floor-wood"}, {"supercategory": "plant", "color": [241, 129, 0], "isthing": 0, "id": 119, "name": "flower"}, {"supercategory": "food-stuff", "color": [217, 17, 255], "isthing": 0, "id": 122, "name": "fruit"}, {"supercategory": "ground", "color": [124, 74, 181], "isthing": 0, "id": 125, "name": "gravel"}, {"supercategory": "building", "color": [70, 70, 70], "isthing": 0, "id": 128, "name": "house"}, {"supercategory": "furniture-stuff", "color": [255, 228, 255], "isthing": 0, "id": 130, "name": "light"}, {"supercategory": "furniture-stuff", "color": [154, 208, 0], "isthing": 0, "id": 133, "name": "mirror-stuff"}, {"supercategory": "structural", "color": [193, 0, 92], "isthing": 0, "id": 138, "name": "net"}, {"supercategory": "textile", "color": [76, 91, 113], "isthing": 0, "id": 141, "name": "pillow"}, {"supercategory": "ground", "color": [255, 180, 195], "isthing": 0, "id": 144, "name": "platform"}, {"supercategory": "ground", "color": [106, 154, 176], "isthing": 0, "id": 145, "name": "playingfield"}, {"supercategory": "ground", "color": [230, 150, 140], "isthing": 0, "id": 147, "name": "railroad"}, {"supercategory": "water", "color": [60, 143, 255], "isthing": 0, "id": 148, "name": "river"}, {"supercategory": "ground", "color": [128, 64, 128], "isthing": 0, "id": 149, "name": "road"}, {"supercategory": "building", "color": [92, 82, 55], "isthing": 0, "id": 151, "name": "roof"}, {"supercategory": "ground", "color": [254, 212, 124], "isthing": 0, "id": 154, "name": "sand"}, {"supercategory": "water", "color": [73, 77, 174], "isthing": 0, "id": 155, "name": "sea"}, {"supercategory": "furniture-stuff", "color": [255, 160, 98], "isthing": 0, "id": 156, "name": "shelf"}, {"supercategory": "ground", "color": [255, 255, 255], "isthing": 0, "id": 159, "name": "snow"}, {"supercategory": "furniture-stuff", "color": [104, 84, 109], "isthing": 0, "id": 161, "name": "stairs"}, {"supercategory": "building", "color": [169, 164, 131], "isthing": 0, "id": 166, "name": "tent"}, {"supercategory": "textile", "color": [225, 199, 255], "isthing": 0, "id": 168, "name": "towel"}, {"supercategory": "wall", "color": [137, 54, 74], "isthing": 0, "id": 171, "name": "wall-brick"}, {"supercategory": "wall", "color": [135, 158, 223], "isthing": 0, "id": 175, "name": "wall-stone"}, {"supercategory": "wall", "color": [7, 246, 231], "isthing": 0, "id": 176, "name": "wall-tile"}, {"supercategory": "wall", "color": [107, 255, 200], "isthing": 0, "id": 177, "name": "wall-wood"}, {"supercategory": "water", "color": [58, 41, 149], "isthing": 0, "id": 178, "name": "water-other"}, {"supercategory": "window", "color": [183, 121, 142], "isthing": 0, "id": 180, "name": "window-blind"}, {"supercategory": "window", "color": [255, 73, 97], "isthing": 0, "id": 181, "name": "window-other"}, {"supercategory": "plant", "color": [107, 142, 35], "isthing": 0, "id": 184, "name": "tree-merged"}, {"supercategory": "structural", "color": [190, 153, 153], "isthing": 0, "id": 185, "name": "fence-merged"}, {"supercategory": "ceiling", "color": [146, 139, 141], "isthing": 0, "id": 186, "name": "ceiling-merged"}, {"supercategory": "sky", "color": [70, 130, 180], "isthing": 0, "id": 187, "name": "sky-other-merged"}, {"supercategory": "furniture-stuff", "color": [134, 199, 156], "isthing": 0, "id": 188, "name": "cabinet-merged"}, {"supercategory": "furniture-stuff", "color": [209, 226, 140], "isthing": 0, "id": 189, "name": "table-merged"}, {"supercategory": "floor", "color": [96, 36, 108], "isthing": 0, "id": 190, "name": "floor-other-merged"}, {"supercategory": "ground", "color": [96, 96, 96], "isthing": 0, "id": 191, "name": "pavement-merged"}, {"supercategory": "solid", "color": [64, 170, 64], "isthing": 0, "id": 192, "name": "mountain-merged"}, {"supercategory": "plant", "color": [152, 251, 152], "isthing": 0, "id": 193, "name": "grass-merged"}, {"supercategory": "ground", "color": [208, 229, 228], "isthing": 0, "id": 194, "name": "dirt-merged"}, {"supercategory": "raw-material", "color": [206, 186, 171], "isthing": 0, "id": 195, "name": "paper-merged"}, {"supercategory": "food-stuff", "color": [152, 161, 64], "isthing": 0, "id": 196, "name": "food-other-merged"}, {"supercategory": "building", "color": [116, 112, 0], "isthing": 0, "id": 197, "name": "building-other-merged"}, {"supercategory": "solid", "color": [0, 114, 143], "isthing": 0, "id": 198, "name": "rock-merged"}, {"supercategory": "wall", "color": [102, 102, 156], "isthing": 0, "id": 199, "name": "wall-other-merged"}, {"supercategory": "textile", "color": [250, 141, 255], "isthing": 0, "id": 200, "name": "rug-merged"}] diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_cityscapes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_cityscapes.py new file mode 100644 index 000000000..583d0c622 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_cityscapes.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python2 +''' +Visualization demo for panoptic COCO sample_data +The code shows an example of color generation for panoptic data (with +"generate_new_colors" set to True). For each segment distinct color is used in +a way that it close to the color of corresponding semantic class. +''' +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import os, sys +import numpy as np +import json +import cv2 +import os + +import PIL.Image as Image +import matplotlib.pyplot as plt +from skimage.segmentation import find_boundaries + +from panopticapi.utils import IdGenerator, rgb2id + +# whether from the PNG are used or new colors are generated +generate_new_colors = True + +json_file = './panoptic_cityscapes_mul2/panoptic/predictions.json' +segmentations_folder = './panoptic_cityscapes_mul2/panoptic/predictions/' +img_folder = '/home2/hongyuan/data/cityscapes/leftImg8bit/val/' +panoptic_coco_categories = './panoptic_coco_categories.json' +output_dir = 'cityscapes_vis_results' + +os.makedirs(output_dir, exist_ok=True) + +with open(json_file, 'r') as f: + coco_d = json.load(f) + +# ann = np.random.choice(coco_d['annotations']) + +with open(panoptic_coco_categories, 'r') as f: + categories_list = json.load(f) +categegories = {category['id']: category for category in categories_list} + +# find input img that correspond to the annotation +img = None +# for image_info in coco_d['images']: +for image_info in coco_d['images']: + for ann in coco_d['annotations']: + if image_info['id'] == ann['image_id']: + try: + img = np.array( + Image.open(os.path.join(img_folder, image_info['file_name'].split('_')[0], image_info['file_name'].split('gtFine_leftImg8bit.png')[0]+'leftImg8bit.png')) + ) + except: + print("Undable to find correspoding input image.") + break + + segmentation = np.array( + Image.open(os.path.join(segmentations_folder, ann['file_name'])), + dtype=np.uint8 + ) + segmentation_id = rgb2id(segmentation) + # find segments boundaries + boundaries = find_boundaries(segmentation_id, mode='thick') + + if generate_new_colors: + segmentation[:, :, :] = 0 + color_generator = IdGenerator(categegories) + for segment_info in ann['segments_info']: + try: + color = color_generator.get_color(segment_info['category_id']) + mask = segmentation_id == segment_info['id'] + segmentation[mask] = color + except: + pass + + # depict boundaries + segmentation[boundaries] = [0, 0, 0] + if img.shape[:2] == segmentation.shape[:2]: + pass + else: + print('img: {} shape error! img shape: {} seg shape: {}'.format(ann['image_id'], img.shape[:2], segmentation.shape[:2])) + continue + + if len(img.shape) == 2: + img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + try: + segmentation = cv2.addWeighted(img, 0.6, segmentation, 0.4, 0) + except: + import pdb; pdb.set_trace() + cv2.imwrite(os.path.join(output_dir, '{}.jpg').format(ann['image_id']), img[:, :, ::-1]) + cv2.imwrite(os.path.join(output_dir, '{}_mask.jpg').format(ann['image_id']), segmentation[:, :, ::-1]) + #if img is None: + # plt.figure() + # plt.imshow(segmentation) + # plt.axis('off') + #else: + # plt.figure(figsize=(9, 5)) + # plt.subplot(121) + # plt.imshow(img) + # plt.axis('off') + # plt.subplot(122) + # plt.imshow(segmentation) + # plt.axis('off') + # plt.tight_layout() + #plt.show() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_coco.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_coco.py new file mode 100644 index 000000000..c74739553 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/tools/vis/vis_coco.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python2 +''' +Visualization demo for panoptic COCO sample_data +The code shows an example of color generation for panoptic data (with +"generate_new_colors" set to True). For each segment distinct color is used in +a way that it close to the color of corresponding semantic class. +''' +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals +import os, sys +import numpy as np +import json +import cv2 +import os + +import PIL.Image as Image +import matplotlib.pyplot as plt +from skimage.segmentation import find_boundaries + +from panopticapi.utils import IdGenerator, rgb2id + +# whether from the PNG are used or new colors are generated +generate_new_colors = True + +json_file = './panoptic_coco_mul2/panoptic/predictions.json' +segmentations_folder = './panoptic_coco_mul2/panoptic/predictions/' +img_folder = '/home2/hongyuan/data/coco2017/val2017/' +panoptic_coco_categories = './panoptic_coco_categories.json' +output_dir = 'coco_vis_results' + +os.makedirs(output_dir, exist_ok=True) + +with open(json_file, 'r') as f: + coco_d = json.load(f) + +# ann = np.random.choice(coco_d['annotations']) + +with open(panoptic_coco_categories, 'r') as f: + categories_list = json.load(f) +categegories = {category['id']: category for category in categories_list} + +# find input img that correspond to the annotation +img = None +# for image_info in coco_d['images']: +for image_info in coco_d['images']: + for ann in coco_d['annotations']: + if image_info['id'] == ann['image_id']: + try: + img = np.array( + Image.open(os.path.join(img_folder, image_info['file_name'])) + ) + except: + print("Undable to find correspoding input image.") + break + + segmentation = np.array( + Image.open(os.path.join(segmentations_folder, ann['file_name'])), + dtype=np.uint8 + ) + segmentation_id = rgb2id(segmentation) + # find segments boundaries + boundaries = find_boundaries(segmentation_id, mode='thick') + + if generate_new_colors: + segmentation[:, :, :] = 0 + color_generator = IdGenerator(categegories) + for segment_info in ann['segments_info']: + color = color_generator.get_color(segment_info['category_id']) + mask = segmentation_id == segment_info['id'] + segmentation[mask] = color + + # depict boundaries + segmentation[boundaries] = [0, 0, 0] + if img.shape[:2] == segmentation.shape[:2]: + pass + else: + print('img: {} shape error! img shape: {} seg shape: {}'.format(ann['image_id'], img.shape[:2], segmentation.shape[:2])) + continue + + if len(img.shape) == 2: + img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + try: + segmentation = cv2.addWeighted(img, 0.6, segmentation, 0.4, 0) + except: + import pdb; pdb.set_trace() + cv2.imwrite(os.path.join(output_dir, '{}.jpg').format(ann['image_id']), img[:, :, ::-1]) + cv2.imwrite(os.path.join(output_dir, '{}_mask.jpg').format(ann['image_id']), segmentation[:, :, ::-1]) + #if img is None: + # plt.figure() + # plt.imshow(segmentation) + # plt.axis('off') + #else: + # plt.figure(figsize=(9, 5)) + # plt.subplot(121) + # plt.imshow(img) + # plt.axis('off') + # plt.subplot(122) + # plt.imshow(segmentation) + # plt.axis('off') + # plt.tight_layout() + #plt.show() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/_init_paths.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/_init_paths.py new file mode 100644 index 000000000..d8237980f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/_init_paths.py @@ -0,0 +1,19 @@ +# ------------------------------------------------------------------------------ +# Adds `segmentation` package into Python path. +# Written by Bowen Cheng (bcheng9@illinois.edu) +# ------------------------------------------------------------------------------ + +import os.path as osp +import sys + + +def add_path(path): + if path not in sys.path: + sys.path.insert(0, path) + + +this_dir = osp.dirname(__file__) +lib_path = osp.join(this_dir, '..') +add_path(lib_path) +add_path(this_dir) +add_path(osp.join(lib_path, 'tools')) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/att_sa.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/att_sa.py new file mode 100644 index 000000000..6761d5b80 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/att_sa.py @@ -0,0 +1,231 @@ + +import torch +import math +import torch.nn as nn +import torch.nn.functional as F +from torch.autograd import Variable +import numpy as np +from torch import nn, einsum + +from einops import rearrange + + +def pair(x): + return (x, x) if not isinstance(x, tuple) else x + +def expand_dim(t, dim, k): + t = t.unsqueeze(dim = dim) + expand_shape = [-1] * len(t.shape) + expand_shape[dim] = k + return t.expand(*expand_shape) + +def rel_to_abs(x): + b, h, l, _, device, dtype = *x.shape, x.device, x.dtype + dd = {'device': device, 'dtype': dtype} + col_pad = torch.zeros((b, h, l, 1), **dd) + x = torch.cat((x, col_pad), dim = 3) + flat_x = rearrange(x, 'b h l c -> b h (l c)') + flat_pad = torch.zeros((b, h, l - 1), **dd) + flat_x_padded = torch.cat((flat_x, flat_pad), dim = 2) + final_x = flat_x_padded.reshape(b, h, l + 1, 2 * l - 1) + final_x = final_x[:, :, :l, (l-1):] + return final_x + +def relative_logits_1d(q, rel_k): + b, heads, h, w, dim = q.shape + logits = einsum('b h x y d, r d -> b h x y r', q, rel_k) + logits = rearrange(logits, 'b h x y r -> b (h x) y r') + logits = rel_to_abs(logits) + logits = logits.reshape(b, heads, h, w, w) + logits = expand_dim(logits, dim = 3, k = h) + return logits + +# positional embeddings + +class AbsPosEmb(nn.Module): + def __init__( + self, + fmap_size, + dim_head + ): + super().__init__() + height, width = pair(fmap_size) + scale = dim_head ** -0.5 + self.height = nn.Parameter(torch.randn(height, dim_head) * scale) + self.width = nn.Parameter(torch.randn(width, dim_head) * scale) + + def forward(self, q): + emb = rearrange(self.height, 'h d -> h () d') + rearrange(self.width, 'w d -> () w d') + emb = rearrange(emb, ' h w d -> (h w) d') + logits = einsum('b h i d, j d -> b h i j', q, emb) + return logits + +class RelPosEmb(nn.Module): + def __init__( + self, + fmap_size, + dim_head + ): + super().__init__() + height, width = pair(fmap_size) + scale = dim_head ** -0.5 + self.fmap_size = fmap_size + self.rel_height = nn.Parameter(torch.randn(height * 2 - 1, dim_head) * scale) + self.rel_width = nn.Parameter(torch.randn(width * 2 - 1, dim_head) * scale) + + def forward(self, q): + h, w = self.fmap_size + + q = rearrange(q, 'b h (x y) d -> b h x y d', x = h, y = w) + rel_logits_w = relative_logits_1d(q, self.rel_width) + rel_logits_w = rearrange(rel_logits_w, 'b h x i y j-> b h (x y) (i j)') + + q = rearrange(q, 'b h x y d -> b h y x d') + rel_logits_h = relative_logits_1d(q, self.rel_height) + rel_logits_h = rearrange(rel_logits_h, 'b h x i y j -> b h (y x) (j i)') + return rel_logits_w + rel_logits_h + +# classes + +class Attention(nn.Module): + def __init__( + self, + *, + dim, + fmap_size, + heads = 4, + dim_head = 128, + rel_pos_emb = False + ): + super().__init__() + self.heads = heads + self.scale = dim_head ** -0.5 + inner_dim = heads * dim_head + + self.to_qkv = nn.Conv2d(dim, inner_dim * 3, 1, bias = False) + + rel_pos_class = AbsPosEmb if not rel_pos_emb else RelPosEmb + self.pos_emb = rel_pos_class(fmap_size, dim_head) + + def forward(self, fmap): + heads, b, c, h, w = self.heads, *fmap.shape + + q, k, v = self.to_qkv(fmap).chunk(3, dim = 1) + q, k, v = map(lambda t: rearrange(t, 'b (h d) x y -> b h (x y) d', h = heads), (q, k, v)) + + q *= self.scale + + sim = einsum('b h i d, b h j d -> b h i j', q, k) + sim += self.pos_emb(q) + + attn = sim.softmax(dim = -1) + + out = einsum('b h i j, b h j d -> b h i d', attn, v) + out = rearrange(out, 'b h (x y) d -> b (h d) x y', x = h, y = w) + return out + +class Self_Attn(nn.Module): + def __init__( + self, + *, + dim, + fmap_size, + dim_out, + proj_factor, + downsample, + heads = 4, + dim_head = 128, + rel_pos_emb = False, + activation = nn.ReLU(inplace=True) + ): + super().__init__() + + # shortcut + proj_factor = 1 + self.stride = 2 if downsample else 1 + + if dim != dim_out or downsample: + kernel_size, stride, padding = (3, 2, 1) if downsample else (1, 1, 0) + + self.shortcut = nn.Sequential( + nn.Conv2d(dim, dim_out, kernel_size, stride = stride, padding = padding, bias = False), + nn.BatchNorm2d(dim_out), + activation + ) + else: + self.shortcut = nn.Identity() + + # contraction and expansion + + attn_dim_in = dim_out // proj_factor + # attn_dim_out = heads * dim_head + attn_dim_out = attn_dim_in + + self.net = nn.Sequential( + nn.Conv2d(dim, attn_dim_in, 1, bias = False), + nn.BatchNorm2d(attn_dim_in), + activation, + ATT(attn_dim_in), + # Attention( + # dim = attn_dim_in, + # fmap_size = fmap_size, + # heads = heads, + # dim_head = dim_head, + # rel_pos_emb = rel_pos_emb + # ), + nn.AvgPool2d((2, 2)) if downsample else nn.Identity(), + nn.BatchNorm2d(attn_dim_out), + activation, + nn.Conv2d(attn_dim_out, dim_out, 1, bias = False), + nn.BatchNorm2d(dim_out) + ) + + # init last batch norm gamma to zero + + nn.init.zeros_(self.net[-1].weight) + + # final activation + + self.activation = activation + + def forward(self, x): + shortcut = self.shortcut(x) + out = F.interpolate(x, size=(int(x.size(2))//2, int(x.size(3))//2), mode='bilinear', align_corners=True) + out = self.net(out) + if self.stride == 1: + out = F.interpolate(out, size=(int(x.size(2)), int(x.size(3))), mode='bilinear', align_corners=True) + out += shortcut + return self.activation(out) + +class ATT(nn.Module): + """ Self attention Layer""" + def __init__(self, in_dim): + super(ATT, self).__init__() + self.chanel_in = in_dim + + self.query_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim//8 , kernel_size= 1) + self.key_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim//8 , kernel_size= 1) + self.value_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim , kernel_size= 1) + self.gamma = nn.Parameter(torch.zeros(1)) + + self.softmax = nn.Softmax(dim=-1) # + def forward(self,x): + """ + inputs : + x : input feature maps( B X C X W X H) + returns : + out : self attention value + input feature + attention: B X N X N (N is Width*Height) + """ + m_batchsize, C, width, height = x.size() + proj_query = self.query_conv(x).view(m_batchsize, -1,width*height).permute(0,2,1) # B X CX(N) + proj_key = self.key_conv(x).view(m_batchsize,-1, width*height) # B X C x (*W*H) + energy = torch.bmm(proj_query, proj_key) # transpose check + attention = self.softmax(energy) # BX (N) X (N) + proj_value = self.value_conv(x).view(m_batchsize,-1,width*height) # B X C X N + + out = torch.bmm(proj_value, attention.permute(0,2,1) ) + out = out.view(m_batchsize, C, width,height) + + out = self.gamma*out + x + return out \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/builder.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/builder.py new file mode 100644 index 000000000..028463f90 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/builder.py @@ -0,0 +1,872 @@ +import torch +import logging +import math +import re +from collections.__init__ import OrderedDict +from copy import deepcopy +from typing import Tuple, Optional, List + +import torch.nn as nn +import numpy as np +from functools import partial +from itertools import repeat +from torch._six import container_abcs +# from timm.models.efficientnet_blocks import * + + +def swish(x, inplace: bool = False): + """Swish - Described in: https://arxiv.org/abs/1710.05941 + """ + return x.mul_(x.sigmoid()) if inplace else x.mul(x.sigmoid()) + +class Swish(nn.Module): + def __init__(self, inplace: bool = False): + super(Swish, self).__init__() + self.inplace = inplace + + def forward(self, x): + return swish(x, self.inplace) + +class HardSwish(nn.Module): + def __init__(self, inplace: bool = False): + super(HardSwish, self).__init__() + self.inplace = inplace + + def forward(self, x): + return hard_swish(x, self.inplace) + +def _ntuple(n): + def parse(x): + if isinstance(x, container_abcs.Iterable): + return x + return tuple(repeat(x, n)) + return parse + +def get_same_padding(x: int, k: int, s: int, d: int): + return max((math.ceil(x / s) - 1) * s + (k - 1) * d + 1 - x, 0) + +def pad_same(x, k: List[int], s: List[int], d: List[int] = (1, 1), value: float = 0): + ih, iw = x.size()[-2:] + pad_h, pad_w = get_same_padding(ih, k[0], s[0], d[0]), get_same_padding(iw, k[1], s[1], d[1]) + if pad_h > 0 or pad_w > 0: + x = F.pad(x, [pad_w // 2, pad_w - pad_w // 2, pad_h // 2, pad_h - pad_h // 2], value=value) + return x + +def conv2d_same( + x, weight: torch.Tensor, bias: Optional[torch.Tensor] = None, stride: Tuple[int, int] = (1, 1), + padding: Tuple[int, int] = (0, 0), dilation: Tuple[int, int] = (1, 1), groups: int = 1): + x = pad_same(x, weight.shape[-2:], stride, dilation) + return F.conv2d(x, weight, bias, stride, (0, 0), dilation, groups) + +tup_pair = _ntuple(2) + +def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int: + padding = ((stride - 1) + dilation * (kernel_size - 1)) // 2 + return padding + +def is_static_pad(kernel_size: int, stride: int = 1, dilation: int = 1, **_): + return stride == 1 and (dilation * (kernel_size - 1)) % 2 == 0 + +def get_padding_value(padding, kernel_size, **kwargs) -> Tuple[Tuple, bool]: + dynamic = False + if isinstance(padding, str): + # for any string padding, the padding will be calculated for you, one of three ways + padding = padding.lower() + if padding == 'same': + # TF compatible 'SAME' padding, has a performance and GPU memory allocation impact + if is_static_pad(kernel_size, **kwargs): + # static case, no extra overhead + padding = get_padding(kernel_size, **kwargs) + else: + # dynamic 'SAME' padding, has runtime/GPU memory overhead + padding = 0 + dynamic = True + elif padding == 'valid': + # 'VALID' padding, same as padding=0 + padding = 0 + else: + # Default to PyTorch style 'same'-ish symmetric padding + padding = get_padding(kernel_size, **kwargs) + return padding, dynamic + +class CondConv2d(nn.Module): + """ Conditionally Parameterized Convolution + Inspired by: https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/condconv/condconv_layers.py + Grouped convolution hackery for parallel execution of the per-sample kernel filters inspired by this discussion: + https://github.com/pytorch/pytorch/issues/17983 + """ + __constants__ = ['bias', 'in_channels', 'out_channels', 'dynamic_padding'] + + def __init__(self, in_channels, out_channels, kernel_size=3, + stride=1, padding='', dilation=1, groups=1, bias=False, num_experts=4): + super(CondConv2d, self).__init__() + + self.in_channels = in_channels + self.out_channels = out_channels + self.kernel_size = tup_pair(kernel_size) + self.stride = tup_pair(stride) + padding_val, is_padding_dynamic = get_padding_value( + padding, kernel_size, stride=stride, dilation=dilation) + self.dynamic_padding = is_padding_dynamic # if in forward to work with torchscript + self.padding = tup_pair(padding_val) + self.dilation = tup_pair(dilation) + self.groups = groups + self.num_experts = num_experts + + self.weight_shape = (self.out_channels, self.in_channels // self.groups) + self.kernel_size + weight_num_param = 1 + for wd in self.weight_shape: + weight_num_param *= wd + self.weight = torch.nn.Parameter(torch.Tensor(self.num_experts, weight_num_param)) + + if bias: + self.bias_shape = (self.out_channels,) + self.bias = torch.nn.Parameter(torch.Tensor(self.num_experts, self.out_channels)) + else: + self.register_parameter('bias', None) + + self.reset_parameters() + + def reset_parameters(self): + init_weight = get_condconv_initializer( + partial(nn.init.kaiming_uniform_, a=math.sqrt(5)), self.num_experts, self.weight_shape) + init_weight(self.weight) + if self.bias is not None: + fan_in = np.prod(self.weight_shape[1:]) + bound = 1 / math.sqrt(fan_in) + init_bias = get_condconv_initializer( + partial(nn.init.uniform_, a=-bound, b=bound), self.num_experts, self.bias_shape) + init_bias(self.bias) + + def forward(self, x, routing_weights): + B, C, H, W = x.shape + weight = torch.matmul(routing_weights, self.weight) + new_weight_shape = (B * self.out_channels, self.in_channels // self.groups) + self.kernel_size + weight = weight.view(new_weight_shape) + bias = None + if self.bias is not None: + bias = torch.matmul(routing_weights, self.bias) + bias = bias.view(B * self.out_channels) + # move batch elements with channels so each batch element can be efficiently convolved with separate kernel + x = x.view(1, B * C, H, W) + if self.dynamic_padding: + out = conv2d_same( + x, weight, bias, stride=self.stride, padding=self.padding, + dilation=self.dilation, groups=self.groups * B) + else: + out = F.conv2d( + x, weight, bias, stride=self.stride, padding=self.padding, + dilation=self.dilation, groups=self.groups * B) + out = out.permute([1, 0, 2, 3]).view(B, self.out_channels, out.shape[-2], out.shape[-1]) + + # Literal port (from TF definition) + # x = torch.split(x, 1, 0) + # weight = torch.split(weight, 1, 0) + # if self.bias is not None: + # bias = torch.matmul(routing_weights, self.bias) + # bias = torch.split(bias, 1, 0) + # else: + # bias = [None] * B + # out = [] + # for xi, wi, bi in zip(x, weight, bias): + # wi = wi.view(*self.weight_shape) + # if bi is not None: + # bi = bi.view(*self.bias_shape) + # out.append(self.conv_fn( + # xi, wi, bi, stride=self.stride, padding=self.padding, + # dilation=self.dilation, groups=self.groups)) + # out = torch.cat(out, 0) + return out + +def get_condconv_initializer(initializer, num_experts, expert_shape): + def condconv_initializer(weight): + """CondConv initializer function.""" + num_params = np.prod(expert_shape) + if (len(weight.shape) != 2 or weight.shape[0] != num_experts or + weight.shape[1] != num_params): + raise (ValueError( + 'CondConv variables must have shape [num_experts, num_params]')) + for i in range(num_experts): + initializer(weight[i].view(expert_shape)) + return condconv_initializer + +def resolve_bn_args(kwargs): + bn_args = get_bn_args_tf() if kwargs.pop('bn_tf', False) else {} + bn_momentum = kwargs.pop('bn_momentum', None) + if bn_momentum is not None: + bn_args['momentum'] = bn_momentum + bn_eps = kwargs.pop('bn_eps', None) + if bn_eps is not None: + bn_args['eps'] = bn_eps + return bn_args + +def round_channels(channels, multiplier=1.0, divisor=8, channel_min=None): + """Round number of filters based on depth multiplier.""" + if not multiplier: + return channels + channels *= multiplier + return make_divisible(channels, divisor, channel_min) + +def _parse_ksize(ss): + if ss.isdigit(): + return int(ss) + else: + return [int(k) for k in ss.split('.')] + +def make_divisible(v, divisor=8, min_value=None): + min_value = min_value or divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + # Make sure that round down does not go down by more than 10%. + if new_v < 0.9 * v: + new_v += divisor + return new_v + +class DepthwiseSeparableConv(nn.Module): + """ DepthwiseSeparable block + Used for DS convs in MobileNet-V1 and in the place of IR blocks that have no expansion + (factor of 1.0). This is an alternative to having a IR with an optional first pw conv. + """ + def __init__(self, in_chs, out_chs, dw_kernel_size=3, + stride=1, dilation=1, pad_type='', act_layer=nn.ReLU, noskip=False, + pw_kernel_size=1, pw_act=False, se_ratio=0., se_kwargs=None, + norm_layer=nn.BatchNorm2d, norm_kwargs=None, drop_path_rate=0.): + super(DepthwiseSeparableConv, self).__init__() + norm_kwargs = norm_kwargs or {} + has_se = se_ratio is not None and se_ratio > 0. + self.has_residual = (stride == 1 and in_chs == out_chs) and not noskip + self.has_pw_act = pw_act # activation after point-wise conv + self.drop_path_rate = drop_path_rate + + self.conv_dw = create_conv2d( + in_chs, in_chs, dw_kernel_size, stride=stride, dilation=dilation, padding=pad_type, depthwise=True) + self.bn1 = norm_layer(in_chs, **norm_kwargs) + self.act1 = act_layer(inplace=True) + + # Squeeze-and-excitation + if has_se: + se_kwargs = resolve_se_args(se_kwargs, in_chs, act_layer) + self.se = SqueezeExcite(in_chs, se_ratio=se_ratio, **se_kwargs) + else: + self.se = None + + self.conv_pw = create_conv2d(in_chs, out_chs, pw_kernel_size, padding=pad_type) + self.bn2 = norm_layer(out_chs, **norm_kwargs) + self.act2 = act_layer(inplace=True) if self.has_pw_act else nn.Identity() + + def feature_info(self, location): + if location == 'expansion': + # no expansion in this block, use depthwise, before SE + info = dict(module='act1', hook_type='forward', num_chs=self.conv_pw.in_channels) + elif location == 'depthwise': # after SE + info = dict(module='conv_pw', hook_type='forward_pre', num_chs=self.conv_pw.in_channels) + else: # location == 'bottleneck' + info = dict(module='', hook_type='', num_chs=self.conv_pw.out_channels) + return info + + def forward(self, x): + residual = x + + x = self.conv_dw(x) + x = self.bn1(x) + x = self.act1(x) + + if self.se is not None: + x = self.se(x) + + x = self.conv_pw(x) + x = self.bn2(x) + x = self.act2(x) + + if self.has_residual: + x += residual + return x + +class InvertedResidual(nn.Module): + """ Inverted residual block w/ optional SE and CondConv routing""" + + def __init__(self, in_chs, out_chs, dw_kernel_size=3, + stride=1, dilation=1, pad_type='', act_layer=nn.ReLU, noskip=False, + exp_ratio=1.0, exp_kernel_size=1, pw_kernel_size=1, + se_ratio=0., se_kwargs=None, norm_layer=nn.BatchNorm2d, norm_kwargs=None, + conv_kwargs=None, drop_path_rate=0.): + super(InvertedResidual, self).__init__() + norm_kwargs = norm_kwargs or {} + conv_kwargs = conv_kwargs or {} + mid_chs = make_divisible(in_chs * exp_ratio) + has_se = se_ratio is not None and se_ratio > 0. + self.has_residual = (in_chs == out_chs and stride == 1) and not noskip + self.drop_path_rate = drop_path_rate + + # Point-wise expansion + self.conv_pw = create_conv2d(in_chs, mid_chs, exp_kernel_size, padding=pad_type, **conv_kwargs) + self.bn1 = norm_layer(mid_chs, **norm_kwargs) + self.act1 = act_layer(inplace=True) + + # Depth-wise convolution + self.conv_dw = create_conv2d( + mid_chs, mid_chs, dw_kernel_size, stride=stride, dilation=dilation, + padding=pad_type, depthwise=True, **conv_kwargs) + self.bn2 = norm_layer(mid_chs, **norm_kwargs) + self.act2 = act_layer(inplace=True) + + # Squeeze-and-excitation + if has_se: + se_kwargs = resolve_se_args(se_kwargs, in_chs, act_layer) + self.se = SqueezeExcite(mid_chs, se_ratio=se_ratio, **se_kwargs) + else: + self.se = None + + # Point-wise linear projection + self.conv_pwl = create_conv2d(mid_chs, out_chs, pw_kernel_size, padding=pad_type, **conv_kwargs) + self.bn3 = norm_layer(out_chs, **norm_kwargs) + + def feature_info(self, location): + if location == 'expansion': + info = dict(module='act1', hook_type='forward', num_chs=self.conv_pw.in_channels) + elif location == 'depthwise': # after SE + info = dict(module='conv_pwl', hook_type='forward_pre', num_chs=self.conv_pwl.in_channels) + else: # location == 'bottleneck' + info = dict(module='', hook_type='', num_chs=self.conv_pwl.out_channels) + return info + + def forward(self, x): + residual = x + + # Point-wise expansion + x = self.conv_pw(x) + x = self.bn1(x) + x = self.act1(x) + + # Depth-wise convolution + x = self.conv_dw(x) + x = self.bn2(x) + x = self.act2(x) + + # Squeeze-and-excitation + if self.se is not None: + x = self.se(x) + + # Point-wise linear projection + x = self.conv_pwl(x) + x = self.bn3(x) + + if self.has_residual: + x += residual + + return x + +def create_conv2d_pad(in_chs, out_chs, kernel_size, **kwargs): + padding = kwargs.pop('padding', '') + kwargs.setdefault('bias', False) + padding, is_dynamic = get_padding_value(padding, kernel_size, **kwargs) + if is_dynamic: + return Conv2dSame(in_chs, out_chs, kernel_size, **kwargs) + else: + return nn.Conv2d(in_chs, out_chs, kernel_size, padding=padding, **kwargs) + +def create_conv2d(in_chs, out_chs, kernel_size, **kwargs): + """ Select a 2d convolution implementation based on arguments + Creates and returns one of torch.nn.Conv2d, Conv2dSame, MixedConv2d, or CondConv2d. + Used extensively by EfficientNet, MobileNetv3 and related networks. + """ + assert 'groups' not in kwargs # only use 'depthwise' bool arg + if isinstance(kernel_size, list): + assert 'num_experts' not in kwargs # MixNet + CondConv combo not supported currently + # We're going to use only lists for defining the MixedConv2d kernel groups, + # ints, tuples, other iterables will continue to pass to normal conv and specify h, w. + m = MixedConv2d(in_chs, out_chs, kernel_size, **kwargs) + else: + depthwise = kwargs.pop('depthwise', False) + groups = out_chs if depthwise else 1 + if 'num_experts' in kwargs and kwargs['num_experts'] > 0: + m = CondConv2d(in_chs, out_chs, kernel_size, groups=groups, **kwargs) + else: + m = create_conv2d_pad(in_chs, out_chs, kernel_size, groups=groups, **kwargs) + return m + +def resolve_se_args(kwargs, in_chs, act_layer=None): + se_kwargs = kwargs.copy() if kwargs is not None else {} + # fill in args that aren't specified with the defaults + for k, v in _SE_ARGS_DEFAULT.items(): + se_kwargs.setdefault(k, v) + # some models, like MobilNetV3, calculate SE reduction chs from the containing block's mid_ch instead of in_ch + if not se_kwargs.pop('reduce_mid'): + se_kwargs['reduced_base_chs'] = in_chs + # act_layer override, if it remains None, the containing block's act_layer will be used + if se_kwargs['act_layer'] is None: + assert act_layer is not None + se_kwargs['act_layer'] = act_layer + return se_kwargs + +def sigmoid(x, inplace: bool = False): + return x.sigmoid_() if inplace else x.sigmoid() + +_SE_ARGS_DEFAULT = dict( + gate_fn=sigmoid, + act_layer=None, + reduce_mid=False, + divisor=1) + +def _decode_block_str(block_str): + """ Decode block definition string + Gets a list of block arg (dicts) through a string notation of arguments. + E.g. ir_r2_k3_s2_e1_i32_o16_se0.25_noskip + All args can exist in any order with the exception of the leading string which + is assumed to indicate the block type. + leading string - block type ( + ir = InvertedResidual, ds = DepthwiseSep, dsa = DeptwhiseSep with pw act, cn = ConvBnAct) + r - number of repeat blocks, + k - kernel size, + s - strides (1-9), + e - expansion ratio, + c - output channels, + se - squeeze/excitation ratio + n - activation fn ('re', 'r6', 'hs', or 'sw') + Args: + block_str: a string representation of block arguments. + Returns: + A list of block args (dicts) + Raises: + ValueError: if the string def not properly specified (TODO) + """ + assert isinstance(block_str, str) + ops = block_str.split('_') + block_type = ops[0] # take the block type off the front + ops = ops[1:] + options = {} + noskip = False + for op in ops: + # string options being checked on individual basis, combine if they grow + if op == 'noskip': + noskip = True + elif op.startswith('n'): + # activation fn + key = op[0] + v = op[1:] + if v == 're': + value = nn.ReLU + elif v == 'r6': + value = nn.ReLU6 + elif v == 'hs': + value = HardSwish + elif v == 'sw': + value = Swish + else: + continue + options[key] = value + else: + # all numeric options + splits = re.split(r'(\d.*)', op) + if len(splits) >= 2: + key, value = splits[:2] + options[key] = value + + # if act_layer is None, the model default (passed to model init) will be used + act_layer = options['n'] if 'n' in options else None + exp_kernel_size = _parse_ksize(options['a']) if 'a' in options else 1 + pw_kernel_size = _parse_ksize(options['p']) if 'p' in options else 1 + fake_in_chs = int(options['fc']) if 'fc' in options else 0 # FIXME hack to deal with in_chs issue in TPU def + + num_repeat = int(options['r']) + # each type of block has different valid arguments, fill accordingly + if block_type == 'ir': + block_args = dict( + block_type=block_type, + dw_kernel_size=_parse_ksize(options['k']), + exp_kernel_size=exp_kernel_size, + pw_kernel_size=pw_kernel_size, + out_chs=int(options['c']), + exp_ratio=float(options['e']), + se_ratio=float(options['se']) if 'se' in options else None, + stride=int(options['s']), + act_layer=act_layer, + noskip=noskip, + ) + if 'cc' in options: + block_args['num_experts'] = int(options['cc']) + elif block_type == 'ds' or block_type == 'dsa': + block_args = dict( + block_type=block_type, + dw_kernel_size=_parse_ksize(options['k']), + pw_kernel_size=pw_kernel_size, + out_chs=int(options['c']), + se_ratio=float(options['se']) if 'se' in options else None, + stride=int(options['s']), + act_layer=act_layer, + pw_act=block_type == 'dsa', + noskip=block_type == 'dsa' or noskip, + ) + elif block_type == 'er': + block_args = dict( + block_type=block_type, + exp_kernel_size=_parse_ksize(options['k']), + pw_kernel_size=pw_kernel_size, + out_chs=int(options['c']), + exp_ratio=float(options['e']), + fake_in_chs=fake_in_chs, + se_ratio=float(options['se']) if 'se' in options else None, + stride=int(options['s']), + act_layer=act_layer, + noskip=noskip, + ) + elif block_type == 'cn': + block_args = dict( + block_type=block_type, + kernel_size=int(options['k']), + out_chs=int(options['c']), + stride=int(options['s']), + act_layer=act_layer, + ) + else: + assert False, 'Unknown block type (%s)' % block_type + + return block_args, num_repeat + +class SqueezeExcite(nn.Module): + def __init__(self, in_chs, se_ratio=0.25, reduced_base_chs=None, + act_layer=nn.ReLU, gate_fn=sigmoid, divisor=1, **_): + super(SqueezeExcite, self).__init__() + self.gate_fn = gate_fn + reduced_chs = make_divisible((reduced_base_chs or in_chs) * se_ratio, divisor) + self.avg_pool = nn.AdaptiveAvgPool2d(1) + self.conv_reduce = nn.Conv2d(in_chs, reduced_chs, 1, bias=True) + self.act1 = act_layer(inplace=True) + self.conv_expand = nn.Conv2d(reduced_chs, in_chs, 1, bias=True) + + def forward(self, x): + x_se = self.avg_pool(x) + x_se = self.conv_reduce(x_se) + x_se = self.act1(x_se) + x_se = self.conv_expand(x_se) + x = x * self.gate_fn(x_se) + return x + +class Sigmoid(nn.Module): + def __init__(self, inplace: bool = False): + super(Sigmoid, self).__init__() + self.inplace = inplace + + def forward(self, x): + return x.sigmoid_() if self.inplace else x.sigmoid() + +class ConvBnAct(nn.Module): + def __init__(self, in_chs, out_chs, kernel_size, + stride=1, dilation=1, pad_type='', act_layer=nn.ReLU, + norm_layer=nn.BatchNorm2d, norm_kwargs=None): + super(ConvBnAct, self).__init__() + norm_kwargs = norm_kwargs or {} + self.conv = create_conv2d(in_chs, out_chs, kernel_size, stride=stride, dilation=dilation, padding=pad_type) + self.bn1 = norm_layer(out_chs, **norm_kwargs) + self.act1 = act_layer(inplace=True) + + def feature_info(self, location): + if location == 'expansion' or location == 'depthwise': + # no expansion or depthwise this block, use act after conv + info = dict(module='act1', hook_type='forward', num_chs=self.conv.out_channels) + else: # location == 'bottleneck' + info = dict(module='', hook_type='', num_chs=self.conv.out_channels) + return info + + def forward(self, x): + x = self.conv(x) + x = self.bn1(x) + x = self.act1(x) + return x + +def adaptive_pool_feat_mult(pool_type='avg'): + if pool_type == 'catavgmax': + return 2 + else: + return 1 + +def modify_block_args(block_args, kernel_size, exp_ratio): + # kernel_size: 3,5,7 + # exp_ratio: 4,6 + block_type = block_args['block_type'] + # each type of block has different valid arguments, fill accordingly + if block_type == 'cn': + block_args['kernel_size'] = kernel_size + elif block_type == 'er': + block_args['exp_kernel_size'] = kernel_size + else: + block_args['dw_kernel_size'] = kernel_size + + if block_type == 'ir' or block_type == 'er': + block_args['exp_ratio'] = exp_ratio + return block_args + +def _scale_stage_depth(stack_args, repeats, depth_multiplier=1.0, depth_trunc='ceil'): + """ Per-stage depth scaling + Scales the block repeats in each stage. This depth scaling impl maintains + compatibility with the EfficientNet scaling method, while allowing sensible + scaling for other models that may have multiple block arg definitions in each stage. + """ + + # We scale the total repeat count for each stage, there may be multiple + # block arg defs per stage so we need to sum. + num_repeat = sum(repeats) + if depth_trunc == 'round': + # Truncating to int by rounding allows stages with few repeats to remain + # proportionally smaller for longer. This is a good choice when stage definitions + # include single repeat stages that we'd prefer to keep that way as long as possible + num_repeat_scaled = max(1, round(num_repeat * depth_multiplier)) + else: + # The default for EfficientNet truncates repeats to int via 'ceil'. + # Any multiplier > 1.0 will result in an increased depth for every stage. + num_repeat_scaled = int(math.ceil(num_repeat * depth_multiplier)) + + # Proportionally distribute repeat count scaling to each block definition in the stage. + # Allocation is done in reverse as it results in the first block being less likely to be scaled. + # The first block makes less sense to repeat in most of the arch definitions. + repeats_scaled = [] + for r in repeats[::-1]: + rs = max(1, round((r / num_repeat * num_repeat_scaled))) + repeats_scaled.append(rs) + num_repeat -= r + num_repeat_scaled -= rs + repeats_scaled = repeats_scaled[::-1] + + # Apply the calculated scaling to each block arg in the stage + sa_scaled = [] + for ba, rep in zip(stack_args, repeats_scaled): + sa_scaled.extend([deepcopy(ba) for _ in range(rep)]) + return sa_scaled + + +def decode_arch_def(arch_def, depth_multiplier=1.0, depth_trunc='ceil', experts_multiplier=1): + arch_args = [] + for stack_idx, block_strings in enumerate(arch_def): + assert isinstance(block_strings, list) + stack_args = [] + repeats = [] + for block_str in block_strings: + assert isinstance(block_str, str) + ba, rep = _decode_block_str(block_str) + if ba.get('num_experts', 0) > 0 and experts_multiplier > 1: + ba['num_experts'] *= experts_multiplier + stack_args.append(ba) + repeats.append(rep) + arch_args.append(_scale_stage_depth(stack_args, repeats, depth_multiplier, depth_trunc)) + return arch_args + + +class ChildNetBuilder: + """ Build Trunk Blocks + """ + def __init__(self, channel_multiplier=1.0, channel_divisor=8, channel_min=None, + output_stride=32, pad_type='', act_layer=None, se_kwargs=None, + norm_layer=nn.BatchNorm2d, norm_kwargs=None, drop_path_rate=0., feature_location='', + verbose=False): + self.channel_multiplier = channel_multiplier + self.channel_divisor = channel_divisor + self.channel_min = channel_min + self.output_stride = output_stride + self.pad_type = pad_type + self.act_layer = act_layer + self.se_kwargs = se_kwargs + self.norm_layer = norm_layer + self.norm_kwargs = norm_kwargs + self.drop_path_rate = drop_path_rate + self.feature_location = feature_location + assert feature_location in ('pre_pwl', 'post_exp', '') + self.verbose = verbose + + # state updated during build, consumed by model + self.in_chs = None + self.features = OrderedDict() + + def _round_channels(self, chs): + return round_channels(chs, self.channel_multiplier, self.channel_divisor, self.channel_min) + + def _make_block(self, ba, block_idx, block_count): + drop_path_rate = self.drop_path_rate * block_idx / block_count + bt = ba.pop('block_type') + ba['in_chs'] = self.in_chs + ba['out_chs'] = self._round_channels(ba['out_chs']) + if 'fake_in_chs' in ba and ba['fake_in_chs']: + # FIXME this is a hack to work around mismatch in origin impl input filters + ba['fake_in_chs'] = self._round_channels(ba['fake_in_chs']) + ba['norm_layer'] = self.norm_layer + ba['norm_kwargs'] = self.norm_kwargs + ba['pad_type'] = self.pad_type + # block act fn overrides the model default + ba['act_layer'] = ba['act_layer'] if ba['act_layer'] is not None else self.act_layer + assert ba['act_layer'] is not None + if bt == 'ir': + ba['drop_path_rate'] = drop_path_rate + ba['se_kwargs'] = self.se_kwargs + if self.verbose: + logging.info(' InvertedResidual {}, Args: {}'.format(block_idx, str(ba))) + if ba.get('num_experts', 0) > 0: + block = CondConvResidual(**ba) + else: + block = InvertedResidual(**ba) + elif bt == 'ds' or bt == 'dsa': + ba['drop_path_rate'] = drop_path_rate + ba['se_kwargs'] = self.se_kwargs + if self.verbose: + logging.info(' DepthwiseSeparable {}, Args: {}'.format(block_idx, str(ba))) + block = DepthwiseSeparableConv(**ba) + elif bt == 'er': + ba['drop_path_rate'] = drop_path_rate + ba['se_kwargs'] = self.se_kwargs + if self.verbose: + logging.info(' EdgeResidual {}, Args: {}'.format(block_idx, str(ba))) + block = EdgeResidual(**ba) + elif bt == 'cn': + if self.verbose: + logging.info(' ConvBnAct {}, Args: {}'.format(block_idx, str(ba))) + block = ConvBnAct(**ba) + else: + assert False, 'Uknkown block type (%s) while building model.' % bt + self.in_chs = ba['out_chs'] # update in_chs for arg of next block + + return block + + def __call__(self, in_chs, model_block_args): + """ Build the blocks + Args: + in_chs: Number of input-channels passed to first block + model_block_args: A list of lists, outer list defines stages, inner + list contains strings defining block configuration(s) + Return: + List of block stacks (each stack wrapped in nn.Sequential) + """ + if self.verbose: + logging.info('Building model trunk with %d stages...' % len(model_block_args)) + self.in_chs = in_chs + total_block_count = sum([len(x) for x in model_block_args]) + total_block_idx = 0 + current_stride = 2 + current_dilation = 1 + feature_idx = 0 + stages = [] + # outer list of block_args defines the stacks ('stages' by some conventions) + for stage_idx, stage_block_args in enumerate(model_block_args): + last_stack = stage_idx == (len(model_block_args) - 1) + if self.verbose: + logging.info('Stack: {}'.format(stage_idx)) + assert isinstance(stage_block_args, list) + + blocks = [] + # each stack (stage) contains a list of block arguments + for block_idx, block_args in enumerate(stage_block_args): + last_block = block_idx == (len(stage_block_args) - 1) + extract_features = '' # No features extracted + if self.verbose: + logging.info(' Block: {}'.format(block_idx)) + + # Sort out stride, dilation, and feature extraction details + assert block_args['stride'] in (1, 2) + if block_idx >= 1: + # only the first block in any stack can have a stride > 1 + block_args['stride'] = 1 + + do_extract = False + if self.feature_location == 'pre_pwl': + if last_block: + next_stage_idx = stage_idx + 1 + if next_stage_idx >= len(model_block_args): + do_extract = True + else: + do_extract = model_block_args[next_stage_idx][0]['stride'] > 1 + elif self.feature_location == 'post_exp': + if block_args['stride'] > 1 or (last_stack and last_block) : + do_extract = True + if do_extract: + extract_features = self.feature_location + + next_dilation = current_dilation + if block_args['stride'] > 1: + next_output_stride = current_stride * block_args['stride'] + if next_output_stride > self.output_stride: + next_dilation = current_dilation * block_args['stride'] + block_args['stride'] = 1 + if self.verbose: + logging.info(' Converting stride to dilation to maintain output_stride=={}'.format( + self.output_stride)) + else: + current_stride = next_output_stride + block_args['dilation'] = current_dilation + if next_dilation != current_dilation: + current_dilation = next_dilation + + # create the block + block = self._make_block(block_args, total_block_idx, total_block_count) + blocks.append(block) + + # stash feature module name and channel info for model feature extraction + if extract_features: + feature_module = block.feature_module(extract_features) + if feature_module: + feature_module = 'blocks.{}.{}.'.format(stage_idx, block_idx) + feature_module + feature_channels = block.feature_channels(extract_features) + self.features[feature_idx] = dict( + name=feature_module, + num_chs=feature_channels + ) + feature_idx += 1 + + total_block_idx += 1 # incr global block idx (across all stacks) + stages.append(nn.Sequential(*blocks)) + return stages + +def _init_weight_goog(m, n='', fix_group_fanout=True, last_bn=None): + """ Weight initialization as per Tensorflow official implementations. + Args: + m (nn.Module): module to init + n (str): module name + fix_group_fanout (bool): enable correct (matching Tensorflow TPU impl) fanout calculation w/ group convs + Handles layers in EfficientNet, EfficientNet-CondConv, MixNet, MnasNet, MobileNetV3, etc: + * https://github.com/tensorflow/tpu/blob/master/models/official/mnasnet/mnasnet_model.py + * https://github.com/tensorflow/tpu/blob/master/models/official/efficientnet/efficientnet_model.py + """ + if isinstance(m, CondConv2d): + fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels + if fix_group_fanout: + fan_out //= m.groups + init_weight_fn = get_condconv_initializer( + lambda w: w.data.normal_(0, math.sqrt(2.0 / fan_out)), m.num_experts, m.weight_shape) + init_weight_fn(m.weight) + if m.bias is not None: + m.bias.data.zero_() + elif isinstance(m, nn.Conv2d): + fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels + if fix_group_fanout: + fan_out //= m.groups + m.weight.data.normal_(0, math.sqrt(2.0 / fan_out)) + if m.bias is not None: + m.bias.data.zero_() + elif isinstance(m, nn.BatchNorm2d): + if n in last_bn: + m.weight.data.zero_() + m.bias.data.zero_() + else: + m.weight.data.fill_(1.0) + m.bias.data.zero_() + m.weight.data.fill_(1.0) + m.bias.data.zero_() + elif isinstance(m, nn.Linear): + fan_out = m.weight.size(0) # fan-out + fan_in = 0 + if 'routing_fn' in n: + fan_in = m.weight.size(1) + init_range = 1.0 / math.sqrt(fan_in + fan_out) + m.weight.data.uniform_(-init_range, init_range) + m.bias.data.zero_() + + +def efficientnet_init_weights(model: nn.Module, init_fn=None, zero_gamma=False): + last_bn = [] + if zero_gamma: + prev_n = '' + for n, m in model.named_modules(): + if isinstance(m, nn.BatchNorm2d): + if ''.join(prev_n.split('.')[:-1]) != ''.join(n.split('.')[:-1]): + last_bn.append(prev_n) + prev_n = n + last_bn.append(prev_n) + + init_fn = init_fn or _init_weight_goog + for n, m in model.named_modules(): + init_fn(m, n, last_bn=last_bn) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cal_model.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cal_model.py new file mode 100644 index 000000000..033d0ce03 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cal_model.py @@ -0,0 +1,68 @@ +from __future__ import division +import os +import sys +import time +import glob +import json +import logging +import argparse +import numpy as np + +import matplotlib as mpl +import matplotlib.pyplot as plt +import seaborn as sns +import warnings; warnings.filterwarnings(action='once') + +class NpEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, np.integer): + return int(obj) + elif isinstance(obj, np.floating): + return float(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + else: + return super(NpEncoder, self).default(obj) + +def main(): + + # Import Data + model_files = glob.glob("train_samples/*.json") + + + for model_file in model_files: + + with open(model_file, 'r') as f: + # dict_a = json.loads(f, cls=NpEncoder) + model_dict = json.loads(f.read()) + + + df = pd.read_csv("mpg_ggplot2.csv") + + # Prepare data + x_var = 'manufacturer' + groupby_var = 'class' + df_agg = df.loc[:, [x_var, groupby_var]].groupby(groupby_var) + vals = [df[x_var].values.tolist() for i, df in df_agg] + + # Draw + plt.figure(figsize=(16,9), dpi= 80) + colors = [plt.cm.Spectral(i/float(len(vals)-1)) for i in range(len(vals))] + n, bins, patches = plt.hist(vals, df[x_var].unique().__len__(), stacked=True, density=False, color=colors[:len(vals)]) + + # Decoration + plt.legend({group:col for group, col in zip(np.unique(df[groupby_var]).tolist(), colors[:len(vals)])}) + plt.title(f"Stacked Histogram of ${x_var}$ colored by ${groupby_var}$", fontsize=22) + plt.xlabel(x_var) + plt.ylabel("Frequency") + plt.ylim(0, 40) + plt.xticks(rotation=90, horizontalalignment='left') + plt.show() + + + + + +if __name__ == '__main__': + main() + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_test.py new file mode 100644 index 000000000..7f549a8bf --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_test.py @@ -0,0 +1,77 @@ +# encoding: utf-8 + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os.path as osp +import sys +import numpy as np +from easydict import EasyDict as edict + +C = edict() +config = C +cfg = C + +C.seed = 12345 + +"""please config ROOT_dir and user when u first using""" +C.abs_dir = osp.realpath(".") +C.root_dir = osp.realpath("..") +C.this_dir = C.abs_dir.split(osp.sep)[-1] +C.log_dir = osp.abspath(osp.join(C.root_dir, 'log', C.this_dir)) + +"""Data Dir""" +C.dataset_path = "/home/t-hongyuanyu/data/cityscapes/" +C.img_root_folder = C.dataset_path +C.gt_root_folder = C.dataset_path +C.train_source = osp.join(C.dataset_path, "cityscapes_train_fine.txt") +C.train_eval_source = osp.join(C.dataset_path, "cityscapes_train_val_fine.txt") +C.eval_source = osp.join(C.dataset_path, "cityscapes_val_fine.txt") +C.test_source = osp.join(C.dataset_path, "cityscapes_test.txt") + +"""Path Config""" +def add_path(path): + if path not in sys.path: + sys.path.insert(0, path) + +add_path(osp.join(C.root_dir, 'tools')) +add_path(C.root_dir) + +"""Image Config""" +C.num_classes = 19 +C.background = -1 +C.image_mean = np.array([0.485, 0.456, 0.406]) +C.image_std = np.array([0.229, 0.224, 0.225]) +C.target_size = 1024 +C.down_sampling = 1 # first down_sampling then crop ...... +C.gt_down_sampling = 1 +C.num_train_imgs = 2975 +C.num_eval_imgs = 500 + +""" Settings for network, this would be different for each kind of model""" +C.bn_eps = 1e-5 +C.bn_momentum = 0.1 + +"""Eval Config""" +C.eval_stride_rate = 5 / 6 +C.eval_scale_array = [1, ] +C.eval_flip = False +C.eval_base_size = 1024 +C.eval_crop_size = 1024 +C.eval_height = 1024 +C.eval_width = 2048 + +C.layers = 16 +C.width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] +C.stem_head_width = (1, 1) +C.Fch = 20 +C.image_height = 512 +C.image_width = 1024 + +######################################## +C.save = "test" +C.is_test = False # if True, prediction files for the test set will be generated +C.is_eval = True # if True, the train.py will only do evaluation for once +C.json_file = "./jsons/3path_big2.json" +C.model_path = "./3path_big2.pth.tar" # path to pretrained directory to be evaluated diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_train.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_train.py new file mode 100644 index 000000000..f23b244e7 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/config_train.py @@ -0,0 +1,115 @@ +# encoding: utf-8 + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os.path as osp +import sys +import numpy as np +from easydict import EasyDict as edict + +C = edict() +config = C +cfg = C + +C.seed = 12345 + +"""please config ROOT_dir and user when u first using""" +#C.repo_name = 'FasterSeg' +#C.abs_dir = osp.realpath(".") +#C.this_dir = C.abs_dir.split(osp.sep)[-1] +#C.root_dir = C.abs_dir[:C.abs_dir.index(C.repo_name) + len(C.repo_name)] +C.abs_dir = osp.realpath(".") +C.root_dir = osp.realpath("..") +C.this_dir = C.abs_dir.split(osp.sep)[-1] +C.log_dir = osp.abspath(osp.join(C.root_dir, 'log', C.this_dir)) + +"""Data Dir""" +C.dataset_path = "../DATASET/cityscapes/" +C.img_root_folder = C.dataset_path +C.gt_root_folder = C.dataset_path +C.train_source = osp.join(C.dataset_path, "cityscapes_train_fine.txt") +C.train_eval_source = osp.join(C.dataset_path, "cityscapes_train_val_fine.txt") +C.eval_source = osp.join(C.dataset_path, "cityscapes_val_fine.txt") +C.test_source = osp.join(C.dataset_path, "cityscapes_test.txt") + +"""Path Config""" +def add_path(path): + if path not in sys.path: + sys.path.insert(0, path) + +add_path(osp.join(C.root_dir, 'tools')) +add_path(C.root_dir) + +"""Image Config""" +C.num_classes = 19 +C.background = -1 +C.image_mean = np.array([0.485, 0.456, 0.406]) +C.image_std = np.array([0.229, 0.224, 0.225]) +C.target_size = 1024 +C.down_sampling = 1 # first down_sampling then crop ...... +C.gt_down_sampling = 1 +C.num_train_imgs = 2975 +C.num_eval_imgs = 500 + +""" Settings for network, this would be different for each kind of model""" +C.bn_eps = 1e-5 +C.bn_momentum = 0.1 + +"""Train Config""" +C.lr = 0.01 +C.momentum = 0.9 +C.weight_decay = 5e-4 +C.nepochs = 600 +C.niters_per_epoch = 1000 +C.num_workers = 4 +C.train_scale_array = [0.75, 1, 1.25] + +"""Eval Config""" +C.eval_stride_rate = 5 / 6 +C.eval_scale_array = [1, ] +C.eval_flip = False +C.eval_base_size = 1024 +C.eval_crop_size = 1024 +C.eval_height = 1024 +C.eval_width = 2048 + + +C.layers = 16 +""" Train Config """ +C.mode = "teacher" # "teacher" or "student" +if C.mode == "teacher": + ##### train teacher model only #################################### + C.arch_idx = [1] # 0 for teacher + C.branch = [3] + C.width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] + # C.stem_head_width = [(1, 1)] + C.stem_head_width = [(8./12, 8./12)] + C.load_path = "search-224x448_F12.L16_batch2-20200828-201547" # path to the searched directory + C.load_epoch = "last" # "last" or "int" (e.g. "30"): which epoch to load from the searched architecture + # C.batch_size = 12 + C.batch_size = 4 + C.Fch = 12 + C.image_height = 512 + C.image_width = 1024 + C.save = "%dx%d_model_batch%d"%(C.image_height, C.image_width, C.batch_size) +elif C.mode == "student": + ##### train student with KL distillation from teacher ############## + C.arch_idx = [0, 1] # 0 for teacher, 1 for student + C.branch = [2, 2] + C.width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] + C.stem_head_width = [(1, 1), (8./12, 8./12),] + C.load_path = "fasterseg" # path to the searched directory + C.teacher_path = "fasterseg" # where to load the pretrained teacher's weight + C.load_epoch = "last" # "last" or "int" (e.g. "30") + C.batch_size = 12 + C.Fch = 12 + C.image_height = 512 + C.image_width = 1024 + C.save = "%dx%d_student_batch%d"%(C.image_height, C.image_width, C.batch_size) + +######################################## +C.is_test = False # if True, prediction files for the test set will be generated +C.is_eval = False # if True, the train.py will only do evaluation for once +C.eval_path = "fasterseg" # path to pretrained directory to be evaluated diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml new file mode 100644 index 000000000..2d0662bf3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml @@ -0,0 +1,42 @@ +_BASE_: ../Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml +MODEL: + WEIGHTS: "detectron2://DeepLab/R-52.pkl" + PIXEL_MEAN: [123.675, 116.280, 103.530] + PIXEL_STD: [58.395, 57.120, 57.375] + BACKBONE: + NAME: "build_resnet_deeplab_backbone" + RESNETS: + DEPTH: 50 + NORM: "SyncBN" + RES5_MULTI_GRID: [1, 2, 4] + STEM_TYPE: "deeplab" + STEM_OUT_CHANNELS: 128 + STRIDE_IN_1X1: False + SEM_SEG_HEAD: + NUM_CLASSES: 133 + LOSS_TOP_K: 1.0 + USE_DEPTHWISE_SEPARABLE_CONV: True + PANOPTIC_DEEPLAB: + STUFF_AREA: 4096 + NMS_KERNEL: 41 + SIZE_DIVISIBILITY: 640 + USE_DEPTHWISE_SEPARABLE_CONV: True +DATASETS: + TRAIN: ("ade20k_sem_seg_train",) + TEST: ("ade20k_sem_seg_val",) +SOLVER: + BASE_LR: 0.0005 + MAX_ITER: 200000000 + IMS_PER_BATCH: 32 +INPUT: + FORMAT: "RGB" + GAUSSIAN_SIGMA: 8 + MIN_SIZE_TRAIN: (256, 320, 352, 416, 448, 512, 576, 608, 672, 704, 768, 832, 864, 928, 960, 1024) + MIN_SIZE_TRAIN_SAMPLING: "choice" + MIN_SIZE_TEST: 512 + MAX_SIZE_TRAIN: 1024 + MAX_SIZE_TEST: 512 + CROP: + ENABLED: True + TYPE: "absolute" + SIZE: (512, 512) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/base.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/base.yaml new file mode 100644 index 000000000..25395009e --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/base.yaml @@ -0,0 +1,42 @@ +_BASE_: ../Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml +MODEL: + WEIGHTS: "detectron2://DeepLab/R-52.pkl" + PIXEL_MEAN: [123.675, 116.280, 103.530] + PIXEL_STD: [58.395, 57.120, 57.375] + BACKBONE: + NAME: "build_resnet_deeplab_backbone" + RESNETS: + DEPTH: 50 + NORM: "SyncBN" + RES5_MULTI_GRID: [1, 2, 4] + STEM_TYPE: "deeplab" + STEM_OUT_CHANNELS: 128 + STRIDE_IN_1X1: False + SEM_SEG_HEAD: + NUM_CLASSES: 133 + LOSS_TOP_K: 1.0 + USE_DEPTHWISE_SEPARABLE_CONV: True + PANOPTIC_DEEPLAB: + STUFF_AREA: 4096 + NMS_KERNEL: 41 + SIZE_DIVISIBILITY: 640 + USE_DEPTHWISE_SEPARABLE_CONV: True +DATASETS: + TRAIN: ("ade20k_sem_seg_train",) + TEST: ("ade20k_sem_seg_val",) +SOLVER: + BASE_LR: 0.0005 + MAX_ITER: 200000000 + IMS_PER_BATCH: 32 +INPUT: + FORMAT: "RGB" + GAUSSIAN_SIGMA: 8 + MIN_SIZE_TRAIN: !!python/object/apply:eval ["[int(x * 0.1 * 640) for x in range(5, 16)]"] + MIN_SIZE_TRAIN_SAMPLING: "choice" + MIN_SIZE_TEST: 640 + MAX_SIZE_TRAIN: 960 + MAX_SIZE_TEST: 640 + CROP: + ENABLED: True + TYPE: "absolute" + SIZE: (640, 640) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml new file mode 100644 index 000000000..e7e134054 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml @@ -0,0 +1,65 @@ +MODEL: + META_ARCHITECTURE: "PanopticDeepLab" + BACKBONE: + FREEZE_AT: 0 + RESNETS: + OUT_FEATURES: ["res2", "res3", "res5"] + RES5_DILATION: 2 + SEM_SEG_HEAD: + NAME: "PanopticDeepLabSemSegHead" + IN_FEATURES: ["res2", "res3", "res5"] + PROJECT_FEATURES: ["res2", "res3"] + PROJECT_CHANNELS: [32, 64] + ASPP_CHANNELS: 256 + ASPP_DILATIONS: [6, 12, 18] + ASPP_DROPOUT: 0.1 + HEAD_CHANNELS: 256 + CONVS_DIM: 256 + COMMON_STRIDE: 4 + NUM_CLASSES: 19 + LOSS_TYPE: "hard_pixel_mining" + NORM: "SyncBN" + INS_EMBED_HEAD: + NAME: "PanopticDeepLabInsEmbedHead" + IN_FEATURES: ["res2", "res3", "res5"] + PROJECT_FEATURES: ["res2", "res3"] + PROJECT_CHANNELS: [32, 64] + ASPP_CHANNELS: 256 + ASPP_DILATIONS: [6, 12, 18] + ASPP_DROPOUT: 0.1 + HEAD_CHANNELS: 32 + CONVS_DIM: 128 + COMMON_STRIDE: 4 + NORM: "SyncBN" + CENTER_LOSS_WEIGHT: 200.0 + OFFSET_LOSS_WEIGHT: 0.01 + PANOPTIC_DEEPLAB: + STUFF_AREA: 2048 + CENTER_THRESHOLD: 0.1 + NMS_KERNEL: 7 + TOP_K_INSTANCE: 200 +DATASETS: + TRAIN: ("cityscapes_fine_panoptic_train",) + TEST: ("cityscapes_fine_panoptic_val",) +SOLVER: + OPTIMIZER: "ADAM" + BASE_LR: 0.001 + WEIGHT_DECAY: 0.0 + WEIGHT_DECAY_NORM: 0.0 + WEIGHT_DECAY_BIAS: 0.0 + MAX_ITER: 60000 + LR_SCHEDULER_NAME: "WarmupPolyLR" + IMS_PER_BATCH: 4 +INPUT: + MIN_SIZE_TRAIN: (512, 640, 704, 832, 896, 1024, 1152, 1216, 1344, 1408, 1536, 1664, 1728, 1856, 1920, 2048) + MIN_SIZE_TRAIN_SAMPLING: "choice" + MIN_SIZE_TEST: 1024 + MAX_SIZE_TRAIN: 4096 + MAX_SIZE_TEST: 2048 + CROP: + ENABLED: True + TYPE: "absolute" + SIZE: (1024, 2048) +DATALOADER: + NUM_WORKERS: 4 +VERSION: 2 \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/base.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/base.yaml new file mode 100644 index 000000000..e7e134054 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/base.yaml @@ -0,0 +1,65 @@ +MODEL: + META_ARCHITECTURE: "PanopticDeepLab" + BACKBONE: + FREEZE_AT: 0 + RESNETS: + OUT_FEATURES: ["res2", "res3", "res5"] + RES5_DILATION: 2 + SEM_SEG_HEAD: + NAME: "PanopticDeepLabSemSegHead" + IN_FEATURES: ["res2", "res3", "res5"] + PROJECT_FEATURES: ["res2", "res3"] + PROJECT_CHANNELS: [32, 64] + ASPP_CHANNELS: 256 + ASPP_DILATIONS: [6, 12, 18] + ASPP_DROPOUT: 0.1 + HEAD_CHANNELS: 256 + CONVS_DIM: 256 + COMMON_STRIDE: 4 + NUM_CLASSES: 19 + LOSS_TYPE: "hard_pixel_mining" + NORM: "SyncBN" + INS_EMBED_HEAD: + NAME: "PanopticDeepLabInsEmbedHead" + IN_FEATURES: ["res2", "res3", "res5"] + PROJECT_FEATURES: ["res2", "res3"] + PROJECT_CHANNELS: [32, 64] + ASPP_CHANNELS: 256 + ASPP_DILATIONS: [6, 12, 18] + ASPP_DROPOUT: 0.1 + HEAD_CHANNELS: 32 + CONVS_DIM: 128 + COMMON_STRIDE: 4 + NORM: "SyncBN" + CENTER_LOSS_WEIGHT: 200.0 + OFFSET_LOSS_WEIGHT: 0.01 + PANOPTIC_DEEPLAB: + STUFF_AREA: 2048 + CENTER_THRESHOLD: 0.1 + NMS_KERNEL: 7 + TOP_K_INSTANCE: 200 +DATASETS: + TRAIN: ("cityscapes_fine_panoptic_train",) + TEST: ("cityscapes_fine_panoptic_val",) +SOLVER: + OPTIMIZER: "ADAM" + BASE_LR: 0.001 + WEIGHT_DECAY: 0.0 + WEIGHT_DECAY_NORM: 0.0 + WEIGHT_DECAY_BIAS: 0.0 + MAX_ITER: 60000 + LR_SCHEDULER_NAME: "WarmupPolyLR" + IMS_PER_BATCH: 4 +INPUT: + MIN_SIZE_TRAIN: (512, 640, 704, 832, 896, 1024, 1152, 1216, 1344, 1408, 1536, 1664, 1728, 1856, 1920, 2048) + MIN_SIZE_TRAIN_SAMPLING: "choice" + MIN_SIZE_TEST: 1024 + MAX_SIZE_TRAIN: 4096 + MAX_SIZE_TEST: 2048 + CROP: + ENABLED: True + TYPE: "absolute" + SIZE: (1024, 2048) +DATALOADER: + NUM_WORKERS: 4 +VERSION: 2 \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml new file mode 100644 index 000000000..fde902bb2 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml @@ -0,0 +1,20 @@ +_BASE_: Base-PanopticDeepLab-OS16.yaml +MODEL: + WEIGHTS: "detectron2://DeepLab/R-52.pkl" + PIXEL_MEAN: [123.675, 116.280, 103.530] + PIXEL_STD: [58.395, 57.120, 57.375] + BACKBONE: + NAME: "build_resnet_deeplab_backbone" + RESNETS: + DEPTH: 50 + NORM: "SyncBN" + RES5_MULTI_GRID: [1, 2, 4] + STEM_TYPE: "deeplab" + STEM_OUT_CHANNELS: 128 + STRIDE_IN_1X1: False +SOLVER: + MAX_ITER: 90000 +INPUT: + FORMAT: "RGB" + CROP: + SIZE: (512, 1024) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml new file mode 100644 index 000000000..8e314204c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024_dsconv.yaml @@ -0,0 +1,24 @@ +_BASE_: Base-PanopticDeepLab-OS16.yaml +MODEL: + WEIGHTS: "detectron2://DeepLab/R-52.pkl" + PIXEL_MEAN: [123.675, 116.280, 103.530] + PIXEL_STD: [58.395, 57.120, 57.375] + BACKBONE: + NAME: "build_resnet_deeplab_backbone" + RESNETS: + DEPTH: 50 + NORM: "SyncBN" + RES5_MULTI_GRID: [1, 2, 4] + STEM_TYPE: "deeplab" + STEM_OUT_CHANNELS: 128 + STRIDE_IN_1X1: False + PANOPTIC_DEEPLAB: + USE_DEPTHWISE_SEPARABLE_CONV: True + SEM_SEG_HEAD: + USE_DEPTHWISE_SEPARABLE_CONV: True +SOLVER: + MAX_ITER: 90000 +INPUT: + FORMAT: "RGB" + CROP: + SIZE: (512, 1024) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cydas.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cydas.py new file mode 100644 index 000000000..2fee9f915 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/cydas.py @@ -0,0 +1,435 @@ +import torch +import torch.nn as nn +from torch.nn import functional as F +from builder import * +from operations import * +from operations import DropPath_ +from genotypes import PRIMITIVES +from pdb import set_trace as bp +from seg_oprs import FeatureFusion, Head, Decoder +from layers import NaiveSyncBatchNorm + +# BatchNorm2d = nn.BatchNorm2d +BatchNorm2d = NaiveSyncBatchNorm + +IMAGENET_DEFAULT_MEAN = (0.485, 0.456, 0.406) +IMAGENET_DEFAULT_STD = (0.229, 0.224, 0.225) +IMAGENET_INCEPTION_MEAN = (0.5, 0.5, 0.5) +IMAGENET_INCEPTION_STD = (0.5, 0.5, 0.5) + +def hard_sigmoid(x, inplace: bool = False): + if inplace: + return x.add_(3.).clamp_(0., 6.).div_(6.) + else: + return F.relu6(x + 3.) / 6. + +class HardSigmoid(nn.Module): + def __init__(self, inplace: bool = False): + super(HardSigmoid, self).__init__() + self.inplace = inplace + + def forward(self, x): + return hard_sigmoid(x, self.inplace) + +class SelectAdaptivePool2d(nn.Module): + """Selectable global pooling layer with dynamic input kernel size + """ + def __init__(self, output_size=1, pool_type='avg', flatten=False): + super(SelectAdaptivePool2d, self).__init__() + self.output_size = output_size + self.pool_type = pool_type + self.flatten = flatten + if pool_type == 'avgmax': + self.pool = AdaptiveAvgMaxPool2d(output_size) + elif pool_type == 'catavgmax': + self.pool = AdaptiveCatAvgMaxPool2d(output_size) + elif pool_type == 'max': + self.pool = nn.AdaptiveMaxPool2d(output_size) + else: + if pool_type != 'avg': + assert False, 'Invalid pool type: %s' % pool_type + self.pool = nn.AdaptiveAvgPool2d(output_size) + + def forward(self, x): + x = self.pool(x) + if self.flatten: + x = x.flatten(1) + return x + + def feat_mult(self): + return adaptive_pool_feat_mult(self.pool_type) + + def __repr__(self): + return self.__class__.__name__ + ' (' \ + + 'output_size=' + str(self.output_size) \ + + ', pool_type=' + self.pool_type + ')' + +def create_conv2d(in_chs, out_chs, kernel_size, **kwargs): + """ Select a 2d convolution implementation based on arguments + Creates and returns one of torch.nn.Conv2d, Conv2dSame, MixedConv2d, or CondConv2d. + Used extensively by EfficientNet, MobileNetv3 and related networks. + """ + assert 'groups' not in kwargs # only use 'depthwise' bool arg + if isinstance(kernel_size, list): + assert 'num_experts' not in kwargs # MixNet + CondConv combo not supported currently + # We're going to use only lists for defining the MixedConv2d kernel groups, + # ints, tuples, other iterables will continue to pass to normal conv and specify h, w. + m = MixedConv2d(in_chs, out_chs, kernel_size, **kwargs) + else: + depthwise = kwargs.pop('depthwise', False) + groups = out_chs if depthwise else 1 + if 'num_experts' in kwargs and kwargs['num_experts'] > 0: + m = CondConv2d(in_chs, out_chs, kernel_size, groups=groups, **kwargs) + else: + m = create_conv2d_pad(in_chs, out_chs, kernel_size, groups=groups, **kwargs) + return m + +def _cfg(url='', **kwargs): + return { + 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), + 'crop_pct': 0.875, 'interpolation': 'bilinear', + 'mean': IMAGENET_DEFAULT_MEAN, 'std': IMAGENET_DEFAULT_STD, + 'first_conv': 'conv_stem', 'classifier': 'classifier', + **kwargs + } + +def conv_bn(inp, oup, stride, groups=1, act_fn=nn.ReLU): + return nn.Sequential( + nn.Conv2d(inp, oup, 3, stride, 1, bias=False, groups=groups), + nn.BatchNorm2d(oup), + act_fn(inplace=True) + ) + + +def conv_1x1_bn(inp, oup, groups=1, act_fn=nn.ReLU): + return nn.Sequential( + nn.Conv2d(inp, oup, 1, 1, 0, bias=False, groups=groups), + nn.BatchNorm2d(oup), + act_fn(inplace=True) + ) + + + +default_cfgs = { + 'mobilenetv3_large_075': _cfg(url=''), + 'mobilenetv3_large_100': _cfg( + interpolation='bicubic', + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_large_100_ra-f55367f5.pth'), + 'mobilenetv3_small_075': _cfg(url=''), + 'mobilenetv3_small_100': _cfg(url=''), + 'mobilenetv3_rw': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/mobilenetv3_100-35495452.pth', + interpolation='bicubic'), + 'tf_mobilenetv3_large_075': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_large_075-150ee8b0.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), + 'tf_mobilenetv3_large_100': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_large_100-427764d5.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), + 'tf_mobilenetv3_large_minimal_100': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_large_minimal_100-8596ae28.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), + 'tf_mobilenetv3_small_075': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_small_075-da427f52.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), + 'tf_mobilenetv3_small_100': _cfg( + url= 'https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_small_100-37f49e2b.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), + 'tf_mobilenetv3_small_minimal_100': _cfg( + url='https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/tf_mobilenetv3_small_minimal_100-922a7843.pth', + mean=IMAGENET_INCEPTION_MEAN, std=IMAGENET_INCEPTION_STD), +} + +_DEBUG = False + + +class ChildNet(nn.Module): + + def __init__(self, block_args, num_classes=1000, in_chans=3, stem_size=16, num_features=1280, head_bias=True, + channel_multiplier=1.0, pad_type='', act_layer=nn.ReLU, drop_rate=0., drop_path_rate=0., + se_kwargs=None, norm_layer=nn.BatchNorm2d, norm_kwargs=None, global_pool='avg', pool_bn=False, zero_gamma=False): + super(ChildNet, self).__init__() + + norm_layer = BatchNorm2d + self.num_classes = num_classes + self.num_features = num_features + self.drop_rate = drop_rate + self._in_chs = in_chans + self.pool_bn = pool_bn + + # Stem + stem_size = round_channels(stem_size, channel_multiplier) + self.conv_stem = create_conv2d(self._in_chs, stem_size, 3, stride=2, padding=pad_type) + self.bn1 = norm_layer(stem_size, **norm_kwargs) + self.act1 = act_layer(inplace=True) + self._in_chs = stem_size + + # Middle stages (IR/ER/DS Blocks) + builder = ChildNetBuilder( + channel_multiplier, 8, None, 32, pad_type, act_layer, se_kwargs, + norm_layer, norm_kwargs, drop_path_rate, verbose=_DEBUG) + self.blocks = nn.Sequential(*builder(self._in_chs, block_args)) + # self.blocks = builder(self._in_chs, block_args) + self._in_chs = builder.in_chs + + # Head + Pooling + self.global_pool = SelectAdaptivePool2d(pool_type=global_pool) + self.conv_head = create_conv2d(self._in_chs, self.num_features, 1, padding=pad_type, bias=head_bias) + self.act2 = act_layer(inplace=True) + + # Classifier + self.classifier = nn.Linear(self.num_features * self.global_pool.feat_mult(), self.num_classes) + + if pool_bn: + self.pool_bn = nn.BatchNorm1d(1) + + efficientnet_init_weights(self, zero_gamma=zero_gamma) + + def get_classifier(self): + return self.classifier + + def reset_classifier(self, num_classes, global_pool='avg'): + self.global_pool = SelectAdaptivePool2d(pool_type=global_pool) + self.num_classes = num_classes + self.classifier = nn.Linear( + self.num_features * self.global_pool.feat_mult(), num_classes) if self.num_classes else None + + def forward_features(self, x): + # architecture = [[0], [], [], [], [], [0]] + x = self.conv_stem(x) + x = self.bn1(x) + x = self.act1(x) + outputs = [] + # 16, 24, 40, 96, 320 + # block_idxs = [0, 1, 2, 4, 6] + block_idxs = [1, 2, 4, 6] + for i, block in enumerate(self.blocks): + x = block(x) + if i in block_idxs: + outputs.append(x) + + # x = self.blocks(x) + return tuple(outputs) + + def forward(self, x): + x = self.forward_features(x) + return x + + +def modify_block_args(block_args, kernel_size, exp_ratio): + # kernel_size: 3,5,7 + # exp_ratio: 4,6 + block_type = block_args['block_type'] + # each type of block has different valid arguments, fill accordingly + if block_type == 'cn': + block_args['kernel_size'] = kernel_size + elif block_type == 'er': + block_args['exp_kernel_size'] = kernel_size + else: + block_args['dw_kernel_size'] = kernel_size + + if block_type == 'ir' or block_type == 'er': + block_args['exp_ratio'] = exp_ratio + return block_args + + +def _gen_childnet(**kwargs): + # arch_list = [[0], [3, 2], [3, 2], [3, 3], [3, 3, 3], [3, 3, 3], [0]] + # arch_list = [[0], [3, 2, 3, 3], [3, 2, 3, 1], [3, 0, 3, 2], [3, 3, 3, 3], [3, 3, 3, 3], [0]] + # arch_list = [[0], [3,4,3,1],[3,2,3,0],[3,3,3,1],[3,3,3,3],[3,3,3,3],[0]] + arch_list = [[0], [3, 4, 2, 0], [5, 2, 4, 0], [4, 3, 2, 2], [1, 3, 0, 1], [2, 4, 4, 2], [0]] + # arch_list = [[0], [], [], [], [], [0]] + choices = {'kernel_size': [3, 5, 7], 'exp_ratio': [4, 6]} + choices_list = [[x,y] for x in choices['kernel_size'] for y in choices['exp_ratio']] + + num_features = 1280 + + # act_layer = HardSwish + act_layer = Swish + ''' + arch_def = [ + # stage 0, 112x112 in + ['ds_r1_k3_s1_e1_c16_se0.25'], + # stage 1, 112x112 in + ['ir_r1_k3_s2_e4_c24_se0.25', 'ir_r1_k3_s1_e4_c24_se0.25'], + # stage 2, 56x56 in + ['ir_r1_k5_s2_e4_c40_se0.25', 'ir_r1_k5_s2_e4_c40_se0.25'], + # stage 3, 28x28 in + ['ir_r1_k3_s2_e6_c80_se0.25', 'ir_r2_k3_s1_e4_c80_se0.25'], + # stage 4, 14x14in + ['ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25'], + # stage 5, 14x14in + ['ir_r1_k5_s2_e6_c192_se0.25', 'ir_r1_k5_s1_e6_c192_se0.25', 'ir_r1_k5_s2_e6_c192_se0.25'], + # stage 6, 7x7 in + ['cn_r1_k1_s1_c320_se0.25'], + ] + ''' + arch_def = [ + # stage 0, 112x112 in + ['ds_r1_k3_s1_e1_c16_se0.25'], + # stage 1, 112x112 in + ['ir_r1_k3_s2_e4_c24_se0.25', 'ir_r1_k3_s1_e4_c24_se0.25', 'ir_r1_k3_s1_e4_c24_se0.25', 'ir_r1_k3_s1_e4_c24_se0.25'], + # stage 2, 56x56 in + ['ir_r1_k5_s2_e4_c40_se0.25', 'ir_r1_k5_s1_e4_c40_se0.25', 'ir_r1_k5_s2_e4_c40_se0.25', 'ir_r1_k5_s2_e4_c40_se0.25'], + # stage 3, 28x28 in + ['ir_r1_k3_s2_e6_c80_se0.25', 'ir_r1_k3_s1_e4_c80_se0.25', 'ir_r1_k3_s1_e4_c80_se0.25', 'ir_r2_k3_s1_e4_c80_se0.25'], + # stage 4, 14x14in + ['ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25'], + # stage 5, 14x14in + ['ir_r1_k5_s2_e6_c192_se0.25', 'ir_r1_k5_s1_e6_c192_se0.25', 'ir_r1_k5_s2_e6_c192_se0.25', 'ir_r1_k5_s2_e6_c192_se0.25'], + # stage 6, 7x7 in + ['cn_r1_k1_s1_c320_se0.25'], + ] + #arch_def = [ + # # stage 0, 112x112 in + # ['ds_r1_k3_s1_e1_c16_se0.25'], + # # stage 1, 112x112 in + # ['ir_r1_k3_s2_e4_c24_se0.25'], + # # stage 2, 56x56 in + # ['ir_r1_k5_s2_e4_c40_se0.25', 'ir_r1_k5_s2_e4_c40_se0.25'], + # # stage 3, 28x28 in + # ['ir_r1_k3_s2_e6_c80_se0.25', 'ir_r1_k3_s2_e6_c80_se0.25', 'ir_r1_k3_s2_e6_c80_se0.25'], + # # stage 4, 14x14in + # ['ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25', 'ir_r1_k3_s1_e6_c96_se0.25'], + # # stage 5, 14x14in + # ['ir_r1_k5_s2_e6_c192_se0.25', 'ir_r1_k5_s2_e6_c192_se0.25', 'ir_r1_k5_s2_e6_c192_se0.25'], + # # stage 6, 7x7 in + # ['cn_r1_k1_s1_c320_se0.25'], + #] + + + new_arch = [] + # change to child arch_def + for i, (layer_choice, layer_arch) in enumerate(zip(arch_list, arch_def)): + if len(layer_arch) == 1: + new_arch.append(layer_arch) + continue + else: + new_layer = [] + for j, (block_choice, block_arch) in enumerate(zip(layer_choice, layer_arch)): + kernel_size, exp_ratio = choices_list[block_choice] + elements = block_arch.split('_') + block_arch = block_arch.replace(elements[2], 'k{}'.format(str(kernel_size))) + block_arch = block_arch.replace(elements[4], 'e{}'.format(str(exp_ratio))) + new_layer.append(block_arch) + new_arch.append(new_layer) + + model_kwargs = dict( + block_args=decode_arch_def(new_arch), + num_features=num_features, + stem_size=16, + # channel_multiplier=channel_multiplier, + norm_kwargs=resolve_bn_args(kwargs), + act_layer=act_layer, + se_kwargs=dict(act_layer=nn.ReLU, gate_fn=hard_sigmoid, reduce_mid=True, divisor=8), + num_classes=1000, + drop_rate=0.2, + drop_path_rate=0.2, + global_pool='avg' + ) + model = ChildNet(**model_kwargs) + return model + +class CyDASseg(nn.Module): + def __init__(self, Fch=12, num_classes=19, stem_head_width=(1., 1.)): + super(CyDASseg, self).__init__() + self._num_classes = num_classes + self._stem_head_width = stem_head_width + self.backbone = _gen_childnet() + # self.f_channels = [16, 24, 40, 96] + self.f_channels = [24, 40, 96, 320] + self._Fch = Fch + # del self.backbone.blocks[3][2] + + #for m in self.backbone.modules(): + # if isinstance(m, nn.BatchNorm2d): + # m.eval() + # m.weight.requires_grad = False + # m.bias.requires_grad = False + + self.last_channel = self.backbone.blocks[-1][-1].conv.out_channels # self.backbone.blocks[-1][-1] + + # building decoder + self.build_arm_ffm_head() + + def init_weights(self, pretrained=None): + if pretrained: + state_dict = torch.load(pretrained) + state_dict = state_dict['state_dict'] + # resume_checkpoint(self.backbone, pretrained) + self.backbone.load_state_dict(state_dict, strict=True) + else: + print("No pretrained model!") + return + + def build_arm_ffm_head(self): + + # 24, 40, 96, 320 + + if self.training: + self.heads32 = Head(self.f_channels[-1], self._num_classes, True, norm_layer=BatchNorm2d) + self.heads16 = Head(self.f_channels[-2], self._num_classes, True, norm_layer=BatchNorm2d) + + self.heads8 = Decoder(self.num_filters(8, self._stem_head_width[1]), self.f_channels[0], self._num_classes, Fch=self._Fch, scale=4, branch=1, is_aux=False, norm_layer=BatchNorm2d) + + self.arms32 = nn.ModuleList([ + ConvNorm(self.f_channels[-1], self.num_filters(16, self._stem_head_width[1]), 1, 1, 0, slimmable=False), + ConvNorm(self.num_filters(16, self._stem_head_width[1]), self.num_filters(8, self._stem_head_width[1]), 1, 1, 0, slimmable=False), + ]) + + self.refines32 = nn.ModuleList([ + ConvNorm(self.num_filters(16, self._stem_head_width[1])+self.f_channels[-2], self.num_filters(16, self._stem_head_width[1]), 3, 1, 1, slimmable=False), + ConvNorm(self.num_filters(8, self._stem_head_width[1])+self.f_channels[-3], self.num_filters(8, self._stem_head_width[1]), 3, 1, 1, slimmable=False), + ]) + + + self.ffm = FeatureFusion(self.num_filters(8, self._stem_head_width[1]), self.num_filters(8, self._stem_head_width[1]), reduction=1, Fch=self._Fch, scale=8, branch=1, norm_layer=BatchNorm2d) + + def agg_ffm(self, outputs8, outputs16, outputs32, outputs4): + pred32 = []; pred16 = []; pred8 = [] # order of predictions is not important + + if self.training: pred32.append(outputs32) + out = self.arms32[0](outputs32) + out = F.interpolate(out, size=(int(out.size(2))*2, int(out.size(3))*2), mode='bilinear', align_corners=False) + out = self.refines32[0](torch.cat([out, outputs16], dim=1)) + if self.training: pred16.append(outputs16) + out = self.arms32[1](out) + out = F.interpolate(out, size=(int(out.size(2))*2, int(out.size(3))*2), mode='bilinear', align_corners=False) + out = self.refines32[1](torch.cat([out, outputs8], dim=1)) + pred8.append(out) + + if len(pred32) > 0: + pred32 = self.heads32(torch.cat(pred32, dim=1)) + else: + pred32 = None + if len(pred16) > 0: + pred16 = self.heads16(torch.cat(pred16, dim=1)) + else: + pred16 = None + pred8 = self.heads8(self.ffm(torch.cat(pred8, dim=1)), outputs4) + if self.training: + return pred8, pred16, pred32 + else: + return pred8 + + def num_filters(self, scale, width=1.0): + return int(np.round(scale * self._Fch * width)) + + def forward(self, x): + b,c,h,w = x.shape + outputs = self.backbone(x) + + outputs4, outputs8, outputs16, outputs32 =outputs[0], outputs[1], outputs[2], outputs[3] + if self.training: + pred8, pred16, pred32 = self.agg_ffm(outputs8, outputs16, outputs32, outputs4) + pred8 = F.interpolate(pred8, size=(h,w), mode='bilinear', align_corners=False) + if pred16 is not None: pred16 = F.interpolate(pred16, size=(h,w), mode='bilinear', align_corners=False) + if pred32 is not None: pred32 = F.interpolate(pred32, size=(h,w), mode='bilinear', align_corners=False) + return pred8, pred16, pred32 + else: + pred8 = self.agg_ffm(outputs8, outputs16, outputs32, outputs4) + out = F.interpolate(pred8, size=(int(pred8.size(2))*4, int(pred8.size(3))*4), mode='bilinear', align_corners=False) + return out + + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/dataloader.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/dataloader.py new file mode 100644 index 000000000..a6e0b213c --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/dataloader.py @@ -0,0 +1,93 @@ +import torch +import cv2 +cv2.setNumThreads(0) +from torch.utils import data + +from utils.img_utils import random_scale, random_mirror, normalize, generate_random_crop_pos, random_crop_pad_to_shape + + +class TrainPre(object): + def __init__(self, config, img_mean, img_std): + self.img_mean = img_mean + self.img_std = img_std + self.config = config + + def __call__(self, img, gt): + img, gt = random_mirror(img, gt) + if self.config.train_scale_array is not None: + img, gt, scale = random_scale(img, gt, self.config.train_scale_array) + + img = normalize(img, self.img_mean, self.img_std) + + crop_size = (self.config.image_height, self.config.image_width) + crop_pos = generate_random_crop_pos(img.shape[:2], crop_size) + p_img, _ = random_crop_pad_to_shape(img, crop_pos, crop_size, 0) + p_gt, _ = random_crop_pad_to_shape(gt, crop_pos, crop_size, 255) + p_gt = cv2.resize(p_gt, (self.config.image_width // self.config.gt_down_sampling, self.config.image_height // self.config.gt_down_sampling), interpolation=cv2.INTER_NEAREST) + + p_img = p_img.transpose(2, 0, 1) + + extra_dict = None + + return p_img, p_gt, extra_dict + + +class CyclicIterator: + def __init__(self, loader, sampler, distributed): + self.loader = loader + self.sampler = sampler + self.epoch = 0 + self.distributed = distributed + self._next_epoch() + + def _next_epoch(self): + if self.distributed: + self.sampler.set_epoch(self.epoch) + self.iterator = iter(self.loader) + self.epoch += 1 + + def __len__(self): + return len(self.loader) + + def __iter__(self): + return self + + def __next__(self): + try: + return next(self.iterator) + except StopIteration: + self._next_epoch() + return next(self.iterator) + +def get_train_loader(config, dataset, portion=None, worker=None, test=False): + data_setting = {'img_root': config.img_root_folder, + 'gt_root': config.gt_root_folder, + 'train_source': config.train_source, + 'eval_source': config.eval_source, + 'down_sampling': config.down_sampling, + 'portion': portion} + if test: + data_setting = {'img_root': config.img_root_folder, + 'gt_root': config.gt_root_folder, + 'train_source': config.train_eval_source, + 'eval_source': config.eval_source, + 'down_sampling': config.down_sampling, + 'portion': portion} + train_preprocess = TrainPre(config, config.image_mean, config.image_std) + + train_dataset = dataset(data_setting, "train", train_preprocess, config.batch_size * config.niters_per_epoch) + + is_shuffle = True + batch_size = config.batch_size + + train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset) + + train_loader = data.DataLoader(train_dataset, + batch_size=batch_size, + sampler = train_sampler, + num_workers=config.num_workers if worker is None else worker, + # drop_last=True, + # shuffle=is_shuffle, + pin_memory=True) + + return train_loader, train_sampler diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/eval.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/eval.py new file mode 100644 index 000000000..678daa385 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/eval.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +import os +import cv2 +cv2.setNumThreads(0) +import numpy as np + +from utils.visualize import print_iou, show_img, show_prediction +from engine.evaluator import Evaluator +from engine.logger import get_logger +from seg_opr.metric import hist_info, compute_score + +logger = get_logger() + + +class SegEvaluator(Evaluator): + def func_per_iteration(self, data, device, iter=None): + if self.config is not None: config = self.config + img = data['data'] + label = data['label'] + name = data['fn'] + + if len(config.eval_scale_array) == 1: + pred = self.whole_eval(img, None, device) + else: + pred = self.sliding_eval(img, config.eval_crop_size, config.eval_stride_rate, device) + hist_tmp, labeled_tmp, correct_tmp = hist_info(config.num_classes, pred, label) + results_dict = {'hist': hist_tmp, 'labeled': labeled_tmp, 'correct': correct_tmp} + + if self.save_path is not None: + fn = name + '.png' + cv2.imwrite(os.path.join(self.save_path, fn), pred) + logger.info('Save the image ' + fn) + + # tensorboard logger does not fit multiprocess + if self.logger is not None and iter is not None: + colors = self.dataset.get_class_colors() + image = img + clean = np.zeros(label.shape) + comp_img = show_img(colors, config.background, image, clean, label, pred) + self.logger.add_image('vis', np.swapaxes(np.swapaxes(comp_img, 0, 2), 1, 2), iter) + + if self.show_image or self.show_prediction: + colors = self.dataset.get_class_colors() + image = img + clean = np.zeros(label.shape) + if self.show_image: + comp_img = show_img(colors, config.background, image, clean, label, pred) + else: + comp_img = show_prediction(colors, config.background, image, pred) + cv2.imwrite(name + ".png", comp_img[:,:,::-1]) + + return results_dict + + def compute_metric(self, results): + hist = np.zeros((self.config.num_classes, self.config.num_classes)) + correct = 0 + labeled = 0 + count = 0 + for d in results: + hist += d['hist'] + correct += d['correct'] + labeled += d['labeled'] + count += 1 + + iu, mean_IU, mean_IU_no_back, mean_pixel_acc = compute_score(hist, correct, labeled) + result_line = print_iou(iu, mean_pixel_acc, self.dataset.get_class_names(), True) + return result_line, mean_IU diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/genotypes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/genotypes.py new file mode 100644 index 000000000..e5d529595 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/genotypes.py @@ -0,0 +1,13 @@ +from collections import namedtuple + +Genotype = namedtuple('Genotype', 'normal normal_concat reduce reduce_concat') + +PRIMITIVES = [ + 'skip', + 'conv', + 'conv_downup', + 'conv_2x_downup', + 'sa', +] + +# 'conv_2x', \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/latency_lookup_table.npy b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/latency_lookup_table.npy new file mode 100644 index 0000000000000000000000000000000000000000..84ee13fae909502070d6086288a5031cd2edaf35 GIT binary patch literal 50122 zcmbuIbwCwa`^OO#yIa>@Yt4Ht%xhn}0}~NZQ33CW0mizn-MYrwC<=ltDh8-vU|^sq z26p$lu3hh$hchz|bIzH2{r%oQUU+@EAD;L=F=ysp{%YT?UB{kjoJKp1D>u+;`bl0@d`1oT_x6w^kATeXl9#8S??``Xl&61Yn^Ve9W%eDI^8eb>v~ikh zbM|!i^c(2qIWn`Cul!ABTUxg?PEJk(Z0X!w$k*W>{@%VOTl#4>m(I2f(`^|$+cK4J zlcoZN4fGEfL0*&D&6)gc2UlB`HcoBQOt)q2Y|B=@O$uqeEqnX+?OXpK|AGH%WAV4; z7%;Q1E$0MVuJUeG$qSqM`HpVyC;7OytX0Fkhso^f-jw{(I%fB#exv;B)N&u@CHZ;{ zH@Op6ya#%jY`LwLox2OBbDwX2{ma)D$z! zw!BtL@Ji3st`{E*Ue2+DIHJWglG07xK&HkkA+) zFY;S0CtMcX^Km`x)<_=>_kn(6d`FFN*GI**ni5-ow+s764I^LJ`2S+H#LcSwrhTh__#Dk1nJD`w>x1PKwOWpN zdS}0-LUcgwuobsjwxoSAdU^lhtQT@r z(J!aL(9~l_*)CzV96J`*>&DyfZjBvPH?4U-u%y*;eb@lcywB_M4b#GFobFOq%jxs! zZ@>8N%I6>lnexC6mbO|>UTf5@c*!fq4kDhCEzLm_irBAK%LPj=&(M+k#JZO24Fk1a z%j&3%)e@DjP~g};Ys5T3e<87Cd1bAZ*f$Nz^yuX-=IQ$Zl?azt&T5Hn{cZf%!P5mo zMUK);R5w?nhM8^UNf+OlHZHk)SvHTU+pwYsZ3f`5SFl=+-pep1+kuQ?xA?+G)}S>0 zX0=@GGU>BZ;8oTxeYmMxYWZP(RkT_z<#WCk5__HHr1np3Cu(%Cf0eA3gWacP+FN3g zSf~2585Uw?t7TvKj{*fcoe&2swSjV=px6r4KlLIT@p@zN=X+cUz}lbN=^1#(r_kAy}4YBJ+LeqB5pB zYx#C*4NHlS<`qt$nRL=k4QoGM9q3j^-$`}ClpBj2Xie!@QPr)MYva5-)E#?>HAqev zsy7-ZZ9rj84XfpFvx?DsGW-w}E{+i0SkwraZ8fcykU^0j^CyoH3sUbF9hm&aS<7lU z7v4H=g*JJ99;oUFN4&Pxa@>DM_!6IbY@qatqW*FBR9CCzN{{5_N#n<|oYWPfB#!T3 z9kQX!*nH<>!<@#-WD}?<3Ma6x)e>rRZtq&Ps~~|0q|87yP-a^_t7UBupN%`h68LW6 z^y?Q4Y({-D01_Ac)4X{nmLrE*D-f9|UYHtKEy*vgzG`^!l{o)8eH+KSA=%{iX1R2D zK@I!yQD(X-aFfkqwS+Z1(IDRsi{RxrK;(6@XPSO&jmT9}j^#7@e+d)2qgNrNX!5~v zZfv#OoS!}S?I>?!`DpQ08j{vWaCtN#i^a)o>s{uFHcSMfS3p`LG1;10EgL<;-2?ka zv1!+(i4h+*qZzplNNe8a+dd1QgRD^I4|m^gP6oD9SpL$j3$PqrA5y}s6$2XlEr^`= z=6HFk?E*)`tjL-lW~pZD`M;oCucSIOh-#^&H~Q}?)G>Q2_T za?kdiy+4&7CZtoPT-5U`9Ht)R!lIzx{o|IoEJv0TsusigbtC(2>mNt`tA-20!!by$ zUz4pTxem0fK34DVkv|*7eOmI}!eKU2V{fAB)&qL>89d9_F65oE zOK_{MkJWOZYh>RUzvVaPX<1YvZZsLcjMFM@!f948=Zx^w7)Ke>s$Xjd&^3^#moG+H}X&<4Kz6ijIMOug(w~ zr~@(vV%ZKPa+6jq&AIHGF;B~?GQ+fE49xQ)a_hA=(gisJ0J98r>!n-ioE#i!w{<_KH2krfb$2z z@dNTu4Vk(~nr+@hX~*9MR(UkX*fWe#`k`8w*t4OeFlXog=n)fVzX8z@X;%*@!98s znm|&OY=^dyl5Q|-o%hQ+tU#{o=@p<~j4)@U)$-7? zz88mlmwLtdm_vQWuuk;0%rt0kepoMuI*G!aZ|E#yiH zwc0V+#*q`Hc};v19;JgG%)PH%y=KZKq}+p3ZY)<3FSqsW>^Ch~A?OuOD_V0D2ksB63O`+I?4QO{>V@C(rjZuq^3Ue*W*Y?Y#wD!uCh}E@_jIzxzkEA5&BbQM z_8<)T7Df%X!_6RvaxrbY?_NKFA16-UxB{PPwcJ?j_S_@a3PD3b2C<2=%_45~9UtR1 z{gkeu;NPz-=;ZbKhBBKplm$gcE-Vmh92PB2GFT3ab_9UaK8MuTlkKi9UIs@d{7J{> z%_Ub46CdQB{6|}Um^HhUYd5}p=8+w7-sgEseO5XgX3Ze8Z9X}}%QUTfoj%u$!-S(w zOoKS_Hl79KWVv(go=({+*mFzS#APx&9~Y7%j(P!izI*O5N`H+MA#>8d$ZEM$rE643 z+YNT@plRoa_b>7YO-$eD!oN%ugjdUxQs$`r*cMwY>uw+Xug<0*)(riar&URsJR6QB z}!CAyYOkF67hy1;0BRRWwFLr0~EMIr_q21c(YP zlw8of-dL}xx8RUm%bd~x_!D3gIZa-$>+9y2*Q`DI%uy+FJ6#xg8tDG*V+Ybd7I!*5 zPf>!lULyy?Nx-Z3@jdG6K%hvZWo>c|+e}KNd;Mvf2UO)dhyuml+d%egA)R+;&Sn+; zoAWtX0Ms6>b0E%Ea`^J9M!=Twzr)DYE+tt*ZVt#Jbj9H&AP2 z1KA0+olMHHiG}Ot=*qe!&?8sZJFJ$(F|SOYn>E#SBJ$J9CAzvo5KB^bB9m<=(NBS8 z`~R-{!q_h@N=m)*{n|wi@n+P>!Q|~56KjGyD4XXO5m?zf<3K#iSR<%~Qn74=MU~E)!`sm7R-uN7T z!`(}6;=gLJZhDq5U7V01W_gUz`!uQJWU@t))h#x%e3gir;=0%AQ8ol{YU9SUaUW@H zRbIS_8q{4JC>h8R0++X6-bid!mX$my=II*~T_MP?U<>8|nNUYNH!7H6xnO0+il7}_ zQ-tlH)v|tAwv72|eHNReuRCgv+TO4ZqR8EWCPlyWbl=MkOg)F{Q!5w@iY6yY+gD`m z`)wLuP}nUx2)O<25E*dU>phxQ>2G5Pk-lWKEC@ABSPzFu;q2*JIlk#p`wr4T@f|!u z4w>^lxZfu9tm8^GJW7fo7jeOxZGp^Ra+W27T|DEc~kzmt5oP~yn9N?%|LPDW8Hrbqjw{GIsP6={WJr`)2Tzjc0!9XWy%pO` zEGWIBROwnT#*UsMz&q7q4<{VwM+`ft)Up~eT+63Pk19Am`h2s)EJ#)+N}&>ZbZUZ@ zl`~e$gMNFKWnDJYaTjTK*VbrkSv+yE;Qd3h^F4rZ!#+!mO{2j=1JHJs9O%rLMDF)G z8EXMys1*1iKPPvqn0Xx!Flz$&<;qFCat=pG`tf(3JhHsMXkwR6?SIxD;?NZOwxnQy-kgZ^6{fLgv&5iSgm88UnIGmz!oUe=I8M?LZw`O~6NU~a5oPo{^IJ$%pyNQgerVFi5xh#8 zMBeQCJDu4mkQyhaTIg)o$n!5n0}r2>(a1PpL|)4Nuk;%7Piz9N6QwQRd^uk~f43r} zyoY#s3`~6&MbT*;+YNGRIr!A5!lPdcEXVSuK~;aJ*_LdzZ0hS1QamxIpa*eYu8GEM zyGe?yOXStsJysfL0(-735^B4~eg77@NAl{^nk<=*8i!I#h@xe!Yh&JRvdYcRV19F( z^Ps1`$msk>{-JJkhiLBKibIaXEfEA-vq-tN)7rktc9*;nb8MOSf@28~fH(h<0Z^Fvi(bL;dZF|TZXiP z6BwK?+Kk8-cJRF=kJA-+`>c7yFJiZJfmiBIeY+yAyZ^{ZnqQ6ROZS%9tzX)f`1yNB zrpTrSJ3HX7R+aI(s4OF zsYl-2{K~`r8E$r8Nay|c@UdAL_pl(HhcZ*%*7+`eB`s;?+^!=m#dL>**c21JO-;n4 zPuVwe`!h?$mWh!=9j-7m`EB3H?d7nkmkuxGOh&mPH08o11;NUrh)QjeCdhUQKnQyH>`{T{2KP!+*BfUZYMYFd1&{|Twdmur z^k0EdICE4++H{n%0wK~`IKA_``uqrK!B&c2ix3WWHb7mgRkz&Oko7D|SO3Ze%2iQz zKt(N#U0TKISDlK;3zW-T^5&A1W<g@Bo~<7J(J6JJ72883FqB-FGf6$ZriK@&O*Ds)|} zTG=eDT3QHv)fNHfg@0K6ZzA2kk3O#oKKFMv9?^XaxSez{qczL@A{NBm^#vnZg> zIC($3(DN7&ExjR;wk2JOEc$V5ra>HNG&;KRBCy^ zk}Cno-2r)~Pi(~bz^BwDrKnfi`Z1~`pbi)MKIl`cmuw#N@-SK_N&)KXnL@SOoY-Wn zI5ZcGJuMB)ll{judEzo(%oNB)J2Ao1`xTf`X}q1@Bs%bp4t;Jhstllxv|Zfn_MSU} zI>o-y?uLq9Dhr5>jdln0%;$9+DXd5$}9@HHkPWAZWX^T(7cTG#gA( zbs(%e*d@>Qc882bjH0XLngp30WHkVJ@@9^P?ff3|C8*h?^iBT7R82tLKA5AsrBkv4 zK~|Ek%Em0!0z_zr9g~hnHWh>j2bsD?s+4*r)doUj{mCzLTkXG*heS!-gI)Hju+hya_q^p9^V85t%wDD<{>H;Dn-J|ZiJHBJB(e*;=m^O^C zHT3`$-SKpje?C?+ZvWUQ+6$3UsQuRm=8cQ}i(S1ih%I=1UsdeWa*tRIfR(s4UB|Ht zM+u^Z^sQVeBEzJHfC$Z#Saj#Bmc}k(5?lAkEDJC%Ryq6XZZA7;ltxUY`czMGCK>_q z=q(rC-5|9hwSu3yvUGde&G$dpOOZT=#Qm)`pw3>spWE+-=%Z_} z>9qXOaBKsFoh6>vJ2~taYm8h8T8A$w*}Ot@GtMK`yChP1r?|w7*bry5NQX5 zkm9@dPssHX%OdrPd|^f09*}1u;=St!m0=|)`^T|Kwk?H)_0j=Y#}{`Vv;6!Nu>^G` zPpv~mielCgkkOkfW)1cU6~qiDkd_FFStlUu&K!2EOWB*o9T$U`_J|$r49rVX{l0nc zMv5KPw@D%tS*qMTbOGeaDc5EP{^|Iq=c-goX7)n2oJAiqu4z}EQcy_h zEkl#k4G1eevfNK9vCx6&QwPZxMX}w15R&=Kq#08y8b_ZaGjwf;G|>Z?i6`lU$%q2v#oC(n+KI<=s~+jU~|bc$6%rIk4jJNZ0*!i-tgo-|$TFK|KJ_guu*ooHQXe2}4bPK)S4sKpvg-(KOv8dS*}aP?@vHL&*yWK}AoG z42#$;HcH=ohlI z_duwmg|U-+2%s)Z>N$DB_MChajy|1?Tt~eDb??E`+<9Ny`Djgyq>geEIuwv6hVBV3 zCYAr`&dOf~h5_?<#}31Nc4v31LZ0wq?*x#1DtFmvYRMO68Vv_PP=4PzwWls;L#9t8 z$%Gt!u75s&irVtly?(D*?A|1!kSWTrR=UO^X9CorRVHHk zrP$~8`;@qBOU2qvEjYzYR96T&0+1)`jw$ii@%avSMwCj)285t2b02>{T!@Xoz(H>3 zmjD%CX__g?HCXJQE)P@^{Jml%Ab0H@7g9D~A7do00y=lOR{8@nVRZVoQ}%}Q9p<1^ z#p1PM6rkd^4c&9+Mk7Jr#)_lr&{AoZMgtSy%mPmL>vW!;Ym@XXk9}aGzBHCh2zo1Qi*5YDBaLn+RP| z%Eriz45bovok_roTbA#9wh?AlVRBNjH?(JSOXv?k9o*nHAgt5EHUpTac2t^qqw60I^il?9l4b&8^MgXu-X(Bu|EErpy02>2)=1&A z02LSc{ZzF?AF+pe4UvSw_~)Jm&IV>oVQX+=M?ovZ31=L{(V7FSgwTiPrtu5;dc+B* z4U7~b+vDc~>hOYY)zf>X+`-d6-2mAmcLHU#(LWzG4-iR>@0@p^q13K+j$o1&0%67e=-1O%R}*w^ z6e-e_lt58yq(wjoUi7Hpi5_!-z>Tq-GWn$hmJ(w1kK9Rr0U^{gbIwiIeC#KjHZyKO z76U5w$7rYFOUm(^1@cC*N&d?A#U;QxyrW3@Cy~trp}|6A_7-U=5Vmw!<9|K)5NnO7 zhp5(I(JTYj)nZ+a<=+%09wz##rSpl{#;WIUKpq+De>!iSHR5w08Hs{MzLoQ+jwfv7 zav<(095sD>|5bd4am1)`+Eof}11o@)+%|2yKPm-5)6{g8YOSIaVproQ|%Bj@~Prb0_W_C3oqvAiA){Y)6M)K3ZkKGzT zZtdjV#rbf5`xQk~N(^R2vKCMW77grI|GzfI*5TArB>BP?RuCW~l7o-D{B<*{5}l*+ zW~%EsC?D&9b@Ir%{yF14#KTO#V<|c2j_dWnyc1W$f6}qqZ1nVHOYKu##RU-zsAI)O zd{`WA6Gu;Pp1#H5y4V27sQr05evj=bM#@p-C{T46Te%UCku!5ot?rcaAwcXw2Tm>> zxthmP2oQFAc;3w6-$0xOL29)zi5(41iQVIsXXdy3|wth0qp2C7CR@JI(asqqOKN3lCZ?P?2s0)aB4>S1vUS6J!$W zOD}(uv<(Pb25ugEbM{u&7&$~3pcg34;C4VATD+=S;;D6P_tAw&*_rq;+5xOv3#_wq z+IHC86HvOyu*38aX6F5!=>a6Sb@wn~e(ViZ5xy8xAtXGcJjr>l)sk7K3}I*wTc zAa`ac_a^gXyMH@MsYJeYy8*TL=FZ~7{x$eyEqz8w(1csZ9zdRptG701`6RbrxbM|h zj55`c_QH=pY+C zm#5P8)MkYn%YI;8`mlCfR24fP%Zrsjb;@lp2LPGWdC`ACH}A29s2^k$Me32=EDi$d zK{x+(3+CJTOfy#c{7xDL$jF%|U*v4<;&^v93}Q4e4?Vtdu5IOej_26O^Fx5Vkgwg9 z_31u|&D6Id!$s&YFi%*IzOFTICqFT0#wkk`H^)Z+b$;8HHlR7r{+s|IQEbt4PMI9qw z=$0`yCGJ)zRnpC8f_;5d8ESYfB&q%#2Bg7xja0?TmLCQ?rrH4``66Y zVpZu2NU3uYLbe^92IiS=jeVj=-u{V0I<@nfr89sC35%H#*k`Q(fx}Pdfc#HN{Nqy) z;jd!TX6ee-o?Z;fL7Gay?f)#W;@>p6e=}oKmZgu5(q6O$8YS@@u4F5G&JBr3*mV`@`w^jXX__Wxxx&Dg$g)0x&OKUs1aD zgP{)OkXnWApGX%0vHMQRs0pXj2pmH}l1-DPu2!K*x&(xf;k}nQM`YHWePB<}OH-eH zn50BNB;Ng__wctD1%7ah(0ZInx}0J~?l0Tdw)lx@N_E8Fn6Cgcrps~5N9P2wj&wRF zhC(yoN;4@1Ss^TahAhs;D!>lY(&1lwUIpfzfVf;AzfN=@daTdVH9&-Vze`@;Bh>y~ zEvh3Vg6jZSzqsl0Z|68q56I=K^-DzwTGVkTxB;lda&v;MnH+ypw#=k`Qc4Cw(BNm~ z3Uq8N&Rc4ujIRoB0`l0`p2ZvfT}GTYofH&DHKF3_y#>rYmHhs6&biz1mZv$2THbA7 zT}gZ3V1=r8*%2?>B^#rBCLc{8`9ga+Lfrw>X|q$oanc1oN=v2j=(`K3{b5C)mEAqj z@u)G)9Y^gRF!#OMktKOsb=EvNsn}EfGJ{d~0d;0f>98RUrWxzR2#Lk}0Fal~%&z@% zKs`36`aG~h6(!Y&xzZE~Z z|E6PN1N2TAh5QL1cejo%dcE9FoH5cf60TmK0`hdAN3B(+Z>%8n)=~F}k?dOa3{V%$ zr$ZB+IG+ftM=70Ntw=1c=fFBKw6(=DgYzK_0+#9_7S)Rsv+mTp(ZAdiaT)2QPlF~) zm#y-bz`S@c&xK6Owy{yuv#3zHqIw0Wh`Y#~&c`OdT*mI6xYIC{{8YR+OKx}JQc--ID9r?slDt*ly=|3PuhFAAET$b}D z8@&n?!E?j>4p{fH7tVOAn8C-H%cH2`vUP|3g3o%*Hd34Z*&&(60W9@+U+EX_zo6WS_= zjr~|C|N9;RceCOH=tujzXR%W_@wdu+uM2a8tadGO8$wR2R{J0 zZ=UOz-cMZ|s8OX2X%}mfle7Gehlm{C`&F5~MjU=!lcbfZi3InvG=NM_>)YM=VR=9a$C4FAkQ>x+^%Z-+59x1m?_q&PwZgp(gG^>RrMydr*fWe(>W@)Gx60@I$%9; z`{PNEgAMp*A$2GZ#tuF#&}8!vQh9^0>M0hS3m{Kdnf=eaif;s$ z&bUfx*wi{OOBsN$*<)3Kd3oLVlM@4oVGt`#UZ|2X0_)0eTg>0LdFZAbhREO3p`@R3 znE;V|Y3vg7zU*wcQ^!Wh9KYLUPO;{%x)Te`eJT!j>iSlYvWaX4vjB2?%=X*M4>h)D zoototrB*>Wb6Ej(zxDR|(yul7C?t1UINGTRMr8xk?o1c0k2# zJAJ$IzqeU6=pQdj zN9J^YPl>QncV@Hn3m`5}Z?rwEXC}vkq_!Cxq@ut&mpIeB`uCH9Em!*xKB*Y|_@`gI zD-|8`hTq_jl9lwRzZv(+;($sXalh%Nw^4RcN`YxLfu>yvKqY((d9ZRt5f-JZdtwa? z18!d{38>f>Wp*v?v6w~4QpTC49&*nQN&)K9_0|5hpW1n|5=I(!^3uS(?A&qVK2mb9_ zyvJ5M?=wRIQ?#L4iIFBi?j8HS&7vWkkDb?b2xZsMHe>9u8CZ#JtG_w$xQkd5vdoAM zbbqu)>pIxH>VQ1bb@jmx{~WR3b?7y;>M6Fa2B3})vSlj!rJu2NoZx91L4%}bigjuG z_xeme$gwK-eY40@Ws<1ttVyZ`grLR&y(4=3;CBv=G5qk?2G+e7e($Eab`U$LODXMY z+A4~}@0#M^{D?0l_jF^;)1efhY2wB4uLG>31y3fmEU-u1*z`$F>bwV;DuJlG-+~r%eDAJ@@sTRf9_N zQK&+dYEs8AMl}UgTx`br+eR%Cr~#WrxU%#$v!rG~*qOg=k7dKEvtifQ4qXcP?V>rb z5*j|~UUqOv2drU6x6}d%A;F<5|F~)A9b?!nDhBRqXa(e@V;9>z`M`N2yFPJ7sFo?H zUi~_Be);kL;2-(CEFi46)LuWXXq>ns2%;{#%x(p(fw_Bn`+1eNaQ+I8U0RvEXTBIXVVCQgHLESKE{2a;^m`M|A1~3zU0*QRtagCfkuZH>l6nFnEaUrbLwu|KyjiMBuvxu;8PlT7^lshlteeCtaRpHhd-V^~suAcSNd z-L_og!Tjzd*OBtqZD=*9nZ;u90MwnPTeF?ce1>hiqKvA&1hWPJD>>bLC!gwX1yzdV zLCwPD;0c7aH%_>ne36m0Ml{gX$%!>P5LgML8c88J1b^L-HAcJdg&p$()PdEm(H+en zjjI$Pl|`K||3Sb!Y1{YbrU-*iw$u-JDu428*j-^TAR~RV+^aO=i~Z=)OA@W)VwZ;i z>%y?!w>`&X6zg6$7nD(>T}Y#=9B)9zm?o6%SI_RJoGOD*O9;;G&=l)-6k1)bqQTVC zsaFvkw`&ed3Et>_W2WY->cCwF0)YiY)t*@z4v1i<5nDfhvom8jGSTV)=fMY*oI1jjI(34DcA;H1(1!Vk>p%s0rS{%L0qY4g_{D5?L=HR-yYh>g1A#4voOeRFE_Z2pbO8@)`EBBpYR2y{N}V zn#NI-M+58pk3*GWg8an}rtT0*Pt=+Y*3%e3?hVUaeMwJ_p7g!YXk!@*s0(Rp55C#7 z0$-Y1{*>nmv=YQt1pw;onM&1qwp=2A1A%xzaxRwsrRW(G);evDn51z) zSQq)<2;YBm7zZC$AdQ%66z(+R0ePh3W+$&FcFXu)op2_!XgAUjm@Ls*D`9Beh0+P;>o3x>-A$Dw5Ki{t4V;0S$TDL z&h-J}g+O22G-k4$?DYNvm}e`vpFX$2;C*kY>q#wg?!=u8$k=H2-?QuyeY6gn092dO zpFjw@+q}`#Q(cWSiK9=q6z)bnCB@I1t4hq^y3+v};S{~&LW5ww?uc4-Z&=fc9qVoeppH*3 zc)QQB*JA4gF;r_6TQ?Js7o!U9C_mvR{+f!)GE1|7u<3l7U3VkT2}%<=s7w{)p)?y1 zVe89nxi&nJolCOjIRu%+iee71&b|-HKcstG`z*Qzqeg)QHWyeYYndWnmRRF}Ysy-p z879pG#KwpBTU@{P$Zqy&+tNx9XMaAR_8+x1S-Y`_1Jjqz>F9Zy2<%BgAWeS=~js%cb!@S$eo^zDi?Pbyg>_lOogJAAyVy9 zK*hd%vapu_aL09`ZLel&86d)@Ebem0KP^B0Z2QvyxWW7lsQ5o~Clw!M@Tj`JXVH{$ zoAh!(#<+AT^NXn>IH;ZPB8jPOnFL(_K*9<@+?luU*_nN<*)E~Ch7L5X<6yC_Okwp3 zUR~xxPVs`sSA&{C9J5tG+}qgs%%mX(yR~d3@>f}|xyaQiF-yOqfAiAu_8q4B;yb(s zSjj=|-(6O6o=wmPkEW8(S_`aev2QCUz5j{3&xYM22$+$V8uUrZ;4QdN!o@@jllV-> ziL?#~d%uqDktZODy++ohk_L+#_w_)ESlIrr&sQ_Em86dqZ9AGNsIG$nb#XwS3QaO5 ziaVKJ74+Cyt4^%l4ZysTzvin#ErM7_bu8*A*Sd{BIuLUD?t#b>g06#uPFYA5QV1Y+ z_I?tWH`L7mgwmt6u_T28A}q9Yws$xFvL9}md2Z%50qW7A#HvAu{^VDT;8OtEmX^6;0ol7ARb<$t5bTR{K- literal 0 HcmV?d00001 diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/launch.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/launch.py new file mode 100644 index 000000000..0e2415656 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/launch.py @@ -0,0 +1,274 @@ +from __future__ import absolute_import, division, print_function, unicode_literals + +""" +Modified by Xiyang for effortlessly launching on Azure ML + +""" + +r""" +`torch.distributed.launch` is a module that spawns up multiple distributed +training processes on each of the training nodes. + +The utility can be used for single-node distributed training, in which one or +more processes per node will be spawned. The utility can be used for either +CPU training or GPU training. If the utility is used for GPU training, +each distributed process will be operating on a single GPU. This can achieve +well-improved single-node training performance. It can also be used in +multi-node distributed training, by spawning up multiple processes on each node +for well-improved multi-node distributed training performance as well. +This will especially be benefitial for systems with multiple Infiniband +interfaces that have direct-GPU support, since all of them can be utilized for +aggregated communication bandwidth. + +In both cases of single-node distributed training or multi-node distributed +training, this utility will launch the given number of processes per node +(``--nproc_per_node``). If used for GPU training, this number needs to be less +or equal to the number of GPUs on the current system (``nproc_per_node``), +and each process will be operating on a single GPU from *GPU 0 to +GPU (nproc_per_node - 1)*. + +**How to use this module:** + +1. Single-Node multi-process distributed training + +:: + + >>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE + YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3 and all other + arguments of your training script) + +2. Multi-Node multi-process distributed training: (e.g. two nodes) + + +Node 1: *(IP: 192.168.1.1, and has a free port: 1234)* + +:: + + >>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE + --nnodes=2 --node_rank=0 --master_addr="192.168.1.1" + --master_port=1234 YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3 + and all other arguments of your training script) + +Node 2: + +:: + + >>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE + --nnodes=2 --node_rank=1 --master_addr="192.168.1.1" + --master_port=1234 YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3 + and all other arguments of your training script) + +3. To look up what optional arguments this module offers: + +:: + + >>> python -m torch.distributed.launch --help + + +**Important Notices:** + +1. This utility and multi-process distributed (single-node or +multi-node) GPU training currently only achieves the best performance using +the NCCL distributed backend. Thus NCCL backend is the recommended backend to +use for GPU training. + +2. In your training program, you must parse the command-line argument: +``--local_rank=LOCAL_PROCESS_RANK``, which will be provided by this module. +If your training program uses GPUs, you should ensure that your code only +runs on the GPU device of LOCAL_PROCESS_RANK. This can be done by: + +Parsing the local_rank argument + +:: + + >>> import argparse + >>> parser = argparse.ArgumentParser() + >>> parser.add_argument("--local_rank", type=int) + >>> args = parser.parse_args() + +Set your device to local rank using either + +:: + + >>> torch.cuda.set_device(arg.local_rank) # before your code runs + +or + +:: + + >>> with torch.cuda.device(arg.local_rank): + >>> # your code to run + +3. In your training program, you are supposed to call the following function +at the beginning to start the distributed backend. You need to make sure that +the init_method uses ``env://``, which is the only supported ``init_method`` +by this module. + +:: + + torch.distributed.init_process_group(backend='YOUR BACKEND', + init_method='env://') + +4. In your training program, you can either use regular distributed functions +or use :func:`torch.nn.parallel.DistributedDataParallel` module. If your +training program uses GPUs for training and you would like to use +:func:`torch.nn.parallel.DistributedDataParallel` module, +here is how to configure it. + +:: + + model = torch.nn.parallel.DistributedDataParallel(model, + device_ids=[arg.local_rank], + output_device=arg.local_rank) + +Please ensure that ``device_ids`` argument is set to be the only GPU device id +that your code will be operating on. This is generally the local rank of the +process. In other words, the ``device_ids`` needs to be ``[args.local_rank]``, +and ``output_device`` needs to be ``args.local_rank`` in order to use this +utility + +5. Another way to pass ``local_rank`` to the subprocesses via environment variable +``LOCAL_RANK``. This behavior is enabled when you launch the script with +``--use_env=True``. You must adjust the subprocess example above to replace +``args.local_rank`` with ``os.environ['LOCAL_RANK']``; the launcher +will not pass ``--local_rank`` when you specify this flag. + +.. warning:: + + ``local_rank`` is NOT globally unique: it is only unique per process + on a machine. Thus, don't use it to decide if you should, e.g., + write to a networked filesystem. See + https://github.com/pytorch/pytorch/issues/12042 for an example of + how things can go wrong if you don't do this correctly. + +""" + +import sys +import subprocess +import os +from argparse import ArgumentParser, REMAINDER + + +NODE_RANK = os.environ['AZ_BATCHAI_TASK_INDEX'] \ + if 'AZ_BATCHAI_TASK_INDEX' in os.environ else 0 +NODE_RANK = int(NODE_RANK) +MASTER_ADDR, MASTER_PORT = os.environ['AZ_BATCH_MASTER_NODE'].split(':') \ + if 'AZ_BATCH_MASTER_NODE' in os.environ else ("127.0.0.1", 29500) +MASTER_PORT = int(MASTER_PORT) + +def parse_args(): + """ + Helper function parsing the command line options + @retval ArgumentParser + """ + parser = ArgumentParser(description="PyTorch distributed training launch " + "helper utility that will spawn up " + "multiple distributed processes") + + # Optional arguments for the launch helper + parser.add_argument("--nnodes", type=int, default=1, + help="The number of nodes to use for distributed " + "training") + parser.add_argument("--node_rank", type=int, default=NODE_RANK, + help="The rank of the node for multi-node distributed " + "training") + parser.add_argument("--nproc_per_node", type=int, default=1, + help="The number of processes to launch on each node, " + "for GPU training, this is recommended to be set " + "to the number of GPUs in your system so that " + "each process can be bound to a single GPU.") + parser.add_argument("--master_addr", default=MASTER_ADDR, type=str, + help="Master node (rank 0)'s address, should be either " + "the IP address or the hostname of node 0, for " + "single node multi-proc training, the " + "--master_addr can simply be 127.0.0.1") + parser.add_argument("--master_port", default=MASTER_PORT, type=int, + help="Master node (rank 0)'s free port that needs to " + "be used for communication during distributed " + "training") + parser.add_argument("--use_env", default=False, action="store_true", + help="Use environment variable to pass " + "'local rank'. For legacy reasons, the default value is False. " + "If set to True, the script will not pass " + "--local_rank as argument, and will instead set LOCAL_RANK.") + parser.add_argument("-m", "--module", default=False, action="store_true", + help="Changes each process to interpret the launch script " + "as a python module, executing with the same behavior as" + "'python -m'.") + parser.add_argument("--no_python", default=False, action="store_true", + help="Do not prepend the training script with \"python\" - just exec " + "it directly. Useful when the script is not a Python script.") + + # positional + parser.add_argument("training_script", type=str, + help="The full path to the single GPU training " + "program/script to be launched in parallel, " + "followed by all the arguments for the " + "training script") + + # rest from the training program + parser.add_argument('training_script_args', nargs=REMAINDER) + return parser.parse_args() + +def main(): + args = parse_args() + + # world size in terms of number of processes + dist_world_size = args.nproc_per_node * args.nnodes + + # set PyTorch distributed related environmental variables + current_env = os.environ.copy() + current_env["MASTER_ADDR"] = args.master_addr + current_env["MASTER_PORT"] = str(args.master_port) + current_env["WORLD_SIZE"] = str(dist_world_size) + + processes = [] + + if 'OMP_NUM_THREADS' not in os.environ and args.nproc_per_node > 1: + current_env["OMP_NUM_THREADS"] = str(1) + print("*****************************************\n" + "Setting OMP_NUM_THREADS environment variable for each process " + "to be {} in default, to avoid your system being overloaded, " + "please further tune the variable for optimal performance in " + "your application as needed. \n" + "*****************************************".format(current_env["OMP_NUM_THREADS"])) + + print('Launching Node', args.node_rank) + for local_rank in range(0, args.nproc_per_node): + # each process's rank + dist_rank = args.nproc_per_node * args.node_rank + local_rank + current_env["RANK"] = str(dist_rank) + current_env["LOCAL_RANK"] = str(local_rank) + + # spawn the processes + with_python = not args.no_python + cmd = [] + if with_python: + cmd = [sys.executable, "-u"] + if args.module: + cmd.append("-m") + else: + if not args.use_env: + raise ValueError("When using the '--no_python' flag, you must also set the '--use_env' flag.") + if args.module: + raise ValueError("Don't use both the '--no_python' flag and the '--module' flag at the same time.") + + cmd.append(args.training_script) + + if not args.use_env: + cmd.append("--local_rank={}".format(local_rank)) + + cmd.extend(args.training_script_args) + + process = subprocess.Popen(cmd, env=current_env) + processes.append(process) + + for process in processes: + process.wait() + if process.returncode != 0: + raise subprocess.CalledProcessError(returncode=process.returncode, + cmd=cmd) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/layers.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/layers.py new file mode 100644 index 000000000..80fccc88a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/layers.py @@ -0,0 +1,116 @@ +import torch +import torch.distributed as dist +from torch import nn +from torch.autograd.function import Function +from torch.nn import functional as F + +class _NewEmptyTensorOp(torch.autograd.Function): + @staticmethod + def forward(ctx, x, new_shape): + ctx.shape = x.shape + return x.new_empty(new_shape) + + @staticmethod + def backward(ctx, grad): + shape = ctx.shape + return _NewEmptyTensorOp.apply(grad, shape), None + +class BatchNorm2d(torch.nn.BatchNorm2d): + """ + For torch < 1.4 + A wrapper around :class:`torch.nn.BatchNorm2d` to support zero-size tensor. + """ + + def forward(self, x): + if x.numel() > 0: + return super(BatchNorm2d, self).forward(x) + # get output shape + output_shape = x.shape + return _NewEmptyTensorOp.apply(x, output_shape) + + +class AllReduce(Function): + @staticmethod + def forward(ctx, input): + input_list = [torch.zeros_like(input) for k in range(dist.get_world_size())] + # Use allgather instead of allreduce since I don't trust in-place operations .. + dist.all_gather(input_list, input, async_op=False) + inputs = torch.stack(input_list, dim=0) + return torch.sum(inputs, dim=0) + + @staticmethod + def backward(ctx, grad_output): + dist.all_reduce(grad_output, async_op=False) + return grad_output + +class NaiveSyncBatchNorm(BatchNorm2d): + """ + In PyTorch<=1.5, ``nn.SyncBatchNorm`` has incorrect gradient + when the batch size on each worker is different. + (e.g., when scale augmentation is used, or when it is applied to mask head). + This is a slower but correct alternative to `nn.SyncBatchNorm`. + Note: + There isn't a single definition of Sync BatchNorm. + When ``stats_mode==""``, this module computes overall statistics by using + statistics of each worker with equal weight. The result is true statistics + of all samples (as if they are all on one worker) only when all workers + have the same (N, H, W). This mode does not support inputs with zero batch size. + When ``stats_mode=="N"``, this module computes overall statistics by weighting + the statistics of each worker by their ``N``. The result is true statistics + of all samples (as if they are all on one worker) only when all workers + have the same (H, W). It is slower than ``stats_mode==""``. + Even though the result of this module may not be the true statistics of all samples, + it may still be reasonable because it might be preferrable to assign equal weights + to all workers, regardless of their (H, W) dimension, instead of putting larger weight + on larger images. From preliminary experiments, little difference is found between such + a simplified implementation and an accurate computation of overall mean & variance. + """ + + def __init__(self, *args, stats_mode="", **kwargs): + super().__init__(*args, **kwargs) + assert stats_mode in ["", "N"] + self._stats_mode = stats_mode + + def forward(self, input): + if not self.training: + return super().forward(input) + + if dist.get_world_size() == 1: + return super().forward(input) + + B, C = input.shape[0], input.shape[1] + + mean = torch.mean(input, dim=[0, 2, 3]) + meansqr = torch.mean(input * input, dim=[0, 2, 3]) + + if self._stats_mode == "": + assert B > 0, 'SyncBatchNorm(stats_mode="") does not support zero batch size.' + vec = torch.cat([mean, meansqr], dim=0) + vec = AllReduce.apply(vec) * (1.0 / dist.get_world_size()) + mean, meansqr = torch.split(vec, C) + momentum = self.momentum + else: + if B == 0: + vec = torch.zeros([2 * C + 1], device=mean.device, dtype=mean.dtype) + vec = vec + input.sum() # make sure there is gradient w.r.t input + else: + vec = torch.cat( + [mean, meansqr, torch.ones([1], device=mean.device, dtype=mean.dtype)], dim=0 + ) + vec = AllReduce.apply(vec * B) + + total_batch = vec[-1].detach() + momentum = total_batch.clamp(max=1) * self.momentum # no update if total_batch is 0 + total_batch = torch.max(total_batch, torch.ones_like(total_batch)) # avoid div-by-zero + mean, meansqr, _ = torch.split(vec / total_batch, C) + + var = meansqr - mean * mean + invstd = torch.rsqrt(var + self.eps) + scale = self.weight * invstd + bias = self.bias - mean * scale + scale = scale.reshape(1, -1, 1, 1) + bias = bias.reshape(1, -1, 1, 1) + + self.running_mean += momentum * (mean.detach() - self.running_mean) + self.running_var += momentum * (var.detach() - self.running_var) + return input * scale + bias \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/loss.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/loss.py new file mode 100644 index 000000000..0f564947d --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/loss.py @@ -0,0 +1,81 @@ +import torch.nn as nn +import torch.nn.functional as F +import torch + + +class CrossEntropyLoss2d(nn.Module): + def __init__(self, weight=None, size_average=True, ignore_index=-100): + super(CrossEntropyLoss2d, self).__init__() + self.nll_loss = nn.NLLLoss(weight, size_average, ignore_index) + + def forward(self, inputs, targets): + return self.nll_loss(F.log_softmax(inputs, dim=1), targets) + + +def one_hot(index, classes): + # index is not flattened (pypass ignore) ############ + # size = index.size()[:1] + (classes,) + index.size()[1:] + # view = index.size()[:1] + (1,) + index.size()[1:] + ##################################################### + # index is flatten (during ignore) ################## + size = index.size()[:1] + (classes,) + view = index.size()[:1] + (1,) + ##################################################### + + mask = torch.Tensor(size).fill_(0).cuda() + index = index.view(view) + ones = 1. + + return mask.scatter_(1, index, ones) + + +class FocalLoss(nn.CrossEntropyLoss): + ''' Focal loss for classification tasks on imbalanced datasets ''' + + def __init__(self, gamma=2, alpha=None, ignore_index=-100, reduction='mean'): + super().__init__(weight=alpha, ignore_index=ignore_index, reduction='mean') + self.reduction = reduction + self.gamma = gamma + + def forward(self, input_, target): + cross_entropy = super().forward(input_, target) + # Temporarily mask out ignore index to '0' for valid gather-indices input. + # This won't contribute final loss as the cross_entropy contribution + # for these would be zero. + target = target * (target != self.ignore_index).long() + input_prob = torch.gather(F.softmax(input_, 1), 1, target.unsqueeze(1)) + loss = torch.pow(1 - input_prob, self.gamma) * cross_entropy + if self.reduction == 'mean': return torch.mean(loss) + elif self.reduction == 'sum': return torch.sum(loss) + else: return loss + + +class SoftCrossEntropyLoss2d(nn.Module): + def __init__(self): + super(SoftCrossEntropyLoss2d, self).__init__() + + def forward(self, inputs, targets): + loss = 0 + inputs = -F.log_softmax(inputs, dim=1) + for index in range(inputs.size()[0]): + loss += F.conv2d(inputs[range(index, index+1)], targets[range(index, index+1)])/(targets.size()[2] * + targets.size()[3]) + return loss + +class OhemCELoss(nn.Module): + def __init__(self, thresh, n_min=0.1, ignore_lb=255, *args, **kwargs): + super(OhemCELoss, self).__init__() + self.thresh = -torch.log(torch.tensor(thresh, dtype=torch.float)).cuda() + self.n_min = n_min + self.ignore_lb = ignore_lb + self.criteria = nn.CrossEntropyLoss(ignore_index=ignore_lb, reduction='none') + + def forward(self, logits, labels): + loss = self.criteria(logits, labels).view(-1) + loss, _ = torch.sort(loss, descending=True) + n_min = int(self.n_min * len(loss)) + if loss[n_min] > self.thresh: + loss = loss[loss>self.thresh] + else: + loss = loss[:n_min] + return torch.mean(loss) \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/operations.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/operations.py new file mode 100644 index 000000000..13b45f111 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/operations.py @@ -0,0 +1,948 @@ +__all__ = ['ConvNorm', 'BasicResidual1x', 'BasicResidual_downup_1x', 'BasicResidual2x', 'BasicResidual_downup_2x', 'FactorizedReduce', 'OPS', 'OPS_name', 'OPS_Class', 'Self_Attn'] + +from pdb import set_trace as bp +import torch +import torch.nn as nn +import torch.nn.functional as F +import numpy as np +from thop import profile +import sys +import os.path as osp +from easydict import EasyDict as edict +from torch import nn, einsum +from einops import rearrange + +C = edict() +"""please config ROOT_dir and user when u first using""" +# C.repo_name = 'FasterSeg' +C.abs_dir = osp.realpath(".") +C.root_dir = osp.realpath("..") +C.this_dir = C.abs_dir.split(osp.sep)[-1] +# C.root_dir = C.abs_dir[:C.abs_dir.index(C.repo_name) + len(C.repo_name)] +"""Path Config""" +def add_path(path): + if path not in sys.path: + sys.path.insert(0, path) + +add_path(osp.join(C.root_dir, 'tools')) +try: + from utils.darts_utils import compute_latency_ms_tensorrt as compute_latency + print("use TensorRT for latency test") +except: + from utils.darts_utils import compute_latency_ms_pytorch as compute_latency + print("use PyTorch for latency test") +from slimmable_ops import USConv2d, USBatchNorm2d +from layers import NaiveSyncBatchNorm + + +latency_lookup_table = {} +# table_file_name = "latency_lookup_table.npy" +# if osp.isfile(table_file_name): +# latency_lookup_table = np.load(table_file_name).item() + + +# BatchNorm2d = nn.BatchNorm2d +BatchNorm2d = NaiveSyncBatchNorm + +def drop_path_(x, drop_prob, training): + if training and drop_prob > 0.: + keep_prob = 1. - drop_prob + # per data point mask; assuming x in cuda. + mask = torch.cuda.FloatTensor(x.size(0), 1, 1, 1).bernoulli_(keep_prob) + x = torch.div(x, keep_prob) + x = torch.mul(x, mask) + # x.div_(keep_prob).mul_(mask) + return x + +class DropPath_(nn.Module): + def __init__(self, p=0.): + """ [!] DropPath is inplace module + Args: + p: probability of an path to be zeroed. + """ + super().__init__() + self.p = p + + def extra_repr(self): + return 'p={}, inplace'.format(self.p) + + def forward(self, x): + drop_path_(x, self.p, self.training) + + return x + + def forward_latency(self, size): + c_in, h_in, w_in = size + latency = 0 + return latency, (c_in, h_in, w_in) + +class ConvNorm(nn.Module): + ''' + conv => norm => activation + use native nn.Conv2d, not slimmable + ''' + def __init__(self, C_in, C_out, kernel_size=3, stride=1, padding=None, dilation=1, groups=1, bias=False, slimmable=True, width_mult_list=[1.]): + super(ConvNorm, self).__init__() + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + assert stride in [1, 2] + self.stride = stride + if padding is None: + # assume h_out = h_in / s + self.padding = int(np.ceil((dilation * (kernel_size - 1) + 1 - stride) / 2.)) + else: + self.padding = padding + self.dilation = dilation + assert type(groups) == int + if kernel_size == 1: + self.groups = 1 + else: + self.groups = groups + self.bias = bias + self.slimmable = slimmable + self.width_mult_list = width_mult_list + self.ratio = (1., 1.) + + if slimmable: + self.conv = nn.Sequential( + USConv2d(C_in, C_out, kernel_size, stride, padding=self.padding, dilation=dilation, groups=self.groups, bias=bias, width_mult_list=width_mult_list), + USBatchNorm2d(C_out, width_mult_list), + nn.ReLU(inplace=True), + ) + else: + self.conv = nn.Sequential( + nn.Conv2d(C_in, C_out, kernel_size, stride, padding=self.padding, dilation=dilation, groups=self.groups, bias=bias), + # nn.BatchNorm2d(C_out), + BatchNorm2d(C_out), + nn.ReLU(inplace=True), + ) + + def set_ratio(self, ratio): + assert self.slimmable + assert len(ratio) == 2 + self.ratio = ratio + self.conv[0].set_ratio(ratio) + self.conv[1].set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, padding=None, dilation=1, groups=1, bias=False): + layer = ConvNorm(C_in, C_out, kernel_size, stride, padding, dilation, groups, bias, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, padding=None, dilation=1, groups=1, bias=False): + layer = ConvNorm(C_in, C_out, kernel_size, stride, padding, dilation, groups, bias, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]), "c_in %d, self.C_in * self.ratio[0] %d"%(c_in, self.C_in * self.ratio[0]) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in %d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "ConvNorm_H%d_W%d_Cin%d_Cout%d_kernel%d_stride%d"%(h_in, w_in, c_in, c_out, self.kernel_size, self.stride) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = ConvNorm._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.padding, self.dilation, self.groups, self.bias) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + assert x.size()[1] == self.C_in, "{} {}".format(x.size()[1], self.C_in) + x = self.conv(x) + return x + + +class BasicResidual1x(nn.Module): + def __init__(self, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1, slimmable=True, width_mult_list=[1.]): + super(BasicResidual1x, self).__init__() + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + groups = 1 + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + self.stride = stride + self.dilation = dilation + self.groups = groups + self.slimmable = slimmable + self.width_mult_list = width_mult_list + assert stride in [1, 2] + if self.stride == 2: self.dilation = 1 + self.ratio = (1., 1.) + + self.relu = nn.ReLU(inplace=True) + if slimmable: + self.conv1 = USConv2d(C_in, C_out, 3, stride, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn1 = USBatchNorm2d(C_out, width_mult_list) + else: + self.conv1 = nn.Conv2d(C_in, C_out, 3, stride, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn1 = nn.BatchNorm2d(C_out) + self.bn1 = BatchNorm2d(C_out) + + def set_ratio(self, ratio): + assert len(ratio) == 2 + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.bn1.set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + layer = BasicResidual1x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + layer = BasicResidual1x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]), "c_in %d, int(self.C_in * self.ratio[0]) %d"%(c_in, int(self.C_in * self.ratio[0])) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in %d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "BasicResidual1x_H%d_W%d_Cin%d_Cout%d_stride%d_dilation%d"%(h_in, w_in, c_in, c_out, self.stride, self.dilation) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = BasicResidual1x._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.dilation, self.groups) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + return out + + +class BasicResidual_downup_1x(nn.Module): + def __init__(self, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1, slimmable=True, width_mult_list=[1.]): + super(BasicResidual_downup_1x, self).__init__() + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + groups = 1 + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + self.stride = stride + self.dilation = dilation + self.groups = groups + self.slimmable = slimmable + self.width_mult_list = width_mult_list + assert stride in [1, 2] + if self.stride == 2: self.dilation = 1 + self.ratio = (1., 1.) + + self.relu = nn.ReLU(inplace=True) + if slimmable: + self.conv1 = USConv2d(C_in, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn1 = USBatchNorm2d(C_out, width_mult_list) + if self.stride==1: + self.downsample = nn.Sequential( + USConv2d(C_in, C_out, 1, 1, padding=0, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list), + USBatchNorm2d(C_out, width_mult_list) + ) + else: + self.conv1 = nn.Conv2d(C_in, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn1 = nn.BatchNorm2d(C_out) + self.bn1 = BatchNorm2d(C_out) + if self.stride==1: + self.downsample = nn.Sequential( + nn.Conv2d(C_in, C_out, 1, 1, padding=0, dilation=dilation, groups=groups, bias=False), + BatchNorm2d(C_out) + ) + + def set_ratio(self, ratio): + assert len(ratio) == 2 + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.bn1.set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = BasicResidual_downup_1x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = BasicResidual_downup_1x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]), "c_in %d, int(self.C_in * self.ratio[0]) %d"%(c_in, int(self.C_in * self.ratio[0])) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in %d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "BasicResidual_downup_1x_H%d_W%d_Cin%d_Cout%d_stride%d_dilation%d"%(h_in, w_in, c_in, c_out, self.stride, self.dilation) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = BasicResidual_downup_1x._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.dilation, self.groups) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + out = F.interpolate(x, size=(int(x.size(2))//2, int(x.size(3))//2), mode='bilinear', align_corners=False) + out = self.conv1(out) + out = self.bn1(out) + if self.stride == 1: + out = F.interpolate(out, size=(int(x.size(2)), int(x.size(3))), mode='bilinear', align_corners=False) + out = out + self.downsample(x) + out = self.relu(out) + return out + + +class BasicResidual2x(nn.Module): + def __init__(self, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1, slimmable=True, width_mult_list=[1.]): + super(BasicResidual2x, self).__init__() + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + groups = 1 + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + self.stride = stride + self.dilation = dilation + self.groups = groups + self.slimmable = slimmable + self.width_mult_list = width_mult_list + assert stride in [1, 2] + if self.stride == 2: self.dilation = 1 + self.ratio = (1., 1.) + + self.relu = nn.ReLU(inplace=True) + if self.slimmable: + self.conv1 = USConv2d(C_in, C_out, 3, stride, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn1 = USBatchNorm2d(C_out, width_mult_list) + self.conv2 = USConv2d(C_out, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn2 = USBatchNorm2d(C_out, width_mult_list) + else: + self.conv1 = nn.Conv2d(C_in, C_out, 3, stride, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn1 = nn.BatchNorm2d(C_out) + self.bn1 = BatchNorm2d(C_out) + self.conv2 = nn.Conv2d(C_out, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn2 = nn.BatchNorm2d(C_out) + self.bn2 = BatchNorm2d(C_out) + + def set_ratio(self, ratio): + assert len(ratio) == 2 + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.bn1.set_ratio(ratio[1]) + self.conv2.set_ratio((ratio[1], ratio[1])) + self.bn2.set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + layer = BasicResidual2x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + layer = BasicResidual2x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in%d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "BasicResidual2x_H%d_W%d_Cin%d_Cout%d_stride%d_dilation%d"%(h_in, w_in, c_in, c_out, self.stride, self.dilation) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = BasicResidual2x._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.dilation, self.groups) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + out = self.conv1(x) + out = self.bn1(out) + out = self.relu(out) + out = self.conv2(out) + out = self.bn2(out) + out = self.relu(out) + return out + + +class BasicResidual_downup_2x(nn.Module): + def __init__(self, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1, slimmable=True, width_mult_list=[1.]): + super(BasicResidual_downup_2x, self).__init__() + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + groups = 1 + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + self.stride = stride + self.dilation = dilation + self.groups = groups + self.slimmable = slimmable + self.width_mult_list = width_mult_list + assert stride in [1, 2] + if self.stride == 2: self.dilation = 1 + self.ratio = (1., 1.) + + self.relu = nn.ReLU(inplace=True) + if self.slimmable: + self.conv1 = USConv2d(C_in, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn1 = USBatchNorm2d(C_out, width_mult_list) + self.conv2 = USConv2d(C_out, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list) + self.bn2 = USBatchNorm2d(C_out, width_mult_list) + if self.stride==1: + self.downsample = nn.Sequential( + USConv2d(C_in, C_out, 1, 1, padding=0, dilation=dilation, groups=groups, bias=False, width_mult_list=width_mult_list), + USBatchNorm2d(C_out, width_mult_list) + ) + else: + self.conv1 = nn.Conv2d(C_in, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn1 = nn.BatchNorm2d(C_out) + self.bn1 = BatchNorm2d(C_out) + self.conv2 = nn.Conv2d(C_out, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn2 = nn.BatchNorm2d(C_out) + self.bn2 = BatchNorm2d(C_out) + if self.stride==1: + self.downsample = nn.Sequential( + nn.Conv2d(C_in, C_out, 1, 1, padding=0, dilation=dilation, groups=groups, bias=False), + BatchNorm2d(C_out) + ) + + def set_ratio(self, ratio): + assert len(ratio) == 2 + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.bn1.set_ratio(ratio[1]) + self.conv2.set_ratio((ratio[1], ratio[1])) + self.bn2.set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = BasicResidual_downup_2x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = BasicResidual_downup_2x(C_in, C_out, kernel_size, stride, dilation, groups, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in%d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "BasicResidual2x_H%d_W%d_Cin%d_Cout%d_stride%d_dilation%d"%(h_in, w_in, c_in, c_out, self.stride, self.dilation) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = BasicResidual2x._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.dilation, self.groups) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + out = F.interpolate(x, size=(int(x.size(2))//2, int(x.size(3))//2), mode='bilinear', align_corners=False) + out = self.conv1(out) + out = self.bn1(out) + out = self.relu(out) + out = self.conv2(out) + out = self.bn2(out) + if self.stride == 1: + out = F.interpolate(out, size=(int(x.size(2)), int(x.size(3))), mode='bilinear', align_corners=False) + out = out + self.downsample(x) + out = self.relu(out) + return out + + +class FactorizedReduce(nn.Module): + def __init__(self, C_in, C_out, stride=1, slimmable=True, width_mult_list=[1.]): + super(FactorizedReduce, self).__init__() + assert stride in [1, 2] + assert C_out % 2 == 0 + self.C_in = C_in + self.C_out = C_out + self.stride = stride + self.slimmable = slimmable + self.width_mult_list = width_mult_list + self.ratio = (1., 1.) + if stride == 1 and slimmable: + self.conv1 = USConv2d(C_in, C_out, 1, stride=1, padding=0, bias=False, width_mult_list=width_mult_list) + self.bn = USBatchNorm2d(C_out, width_mult_list) + self.relu = nn.ReLU(inplace=True) + elif stride == 2: + self.relu = nn.ReLU(inplace=True) + if slimmable: + self.conv1 = USConv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False, width_mult_list=width_mult_list) + self.conv2 = USConv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False, width_mult_list=width_mult_list) + self.bn = USBatchNorm2d(C_out, width_mult_list) + else: + self.conv1 = nn.Conv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False) + self.conv2 = nn.Conv2d(C_in, C_out // 2, 1, stride=2, padding=0, bias=False) + self.bn = BatchNorm2d(C_out) + + def set_ratio(self, ratio): + assert len(ratio) == 2 + if self.stride == 1: + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.bn.set_ratio(ratio[1]) + elif self.stride == 2: + self.ratio = ratio + self.conv1.set_ratio(ratio) + self.conv2.set_ratio(ratio) + self.bn.set_ratio(ratio[1]) + + @staticmethod + def _flops(h, w, C_in, C_out, stride=1): + layer = FactorizedReduce(C_in, C_out, stride, slimmable=False) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, stride=1): + layer = FactorizedReduce(C_in, C_out, stride, slimmable=False) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "FactorizedReduce_H%d_W%d_Cin%d_Cout%d_stride%d"%(h_in, w_in, c_in, c_out, self.stride) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = FactorizedReduce._latency(h_in, w_in, c_in, c_out, self.stride) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + if self.stride == 2: + out = torch.cat([self.conv1(x), self.conv2(x[:,:,1:,1:])], dim=1) + out = self.bn(out) + out = self.relu(out) + return out + else: + if self.slimmable: + out = self.conv1(x) + out = self.bn(out) + out = self.relu(out) + return out + else: + return x + + +def pair(x): + return (x, x) if not isinstance(x, tuple) else x + +def expand_dim(t, dim, k): + t = t.unsqueeze(dim = dim) + expand_shape = [-1] * len(t.shape) + expand_shape[dim] = k + return t.expand(*expand_shape) + +def rel_to_abs(x): + b, h, l, _, device, dtype = *x.shape, x.device, x.dtype + dd = {'device': device, 'dtype': dtype} + col_pad = torch.zeros((b, h, l, 1), **dd) + x = torch.cat((x, col_pad), dim = 3) + flat_x = rearrange(x, 'b h l c -> b h (l c)') + flat_pad = torch.zeros((b, h, l - 1), **dd) + flat_x_padded = torch.cat((flat_x, flat_pad), dim = 2) + final_x = flat_x_padded.reshape(b, h, l + 1, 2 * l - 1) + final_x = final_x[:, :, :l, (l-1):] + return final_x + +def relative_logits_1d(q, rel_k): + b, heads, h, w, dim = q.shape + logits = einsum('b h x y d, r d -> b h x y r', q, rel_k) + logits = rearrange(logits, 'b h x y r -> b (h x) y r') + logits = rel_to_abs(logits) + logits = logits.reshape(b, heads, h, w, w) + logits = expand_dim(logits, dim = 3, k = h) + return logits + +# positional embeddings + +class AbsPosEmb(nn.Module): + def __init__( + self, + fmap_size, + dim_head + ): + super().__init__() + height, width = pair(fmap_size) + scale = dim_head ** -0.5 + self.height = nn.Parameter(torch.randn(height, dim_head) * scale) + self.width = nn.Parameter(torch.randn(width, dim_head) * scale) + + def forward(self, q): + emb = rearrange(self.height, 'h d -> h () d') + rearrange(self.width, 'w d -> () w d') + emb = rearrange(emb, ' h w d -> (h w) d') + logits = einsum('b h i d, j d -> b h i j', q, emb) + return logits + +class RelPosEmb(nn.Module): + def __init__( + self, + fmap_size, + dim_head + ): + super().__init__() + height, width = pair(fmap_size) + scale = dim_head ** -0.5 + self.fmap_size = fmap_size + self.rel_height = nn.Parameter(torch.randn(height * 2 - 1, dim_head) * scale) + self.rel_width = nn.Parameter(torch.randn(width * 2 - 1, dim_head) * scale) + + def forward(self, q): + h, w = self.fmap_size + + q = rearrange(q, 'b h (x y) d -> b h x y d', x = h, y = w) + rel_logits_w = relative_logits_1d(q, self.rel_width) + rel_logits_w = rearrange(rel_logits_w, 'b h x i y j-> b h (x y) (i j)') + + q = rearrange(q, 'b h x y d -> b h y x d') + rel_logits_h = relative_logits_1d(q, self.rel_height) + rel_logits_h = rearrange(rel_logits_h, 'b h x i y j -> b h (y x) (j i)') + return rel_logits_w + rel_logits_h + +# classes + +class Attention(nn.Module): + def __init__( + self, + *, + dim, + fmap_size, + heads = 4, + dim_head = 128, + rel_pos_emb = False + ): + super().__init__() + self.heads = heads + + self.scale = dim_head ** -0.5 + inner_dim = heads * dim_head + + self.to_qkv = nn.Conv2d(dim, inner_dim * 3, 1, bias = False) + + rel_pos_class = AbsPosEmb if not rel_pos_emb else RelPosEmb + self.pos_emb = rel_pos_class(fmap_size, dim_head) + + def forward(self, fmap): + heads, b, c, h, w = self.heads, *fmap.shape + + q, k, v = self.to_qkv(fmap).chunk(3, dim = 1) + q, k, v = map(lambda t: rearrange(t, 'b (h d) x y -> b h (x y) d', h = heads), (q, k, v)) + + q *= self.scale + + sim = einsum('b h i d, b h j d -> b h i j', q, k) + sim += self.pos_emb(q) + + attn = sim.softmax(dim = -1) + + out = einsum('b h i j, b h j d -> b h i d', attn, v) + out = rearrange(out, 'b h (x y) d -> b (h d) x y', x = h, y = w) + return out + +class Self_Attn(nn.Module): + def __init__( + self, + *, + dim, + fmap_size, + dim_out, + proj_factor, + downsample, + slimmable=True, + width_mult_list=[1.], + heads = 4, + dim_head = 128, + rel_pos_emb = False, + activation = nn.ReLU(inplace=True) + ): + super().__init__() + + # shortcut + + # contraction and expansion + self.slimmable = slimmable + self.width_mult_list = width_mult_list + + + if slimmable: + kernel_size, stride, padding = (3, 2, 1) if downsample else (1, 1, 0) + self.sk = False + self.shortcut = nn.Sequential( + USConv2d(dim, dim_out, kernel_size, padding=padding, stride=stride, dilation=1, groups=1, bias=False, width_mult_list=width_mult_list), + USBatchNorm2d(dim_out, width_mult_list), + activation + ) + else: + if dim != dim_out or downsample: + self.sk = False + kernel_size, stride, padding = (3, 2, 1) if downsample else (1, 1, 0) + + self.shortcut = nn.Sequential( + nn.Conv2d(dim, dim_out, kernel_size, stride = stride, padding = padding, bias = False), + BatchNorm2d(dim_out), + activation + ) + else: + self.sk = True + self.shortcut = nn.Identity() + + self.mix_bn1 = nn.ModuleList([]) + self.mix_bn2 = nn.ModuleList([]) + self.mix_bn3 = nn.ModuleList([]) + + # attn_dim_in = dim_out // proj_factor + attn_dim_in = dim_out + # attn_dim_out = heads * dim_head + attn_dim_out = attn_dim_in + + if self.slimmable: + self.mix_bn1.append(USBatchNorm2d(dim_out, width_mult_list)) + self.mix_bn2.append(USBatchNorm2d(dim_out, width_mult_list)) + self.mix_bn3.append(USBatchNorm2d(dim_out, width_mult_list)) + nn.init.zeros_(self.mix_bn3[0].weight) + else: + self.mix_bn1.append(BatchNorm2d(dim_out)) + self.mix_bn2.append(BatchNorm2d(dim_out)) + self.mix_bn3.append(BatchNorm2d(dim_out)) + nn.init.zeros_(self.mix_bn3[0].weight) + + if self.slimmable: + self.net1 = USConv2d(dim, attn_dim_in, 1, padding=0, stride=1, dilation=1, groups=1, bias=False, width_mult_list=width_mult_list) + + self.net2 = nn.Sequential( + activation, + ATT(attn_dim_in, slimmable=True, width_mult_list=width_mult_list), + nn.AvgPool2d((2, 2)) if downsample else nn.Identity() + ) + + self.net3 = nn.Sequential( + activation, + USConv2d(attn_dim_out, dim_out, 1, padding=0, stride=1, dilation=1, groups=1, bias=False, width_mult_list=width_mult_list), + ) + + else: + self.net1 = nn.Conv2d(dim, attn_dim_in, 1, bias = False) + + self.net2 = nn.Sequential( + activation, + ATT(attn_dim_in, slimmable=False), + nn.AvgPool2d((2, 2)) if downsample else nn.Identity() + ) + + self.net3 = nn.Sequential( + activation, + nn.Conv2d(attn_dim_out, dim_out, 1, bias = False), + ) + + # init last batch norm gamma to zero + + # nn.init.zeros_(self.net[-1].weight) + + # final activation + + self.activation = activation + + def set_ratio(self, ratio): + if not self.sk: + self.shortcut[0].set_ratio(ratio) + self.shortcut[1].set_ratio(ratio[1]) + + for i in range(len(self.mix_bn1)): + self.mix_bn1[i].set_ratio(ratio[1]) + self.mix_bn2[i].set_ratio(ratio[1]) + self.mix_bn3[i].set_ratio(ratio[1]) + + self.net1.set_ratio(ratio) + self.net2[1].set_ratio((ratio[1], ratio[1])) + self.net3[1].set_ratio((ratio[1], ratio[1])) + + @staticmethod + def _flops(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = Self_Attn(dim=C_in, fmap_size=(128, 256), dim_out=C_out, downsample=(stride==2)) + flops, params = profile(layer, inputs=(torch.randn(1, C_in, h, w),), verbose=False) + return flops + + @staticmethod + def _latency(h, w, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + assert stride in [1, 2] + layer = Self_Attn(dim=C_in, fmap_size=(128, 256), dim_out=C_out, downsample=(stride==2)) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + c_in, h_in, w_in = size + if self.slimmable: + assert c_in == int(self.C_in * self.ratio[0]) + c_out = int(self.C_out * self.ratio[1]) + else: + assert c_in == self.C_in, "c_in %d, self.C_in%d"%(c_in, self.C_in) + c_out = self.C_out + if self.stride == 1: + h_out = h_in; w_out = w_in + else: + h_out = h_in // 2; w_out = w_in // 2 + name = "Self_Attn_H%d_W%d_Cin%d_Cout%d_stride%d_dilation%d"%(h_in, w_in, c_in, c_out, self.stride, self.dilation) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + else: + print("not found in latency_lookup_table:", name) + latency = Self_Attn._latency(h_in, w_in, c_in, c_out, self.kernel_size, self.stride, self.dilation, self.groups) + latency_lookup_table[name] = latency + np.save(table_file_name, latency_lookup_table) + return latency, (c_out, h_out, w_out) + + def forward(self, x): + branch = 0 + shortcut = self.shortcut(x) + x = self.net1(x) + x = self.mix_bn1[branch](x) + x = self.net2(x) + x = self.mix_bn2[branch](x) + x = self.net3(x) + x = self.mix_bn3[branch](x) + x += shortcut + return self.activation(x) + +class ATT(nn.Module): + """ Self attention Layer""" + def __init__(self, in_dim, slimmable=True, width_mult_list=[1.]): + super(ATT, self).__init__() + self.chanel_in = in_dim + + self.slimmable = slimmable + self.width_mult_list = width_mult_list + self.ratio = (1., 1.) + + if self.slimmable: + self.query_conv = USConv2d(in_dim , in_dim//8 , 1, padding=0, stride=1, bias=False, width_mult_list=width_mult_list) + self.key_conv = USConv2d(in_dim , in_dim//8 , 1, padding=0, stride=1, bias=False, width_mult_list=width_mult_list) + self.value_conv = USConv2d(in_dim , in_dim , 1, padding=0, stride=1, bias=False, width_mult_list=width_mult_list) + else: + self.query_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim//8 , kernel_size= 1) + self.key_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim//8 , kernel_size= 1) + self.value_conv = nn.Conv2d(in_channels = in_dim , out_channels = in_dim , kernel_size= 1) + self.gamma = nn.Parameter(torch.zeros(1)) + + self.softmax = nn.Softmax(dim=-1) # + + def set_ratio(self, ratio): + assert len(ratio) == 2 + self.ratio = ratio + self.query_conv.set_ratio(ratio) + self.key_conv.set_ratio(ratio) + self.value_conv.set_ratio(ratio) + + def forward(self,x): + """ + inputs : + x : input feature maps( B X C X W X H) + returns : + out : self attention value + input feature + attention: B X N X N (N is Width*Height) + """ + m_batchsize, C, width, height = x.size() + proj_query = self.query_conv(x).view(m_batchsize, -1,width*height).permute(0,2,1) # B X CX(N) + proj_key = self.key_conv(x).view(m_batchsize,-1, width*height) # B X C x (*W*H) + energy = torch.bmm(proj_query, proj_key) # transpose check + attention = self.softmax(energy) # BX (N) X (N) + proj_value = self.value_conv(x).view(m_batchsize,-1,width*height) # B X C X N + + out = torch.bmm(proj_value, attention.permute(0,2,1) ) + out = out.view(m_batchsize, C, width,height) + + out = self.gamma*out + x + return out + +from collections import OrderedDict +OPS = { + 'skip' : lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: FactorizedReduce(C_in, C_out, stride, slimmable, width_mult_list), + 'conv' : lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: BasicResidual1x(C_in, C_out, kernel_size=3, stride=stride, dilation=1, slimmable=slimmable, width_mult_list=width_mult_list), + 'conv_downup' : lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: BasicResidual_downup_1x(C_in, C_out, kernel_size=3, stride=stride, dilation=1, slimmable=slimmable, width_mult_list=width_mult_list), + 'conv_2x' : lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: BasicResidual2x(C_in, C_out, kernel_size=3, stride=stride, dilation=1, slimmable=slimmable, width_mult_list=width_mult_list), + 'conv_2x_downup' : lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: BasicResidual_downup_2x(C_in, C_out, kernel_size=3, stride=stride, dilation=1, slimmable=slimmable, width_mult_list=width_mult_list), + 'sa': lambda C_in, C_out, stride, slimmable, width_mult_list, fmap_size: Self_Attn(dim=C_in, fmap_size=(128, 256), dim_out=C_out, proj_factor=1, downsample=(stride==2), slimmable=slimmable, width_mult_list=width_mult_list) +} + +OPS_name = ["FactorizedReduce", "BasicResidual1x", "BasicResidual_downup_1x", "BasicResidual2x", "BasicResidual_downup_2x", "Self_Attn"] + +OPS_Class = OrderedDict() +OPS_Class['skip'] = FactorizedReduce +OPS_Class['conv'] = BasicResidual1x +OPS_Class['conv_downup'] = BasicResidual_downup_1x +OPS_Class['conv_2x'] = BasicResidual2x +OPS_Class['conv_2x_downup'] = BasicResidual_downup_2x +OPS_Class['sa'] = Self_Attn diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py new file mode 100644 index 000000000..79afbaa4f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_metrics.py @@ -0,0 +1,98 @@ +import numpy as np +import torch + + +class Seg_Metrics(object): + def __init__(self, n_classes=19): + self.n_classes = n_classes + self.total_inter = np.zeros(n_classes) + self.total_union = np.zeros(n_classes) + + def update(self, inter, union, N): + self.total_inter += inter * N + self.total_union += union * N + + def get_scores(self): + idx = self.total_union > 0 + IoU = 1.0 * self.total_inter[idx] / (np.spacing(1) + self.total_union[idx]) + mIoU = IoU.mean() + return mIoU + + def reset(self): + self.total_inter = np.zeros(n_classes) + self.total_union = np.zeros(n_classes) + + +def batch_pix_accuracy(predict, target): + """Batch Pixel Accuracy + Args: + predict: input 4D tensor + target: label 3D tensor + """ + _, predict = torch.max(predict, 1) + predict = predict.cpu().numpy() + 1 + target = target.cpu().numpy() + 1 + pixel_labeled = np.sum(target > 0) + pixel_correct = np.sum((predict == target)*(target > 0)) + assert pixel_correct <= pixel_labeled, \ + "Correct area should be smaller than Labeled" + return pixel_correct, pixel_labeled + + +def batch_intersection_union(predict, target, nclass): + """Batch Intersection of Union + Args: + predict: input 4D tensor + target: label 3D tensor + nclass: number of categories (int) + """ + _, predict = torch.max(predict, 1) + mini = 1 + maxi = nclass + nbins = nclass + predict = predict.cpu().numpy() + 1 + target = target.cpu().numpy() + 1 + + k = (target >= 1) & (target <= nclass) + # predict = predict * (target > 0).astype(predict.dtype) + predict = predict * k.astype(predict.dtype) + intersection = predict * (predict == target) + # areas of intersection and union + area_inter, _ = np.histogram(intersection, bins=nbins, range=(mini, maxi)) + area_pred, _ = np.histogram(predict, bins=nbins, range=(mini, maxi)) + area_lab, _ = np.histogram(target, bins=nbins, range=(mini, maxi)) + area_union = area_pred + area_lab - area_inter + assert (area_inter <= area_union).all(), \ + "Intersection area should be smaller than Union area" + return area_inter, area_union + + +# ref https://github.com/CSAILVision/sceneparsing/blob/master/evaluationCode/utils_eval.py +def pixel_accuracy(im_pred, im_lab): + im_pred = np.asarray(im_pred) + im_lab = np.asarray(im_lab) + + # Remove classes from unlabeled pixels in gt image. + # We should not penalize detections in unlabeled portions of the image. + pixel_labeled = np.sum(im_lab > 0) + pixel_correct = np.sum((im_pred == im_lab) * (im_lab > 0)) + #pixel_accuracy = 1.0 * pixel_correct / pixel_labeled + return pixel_correct, pixel_labeled + + +def intersection_and_union(im_pred, im_lab, num_class): + im_pred = np.asarray(im_pred) + im_lab = np.asarray(im_lab) + # Remove classes from unlabeled pixels in gt image. + im_pred = im_pred * (im_lab > 0) + # Compute area intersection: + intersection = im_pred * (im_pred == im_lab) + area_inter, _ = np.histogram(intersection, bins=num_class-1, + range=(1, num_class - 1)) + # Compute area union: + area_pred, _ = np.histogram(im_pred, bins=num_class-1, + range=(1, num_class - 1)) + area_lab, _ = np.histogram(im_lab, bins=num_class-1, + range=(1, num_class - 1)) + area_union = area_pred + area_lab - area_inter + return area_inter, area_union diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py new file mode 100644 index 000000000..7000f01b5 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py @@ -0,0 +1,558 @@ +import numpy as np +try: + from utils.darts_utils import compute_latency_ms_tensorrt as compute_latency + print("use TensorRT for latency test") +except: + from utils.darts_utils import compute_latency_ms_pytorch as compute_latency + print("use PyTorch for latency test") +import torch +import torch.nn as nn + +import os.path as osp +latency_lookup_table = {} +# table_file_name = "latency_lookup_table.npy" +# if osp.isfile(table_file_name): +# latency_lookup_table = np.load(table_file_name).item() + +import torch.nn.functional as F +from collections import OrderedDict +from layers import NaiveSyncBatchNorm +from operations import ConvNorm +from att_sa import Self_Attn +BatchNorm2d = NaiveSyncBatchNorm + +class ConvBnRelu(nn.Module): + def __init__(self, in_planes, out_planes, ksize, stride, pad, dilation=1, + groups=1, has_bn=True, norm_layer=nn.BatchNorm2d, bn_eps=1e-5, + has_relu=True, inplace=True, has_bias=False): + super(ConvBnRelu, self).__init__() + groups = 1 + self.conv = nn.Conv2d(in_planes, out_planes, kernel_size=ksize, + stride=stride, padding=pad, + dilation=dilation, groups=groups, bias=has_bias) + self.has_bn = has_bn + if self.has_bn: + self.bn = norm_layer(out_planes, eps=bn_eps) + self.has_relu = has_relu + if self.has_relu: + self.relu = nn.ReLU(inplace=inplace) + + def forward(self, x): + x = self.conv(x) + if self.has_bn: + x = self.bn(x) + if self.has_relu: + x = self.relu(x) + + return x + + +class SeparableConvBnRelu(nn.Module): + def __init__(self, in_channels, out_channels, + kernel_size=1, stride=1, padding=0, dilation=1, + has_relu=True, norm_layer=nn.BatchNorm2d): + super(SeparableConvBnRelu, self).__init__() + + self.conv1 = nn.Conv2d(in_channels, in_channels, kernel_size, stride, + padding, dilation, groups=in_channels, + bias=False) + self.bn = norm_layer(in_channels) + self.point_wise_cbr = ConvBnRelu(in_channels, out_channels, 1, 1, 0, + has_bn=True, norm_layer=norm_layer, + has_relu=has_relu, has_bias=False) + + def forward(self, x): + x = self.conv1(x) + x = self.bn(x) + x = self.point_wise_cbr(x) + return x + + +class GlobalAvgPool2d(nn.Module): + def __init__(self): + """Global average pooling over the input's spatial dimensions""" + super(GlobalAvgPool2d, self).__init__() + + def forward(self, inputs): + in_size = inputs.size() + inputs = inputs.view((in_size[0], in_size[1], -1)).mean(dim=2) + inputs = inputs.view(in_size[0], in_size[1], 1, 1) + + return inputs + + +class SELayer(nn.Module): + def __init__(self, in_planes, out_planes, reduction=16): + super(SELayer, self).__init__() + self.avg_pool = nn.AdaptiveAvgPool2d(1) + self.fc = nn.Sequential( + nn.Linear(in_planes, out_planes // reduction), + nn.ReLU(inplace=True), + nn.Linear(out_planes // reduction, out_planes), + nn.Sigmoid() + ) + self.out_planes = out_planes + + def forward(self, x): + b, c, _, _ = x.size() + y = self.avg_pool(x).view(b, c) + y = self.fc(y).view(b, self.out_planes, 1, 1) + return y + + +# For DFN +class ChannelAttention(nn.Module): + def __init__(self, in_planes, out_planes, reduction): + super(ChannelAttention, self).__init__() + self.channel_attention = SELayer(in_planes, out_planes, reduction) + + def forward(self, x1, x2): + fm = torch.cat([x1, x2], 1) + channel_attetion = self.channel_attention(fm) + fm = x1 * channel_attetion + x2 + + return fm + + +class BNRefine(nn.Module): + def __init__(self, in_planes, out_planes, ksize, has_bias=False, + has_relu=False, norm_layer=nn.BatchNorm2d, bn_eps=1e-5): + super(BNRefine, self).__init__() + self.conv_bn_relu = ConvBnRelu(in_planes, out_planes, ksize, 1, + ksize // 2, has_bias=has_bias, + norm_layer=norm_layer, bn_eps=bn_eps) + self.conv_refine = nn.Conv2d(out_planes, out_planes, kernel_size=ksize, + stride=1, padding=ksize // 2, dilation=1, + bias=has_bias) + self.has_relu = has_relu + if self.has_relu: + self.relu = nn.ReLU(inplace=False) + + def forward(self, x): + t = self.conv_bn_relu(x) + t = self.conv_refine(t) + if self.has_relu: + return self.relu(t + x) + return t + x + + +class RefineResidual(nn.Module): + def __init__(self, in_planes, out_planes, ksize, has_bias=False, + has_relu=False, norm_layer=nn.BatchNorm2d, bn_eps=1e-5): + super(RefineResidual, self).__init__() + self.conv_1x1 = nn.Conv2d(in_planes, out_planes, kernel_size=1, + stride=1, padding=0, dilation=1, + bias=has_bias) + self.cbr = ConvBnRelu(out_planes, out_planes, ksize, 1, + ksize // 2, has_bias=has_bias, + norm_layer=norm_layer, bn_eps=bn_eps) + self.conv_refine = nn.Conv2d(out_planes, out_planes, kernel_size=ksize, + stride=1, padding=ksize // 2, dilation=1, + bias=has_bias) + self.has_relu = has_relu + if self.has_relu: + self.relu = nn.ReLU(inplace=False) + + def forward(self, x): + x = self.conv_1x1(x) + t = self.cbr(x) + t = self.conv_refine(t) + if self.has_relu: + return self.relu(t + x) + return t + x + + +# For BiSeNet +class AttentionRefinement(nn.Module): + def __init__(self, in_planes, out_planes, + norm_layer=nn.BatchNorm2d): + super(AttentionRefinement, self).__init__() + self.conv_3x3 = ConvBnRelu(in_planes, out_planes, 3, 1, 1, + has_bn=True, norm_layer=norm_layer, + has_relu=True, has_bias=False) + self.channel_attention = nn.Sequential( + nn.AdaptiveAvgPool2d(1), + ConvBnRelu(out_planes, out_planes, 1, 1, 0, + has_bn=True, norm_layer=norm_layer, + has_relu=False, has_bias=False), + nn.Sigmoid() + ) + + def forward(self, x): + fm = self.conv_3x3(x) + fm_se = self.channel_attention(fm) + fm = fm * fm_se + + return fm + + +class FeatureFusion(nn.Module): + def __init__(self, in_planes, out_planes, reduction=1, Fch=16, scale=4, branch=2, norm_layer=nn.BatchNorm2d): + super(FeatureFusion, self).__init__() + self.conv_1x1 = ConvBnRelu(in_planes, out_planes, 1, 1, 0, + has_bn=True, norm_layer=norm_layer, + has_relu=True, has_bias=False) + # self.channel_attention = nn.Sequential( + # nn.AdaptiveAvgPool2d(1), + # ConvBnRelu(out_planes, out_planes // reduction, 1, 1, 0, + # has_bn=False, norm_layer=norm_layer, + # has_relu=True, has_bias=False), + # ConvBnRelu(out_planes // reduction, out_planes, 1, 1, 0, + # has_bn=False, norm_layer=norm_layer, + # has_relu=False, has_bias=False), + # nn.Sigmoid() + # ) + self._Fch = Fch + self._scale = scale + self._branch = branch + + @staticmethod + def _latency(h, w, C_in, C_out): + layer = FeatureFusion(C_in, C_out) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + name = "ff_H%d_W%d_C%d"%(size[1], size[2], size[0]) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + return latency, size + else: + print("not found in latency_lookup_table:", name) + latency = FeatureFusion._latency(size[1], size[2], self._scale*self._Fch*self._branch, self._scale*self._Fch*self._branch) + latency_lookup_table[name] = latency + np.save("latency_lookup_table.npy", latency_lookup_table) + return latency, size + + def forward(self, fm): + # fm is already a concatenation of multiple scales + fm = self.conv_1x1(fm) + return fm + # fm_se = self.channel_attention(fm) + # output = fm + fm * fm_se + # return output + + +class Head(nn.Module): + def __init__(self, in_planes, out_planes=19, Fch=16, scale=4, branch=2, is_aux=False, norm_layer=nn.BatchNorm2d, fmap_size=(128, 256)): + super(Head, self).__init__() + if in_planes <= 64: + mid_planes = in_planes + elif in_planes <= 256: + if is_aux: + mid_planes = in_planes + else: + mid_planes = in_planes + else: + # in_planes > 256: + if is_aux: + mid_planes = in_planes // 2 + else: + mid_planes = in_planes // 2 + + self.att_sa = Self_Attn(dim=in_planes, fmap_size=fmap_size, dim_out=mid_planes, proj_factor=4, downsample=False) + # self.conv_3x3 = ConvBnRelu(in_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.conv_1x1 = nn.Conv2d(mid_planes, out_planes, kernel_size=1, stride=1, padding=0) + self._in_planes = in_planes + self._out_planes = out_planes + self._Fch = Fch + self._scale = scale + self._branch = branch + + @staticmethod + def _latency(h, w, C_in, C_out=19): + layer = Head(C_in, C_out) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + assert size[0] == self._in_planes, "size[0] %d, self._in_planes %d"%(size[0], self._in_planes) + name = "head_H%d_W%d_Cin%d_Cout%d"%(size[1], size[2], size[0], self._out_planes) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + return latency, (self._out_planes, size[1], size[2]) + else: + print("not found in latency_lookup_table:", name) + latency = Head._latency(size[1], size[2], self._scale*self._Fch*self._branch, self._out_planes) + latency_lookup_table[name] = latency + np.save("latency_lookup_table.npy", latency_lookup_table) + return latency, (self._out_planes, size[1], size[2]) + + def forward(self, x): + # fm = self.conv_3x3(x) + fm = self.att_sa(x) + output = self.conv_1x1(fm) + return output + +class Decoder(nn.Module): + def __init__(self, in_planes, low_level_inplanes, out_planes=19, Fch=16, scale=4, branch=2, is_aux=False, norm_layer=nn.BatchNorm2d, fmap_size=(128, 256)): + super(Decoder, self).__init__() + C_low = 48 + self.feature_projection = ConvNorm(low_level_inplanes, C_low, kernel_size=1, stride=1, padding=0, bias=False, groups=1, slimmable=False) + + # in_planes = in_planes + C_low + if in_planes <= 64: + mid_planes = in_planes + elif in_planes <= 256: + if is_aux: + mid_planes = in_planes + else: + mid_planes = in_planes + else: + # in_planes > 256: + if is_aux: + mid_planes = in_planes // 2 + else: + mid_planes = in_planes // 2 + + + self.att_sa = Self_Attn(dim=in_planes, fmap_size=fmap_size, dim_out=mid_planes, proj_factor=4, downsample=False) + self.conv_3x3 = ConvBnRelu(mid_planes + C_low, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.conv_1x1 = nn.Conv2d(mid_planes, out_planes, kernel_size=1, stride=1, padding=0) + self._in_planes = in_planes + self._out_planes = out_planes + self._Fch = Fch + self._scale = scale + self._branch = branch + + @staticmethod + def _latency(h, w, C_in, C_out=19): + layer = Head(C_in, C_out) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + assert size[0] == self._in_planes, "size[0] %d, self._in_planes %d"%(size[0], self._in_planes) + name = "head_H%d_W%d_Cin%d_Cout%d"%(size[1], size[2], size[0], self._out_planes) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + return latency, (self._out_planes, size[1], size[2]) + else: + print("not found in latency_lookup_table:", name) + latency = Head._latency(size[1], size[2], self._scale*self._Fch*self._branch, self._out_planes) + latency_lookup_table[name] = latency + np.save("latency_lookup_table.npy", latency_lookup_table) + return latency, (self._out_planes, size[1], size[2]) + + def forward(self, x, low_level_feat): + low_level_feat = self.feature_projection(low_level_feat) + x = self.att_sa(x) + x = F.interpolate(x, size=low_level_feat.size()[2:], mode='bilinear', align_corners=False) + x = torch.cat((x, low_level_feat), dim=1) + # x = self.att_sa(x) + x = self.conv_3x3(x) + output = self.conv_1x1(x) + return output + +class BasicResidual_downup_2x(nn.Module): + def __init__(self, C_in, C_out, kernel_size=3, stride=1, dilation=1, groups=1): + super(BasicResidual_downup_2x, self).__init__() + # Both self.conv1 and self.downsample layers downsample the input when stride != 1 + groups = 1 + self.C_in = C_in + self.C_out = C_out + self.kernel_size = kernel_size + self.stride = stride + self.dilation = dilation + self.groups = groups + assert stride in [1, 2] + if self.stride == 2: self.dilation = 1 + + self.relu = nn.ReLU(inplace=True) + self.conv1 = nn.Conv2d(C_in, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn1 = nn.BatchNorm2d(C_out) + self.bn1 = BatchNorm2d(C_out) + self.conv2 = nn.Conv2d(C_out, C_out, 3, 1, padding=dilation, dilation=dilation, groups=groups, bias=False) + # self.bn2 = nn.BatchNorm2d(C_out) + self.bn2 = BatchNorm2d(C_out) + if self.stride==1: + self.downsample = nn.Sequential( + nn.Conv2d(C_in, C_out, 1, 1, padding=0, dilation=dilation, groups=groups, bias=False), + BatchNorm2d(C_out) + ) + + def forward(self, x): + out = F.interpolate(x, size=(int(x.size(2))//2, int(x.size(3))//2), mode='bilinear', align_corners=False) + out = self.conv1(out) + out = self.bn1(out) + out = self.relu(out) + out = self.conv2(out) + out = self.bn2(out) + if self.stride == 1: + out = F.interpolate(out, size=(int(x.size(2)), int(x.size(3))), mode='bilinear', align_corners=False) + out = out + self.downsample(x) + out = self.relu(out) + return out + +class PanopticHead(nn.Module): + def __init__(self, in_planes, out_planes=19, Fch=16, scale=4, branch=2, is_aux=False, norm_layer=nn.BatchNorm2d, fmap_size=(128, 256)): + super(PanopticHead, self).__init__() + if in_planes <= 64: + mid_planes = in_planes + elif in_planes <= 256: + if is_aux: + mid_planes = in_planes + else: + mid_planes = in_planes + else: + # in_planes > 256: + if is_aux: + mid_planes = in_planes // 2 + else: + mid_planes = in_planes // 2 + + decoder2_planes = mid_planes // 2 + + self.att_sa = Self_Attn(dim=in_planes, fmap_size=(128, 256), dim_out=in_planes, proj_factor=4, downsample=False) + self.decoder1 = BasicResidual_downup_2x(in_planes, mid_planes, 3, 1, 1) + self.conv_3x3 = ConvBnRelu(mid_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.conv_1x1 = nn.Conv2d(mid_planes, out_planes, kernel_size=1, stride=1, padding=0) + self._in_planes = in_planes + self._out_planes = out_planes + self._Fch = Fch + self._scale = scale + self._branch = branch + + # self.att_sa2 = Self_Attn(dim=in_planes, fmap_size=(128, 256), dim_out=mid_planes, proj_factor=4, downsample=False) + self.decoder2 = BasicResidual_downup_2x(in_planes, decoder2_planes, 3, 1, 1) + self.center_conv_3x3 = ConvBnRelu(decoder2_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.center_conv_1x1 = nn.Conv2d(mid_planes, 1, kernel_size=1, stride=1, padding=0) + + self.offset_conv_3x3 = ConvBnRelu(decoder2_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.offset_conv_1x1 = nn.Conv2d(mid_planes, 2, kernel_size=1, stride=1, padding=0) + + @staticmethod + def _latency(h, w, C_in, C_out=19): + layer = PanopticHead(C_in, C_out) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + assert size[0] == self._in_planes, "size[0] %d, self._in_planes %d"%(size[0], self._in_planes) + name = "panoptichead%d_W%d_Cin%d_Cout%d"%(size[1], size[2], size[0], self._out_planes) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + return latency, (self._out_planes, size[1], size[2]) + else: + print("not found in latency_lookup_table:", name) + latency = Head._latency(size[1], size[2], self._scale*self._Fch*self._branch, self._out_planes) + latency_lookup_table[name] = latency + np.save("latency_lookup_table.npy", latency_lookup_table) + return latency, (self._out_planes, size[1], size[2]) + + def forward(self, x): + output_dict = OrderedDict() + xs = self.att_sa(x) + + # semantic = self.att_sa1(x) + semantic = self.decoder1(xs) + semantic = self.conv_3x3(semantic) + semantic = self.conv_1x1(semantic) + + # other = self.att_sa2(x) + other = self.decoder2(x) + center = self.center_conv_3x3(other) + center = self.center_conv_1x1(center) + + offset = self.offset_conv_3x3(other) + offset = self.offset_conv_1x1(offset) + + output_dict['semantic'] = semantic + output_dict['center'] = center + output_dict['offset'] = offset + + return output_dict + +class PanopticHeadDecoder(nn.Module): + def __init__(self, in_planes, low_level_inplanes, out_planes=19, Fch=16, scale=4, branch=2, is_aux=False, norm_layer=nn.BatchNorm2d, fmap_size=(128, 256)): + super(PanopticHeadDecoder, self).__init__() + + C_low = 48 + self.feature_projection = ConvNorm(low_level_inplanes, C_low, kernel_size=1, stride=1, padding=0, bias=False, groups=1, slimmable=False) + self.feature_projection_sem = ConvNorm(low_level_inplanes, C_low, kernel_size=1, stride=1, padding=0, bias=False, groups=1, slimmable=False) + # in_planes = in_planes + C_low + + if in_planes <= 64: + mid_planes = in_planes + elif in_planes <= 256: + if is_aux: + mid_planes = in_planes + else: + mid_planes = in_planes + else: + # in_planes > 256: + if is_aux: + mid_planes = in_planes // 2 + else: + mid_planes = in_planes // 2 + + decoder2_planes = mid_planes // 2 + + self.att_sa = Self_Attn(dim=in_planes, fmap_size=fmap_size, dim_out=in_planes, proj_factor=4, downsample=False) + + # self.att_sa1 = Self_Attn(dim=in_planes, fmap_size=(128, 256), dim_out=mid_planes, proj_factor=4, downsample=False) + self.decoder1 = BasicResidual_downup_2x(in_planes+C_low, mid_planes, 3, 1, 1) + self.conv_3x3 = ConvBnRelu(mid_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.conv_1x1 = nn.Conv2d(mid_planes, out_planes, kernel_size=1, stride=1, padding=0) + self._in_planes = in_planes + self._out_planes = out_planes + self._Fch = Fch + self._scale = scale + self._branch = branch + + # self.att_sa2 = Self_Attn(dim=in_planes, fmap_size=(128, 256), dim_out=mid_planes, proj_factor=4, downsample=False) + self.decoder2 = BasicResidual_downup_2x(in_planes+C_low, decoder2_planes, 3, 1, 1) + self.center_conv_3x3 = ConvBnRelu(decoder2_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.center_conv_1x1 = nn.Conv2d(mid_planes, 1, kernel_size=1, stride=1, padding=0) + + self.offset_conv_3x3 = ConvBnRelu(decoder2_planes, mid_planes, 3, 1, 1, has_bn=True, norm_layer=norm_layer, has_relu=True, has_bias=False) + self.offset_conv_1x1 = nn.Conv2d(mid_planes, 2, kernel_size=1, stride=1, padding=0) + + @staticmethod + def _latency(h, w, C_in, C_out=19): + layer = PanopticHead(C_in, C_out) + latency = compute_latency(layer, (1, C_in, h, w)) + return latency + + def forward_latency(self, size): + assert size[0] == self._in_planes, "size[0] %d, self._in_planes %d"%(size[0], self._in_planes) + name = "panopticheaddecoder%d_W%d_Cin%d_Cout%d"%(size[1], size[2], size[0], self._out_planes) + if name in latency_lookup_table: + latency = latency_lookup_table[name] + return latency, (self._out_planes, size[1], size[2]) + else: + print("not found in latency_lookup_table:", name) + latency = Head._latency(size[1], size[2], self._scale*self._Fch*self._branch, self._out_planes) + latency_lookup_table[name] = latency + np.save("latency_lookup_table.npy", latency_lookup_table) + return latency, (self._out_planes, size[1], size[2]) + + def forward(self, x, low_level_feat): + output_dict = OrderedDict() + + + xs = self.att_sa(x) + low_level_feat_sem = self.feature_projection_sem(low_level_feat) + xs = F.interpolate(xs, size=low_level_feat_sem.size()[2:], mode='bilinear', align_corners=False) + xs = torch.cat((xs, low_level_feat_sem), dim=1) + + semantic = self.decoder1(xs) + semantic = self.conv_3x3(semantic) + semantic = self.conv_1x1(semantic) + + low_level_feat = self.feature_projection(low_level_feat) + x = F.interpolate(x, size=low_level_feat.size()[2:], mode='bilinear', align_corners=False) + x = torch.cat((x, low_level_feat), dim=1) + + other = self.decoder2(x) + center = self.center_conv_3x3(other) + center = self.center_conv_1x1(center) + + offset = self.offset_conv_3x3(other) + offset = self.offset_conv_1x1(offset) + + output_dict['semantic'] = semantic + output_dict['center'] = center + output_dict['offset'] = offset + + return output_dict diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/slimmable_ops.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/slimmable_ops.py new file mode 100644 index 000000000..b79f66f95 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/slimmable_ops.py @@ -0,0 +1,72 @@ +import torch.nn as nn +from pdb import set_trace as bp +from layers import NaiveSyncBatchNorm + +BatchNorm2d = NaiveSyncBatchNorm + +def make_divisible(v, divisor=8, min_value=1): + """ + forked from slim: + https://github.com/tensorflow/models/blob/\ + 0344c5503ee55e24f0de7f37336a6e08f10976fd/\ + research/slim/nets/mobilenet/mobilenet.py#L62-L69 + """ + if min_value is None: + min_value = divisor + new_v = max(min_value, int(v + divisor / 2) // divisor * divisor) + # Make sure that round down does not go down by more than 10%. + if new_v < 0.9 * v: + new_v += divisor + return new_v + + +class USConv2d(nn.Conv2d): + def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, depthwise=False, bias=True, width_mult_list=[1.]): + super(USConv2d, self).__init__( + in_channels, out_channels, + kernel_size, stride=stride, padding=padding, dilation=dilation, + groups=groups, bias=bias) + self.depthwise = depthwise + self.in_channels_max = in_channels + self.out_channels_max = out_channels + self.width_mult_list = width_mult_list + self.ratio = (1., 1.) + + def set_ratio(self, ratio): + self.ratio = ratio + + def forward(self, input): + assert self.ratio[0] in self.width_mult_list, str(self.ratio[0]) + " in? " + str(self.width_mult_list) + self.in_channels = make_divisible(self.in_channels_max * self.ratio[0]) + assert self.ratio[1] in self.width_mult_list, str(self.ratio[1]) + " in? " + str(self.width_mult_list) + self.out_channels = make_divisible(self.out_channels_max * self.ratio[1]) + self.groups = self.in_channels if self.depthwise else 1 + weight = self.weight[:self.out_channels, :self.in_channels, :, :] + if self.bias is not None: + bias = self.bias[:self.out_channels] + else: + bias = self.bias + y = nn.functional.conv2d(input, weight, bias, self.stride, self.padding, self.dilation, self.groups) + return y + + +class USBatchNorm2d(BatchNorm2d): + def __init__(self, num_features, width_mult_list=[1.]): + super(USBatchNorm2d, self).__init__( + num_features, affine=True, track_running_stats=False) + self.num_features_max = num_features + self.width_mult_list = width_mult_list + # for tracking performance during training + self.bn = nn.ModuleList( + [ BatchNorm2d(i, affine=True) for i in [ make_divisible(self.num_features_max * width_mult) for width_mult in width_mult_list ] ] + ) + self.ratio = 1. + + def set_ratio(self, ratio): + self.ratio = ratio + + def forward(self, input): + assert self.ratio in self.width_mult_list + idx = self.width_mult_list.index(self.ratio) + y = self.bn[idx](input) + return y diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test.py new file mode 100644 index 000000000..b2b21e538 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +import os +import time +import cv2 +cv2.setNumThreads(0) +import torchvision +from PIL import Image +import argparse +import numpy as np + +import torch +import torch.multiprocessing as mp + +from utils.pyt_utils import ensure_dir, link_file, load_model, parse_devices +from utils.visualize import print_iou, show_prediction +from engine.tester import Tester +from engine.logger import get_logger +from seg_opr.metric import hist_info, compute_score +from datasets.cityscapes import Cityscapes + +logger = get_logger() + + +cityscapes_trainID2id = { + 0: 7, + 1: 8, + 2: 11, + 3: 12, + 4: 13, + 5: 17, + 6: 19, + 7: 20, + 8: 21, + 9: 22, + 10: 23, + 11: 24, + 12: 25, + 13: 26, + 14: 27, + 15: 28, + 16: 31, + 17: 32, + 18: 33, + 19: 0 +} + +class SegTester(Tester): + def func_per_iteration(self, data, device, iter=None): + if self.config is not None: config = self.config + img = data['data'] + label = data['label'] + name = data['fn'] + + if len(config.eval_scale_array) == 1: + pred = self.whole_eval(img, None, device) + else: + pred = self.sliding_eval(img, config.eval_crop_size, config.eval_stride_rate, device) + + if self.show_prediction: + colors = self.dataset.get_class_colors() + image = img + comp_img = show_prediction(colors, config.background, image, pred) + cv2.imwrite(os.path.join(os.path.realpath('.'), self.config.save, "test", name+".viz.png"), comp_img[:,:,::-1]) + + for x in range(pred.shape[0]): + for y in range(pred.shape[1]): + pred[x, y] = cityscapes_trainID2id[pred[x, y]] + cv2.imwrite(os.path.join(os.path.realpath('.'), self.config.save, "test", name+".png"), pred) + + def compute_metric(self, results): + hist = np.zeros((self.config.num_classes, self.config.num_classes)) + correct = 0 + labeled = 0 + count = 0 + for d in results: + hist += d['hist'] + correct += d['correct'] + labeled += d['labeled'] + count += 1 + + iu, mean_IU, mean_IU_no_back, mean_pixel_acc = compute_score(hist, correct, labeled) + result_line = print_iou(iu, mean_pixel_acc, self.dataset.get_class_names(), True) + return result_line, mean_IU diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test_seg.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test_seg.py new file mode 100644 index 000000000..27b5c9e19 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/test_seg.py @@ -0,0 +1,191 @@ +from __future__ import division +import os +import sys +import time +import glob +import json +import yaml +import logging +import argparse +from tqdm import tqdm + +import torch +import torch.nn as nn +import torch.utils +import torch.nn.functional as F +import torch.optim as optim +from tensorboardX import SummaryWriter + +import numpy as np +from thop import profile + +from config_test import config +if config.is_eval: + config.save = 'eval-{}-{}'.format(config.save, time.strftime("%Y%m%d-%H%M%S")) +else: + config.save = 'train-{}-{}'.format(config.save, time.strftime("%Y%m%d-%H%M%S")) +from dataloader import get_train_loader, CyclicIterator +from datasets import Cityscapes + +import dataloaders +from utils.init_func import init_weight +from eval import SegEvaluator +from test import SegTester + +from utils.darts_utils import create_exp_dir, save, plot_op, plot_path_width, objective_acc_lat +from model_seg import Network_Multi_Path_Infer_SPOS as Network +import seg_metrics + +from utils.pyt_utils import load_pretrain + +## dist train +try: + import apex + from apex import amp + from apex.parallel import DistributedDataParallel as DDP + from apex.parallel import convert_syncbn_model + has_apex = True +except ImportError: + from torch.nn.parallel import DistributedDataParallel as DDP + has_apex = False + +# The first arg parser parses out only the --config argument, this argument is used to +# load a yaml file containing key-values that override the defaults for the main parser below +config_parser = parser = argparse.ArgumentParser(description='Training Config', add_help=False) +parser.add_argument('-c', '--config', default='../configs/auto2/sz512drop0.2.yaml', type=str, metavar='FILE', + help='YAML config file specifying default arguments') + +parser = argparse.ArgumentParser(description='PyTorch Training') +parser.add_argument("--local_rank", default=0, type=int) +parser.add_argument("--world_size", default=1, type=int) +parser.add_argument("--seed", default=12345, type=int) + +def _parse_args(): + # Do we have a config file to parse? + args_config, remaining = config_parser.parse_known_args() + if args_config.config: + with open(args_config.config, 'r') as f: + cfg = yaml.safe_load(f) + parser.set_defaults(**cfg) + + # The main arg parser parses the rest of the args, the usual + # defaults will have been overridden if config file specified. + args = parser.parse_args(remaining) + + # Cache the args as a text string to save them in the output dir later + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + return args, args_text + +def main(): + args, args_text = _parse_args() + + # dist init + torch.distributed.init_process_group(backend='nccl', init_method='tcp://127.0.0.1:26442', world_size=1, rank=0) + config.device = 'cuda:%d' % args.local_rank + torch.cuda.set_device(args.local_rank) + args.world_size = torch.distributed.get_world_size() + args.local_rank = torch.distributed.get_rank() + logging.info("rank: {} world_size: {}".format(args.local_rank, args.world_size)) + + if args.local_rank == 0: + create_exp_dir(config.save, scripts_to_save=glob.glob('*.py')+glob.glob('*.sh')) + logger = SummaryWriter(config.save) + log_format = '%(asctime)s %(message)s' + logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format, datefmt='%m/%d %I:%M:%S %p') + fh = logging.FileHandler(os.path.join(config.save, 'log.txt')) + fh.setFormatter(logging.Formatter(log_format)) + logging.getLogger().addHandler(fh) + logging.info("args = %s", str(config)) + else: + logger = None + + # preparation ################ + np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.cuda.manual_seed_all(args.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + + # data loader ########################### + if config.is_test: + data_setting = {'img_root': config.img_root_folder, + 'gt_root': config.gt_root_folder, + 'train_source': config.train_eval_source, + 'eval_source': config.eval_source, + 'test_source': config.test_source, + 'down_sampling': config.down_sampling} + else: + data_setting = {'img_root': config.img_root_folder, + 'gt_root': config.gt_root_folder, + 'train_source': config.train_source, + 'eval_source': config.eval_source, + 'test_source': config.test_source, + 'down_sampling': config.down_sampling} + + with open(config.json_file, 'r') as f: + model_dict = json.loads(f.read()) + + model = Network( + model_dict["ops"], model_dict["paths"], model_dict["downs"], model_dict["widths"], model_dict["lasts"], + num_classes=config.num_classes, layers=config.layers, Fch=config.Fch, width_mult_list=config.width_mult_list, stem_head_width=config.stem_head_width) + + if args.local_rank == 0: + logging.info("net: " + str(model)) + flops, params = profile(model, inputs=(torch.randn(1, 3, 1024, 2048),), verbose=False) + logging.info("params = %fMB, FLOPs = %fGB", params / 1e6, flops / 1e9) + logging.info("ops:" + str(model.ops)) + logging.info("path:" + str(model.paths)) + logging.info("last:" + str(model.lasts)) + with open(os.path.join(config.save, 'args.yaml'), 'w') as f: + f.write(args_text) + + model = model.cuda() + init_weight(model, nn.init.kaiming_normal_, torch.nn.BatchNorm2d, config.bn_eps, config.bn_momentum, mode='fan_in', nonlinearity='relu') + + model = load_pretrain(model, config.model_path) + + # partial = torch.load(config.model_path) + # state = model.state_dict() + # pretrained_dict = {k: v for k, v in partial.items() if k in state} + # state.update(pretrained_dict) + # model.load_state_dict(state) + + eval_model = model + evaluator = SegEvaluator(Cityscapes(data_setting, 'val', None), config.num_classes, config.image_mean, + config.image_std, eval_model, config.eval_scale_array, config.eval_flip, 0, out_idx=0, config=config, + verbose=False, save_path=None, show_image=False, show_prediction=False) + tester = SegTester(Cityscapes(data_setting, 'test', None), config.num_classes, config.image_mean, + config.image_std, eval_model, config.eval_scale_array, config.eval_flip, 0, out_idx=0, config=config, + verbose=False, save_path=None, show_prediction=False) + + # Cityscapes ########################################### + logging.info(config.model_path) + logging.info(config.save) + with torch.no_grad(): + if config.is_test: + # test + print("[test...]") + with torch.no_grad(): + test(0, model, tester, logger) + else: + # validation + print("[validation...]") + valid_mIoU = infer(model, evaluator, logger) + logger.add_scalar("mIoU/val", valid_mIoU, 0) + logging.info("Model valid_mIoU %.3f"%(valid_mIoU)) + +def infer(model, evaluator, logger): + model.eval() + # _, mIoU = evaluator.run_online() + _, mIoU = evaluator.run_online_multiprocess() + return mIoU + +def test(epoch, model, tester, logger): + output_path = os.path.realpath('.') + os.system("mkdir %s"%os.path.join(output_path, config.save, "test")) + model.eval() + tester.run_online_multiprocess() + os.system("mv %s %s"%(os.path.join(output_path, config.save, "test"), os.path.join(output_path, config.save, "test_%d_%d"%(0, epoch)))) + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py new file mode 100644 index 000000000..021a148a9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_ade20k_cydas.py @@ -0,0 +1,569 @@ +from __future__ import division +import os +import sys +import time +import glob +import json +import logging +import argparse +from tqdm import tqdm + +import torch +import torch.nn as nn +import torch.utils +import torch.nn.functional as F +import torch.optim as optim +import torch.distributed as dist +from tensorboardX import SummaryWriter + +import numpy as np +import _init_paths +from ptflops import get_model_complexity_info +from dataloader import get_train_loader, CyclicIterator +from datasets import Cityscapes + +import dataloaders +from utils.init_func import init_weight +from utils.lr_scheduler import Iter_LR_Scheduler +from seg_opr.loss_opr import ProbOhemCrossEntropy2d +from eval import SegEvaluator +from test import SegTester + +from utils.darts_utils import create_exp_dir, save, plot_op, plot_path_width, objective_acc_lat +from utils.dist_utils import reduce_tensor, ModelEma +from cydas import CyDASseg as Network +import seg_metrics + +import yaml +import timm +from timm.optim import create_optimizer +from utils.pyt_utils import AverageMeter, to_cuda, get_loss_info_str, compute_hist, compute_hist_np, load_pretrain + +from detectron2.config import get_cfg +from detectron2.engine import launch, default_setup, default_argument_parser +import detectron2.data.transforms as T +from detectron2.structures import BitMasks, ImageList, Instances +from detectron2.data import MetadataCatalog, DatasetMapper, build_detection_train_loader, build_detection_test_loader + +from detectron2.config import configurable +from detectron2.data.build import _test_loader_from_config, trivial_batch_collator +from detectron2.data.samplers import InferenceSampler, RepeatFactorTrainingSampler, TrainingSampler +from detectron2.data.common import AspectRatioGroupedDataset, DatasetFromList, MapDataset + +from detectron2.projects.panoptic_deeplab import ( + PanopticDeeplabDatasetMapper, + add_panoptic_deeplab_config, +) + +## dist train +try: + import apex + from apex import amp + from apex.parallel import DistributedDataParallel as DDP + from apex.parallel import convert_syncbn_model + has_apex = True +except ImportError: + from torch.nn.parallel import DistributedDataParallel as DDP + has_apex = False + +def adjust_learning_rate(base_lr, power, optimizer, epoch, total_epoch): + for param_group in optimizer.param_groups: + param_group['lr'] = param_group['lr'] * power + + +# The first arg parser parses out only the --config argument, this argument is used to +# load a yaml file containing key-values that override the defaults for the main parser below +config_parser = parser = argparse.ArgumentParser(description='Training Config', add_help=False) +parser.add_argument('-c', '--config', default='../configs/ade/cydas.yaml', type=str, metavar='FILE', + help='YAML config file specifying default arguments') + +parser = argparse.ArgumentParser(description='PyTorch Training') +parser.add_argument('--det2_cfg', type=str, default='configs/ADE20K/base.yaml', help='') +parser.add_argument('--save', type=str, default='../OUTPUT/train_', help='') +parser.add_argument('--exp_name', type=str, default='ade20k', help='') +parser.add_argument('--pretrain', type=str, default=None, help='resume path') +parser.add_argument('--resume', type=str, default='../OUTPUT/train/', help='resume path') +parser.add_argument("--local_rank", default=0, type=int) +parser.add_argument("--num_classes", default=150, type=int) +parser.add_argument("--max_iteration", default=160000, type=int) +parser.add_argument("--world_size", default=1, type=int) +parser.add_argument("--eval_height", default=1025, type=int, help='train height') +parser.add_argument("--eval_width", default=2049, type=int, help='train width') +parser.add_argument("--test_epoch", default=250, type=int, help='Epochs for test') +parser.add_argument("--batch_size", default=12, type=int, help='batch size') +parser.add_argument("--Fch", default=12, type=int, help='Fch') +parser.add_argument('--stem_head_width', type=float, default=1.0, help='base learning rate') + +## new retrain ### +parser.add_argument('--sched', default='step', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "step"') +parser.add_argument('--epochs', type=int, default=4000, help='num of training epochs') +parser.add_argument('--dataset', type=str, default='cityscapes', help='pascal or cityscapes') +parser.add_argument('--base_lr', type=float, default=0.05, help='base learning rate') +parser.add_argument('--warmup_start_lr', type=float, default=5e-6, help='warm up learning rate') +parser.add_argument('--lr-step', type=float, default=None) +parser.add_argument('--warmup-iters', type=int, default=1000) +parser.add_argument('--min-lr', type=float, default=None) +parser.add_argument('--layers', type=int, default=20, help='layers') +parser.add_argument('--size_divisibility', type=int, default=32, help='size_divisibility') +parser.add_argument('--crop_size', type=int, default=769, help='image crop size') +parser.add_argument('--resize', type=int, default=769, help='image crop size') +parser.add_argument("--image_height", default=513, type=int, help='train height') +parser.add_argument("--image_width", default=1025, type=int, help='train width') +parser.add_argument('--workers', type=int, default=4, help='number of data loading workers') +parser.add_argument('--dist', type=bool, default=True) +parser.add_argument('--autodeeplab', type=str, default='train_seg') +parser.add_argument('--max-iteration', default=1000000, type=bool) +parser.add_argument('--mode', default='poly', type=str, help='how lr decline') +parser.add_argument('--train_mode', type=str, default='iter', choices=['iter', 'epoch']) + +parser.add_argument("--data_path", default='/home/hongyuan/data/cityscapes', type=str, help='If specified, replace config.load_path') +parser.add_argument("--load_path", default='', type=str, help='If specified, replace config.load_path') +parser.add_argument("--json_file", default='jsons/0.json', type=str, help='model_arch') +parser.add_argument("--seed", default=12345, type=int, help="random seed") +parser.add_argument('--sync_bn', action='store_false', + help='Enable NVIDIA Apex or Torch synchronized BatchNorm.') +parser.add_argument('--random_sample', action='store_true', + help='Random sample path.') +parser.add_argument('--drop_path_prob', type=float, default=0.0, help='drop path prob') + +# Optimizer parameters +parser.add_argument('--opt', default='sgd', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "sgd"') +parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') +parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') +parser.add_argument('--weight-decay', type=float, default=0.0001, + help='weight decay (default: 0.0001)') + +# Model Exponential Moving Average +parser.add_argument('--model-ema', action='store_true', default=False, + help='Enable tracking moving average of model weights') +parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, + help='Force ema to be tracked on CPU, rank=0 node only. Disables EMA validation.') +parser.add_argument('--model-ema-decay', type=float, default=0.9998, + help='decay factor for model weights moving average (default: 0.9998)') + +# train val +parser.add_argument('--bn_eps', type=float, default=1e-5, help='bn eps') +parser.add_argument('--bn_momentum', type=float, default=0.01, help='bn momentum') +parser.add_argument('--ignore', type=int, default=255, help='semantic ignore') +parser.add_argument('--eval_flip', action='store_true', default=False, + help='semantic eval flip') + + +def _parse_args(): + # Do we have a config file to parse? + args_config, remaining = config_parser.parse_known_args() + if args_config.config: + with open(args_config.config, 'r') as f: + cfg = yaml.safe_load(f) + parser.set_defaults(**cfg) + + # The main arg parser parses the rest of the args, the usual + # defaults will have been overridden if config file specified. + args = parser.parse_args(remaining) + + # Cache the args as a text string to save them in the output dir later + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + return args, args_text + +def build_sem_seg_train_aug(cfg): + augs = [ + T.ResizeShortestEdge( + cfg.INPUT.MIN_SIZE_TRAIN, cfg.INPUT.MAX_SIZE_TRAIN, cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING + ) + ] + if cfg.INPUT.CROP.ENABLED: + augs.append(T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE)) + augs.append(T.RandomFlip()) + return augs + +def setup(args): + """ + Create configs and perform basic setups. + """ + cfg = get_cfg() + add_panoptic_deeplab_config(cfg) + cfg.merge_from_file(args.config_file) + # cfg.merge_from_list(args.opts) + cfg.freeze() + default_setup(cfg, args) + return cfg + +@configurable(from_config=_test_loader_from_config) +def build_batch_test_loader(dataset, *, mapper, sampler=None, num_workers=0): + """ + Similar to `build_detection_train_loader`, but uses a batch size of 1, + and :class:`InferenceSampler`. This sampler coordinates all workers to + produce the exact set of all samples. + This interface is experimental. + Args: + dataset (list or torch.utils.data.Dataset): a list of dataset dicts, + or a map-style pytorch dataset. They can be obtained by using + :func:`DatasetCatalog.get` or :func:`get_detection_dataset_dicts`. + mapper (callable): a callable which takes a sample (dict) from dataset + and returns the format to be consumed by the model. + When using cfg, the default choice is ``DatasetMapper(cfg, is_train=False)``. + sampler (torch.utils.data.sampler.Sampler or None): a sampler that produces + indices to be applied on ``dataset``. Default to :class:`InferenceSampler`, + which splits the dataset across all workers. + num_workers (int): number of parallel data loading workers + Returns: + DataLoader: a torch DataLoader, that loads the given detection + dataset, with test-time transformation and batching. + Examples: + :: + data_loader = build_detection_test_loader( + DatasetRegistry.get("my_test"), + mapper=DatasetMapper(...)) + # or, instantiate with a CfgNode: + data_loader = build_detection_test_loader(cfg, "my_test") + """ + if isinstance(dataset, list): + dataset = DatasetFromList(dataset, copy=False) + if mapper is not None: + dataset = MapDataset(dataset, mapper) + if sampler is None: + sampler = InferenceSampler(len(dataset)) + # Always use 1 image per worker during inference since this is the + # standard when reporting inference time in papers. + batch_sampler = torch.utils.data.sampler.BatchSampler(sampler, 4, drop_last=False) + data_loader = torch.utils.data.DataLoader( + dataset, + num_workers=num_workers, + batch_sampler=batch_sampler, + collate_fn=trivial_batch_collator, + ) + return data_loader + + +def main(): + args, args_text = _parse_args() + + # dist init + torch.distributed.init_process_group(backend='nccl', init_method='env://') + torch.cuda.set_device(args.local_rank) + args.world_size = torch.distributed.get_world_size() + args.local_rank = torch.distributed.get_rank() + args.save = args.save + args.exp_name + + # detectron2 data loader ########################### + # det2_args = default_argument_parser().parse_args() + det2_args = args + det2_args.config_file = args.det2_cfg + cfg = setup(det2_args) + mapper = DatasetMapper(cfg, augmentations=build_sem_seg_train_aug(cfg)) + det2_dataset = iter(build_detection_train_loader(cfg, mapper=mapper)) + det2_val = build_batch_test_loader(cfg, cfg.DATASETS.TEST[0]) + len_det2_train = 20210 // cfg.SOLVER.IMS_PER_BATCH + + if args.local_rank == 0: + create_exp_dir(args.save, scripts_to_save=glob.glob('*.py')+glob.glob('*.sh')) + logger = SummaryWriter(args.save) + log_format = '%(asctime)s %(message)s' + logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format, datefmt='%m/%d %I:%M:%S %p') + fh = logging.FileHandler(os.path.join(args.save, 'log.txt')) + fh.setFormatter(logging.Formatter(log_format)) + logging.getLogger().addHandler(fh) + logging.info("args = %s", str(args)) + else: + logger = None + + # preparation ################ + np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.cuda.manual_seed_all(args.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + + # config network and criterion ################ + gt_down_sampling = 1 + min_kept = int(args.batch_size * args.image_height * args.image_width // (16 * gt_down_sampling ** 2)) + ohem_criterion = ProbOhemCrossEntropy2d(ignore_label=255, thresh=0.7, min_kept=min_kept, use_weight=False) + + # data loader ########################### + + num_classes = args.num_classes + + with open(args.json_file, 'r') as f: + # dict_a = json.loads(f, cls=NpEncoder) + model_dict = json.loads(f.read()) + + width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] + model = Network(Fch=args.Fch, num_classes=num_classes, stem_head_width=(args.stem_head_width, args.stem_head_width)) + last = model_dict["lasts"] + + if args.local_rank == 0: + with torch.cuda.device(0): + macs, params = get_model_complexity_info(model, (3, args.eval_height, args.eval_width), as_strings=True, + print_per_layer_stat=True, verbose=True) + logging.info('{:<30} {:<8}'.format('Computational complexity: ', macs)) + logging.info('{:<30} {:<8}'.format('Number of parameters: ', params)) + + with open(os.path.join(args.save, 'args.yaml'), 'w') as f: + f.write(args_text) + + init_weight(model, nn.init.kaiming_normal_, torch.nn.BatchNorm2d, args.bn_eps, args.bn_momentum, mode='fan_in', nonlinearity='relu') + + if args.pretrain: + model.backbone = load_pretrain(model.backbone, args.pretrain) + model = model.cuda() + + # if args.sync_bn: + # if has_apex: + # model = apex.parallel.convert_syncbn_model(model) + # else: + # model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model) + + # Optimizer ################################### + base_lr = args.base_lr + + if args.opt == "sgd": + optimizer = torch.optim.SGD(model.parameters(), lr=base_lr, momentum=args.momentum, weight_decay=args.weight_decay) + elif args.opt == "adam": + optimizer = torch.optim.Adam(model.parameters(), lr=base_lr, betas=(0.9, 0.999), eps=1e-08) + elif args.opt == "adamw": + optimizer = torch.optim.AdamW(model.parameters(), lr=base_lr, betas=(0.9, 0.999), eps=1e-08, weight_decay=args.weight_decay) + else: + optimizer = create_optimizer(args, model) + + if args.sched == "raw": + lr_scheduler =None + else: + max_iteration = args.epochs * len_det2_train + lr_scheduler = Iter_LR_Scheduler(args, max_iteration, len_det2_train) + + start_epoch = 0 + if os.path.exists(os.path.join(args.save, 'last.pth.tar')): + args.resume = os.path.join(args.save, 'last.pth.tar') + + if args.resume: + model_state_file = args.resume + if os.path.isfile(model_state_file): + checkpoint = torch.load(model_state_file, map_location=torch.device('cpu')) + start_epoch = checkpoint['start_epoch'] + model.load_state_dict(checkpoint['state_dict']) + optimizer.load_state_dict(checkpoint['optimizer']) + logging.info('Loaded checkpoint (starting from iter {})'.format(checkpoint['start_epoch'])) + + model_ema = None + if args.model_ema: + # Important to create EMA model after cuda(), DP wrapper, and AMP but before SyncBN and DDP wrapper + model_ema = ModelEma( + model, + decay=args.model_ema_decay, + device='cpu' if args.model_ema_force_cpu else '', + resume=None) + + if model_ema: + eval_model = model_ema.ema + else: + eval_model = model + + if has_apex: + model = DDP(model, delay_allreduce=True) + else: + model = DDP(model, device_ids=[args.local_rank]) + + best_valid_iou = 0. + best_epoch = 0 + temp_iou = 0. + avg_loss = -1 + + logging.info("rank: {} world_size: {}".format(args.local_rank, args.world_size)) + for epoch in range(start_epoch, args.epochs): + if args.local_rank == 0: + logging.info(args.load_path) + logging.info(args.save) + logging.info("lr: " + str(optimizer.param_groups[0]['lr'])) + + # training + drop_prob = args.drop_path_prob * epoch / args.epochs + # model.module.drop_path_prob(drop_prob) + + train_mIoU = train(len_det2_train, det2_dataset, model, model_ema, ohem_criterion, num_classes, lr_scheduler, optimizer, logger, epoch, args, cfg) + + # torch.cuda.empty_cache() + + # if epoch > args.epochs // 3: + if epoch >= 0: + temp_iou, avg_loss = validation(det2_val, eval_model, ohem_criterion, num_classes, args, cfg) + + torch.cuda.empty_cache() + if args.local_rank == 0: + logging.info("Epoch: {} train miou: {:.2f}".format(epoch+1, 100*train_mIoU)) + if temp_iou > best_valid_iou: + best_valid_iou = temp_iou + best_epoch = epoch + + if model_ema is not None: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model_ema.ema.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'best_checkpoint.pth.tar')) + else: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model.module.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'best_checkpoint.pth.tar')) + + logger.add_scalar("mIoU/val", temp_iou, epoch) + logging.info("[Epoch %d/%d] valid mIoU %.4f eval loss %.4f"%(epoch + 1, args.epochs, temp_iou, avg_loss)) + logging.info("Best valid mIoU %.4f Epoch %d"%(best_valid_iou, best_epoch)) + + if model_ema is not None: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model_ema.ema.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'last.pth.tar')) + else: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model.module.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'last.pth.tar')) + + +def train(len_det2_train, det2_dataset, model, model_ema, criterion, num_classes, lr_scheduler, optimizer, logger, epoch, args, cfg): + + model.train() + pixel_mean = cfg.MODEL.PIXEL_MEAN + pixel_std = cfg.MODEL.PIXEL_STD + pixel_mean = torch.Tensor(pixel_mean).view(-1, 1, 1).cuda() + pixel_std = torch.Tensor(pixel_std).view(-1, 1, 1).cuda() + + metric = seg_metrics.Seg_Metrics(n_classes=num_classes) + lamb = 0.2 + # for i, sample in enumerate(train_loader): + for i in range(len_det2_train): + cur_iter = epoch * len_det2_train + i + lr_scheduler(optimizer, cur_iter) + + det2_data = next(det2_dataset) + det2_inputs = [x["image"].cuda(non_blocking=True) for x in det2_data] + det2_inputs = [(x - pixel_mean) / pixel_std for x in det2_inputs] + det2_inputs = ImageList.from_tensors(det2_inputs, args.size_divisibility).tensor + + b, c, h, w = det2_inputs.shape + if h % 32 != 0 or w % 32 != 0: + logging.info("pass bad data!") + continue + + det2_targets = [x["sem_seg"].cuda(non_blocking=True) for x in det2_data] + det2_targets = ImageList.from_tensors(det2_targets, args.size_divisibility, args.ignore).tensor + + N = det2_inputs.size(0) + + loss = 0 + description = "" + + logits8, logits16, logits32 = model(det2_inputs) + loss = loss + criterion(logits8, det2_targets) + if logits16 is not None: + loss = loss + lamb * criterion(logits16, det2_targets) + if logits32 is not None: + loss = loss + lamb * criterion(logits32, det2_targets) + + inter, union = seg_metrics.batch_intersection_union(logits8.data, det2_targets, num_classes) + inter = reduce_tensor(torch.FloatTensor(inter).cuda(), args.world_size) + union = reduce_tensor(torch.FloatTensor(union).cuda(), args.world_size) + metric.update(inter.cpu().numpy(), union.cpu().numpy(), N) + + if args.local_rank == 0: + description += "[mIoU%d: %.3f]"%(0, metric.get_scores()) + + torch.cuda.synchronize() + + reduced_loss = loss + reduced_loss = reduce_tensor(reduced_loss.data, args.world_size) + if args.local_rank == 0 and i % 20 == 0: + logger.add_scalar('loss/train', reduced_loss, epoch*len_det2_train+i) + logging.info('epoch: {0}\t''iter: {1}/{2}\t''lr: {3:.6f}\t''loss: {4:.4f}'.format( + epoch + 1, i + 1, len_det2_train, lr_scheduler.get_lr(optimizer), reduced_loss)) + + loss.backward() + optimizer.step() + optimizer.zero_grad() + torch.cuda.synchronize() + + if model_ema is not None: + model_ema.update(model) + + return metric.get_scores() + + +def validation(val_loader, model, criterion, n_classes, args, cfg): + device = torch.device('cuda:{}'.format(args.local_rank)) + + pixel_mean = cfg.MODEL.PIXEL_MEAN + pixel_std = cfg.MODEL.PIXEL_STD + pixel_mean = torch.Tensor(pixel_mean).view(-1, 1, 1).cuda() + pixel_std = torch.Tensor(pixel_std).view(-1, 1, 1).cuda() + + model.eval() + test_loss = 0.0 + hist_size = (n_classes, n_classes) + hist = torch.zeros(hist_size, dtype=torch.float32).cuda() + + for i, sample in enumerate(val_loader): + image = [x["image"].cuda(non_blocking=True) for x in sample] + image = [(x - pixel_mean) / pixel_std for x in image] + image = ImageList.from_tensors(image, args.size_divisibility).tensor + + target = [x["sem_seg"].cuda(non_blocking=True) for x in sample] + target = ImageList.from_tensors(target, args.size_divisibility, args.ignore).tensor + + N, H, W = target.shape + probs = torch.zeros((N, n_classes, H, W)).cuda() + probs.requires_grad = False + + torch.cuda.synchronize() + if args.local_rank==0: + logging.info("Evaluation [{}/{}]".format(i+1, len(val_loader))) + with torch.no_grad(): + output = model(image) + prob = F.softmax(output, 1) + probs += prob + loss = criterion(output, target).detach().data + dist.all_reduce(loss, dist.ReduceOp.SUM) + test_loss += loss + + if args.eval_flip: + output = model(torch.flip(image, dims=(3,))) + output = torch.flip(output, dims=(3,)) + prob = F.softmax(output, 1) + probs += prob + loss = criterion(output, target).detach().data + dist.all_reduce(loss, dist.ReduceOp.SUM) + test_loss += loss + + + preds = torch.argmax(probs, dim=1) + hist_once = compute_hist(preds, target, n_classes, args.ignore) + hist = hist + hist_once + torch.cuda.synchronize() + + + if args.eval_flip: + avg_loss = test_loss / 2*len(val_loader) + else: + avg_loss = test_loss / len(val_loader) + + dist.all_reduce(hist, dist.ReduceOp.SUM) + hist = hist.cpu().numpy().astype(np.float32) + IOUs = np.diag(hist) / (np.sum(hist, axis=0) + np.sum(hist, axis=1) - np.diag(hist)) + mIOU = np.mean(IOUs) + + return mIOU*100, avg_loss + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_cydas.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_cydas.py new file mode 100644 index 000000000..b7b1c866f --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/train_cydas.py @@ -0,0 +1,516 @@ +from __future__ import division +import os +import sys +import time +import glob +import json +import logging +import argparse +from tqdm import tqdm + +import torch +import torch.nn as nn +import torch.utils +import torch.nn.functional as F +import torch.optim as optim +import torch.distributed as dist +from tensorboardX import SummaryWriter + +import numpy as np +import _init_paths +from ptflops import get_model_complexity_info +from dataloader import get_train_loader, CyclicIterator +from datasets import Cityscapes + +import dataloaders +from utils.init_func import init_weight +from utils.lr_scheduler import Iter_LR_Scheduler +from seg_opr.loss_opr import ProbOhemCrossEntropy2d +from eval import SegEvaluator +from test import SegTester + +from utils.darts_utils import create_exp_dir, save, plot_op, plot_path_width, objective_acc_lat +from utils.dist_utils import reduce_tensor, ModelEma +from cydas import CyDASseg as Network +import seg_metrics + +import yaml +import timm +from timm.optim import create_optimizer +from utils.pyt_utils import AverageMeter, to_cuda, get_loss_info_str, compute_hist, compute_hist_np, load_pretrain + +from detectron2.config import get_cfg +from detectron2.engine import launch, default_setup, default_argument_parser +import detectron2.data.transforms as T +from detectron2.structures import BitMasks, ImageList, Instances +from detectron2.data import MetadataCatalog, build_detection_train_loader +from detectron2.projects.panoptic_deeplab import ( + PanopticDeeplabDatasetMapper, + add_panoptic_deeplab_config, +) + +## dist train +try: + import apex + from apex import amp + from apex.parallel import DistributedDataParallel as DDP + from apex.parallel import convert_syncbn_model + has_apex = True +except ImportError: + from torch.nn.parallel import DistributedDataParallel as DDP + has_apex = False + +def adjust_learning_rate(base_lr, power, optimizer, epoch, total_epoch): + for param_group in optimizer.param_groups: + param_group['lr'] = param_group['lr'] * power + + +# The first arg parser parses out only the --config argument, this argument is used to +# load a yaml file containing key-values that override the defaults for the main parser below +config_parser = parser = argparse.ArgumentParser(description='Training Config', add_help=False) +parser.add_argument('-c', '--config', default='../configs/auto2/cydas.yaml', type=str, metavar='FILE', + help='YAML config file specifying default arguments') + +parser = argparse.ArgumentParser(description='PyTorch Training') +parser.add_argument('--det2_cfg', type=str, default='configs/Cityscapes-PanopticSegmentation/panoptic_deeplab_R_52_os16_mg124_poly_90k_bs32_crop_512_1024.yaml', help='') +parser.add_argument('--save', type=str, default='../OUTPUT/train_', help='') +parser.add_argument('--exp_name', type=str, default='cydas', help='') +parser.add_argument('--pretrain', type=str, default=None, help='resume path') +parser.add_argument('--size_divisibility', type=int, default=32, help='size_divisibility') +parser.add_argument('--resume', type=str, default='../OUTPUT/train/', help='resume path') +parser.add_argument("--local_rank", default=0, type=int) +parser.add_argument("--world_size", default=1, type=int) +parser.add_argument("--eval_height", default=1025, type=int, help='train height') +parser.add_argument("--eval_width", default=2049, type=int, help='train width') +parser.add_argument("--test_epoch", default=250, type=int, help='Epochs for test') +parser.add_argument("--batch_size", default=12, type=int, help='batch size') +parser.add_argument("--Fch", default=12, type=int, help='Fch') +parser.add_argument('--stem_head_width', type=float, default=1.0, help='base learning rate') + +## new retrain ### +parser.add_argument('--sched', default='step', type=str, metavar='SCHEDULER', + help='LR scheduler (default: "step"') +parser.add_argument('--epochs', type=int, default=4000, help='num of training epochs') +parser.add_argument('--dataset', type=str, default='cityscapes', help='pascal or cityscapes') +parser.add_argument('--base_lr', type=float, default=0.05, help='base learning rate') +parser.add_argument('--warmup_start_lr', type=float, default=5e-6, help='warm up learning rate') +parser.add_argument('--lr-step', type=float, default=None) +parser.add_argument('--warmup-iters', type=int, default=1000) +parser.add_argument('--min-lr', type=float, default=None) +parser.add_argument('--layers', type=int, default=20, help='layers') +parser.add_argument('--crop_size', type=int, default=769, help='image crop size') +parser.add_argument('--resize', type=int, default=769, help='image crop size') +parser.add_argument("--image_height", default=513, type=int, help='train height') +parser.add_argument("--image_width", default=1025, type=int, help='train width') +parser.add_argument('--workers', type=int, default=4, help='number of data loading workers') +parser.add_argument('--dist', type=bool, default=True) +parser.add_argument('--autodeeplab', type=str, default='train_seg') +parser.add_argument('--max-iteration', default=1000000, type=bool) +parser.add_argument('--mode', default='poly', type=str, help='how lr decline') +parser.add_argument('--train_mode', type=str, default='iter', choices=['iter', 'epoch']) + +parser.add_argument("--data_path", default='/home/hongyuan/data/cityscapes', type=str, help='If specified, replace config.load_path') +parser.add_argument("--load_path", default='', type=str, help='If specified, replace config.load_path') +parser.add_argument("--json_file", default='jsons/0.json', type=str, help='model_arch') +parser.add_argument("--seed", default=12345, type=int, help="random seed") +parser.add_argument('--sync_bn', action='store_false', + help='Enable NVIDIA Apex or Torch synchronized BatchNorm.') +parser.add_argument('--random_sample', action='store_true', + help='Random sample path.') +parser.add_argument('--drop_path_prob', type=float, default=0.0, help='drop path prob') + +# Optimizer parameters +parser.add_argument('--opt', default='sgd', type=str, metavar='OPTIMIZER', + help='Optimizer (default: "sgd"') +parser.add_argument('--opt-eps', default=1e-8, type=float, metavar='EPSILON', + help='Optimizer Epsilon (default: 1e-8)') +parser.add_argument('--momentum', type=float, default=0.9, metavar='M', + help='SGD momentum (default: 0.9)') +parser.add_argument('--weight-decay', type=float, default=0.0001, + help='weight decay (default: 0.0001)') + +# Model Exponential Moving Average +parser.add_argument('--model-ema', action='store_true', default=False, + help='Enable tracking moving average of model weights') +parser.add_argument('--model-ema-force-cpu', action='store_true', default=False, + help='Force ema to be tracked on CPU, rank=0 node only. Disables EMA validation.') +parser.add_argument('--model-ema-decay', type=float, default=0.9998, + help='decay factor for model weights moving average (default: 0.9998)') + +# train val +parser.add_argument('--bn_eps', type=float, default=1e-5, help='bn eps') +parser.add_argument('--bn_momentum', type=float, default=0.01, help='bn momentum') +parser.add_argument('--ignore', type=int, default=255, help='semantic ignore') +parser.add_argument('--eval_flip', action='store_true', default=False, + help='semantic eval flip') + + +def _parse_args(): + # Do we have a config file to parse? + args_config, remaining = config_parser.parse_known_args() + if args_config.config: + with open(args_config.config, 'r') as f: + cfg = yaml.safe_load(f) + parser.set_defaults(**cfg) + + # The main arg parser parses the rest of the args, the usual + # defaults will have been overridden if config file specified. + args = parser.parse_args(remaining) + + # Cache the args as a text string to save them in the output dir later + args_text = yaml.safe_dump(args.__dict__, default_flow_style=False) + return args, args_text + +def build_sem_seg_train_aug(cfg): + augs = [ + T.ResizeShortestEdge( + cfg.INPUT.MIN_SIZE_TRAIN, cfg.INPUT.MAX_SIZE_TRAIN, cfg.INPUT.MIN_SIZE_TRAIN_SAMPLING + ) + ] + if cfg.INPUT.CROP.ENABLED: + augs.append(T.RandomCrop(cfg.INPUT.CROP.TYPE, cfg.INPUT.CROP.SIZE)) + augs.append(T.RandomFlip()) + return augs + +def setup(args): + """ + Create configs and perform basic setups. + """ + cfg = get_cfg() + add_panoptic_deeplab_config(cfg) + cfg.merge_from_file(args.config_file) + # cfg.merge_from_list(args.opts) + cfg.freeze() + default_setup(cfg, args) + return cfg + +def main(): + args, args_text = _parse_args() + + # detectron2 data loader ########################### + # det2_args = default_argument_parser().parse_args() + det2_args = args + det2_args.config_file = args.det2_cfg + cfg = setup(det2_args) + mapper = PanopticDeeplabDatasetMapper(cfg, augmentations=build_sem_seg_train_aug(cfg)) + det2_dataset = iter(build_detection_train_loader(cfg, mapper=mapper)) + + # dist init + torch.distributed.init_process_group(backend='nccl', init_method='env://') + torch.cuda.set_device(args.local_rank) + args.world_size = torch.distributed.get_world_size() + args.local_rank = torch.distributed.get_rank() + + args.save = args.save + args.exp_name + + if args.local_rank == 0: + create_exp_dir(args.save, scripts_to_save=glob.glob('*.py')+glob.glob('*.sh')) + logger = SummaryWriter(args.save) + log_format = '%(asctime)s %(message)s' + logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format, datefmt='%m/%d %I:%M:%S %p') + fh = logging.FileHandler(os.path.join(args.save, 'log.txt')) + fh.setFormatter(logging.Formatter(log_format)) + logging.getLogger().addHandler(fh) + logging.info("args = %s", str(args)) + else: + logger = None + + # preparation ################ + np.random.seed(args.seed) + torch.manual_seed(args.seed) + torch.cuda.manual_seed_all(args.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = False + + # config network and criterion ################ + gt_down_sampling = 1 + min_kept = int(args.batch_size * args.image_height * args.image_width // (16 * gt_down_sampling ** 2)) + ohem_criterion = ProbOhemCrossEntropy2d(ignore_label=255, thresh=0.7, min_kept=min_kept, use_weight=False) + + # data loader ########################### + + kwargs = {'num_workers': args.workers, 'pin_memory': True, 'drop_last': True} + train_loader, train_sampler, val_loader, val_sampler, num_classes = dataloaders.make_data_loader(args, **kwargs) + + with open(args.json_file, 'r') as f: + # dict_a = json.loads(f, cls=NpEncoder) + model_dict = json.loads(f.read()) + + width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] + model = Network(Fch=args.Fch, num_classes=num_classes, stem_head_width=(args.stem_head_width, args.stem_head_width)) + + last = model_dict["lasts"] + + if args.local_rank == 0: + logging.info("net: " + str(model)) + with torch.cuda.device(0): + macs, params = get_model_complexity_info(model, (3, 1024, 2048), as_strings=True, + print_per_layer_stat=True, verbose=True) + logging.info('{:<30} {:<8}'.format('Computational complexity: ', macs)) + logging.info('{:<30} {:<8}'.format('Number of parameters: ', params)) + + with open(os.path.join(args.save, 'args.yaml'), 'w') as f: + f.write(args_text) + + init_weight(model, nn.init.kaiming_normal_, torch.nn.BatchNorm2d, args.bn_eps, args.bn_momentum, mode='fan_in', nonlinearity='relu') + + if args.pretrain: + model.backbone = load_pretrain(model.backbone, args.pretrain) + model = model.cuda() + + # if args.sync_bn: + # if has_apex: + # model = apex.parallel.convert_syncbn_model(model) + # else: + # model = torch.nn.SyncBatchNorm.convert_sync_batchnorm(model) + + # Optimizer ################################### + base_lr = args.base_lr + + if args.opt == "sgd": + optimizer = torch.optim.SGD(model.parameters(), lr=base_lr, momentum=args.momentum, weight_decay=args.weight_decay) + elif args.opt == "adam": + optimizer = torch.optim.Adam(model.parameters(), lr=base_lr, betas=(0.9, 0.999), eps=1e-08) + elif args.opt == "adamw": + optimizer = torch.optim.AdamW(model.parameters(), lr=base_lr, betas=(0.9, 0.999), eps=1e-08, weight_decay=args.weight_decay) + else: + optimizer = create_optimizer(args, model) + + if args.sched == "raw": + lr_scheduler =None + else: + max_iteration = len(train_loader) * args.epochs + lr_scheduler = Iter_LR_Scheduler(args, max_iteration, len(train_loader)) + + start_epoch = 0 + if os.path.exists(os.path.join(args.save, 'last.pth.tar')): + args.resume = os.path.join(args.save, 'last.pth.tar') + + if args.resume: + model_state_file = args.resume + if os.path.isfile(model_state_file): + checkpoint = torch.load(model_state_file, map_location=torch.device('cpu')) + start_epoch = checkpoint['start_epoch'] + model.load_state_dict(checkpoint['state_dict']) + optimizer.load_state_dict(checkpoint['optimizer']) + logging.info('Loaded checkpoint (starting from iter {})'.format(checkpoint['start_epoch'])) + + model_ema = None + if args.model_ema: + # Important to create EMA model after cuda(), DP wrapper, and AMP but before SyncBN and DDP wrapper + model_ema = ModelEma( + model, + decay=args.model_ema_decay, + device='cpu' if args.model_ema_force_cpu else '', + resume=None) + + if model_ema: + eval_model = model_ema.ema + else: + eval_model = model + + if has_apex: + model = DDP(model, delay_allreduce=True) + else: + model = DDP(model, device_ids=[args.local_rank]) + + best_valid_iou = 0. + best_epoch = 0 + + logging.info("rank: {} world_size: {}".format(args.local_rank, args.world_size)) + for epoch in range(start_epoch, args.epochs): + train_sampler.set_epoch(epoch) + val_sampler.set_epoch(epoch) + if args.local_rank == 0: + logging.info(args.load_path) + logging.info(args.save) + logging.info("lr: " + str(optimizer.param_groups[0]['lr'])) + + # training + drop_prob = args.drop_path_prob * epoch / args.epochs + # model.module.drop_path_prob(drop_prob) + + train_mIoU = train(train_loader, det2_dataset, model, model_ema, ohem_criterion, num_classes, lr_scheduler, optimizer, logger, epoch, args, cfg) + + torch.cuda.empty_cache() + + if epoch > args.epochs // 3: + # if epoch >= 10: + temp_iou, avg_loss = validation(val_loader, eval_model, ohem_criterion, num_classes, args, cal_miou=True) + else: + temp_iou = 0. + avg_loss = -1 + + torch.cuda.empty_cache() + if args.local_rank == 0: + logging.info("Epoch: {} train miou: {:.2f}".format(epoch+1, 100*train_mIoU)) + if temp_iou > best_valid_iou: + best_valid_iou = temp_iou + best_epoch = epoch + + if model_ema is not None: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model_ema.ema.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'best_checkpoint.pth.tar')) + else: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model.module.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'best_checkpoint.pth.tar')) + + logger.add_scalar("mIoU/val", temp_iou, epoch) + logging.info("[Epoch %d/%d] valid mIoU %.4f eval loss %.4f"%(epoch + 1, args.epochs, temp_iou, avg_loss)) + logging.info("Best valid mIoU %.4f Epoch %d"%(best_valid_iou, best_epoch)) + + if model_ema is not None: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model_ema.ema.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'last.pth.tar')) + else: + torch.save({ + 'start_epoch': epoch + 1, + 'state_dict': model.module.state_dict(), + 'optimizer': optimizer.state_dict(), + # 'lr_scheduler': lr_scheduler.state_dict(), + }, os.path.join(args.save, 'last.pth.tar')) + + +def train(train_loader, det2_dataset, model, model_ema, criterion, num_classes, lr_scheduler, optimizer, logger, epoch, args, cfg): + + model.train() + pixel_mean = cfg.MODEL.PIXEL_MEAN + pixel_std = cfg.MODEL.PIXEL_STD + # pixel_mean = [123.675, 116.28, 103.53] + # pixel_std = [58.395, 57.12, 57.375] + pixel_mean = torch.Tensor(pixel_mean).view(-1, 1, 1).cuda() + pixel_std = torch.Tensor(pixel_std).view(-1, 1, 1).cuda() + + metric = seg_metrics.Seg_Metrics(n_classes=num_classes) + lamb = 0.2 + # for i, sample in enumerate(train_loader): + for i in range(len(train_loader)): + cur_iter = epoch * len(train_loader) + i + lr_scheduler(optimizer, cur_iter) + # inputs = sample['image'].cuda(non_blocking=True) + # target = sample['semantic'].cuda(non_blocking=True) + + det2_data = next(det2_dataset) + det2_inputs = [x["image"].cuda(non_blocking=True) for x in det2_data] + det2_inputs = [(x - pixel_mean) / pixel_std for x in det2_inputs] + det2_inputs = ImageList.from_tensors(det2_inputs, args.size_divisibility).tensor + + det2_targets = [x["sem_seg"].cuda(non_blocking=True) for x in det2_data] + det2_targets = ImageList.from_tensors(det2_targets, args.size_divisibility, args.ignore).tensor + + N = det2_inputs.size(0) + + loss = 0 + description = "" + + logits8, logits16, logits32 = model(det2_inputs) + loss = loss + criterion(logits8, det2_targets) + if logits16 is not None: + loss = loss + lamb * criterion(logits16, det2_targets) + if logits32 is not None: + loss = loss + lamb * criterion(logits32, det2_targets) + + inter, union = seg_metrics.batch_intersection_union(logits8.data, det2_targets, num_classes) + inter = reduce_tensor(torch.FloatTensor(inter).cuda(), args.world_size) + union = reduce_tensor(torch.FloatTensor(union).cuda(), args.world_size) + metric.update(inter.cpu().numpy(), union.cpu().numpy(), N) + + if args.local_rank == 0: + description += "[mIoU%d: %.3f]"%(0, metric.get_scores()) + + torch.cuda.synchronize() + + reduced_loss = loss + reduced_loss = reduce_tensor(reduced_loss.data, args.world_size) + if args.local_rank == 0 and i % 20 == 0: + logger.add_scalar('loss/train', reduced_loss, epoch*len(train_loader)+i) + logging.info('epoch: {0}\t''iter: {1}/{2}\t''lr: {3:.6f}\t''loss: {4:.4f}'.format( + epoch + 1, i + 1, len(train_loader), lr_scheduler.get_lr(optimizer), reduced_loss)) + + loss.backward() + optimizer.step() + optimizer.zero_grad() + torch.cuda.synchronize() + + if model_ema is not None: + model_ema.update(model) + + return metric.get_scores() + + +def validation(val_loader, model, criterion, n_classes, args, cal_miou=True): + device = torch.device('cuda:{}'.format(args.local_rank)) + model.eval() + test_loss = 0.0 + + hist_size = (n_classes, n_classes) + hist = torch.zeros(hist_size, dtype=torch.float32).cuda() + + for i, sample in enumerate(val_loader): + sample = to_cuda(sample, device) + image = sample['image'] + target = sample['semantic'] + + N, H, W = target.shape + probs = torch.zeros((N, n_classes, H, W)).cuda() + probs.requires_grad = False + + torch.cuda.synchronize() + if args.local_rank==0: + logging.info("Evaluation [{}/{}]".format(i+1, len(val_loader))) + with torch.no_grad(): + output = model(image) + prob = F.softmax(output, 1) + probs += prob + loss = criterion(output, target).detach().data + dist.all_reduce(loss, dist.ReduceOp.SUM) + test_loss += loss + + if args.eval_flip: + output = model(torch.flip(image, dims=(3,))) + output = torch.flip(output, dims=(3,)) + prob = F.softmax(output, 1) + probs += prob + loss = criterion(output, target).detach().data + dist.all_reduce(loss, dist.ReduceOp.SUM) + test_loss += loss + + if cal_miou: + # probs = probs.data.numpy() + preds = torch.argmax(probs, dim=1) + hist_once = compute_hist(preds, target, n_classes, args.ignore) + hist = hist + hist_once + + torch.cuda.synchronize() + + + if args.eval_flip: + avg_loss = test_loss / 2*len(val_loader) + else: + avg_loss = test_loss / len(val_loader) + + if cal_miou: + # hist = torch.tensor(hist).cuda() + dist.all_reduce(hist, dist.ReduceOp.SUM) + hist = hist.cpu().numpy().astype(np.float32) + IOUs = np.diag(hist) / (np.sum(hist, axis=0) + np.sum(hist, axis=1) - np.diag(hist)) + mIOU = np.mean(IOUs) + else: + mIOU = -avg_loss + + return mIOU*100, avg_loss + +if __name__ == '__main__': + main() diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/vis_arch.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/vis_arch.py new file mode 100644 index 000000000..b4f0ecf51 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/CDARTS_segmentation/train/vis_arch.py @@ -0,0 +1,44 @@ +from __future__ import division +import os +import shutil +import sys +import time +import glob +import json +import logging +import argparse +import _init_paths +from utils.darts_utils import create_exp_dir, save, plot_op, plot_path_width, objective_acc_lat + +parser = argparse.ArgumentParser(description='parameters for sampling') +parser.add_argument('--arch_loc', default='./jsons', type=str, help='resumed model') +parser.add_argument('--save_dir', default='./archs', type=str, help='saved dict') +parser.add_argument("--Fch", default=12, type=int, help='Fch') +parser.add_argument('--stem_head_width', type=float, default=0.6666666666666666, help='base learning rate') +args = parser.parse_args() + +def main(): + width_mult_list = [4./12, 6./12, 8./12, 10./12, 1.,] + json_files = glob.glob(os.path.join(args.arch_loc, "*.json")) + for json_file in json_files: + with open(json_file, 'r') as f: + model_dict = json.loads(f.read()) + + last = model_dict["lasts"] + save_dir = os.path.join(args.save_dir, os.path.basename(json_file).strip('.json')) + os.makedirs(save_dir, exist_ok=True) + + try: + for b in range(len(last)): + if len(width_mult_list) > 1: + plot_op(model_dict["ops"][b], model_dict["paths"][b], width=model_dict["widths"][b], head_width=args.stem_head_width, F_base=args.Fch).savefig(os.path.join(save_dir, "ops_%d_%d.png"%(0,b)), bbox_inches="tight") + else: + plot_op(model_dict["ops"][b], model_dict["paths"][b], F_base=args.Fch).savefig(os.path.join(save_dir, "ops_%d_%d.png"%(0,b)), bbox_inches="tight") + plot_path_width(model_dict["lasts"], model_dict["paths"], model_dict["widths"]).savefig(os.path.join(save_dir, "path_width%d.png"%0)) + except: + print("Arch: {} is invalid".format(json_file)) + shutil.rmtree(save_dir) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/LICENSE b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/LICENSE new file mode 100644 index 000000000..5ddf12ad3 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/LICENSE @@ -0,0 +1,23 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE + + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/README.md new file mode 100644 index 000000000..8a09bcd54 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/README.md @@ -0,0 +1,67 @@ +# Cyclic Differentiable Architecture Search + +**This is an official implementation of CDARTS** + +In this work, we propose new joint optimization objectives and a novel Cyclic Differentiable ARchiTecture Search framework, dubbed CDARTS. Considering the structure difference, CDARTS builds a cyclic feedback mechanism between the search and evaluation networks with introspective distillation. First, the search network generates an initial architecture for evaluation, and the weights of the evaluation network are optimized. Second, the architecture weights in the search network are further optimized by the label supervision in classification, as well as the regularization from the evaluation network through feature distillation. Repeating the above cycle results in a joint optimization of the search and evaluation networks and thus enables the evolution of the architecture to fit the final evaluation network. + +
+ CDARTS overview +
+ +## Model Zoo +For evaluation, we provide the checkpoints and configs of our models in [Google Drive](https://drive.google.com/drive/folders/1CkFp24bEDq0wUp504BQ68jn5Vs069qox?usp=sharing). + +After downloading the models, you can do the evaluation following the description in *SETUP.md*. + +Model download links: + +### DARTS Search Space +#### CIFAR10 +| Top-1 Acc. % | 97.60 | 97.45 | 97.52 | 97.53 | 97.54 | 97.77 | +|--------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| Cell Download link | [Cell-1](https://drive.google.com/file/d/1mlRQUo2DyiZvwfhVfkcjJRAaaxJLmkjs/view?usp=sharing) | [Cell-2](https://drive.google.com/file/d/1W-2uvAQZVTuWEDHEhvb_FHv_US9Pl6tS/view?usp=sharing) | [Cell-3](https://drive.google.com/file/d/12j6SwGAfE4_eKIBr38PSy9pyxMG_9avB/view?usp=sharing) | [Cell-4](https://drive.google.com/file/d/1muuQLTxFX7oKAd8hjsxwOzRx1hGYsCjP/view?usp=sharing) | [Cell-5](https://drive.google.com/file/d/1eBJjEldqfo3AsfPT5wemI46PdhtgQh5i/view?usp=sharing) | [Cell-6](https://drive.google.com/file/d/1nZ1XNOAb325-UZN-rbs17fzLfjKrhd-S/view?usp=sharing) | + +#### ImageNet +| Top-1 Acc. % | 75.90 | 75.93 | 76.40 | 76.60 | 76.44 | +|--------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| Cell Download link | [Cell-1](https://drive.google.com/file/d/1VY8MyWaDbrWQdi4xyKEcaX88ndH_o9XP/view?usp=sharing) | [Cell-2](https://drive.google.com/file/d/1nokqF1HaPrKbW0vkeN3mB9M5mHRI745U/view?usp=sharing) | [Cell-3](https://drive.google.com/file/d/1Rk8JbHAUUG5pE4t3AU94yfIsPsE5GTJH/view?usp=sharing) | [Cell-4](https://drive.google.com/file/d/1fgQk3o4svX8hoP__MK2qikokrDpn9rx7/view?usp=sharing) | [Cell-5](https://drive.google.com/file/d/12_TG4F0cnHc9lmsRiKK7TiN5CsyncBkx/view?usp=sharing) | + +### NATS-Bench +| Model | CIFAR10 Validation | CIFAR10 Test | CIFAR100 Validation | CIFAR100 Test | ImageNet-16-120 Validation | ImageNet-16-120 Test | Download link | +|-------|--------------------|--------------|---------------------|---------------|----------------------------|----------------------|---------------| +| Cell-1 | 91.50% | 94.37% | 73.31% | 73.09% | 45.59% | 46.33% | [Cell, Log](https://drive.google.com/file/d/13CpMr1V-S0d8C2WbIHwSzApmdBInKn0U/view?usp=sharing) | +| Cell-2 | 91.37% | 94.09% | 72.64% | 72.57% | 45.46% | 45.63% | [Cell, Log](https://drive.google.com/file/d/1Gbnm61NbYmEkdW6YCBUWDA_sQGtm83vR/view?usp=sharing) | +| Cell-3 | 90.51% | 93.62% | 70.43 | 70.10% | 44.23% | 44.57% | [Cell, Log](https://drive.google.com/file/d/1zq2Eg8IZt5MVXFnmKuuCDS5bei-ENlWw/view?usp=sharing) | + +### Chain-structured Search Space + +Model | Params. | Flops | Top-1 Acc. % | Download link +--- |:---:|:---:|:---:|:---: +CDARTS-a | 7.0M | 294M | 77.4 | [Model, Config, Log](https://drive.google.com/drive/folders/146h42gj9yNhmOoJX87hTeHw5PvOIyGPi?usp=sharing) +CDARTS-b | 6.4M | 394M | 78.2 | [Model, Config, Log](https://drive.google.com/drive/folders/1LUY9dfLIGSQicfoInHaffIepunujyuGe?usp=sharing) + +### Object Detection +Backbone | Input Size | Params. | Flops | AP | AP\_50 | AP\_75 | AP\_S | AP\_M | AP\_L | Download link +----------------------- | --------- | -------- | ----- | ----- | ------ | ------ | ----- | ----- | ----- | --- +CDARTS-a | 1280x800 | 6.0G | 7.0M | 35.2 | 55.5 | 37.5 | 19.8 | 38.7 | 47.5 | [Model, Config, Log](https://drive.google.com/drive/folders/1xkV_ZJXhHPkDbL1Ogc3AQJvi9HC1Egyn?usp=sharing) +CDARTS-b | 1280x800 | 8.1G | 6.4M | 36.2 | 56.7 | 38.3 | 20.9 | 39.8 | 48.5 | [Model, Config, Log](https://drive.google.com/drive/folders/1xkV_ZJXhHPkDbL1Ogc3AQJvi9HC1Egyn?usp=sharing) + + +### Semantic Segmentation +| Dataset | Encoder | Input Size | Params. | Flops | mIoU % | Download link | +|------------|----------|-------------|---------|-------|--------|---------------| +| Cityscapes | CDARTS-b | 1024x2048 | 5.9M | 20.7G | 78.1 | [Model, Config, Log](https://drive.google.com/drive/folders/1MO_hgwWcUf1c1OFYO-6Rit6IA-3fMKAO?usp=sharing) | +| ADE20K | CDARTS-b | 640x640 | 2.7M | 5.9G | 40.4 | [Model, Config, Log](https://drive.google.com/drive/folders/1OJyNLkMMK1IIu1F3USrkNsa9BeLlGiUp?usp=sharing) | + + +## Bibtex + +If this repo is helpful for you, please consider to cite it. Thank you! :) +```bibtex +@article{CDARTS, + title={Cyclic Differentiable Architecture Search}, + author={Yu, Hongyuan and Peng, Houwen and Huang, Yan and Fu, Jianlong and Du, Hao and Wang, Liang and Ling, Haibin}, + journal={IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI)}, + year={2022} +} +``` \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/SETUP.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/SETUP.md new file mode 100644 index 000000000..eeac35b60 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/SETUP.md @@ -0,0 +1,137 @@ +## Environment Setup + +Tesla V100, CUDA10.0, linux 16.04, pytorch>=1.2, python3, [apex](https://github.com/NVIDIA/apex) + +### Data Preparation +* [Cifar-10](https://www.cs.toronto.edu/~kriz/cifar.html) +* [Cifar-100](https://www.cs.toronto.edu/~kriz/cifar.html) +* [ImageNet-2012](http://www.image-net.org/) + +Create soft link in main dir. +``` +ln -s $DataLocation experiments/data +``` +In ${ROOT}/experiments/data, it should be like this. +``` +experiments/data/imagenet/train +experiments/data/imagenet/val +... +``` + +### Installation +* First, you should install graphviz. + ``` + apt-get install graphviz + ``` +* Install python requirements. + ```buildoutcfg + pip install -r requirements + ``` +* Then you should install apex. + ```buildoutcfg + git clone https://github.com/NVIDIA/apex + cd apex + python setup.py install --cpp_ext --cuda_ext + ``` + +### Search, Retrain and Evaluation +We have provided all the shell scripts and the corresponding default parameters, which are stored in the scripts folder. +* For example: + ```buildoutcfg + cd ${CODE_ROOT} + + bash CyDAS/scripts/run_search_cifar_1gpu.sh + bash CyDAS/scripts/run_retrain_cifar_1gpu.sh + ... + ``` + +#### Search +* Main python file is + ```buildoutcfg + ${ROOT}/CyDAS/search.py + ``` +* Followings are options during training. + ```buildoutcfg + --regular # whether to use regular + --regular_ratio # if use regular, the ragular ratio + --regular_coeff # if use regular, the regular coefficient + --ensemble_param # Ensemble different layer features + --loss_alpha # the loss coefficient + --w_lr # the learning rate of the search network + --alpha_lr # the learning rate of the architecture parameters + --nasnet_lr # the learning rate of the evaluation network + --w_weight_decay # the weight decay the search and the evaluation network + --alpha_weight_decay # the weight decay the the architecture parameters + --fix_head # wheter to fix the parameters of auxiliary heads + --interactive_type # The KD function, 0 kl, 1 cosine, 2 mse, 3 sl1 + --pretrain_epochs # the pretrain epochs of the search network + --search_iter # the search iterations + --search_iter_epochs # the epochs in each search iteration + --nasnet_warmup # the epochs used to train a new evaluation network + ``` +* Here we present our search scripts on CIFAR and ImageNet. + ```buildoutcfg + bash CyDAS/scripts/run_search_cifar_1gpu.sh + bash CyDAS/scripts/run_search_cifar_4gpus.sh + bash CyDAS/scripts/run_search_imagenet.sh + ``` +* Modify the following settings in `run_search_cifar_1gpu.sh` and `run_search_cifar_4gpus.sh` to search on CIFAR100. + ``` + --dataset cifar100 + --n_classes 100 + ``` + +#### Retrain +* Main python file is + ```buildoutcfg + ${ROOT}/CyDAS/retrain.py + ``` +* We have provided all cell genotypes of Cifar and ImageNet in + ```buildoutcfg + ${ROOT}/CyDAS/cells/cifar_genotypes.json + ... + ``` +* Followings are options during training. + ```buildoutcfg + --cell_file # path of cell genotype + --weight_decay # decay of W in the Retrain-Phase + --lr # learning rate of W in the Retrain-Phase + --warmup_epochs # warmup epochs + --epochs # total retrain epochs + --cutout_length # cutout length for cifar + --aux_weight # weight of auxiliary loss, 0.4 is the best option + --drop_path_prob # used for dropping path in NAS + --label_smooth # label smooth ratio + ``` +* Here we present our train scripts on CIFAR and ImageNet. + ```buildoutcfg + bash CyDAS/scripts/run_retrain_cifar_1gpu.sh + bash CyDAS/scripts/run_retrain_cifar_4gpus.sh + bash CyDAS/scripts/run_retrain_imagenet.sh + ``` +* Modify the following settings in `run_retrain_cifar.sh` to train CIFAR100. + ``` + --dataset cifar100 + --n_classes 100 + ``` + +#### Evaluation +* Main python file is + ```buildoutcfg + ${ROOT}/CyDAS/test.py + ``` +* Followings are options during testing. + ```buildoutcfg + --resume # whether to load checkpint + --resume_name # checkpint name + ``` +* Here we present our test scripts on CIFAR and ImageNet. + ```buildoutcfg + bash CyDAS/scripts/run_test_cifar.sh + bash CyDAS/scripts/run_test_imagenet.sh + ``` +* Modify the following settings in `run_test_cifar.sh` to test CIFAR100. + ``` + --dataset cifar100 + --n_classes 100 + ``` diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/README.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/README.md new file mode 100644 index 000000000..73c1e26f8 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/README.md @@ -0,0 +1,10 @@ +## NAS-Bench-201 +* Main python file is + ```buildoutcfg + ${ROOT}/benchmark201/search.py + ``` +* Here we present our search script on NAS-Bench-201. + ```buildoutcfg + cd benchmark201 + bash run_search_cifar_1gpu.sh + ``` diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/configs/config.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/configs/config.py new file mode 100644 index 000000000..b28e13cd9 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/configs/config.py @@ -0,0 +1,228 @@ +""" Config class for search/augment """ +import argparse +import os +from functools import partial +import torch + + +def get_parser(name): + """ make default formatted parser """ + parser = argparse.ArgumentParser(name, formatter_class=argparse.ArgumentDefaultsHelpFormatter) + # print default value always + parser.add_argument = partial(parser.add_argument, help=' ') + return parser + + +def parse_gpus(gpus): + if gpus == 'all': + return list(range(torch.cuda.device_count())) + else: + return [int(s) for s in gpus.split(',')] + + +class BaseConfig(argparse.Namespace): + def print_params(self, prtf=print): + prtf("") + prtf("Parameters:") + for attr, value in sorted(vars(self).items()): + prtf("{}={}".format(attr.upper(), value)) + prtf("") + + def as_markdown(self): + """ Return configs as markdown format """ + text = "|name|value| \n|-|-| \n" + for attr, value in sorted(vars(self).items()): + text += "|{}|{}| \n".format(attr, value) + + return text + + +class SearchConfig(BaseConfig): + def build_parser(self): + parser = get_parser("Search config") + parser.add_argument('--name', required=True) + ########### basic settings ############ + parser.add_argument('--dataset', default='imagenet', help='CIFAR10 / MNIST / FashionMNIST / imagenet') + parser.add_argument('--model_type', type=str, default='cifar', help='cifar or imagenet') + parser.add_argument('--data_dir', type=str, default='data/cifar', help='cifar dataset') + parser.add_argument('--train_dir', type=str, default='data/imagenet/train', help='') + parser.add_argument('--val_dir', type=str, default='data/imagenet/train', help='') + parser.add_argument('--test_dir', type=str, default='data/imagenet/val', help='') + parser.add_argument('--param_pool_path', type=str, default=None, help='') + parser.add_argument('--input_channels', type=int, default=3) + parser.add_argument('--init_channels', type=int, default=16) + parser.add_argument('--stem_multiplier', type=int, default=3) + parser.add_argument('--n_classes', type=int, default=10) + parser.add_argument('--batch_size', type=int, default=128, help='batch size') + parser.add_argument('--print_freq', type=int, default=50, help='print frequency') + parser.add_argument('--seed', type=int, default=0, help='random seed') + parser.add_argument('--workers', type=int, default=4, help='# of workers') + parser.add_argument('--gpus', default='0', help='gpu device ids separated by comma. ' + '`all` indicates use all gpus.') + parser.add_argument('--sample_ratio', type=float, default=0.2, help='imagenet sample ratio') + parser.add_argument('--resume', action='store_true', default=False, help='resnet stem(pretrain)') + + ########### learning rate ############ + parser.add_argument('--w_lr', type=float, default=0.05, help='lr for weights') + parser.add_argument('--lr_ratio', type=float, default=0.5, help='lr for trained layers') + parser.add_argument('--w_lr_min', type=float, default=0.001, help='minimum lr for weights') + parser.add_argument('--w_momentum', type=float, default=0.9, help='momentum for weights') + parser.add_argument('--w_weight_decay', type=float, default=3e-4, + help='weight decay for weights') + parser.add_argument('--w_grad_clip', type=float, default=5., + help='gradient clipping for weights') + parser.add_argument('--alpha_lr', type=float, default=6e-4, help='lr for alpha') + parser.add_argument('--alpha_weight_decay', type=float, default=1e-3, + help='weight decay for alpha') + + ########### alternate training ############ + parser.add_argument('--res_stem', action='store_true', default=False, help='resnet stem(pretrain)') + parser.add_argument('--layer_num', type=int, default=3, help='layer need to be replaced') + parser.add_argument('--cells_num', type=int, default=3, help='cells num of one layer') + parser.add_argument('--pretrain_epochs', type=int, default=5, help='# of training epochs') + parser.add_argument('--pretrain_decay', type=int, default=5, help='pretrain epochs') + parser.add_argument('--random_times', type=int, default=10, help='# of training epochs') + parser.add_argument('--random_epochs', type=int, default=3, help='# of training epochs') + parser.add_argument('--search_iter', type=int, default=5, help='times of search') + parser.add_argument('--search_iter_epochs', type=int, default=5, help='# of training epochs') + parser.add_argument('--unrolled', action='store_true', default=False, help='use one-step unrolled validation loss') + parser.add_argument('--one_stage', action='store_true', default=False, help='one_stage search') + parser.add_argument('--same_structure', action='store_true', default=False, help='same_structure search and retrain') + parser.add_argument('--clean_arch', action='store_true', default=False, help='clean archs each epoch') + parser.add_argument('--sync_param', action='store_true', default=False, help='whether to sync param') + parser.add_argument('--ensemble_sum', action='store_true', default=False, help='ensemble sum or concat') + parser.add_argument('--ensemble_param', action='store_true', default=False, help='whether to learn ensemble params') + parser.add_argument('--use_beta', action='store_true', default=False, help='whether to use beta arch param') + parser.add_argument('--bn_affine', action='store_true', default=False, help='main bn affine') + parser.add_argument('--sync_bn', action='store_true', default=False, help='whether to sync bn') + parser.add_argument('--use_apex', action='store_true', default=False, help='whether to apex') + parser.add_argument('--regular', action='store_true', default=False, help='resnet stem(pretrain)') + parser.add_argument('--regular_ratio', type=float, default=0.5, help='regular ratio') + parser.add_argument('--regular_coeff', type=float, default=5, help='regular coefficient') + parser.add_argument('--repeat_cell', action='store_true', default=False, help='use repeat cell') + parser.add_argument('--fix_head', action='store_true', default=False, help='whether to fix head') + parser.add_argument('--share_fc', action='store_true', default=False, help='whether to share fc') + parser.add_argument('--nasnet_lr', type=float, default=0.1, help='lr of nasnet') + parser.add_argument('--nasnet_warmup', type=int, default=5, help='warm up of nasnet') + parser.add_argument('--loss_alpha', type=float, default=1, help='loss alpha') + parser.add_argument('--loss_T', type=float, default=2, help='loss T') + parser.add_argument('--interactive_type', type=int, default=0, help='0 kl 1 cosine 2 mse') + parser.add_argument('--gumbel_sample', action='store_true', default=False, help='whether to use gumbel sample') + parser.add_argument('--sample_pretrain', action='store_true', default=False, help='sample_pretrain') + + + ########### data augument ############ + parser.add_argument('--aux_weight', type=float, default=0.4, help='auxiliary loss weight') + parser.add_argument('--cutout_length', type=int, default=16, help='cutout length') + parser.add_argument('--drop_path_prob', type=float, default=0.2, help='drop path prob') + parser.add_argument('--use_aa', action='store_true', default=False, help='whether to use aa') + parser.add_argument('--mixup_alpha', default=0., type=float, + help='mixup interpolation coefficient (default: 1)') + + ########### distributed ############ + parser.add_argument("--local_rank", default=0, type=int) + parser.add_argument("--world_size", default=1, type=int) + parser.add_argument('--dist_url', default='tcp://127.0.0.1:23456', type=str, help='url used to set up distributed training') + parser.add_argument('--distributed', action='store_true', help='Run model distributed mode.') + + + return parser + + def __init__(self): + parser = self.build_parser() + args = parser.parse_args() + super().__init__(**vars(args)) + + self.data_path = './data/' + self.path = os.path.join('search', self.name) + self.resume_path = os.path.join(self.path, 'search_resume.pth.tar') + self.plot_path = os.path.join(self.path, 'plots') + self.gpus = parse_gpus(self.gpus) + + +class AugmentConfig(BaseConfig): + def build_parser(self): + parser = get_parser("Augment config") + parser.add_argument('--name', required=True) + parser.add_argument('--dataset', required=True, help='cifar10 / cifar100 / imagenet') + parser.add_argument('--model_type', type=str, default='cifar', help='cifar or imagenet') + + parser.add_argument('--data_dir', type=str, default='data/cifar', help='cifar dataset') + parser.add_argument('--train_dir', type=str, default='data/imagenet/train', help='') + parser.add_argument('--test_dir', type=str, default='data/imagenet/val', help='') + parser.add_argument('--cell_file', type=str, default='cells/cifar_genotype.json', help='') + parser.add_argument('--resume', action='store_true', default=False, help='resnet stem(pretrain)') + + parser.add_argument('--n_classes', type=int, default=10) + parser.add_argument('--input_channels', type=int, default=3) + parser.add_argument('--stem_multiplier', type=int, default=3) + + ########### alternate training ############ + parser.add_argument('--res_stem', action='store_true', default=False, help='resnet stem(pretrain)') + parser.add_argument('--layer_num', type=int, default=3, help='layer need to be replaced') + parser.add_argument('--cells_num', type=int, default=3, help='cells num of one layer') + parser.add_argument('--same_structure', action='store_true', default=False, help='same_structure search and retrain') + parser.add_argument('--ensemble_sum', action='store_true', default=False, help='whether to ensemble') + parser.add_argument('--ensemble_param', action='store_true', default=False, help='whether to learn ensemble params') + parser.add_argument('--use_beta', action='store_true', default=False, help='whether to use beta arch param') + parser.add_argument('--bn_affine', action='store_true', default=False, help='main bn affine') + parser.add_argument('--repeat_cell', action='store_true', default=False, help='use repeat cell') + parser.add_argument('--fix_head', action='store_true', default=False, help='whether to fix head') + parser.add_argument('--share_fc', action='store_true', default=False, help='whether to share fc') + parser.add_argument('--sample_pretrain', action='store_true', default=False, help='sample_pretrain') + + parser.add_argument('--use_aa', action='store_true', default=False, help='whether to use aa') + parser.add_argument('--mixup_alpha', default=0., type=float, + help='mixup interpolation coefficient (default: 1)') + parser.add_argument('--resume_name', type=str, default='retrain_resume.pth.tar') + + parser.add_argument('--batch_size', type=int, default=128, help='batch size') + parser.add_argument('--lr', type=float, default=0.025, help='lr for weights') + parser.add_argument('--momentum', type=float, default=0.9, help='momentum') + parser.add_argument('--weight_decay', type=float, default=5e-4, help='weight decay') + parser.add_argument('--grad_clip', type=float, default=5., + help='gradient clipping for weights') + parser.add_argument('--print_freq', type=int, default=200, help='print frequency') + parser.add_argument('--gpus', default='0', help='gpu device ids separated by comma. ' + '`all` indicates use all gpus.') + parser.add_argument('--epochs', type=int, default=600, help='# of training epochs') + parser.add_argument('--warmup_epochs', type=int, default=5, help='# warmup') + parser.add_argument('--init_channels', type=int, default=36) + parser.add_argument('--layers', type=int, default=20, help='# of layers') + parser.add_argument('--seed', type=int, default=0, help='random seed') + parser.add_argument('--workers', type=int, default=4, help='# of workers') + parser.add_argument('--aux_weight', type=float, default=0.4, help='auxiliary loss weight') + parser.add_argument('--cutout_length', type=int, default=16, help='cutout length') + parser.add_argument('--sample_archs', type=int, default=1, help='sample arch num') + parser.add_argument('--label_smooth', type=float, default=0.1, help='label smoothing') + parser.add_argument('--drop_path_prob', type=float, default=0.3, help='drop path prob') + + ########### distributed ############ + parser.add_argument("--local_rank", default=0, type=int) + parser.add_argument("--world_size", default=1, type=int) + parser.add_argument('--use_amp', action='store_true', default=False, help='whether to use amp') + parser.add_argument('--opt-level', type=str, default='O1') + + parser.add_argument('--dist_url', default='tcp://127.0.0.1:23456', type=str, help='url used to set up distributed training') + parser.add_argument('--fp16', action='store_true', + help='Run model fp16 mode.') + parser.add_argument('--distributed', action='store_true', + help='Run model distributed mode.') + + parser.add_argument('--static-loss-scale', type=float, default=1, + help='Static loss scale, positive power of 2 values can improve fp16 convergence.') + parser.add_argument('--dynamic-loss-scale', action='store_true', + help='Use dynamic loss scaling. If supplied, this argument supersedes ' + + '--static-loss-scale.') + return parser + + def __init__(self): + parser = self.build_parser() + args = parser.parse_args() + super().__init__(**vars(args)) + + self.data_path = './data/' + self.path = os.path.join('augments', self.name) + self.gpus = parse_gpus(self.gpus) + self.resume_path = os.path.join(self.path, self.resume_name) + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/augment_function.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/augment_function.py new file mode 100644 index 000000000..e4c08fd50 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/augment_function.py @@ -0,0 +1,130 @@ +import torch +import torch.nn as nn +from utils import utils +from datasets import data_utils +from models.loss import CrossEntropyLabelSmooth + +def train(train_loader, model, optimizer, epoch, writer, logger, config): + device = torch.device("cuda") + if config.label_smooth > 0: + criterion = CrossEntropyLabelSmooth(config.n_classes, config.label_smooth).to(device) + else: + criterion = nn.CrossEntropyLoss().to(device) + + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + step_num = len(train_loader) + cur_step = epoch*step_num + cur_lr = optimizer.param_groups[0]['lr'] + if config.local_rank == 0: + logger.info("Train Epoch {} LR {}".format(epoch, cur_lr)) + writer.add_scalar('train/lr', cur_lr, cur_step) + + model.train() + + for step, (X, y) in enumerate(train_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + X, target_a, target_b, lam = data_utils.mixup_data(X, y, config.mixup_alpha, use_cuda=True) + + optimizer.zero_grad() + logits, logits_aux = model(X) + # loss = criterion(logits, y) + loss = data_utils.mixup_criterion(criterion, logits, target_a, target_b, lam) + if config.aux_weight > 0: + # loss_aux = criterion(logits_aux, y) + loss_aux = data_utils.mixup_criterion(criterion, logits_aux, target_a, target_b, lam) + loss = loss + config.aux_weight * loss_aux + + if config.use_amp: + from apex import amp + with amp.scale_loss(loss, optimizer) as scaled_loss: + scaled_loss.backward() + else: + loss.backward() + # gradient clipping + nn.utils.clip_grad_norm_(model.module.parameters(), config.grad_clip) + optimizer.step() + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num): + logger.info( + "Train: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.epochs, step, + step_num, losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('train/loss', reduced_loss.item(), cur_step) + writer.add_scalar('train/top1', prec1.item(), cur_step) + writer.add_scalar('train/top5', prec5.item(), cur_step) + cur_step += 1 + + if config.local_rank == 0: + logger.info("Train: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.epochs, top1.avg)) + +def validate(valid_loader, model, epoch, cur_step, writer, logger, config): + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + model.eval() + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + + with torch.no_grad(): + for step, (X, y) in enumerate(valid_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + logits, _ = model(X) + loss = criterion(logits, y) + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + step_num = len(valid_loader) + + if (step % config.print_freq == 0 or step == step_num-1) and config.local_rank == 0: + logger.info( + "Valid: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.epochs, step, step_num, + losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('val/loss', losses.avg, cur_step) + writer.add_scalar('val/top1', top1.avg, cur_step) + writer.add_scalar('val/top5', top5.avg, cur_step) + + logger.info("Valid: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.epochs, top1.avg)) + + return top1.avg, top5.avg diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/pretrain_function.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/pretrain_function.py new file mode 100644 index 000000000..b55c7c1db --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/pretrain_function.py @@ -0,0 +1,342 @@ +import torch +import torch.nn as nn +from utils import utils +from datasets import data_utils +from models.loss import CrossEntropyLabelSmooth + +def train(train_loader, model, optimizer, epoch, writer, logger, config): + device = torch.device("cuda") + if config.label_smooth > 0: + criterion = CrossEntropyLabelSmooth(config.n_classes, config.label_smooth).to(device) + else: + criterion = nn.CrossEntropyLoss().to(device) + + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + step_num = len(train_loader) + cur_step = epoch*step_num + cur_lr = optimizer.param_groups[0]['lr'] + if config.local_rank == 0: + logger.info("Train Epoch {} LR {}".format(epoch, cur_lr)) + writer.add_scalar('train/lr', cur_lr, cur_step) + + model.train() + + for step, (X, y) in enumerate(train_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + X, target_a, target_b, lam = data_utils.mixup_data(X, y, config.mixup_alpha, use_cuda=True) + + optimizer.zero_grad() + logits, logits_aux = model(X, layer_idx=0, super_flag=True, pretrain_flag=True) + loss = data_utils.mixup_criterion(criterion, logits, target_a, target_b, lam) + if config.aux_weight > 0: + # loss_aux = criterion(logits_aux, y) + loss_aux = data_utils.mixup_criterion(criterion, logits_aux, target_a, target_b, lam) + loss = loss + config.aux_weight * loss_aux + + if config.use_amp: + from apex import amp + with amp.scale_loss(loss, optimizer) as scaled_loss: + scaled_loss.backward() + else: + loss.backward() + # gradient clipping + nn.utils.clip_grad_norm_(model.module.parameters(), config.grad_clip) + optimizer.step() + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num): + logger.info( + "Train: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.epochs, step, + step_num, losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('train/loss', reduced_loss.item(), cur_step) + writer.add_scalar('train/top1', prec1.item(), cur_step) + writer.add_scalar('train/top5', prec5.item(), cur_step) + cur_step += 1 + + if config.local_rank == 0: + logger.info("Train: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.epochs, top1.avg)) + +def validate(valid_loader, model, epoch, cur_step, writer, logger, config): + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + model.eval() + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + + with torch.no_grad(): + for step, (X, y) in enumerate(valid_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + logits, _ = model(X, layer_idx=0, super_flag=True, pretrain_flag=True) + loss = criterion(logits, y) + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + step_num = len(valid_loader) + + if (step % config.print_freq == 0 or step == step_num-1) and config.local_rank == 0: + logger.info( + "Valid: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.epochs, step, step_num, + losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('val/loss', losses.avg, cur_step) + writer.add_scalar('val/top1', top1.avg, cur_step) + writer.add_scalar('val/top5', top5.avg, cur_step) + + logger.info("Valid: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.epochs, top1.avg)) + + return top1.avg, top5.avg + + +def sample_train(train_loader, model, optimizer, epoch, writer, logger, config): + device = torch.device("cuda") + if config.label_smooth > 0: + criterion = CrossEntropyLabelSmooth(config.n_classes, config.label_smooth).to(device) + else: + criterion = nn.CrossEntropyLoss().to(device) + + step_num = len(train_loader) + cur_step = epoch*step_num + cur_lr = optimizer.param_groups[0]['lr'] + if config.local_rank == 0: + logger.info("Train Epoch {} LR {}".format(epoch, cur_lr)) + writer.add_scalar('train/lr', cur_lr, cur_step) + + model.train() + + for step, (X, y) in enumerate(train_loader): + + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + X, target_a, target_b, lam = data_utils.mixup_data(X, y, config.mixup_alpha, use_cuda=True) + + optimizer.zero_grad() + + all_losses = [] + all_logits = [] + for i in range(config.sample_archs): + ### sample new arch ### + model.module.init_arch_params(layer_idx=0) + genotypes = [] + for i in range(config.layer_num): + genotype, connect = model.module.generate_genotype(i) + genotypes.append(genotype) + + model.module.genotypes[i] = genotype + model.module.connects[i] = connect + + logits, logits_aux = model(X, layer_idx=0, super_flag=True, pretrain_flag=True, is_slim=True) + all_logits.append(logits) + loss = data_utils.mixup_criterion(criterion, logits, target_a, target_b, lam) + if config.aux_weight > 0: + # loss_aux = criterion(logits_aux, y) + loss_aux = data_utils.mixup_criterion(criterion, logits_aux, target_a, target_b, lam) + loss = loss + config.aux_weight * loss_aux + + all_losses.append(loss) + + ''' + for j, genotype in enumerate(genotypes): + if config.local_rank == 0: + logger.info("Random stage: {} layer: {} genotype = {}".format(i, j, genotype)) + ''' + + loss = torch.sum(torch.stack(all_losses)) + + if config.use_amp: + from apex import amp + with amp.scale_loss(loss, optimizer) as scaled_loss: + scaled_loss.backward() + else: + loss.backward() + + # tricks + for p in model.module.parameters(): + if p.grad is not None and p.grad.sum() == 0: + p.grad = None + + # gradient clipping + nn.utils.clip_grad_norm_(model.module.parameters(), config.grad_clip) + optimizer.step() + + for i, logits in enumerate(all_logits): + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + if config.distributed: + reduced_loss = utils.reduce_tensor(all_losses[i].data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = all_losses[i].data + + + torch.cuda.synchronize() + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num): + logger.info( + "Train: Epoch {:2d}/{} Step {:03d}/{:03d} Sample idx {} Loss {:.3f} " + "Prec@(1,5) ({:.1%}, {:.1%})".format( + epoch+1, config.epochs, step, step_num, i, + reduced_loss.item(), prec1.item(), prec5.item())) + + if config.local_rank == 0: + writer.add_scalar('train/loss', reduced_loss.item(), cur_step) + writer.add_scalar('train/top1', prec1.item(), cur_step) + writer.add_scalar('train/top5', prec5.item(), cur_step) + cur_step += 1 + + + +def sample_validate(valid_loader, model, epoch, cur_step, writer, logger, config): + + model.eval() + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + + with torch.no_grad(): + for step, (X, y) in enumerate(valid_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + for i in range(config.sample_archs): + ### sample new arch ### + model.module.init_arch_params(layer_idx=0) + genotypes = [] + for i in range(config.layer_num): + genotype, connect = model.module.generate_genotype(i) + genotypes.append(genotype) + + model.module.genotypes[i] = genotype + model.module.connects[i] = connect + + logits, _ = model(X, layer_idx=0, super_flag=True, pretrain_flag=True, is_slim=True) + loss = criterion(logits, y) + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + torch.cuda.synchronize() + step_num = len(valid_loader) + + if (step % config.print_freq == 0 or step == step_num-1) and config.local_rank == 0: + logger.info( + "Valid: Epoch {:2d}/{} Step {:03d}/{:03d} Sample_index {} Loss {:.3f} " + "Prec@(1,5) ({:.1%}, {:.1%})".format( + epoch+1, config.epochs, step, step_num, i, + reduced_loss.item(), prec1.item(), prec5.item())) + + if config.local_rank == 0: + writer.add_scalar('val/loss', reduced_loss.item(), cur_step) + writer.add_scalar('val/top1', prec1.item(), cur_step) + writer.add_scalar('val/top5', prec5.item(), cur_step) + + return prec1.item(), prec5.item() + + +def test_sample(valid_loader, model, epoch, cur_step, writer, logger, config): + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + model.eval() + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + + + model.module.init_arch_params(layer_idx=0) + genotypes = [] + + for i in range(config.layer_num): + genotype, connect = model.module.generate_genotype(i) + genotypes.append(genotype) + + model.module.genotypes[i] = genotype + model.module.connects[i] = connect + + with torch.no_grad(): + for step, (X, y) in enumerate(valid_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + # logits, _ = model(X, layer_idx=0, super_flag=True, pretrain_flag=True) + logits, _ = model(X, layer_idx=0, super_flag=True, pretrain_flag=True, is_slim=True) + loss = criterion(logits, y) + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + step_num = len(valid_loader) + + if (step % config.print_freq == 0 or step == step_num-1) and config.local_rank == 0: + logger.info( + "Valid: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.epochs, step, step_num, + losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('val/loss', losses.avg, cur_step) + writer.add_scalar('val/top1', top1.avg, cur_step) + writer.add_scalar('val/top5', top5.avg, cur_step) + + logger.info("Valid: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.epochs, top1.avg)) + + return top1.avg, top5.avg \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/search_function.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/search_function.py new file mode 100644 index 000000000..29c60e386 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/core/search_function.py @@ -0,0 +1,241 @@ +import torch +import torch.nn as nn +import torch.nn.functional as F +from utils import utils +from models.loss import Loss_interactive + +def search(train_loader, valid_loader, model, optimizer, w_optim, alpha_optim, epoch, writer, logger, config): + # interactive retrain and kl + + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + losses_interactive = utils.AverageMeter() + losses_cls = utils.AverageMeter() + losses_reg = utils.AverageMeter() + + step_num = len(train_loader) + step_num = int(step_num * config.sample_ratio) + + cur_step = epoch*step_num + cur_lr_search = w_optim.param_groups[0]['lr'] + cur_lr_main = optimizer.param_groups[0]['lr'] + if config.local_rank == 0: + logger.info("Train Epoch {} Search LR {}".format(epoch, cur_lr_search)) + logger.info("Train Epoch {} Main LR {}".format(epoch, cur_lr_main)) + writer.add_scalar('retrain/lr', cur_lr_search, cur_step) + + model.train() + + for step, ((trn_X, trn_y), (val_X, val_y)) in enumerate(zip(train_loader, valid_loader)): + if step > step_num: + break + + trn_X, trn_y = trn_X.to(device, non_blocking=True), trn_y.to(device, non_blocking=True) + val_X, val_y = val_X.to(device, non_blocking=True), val_y.to(device, non_blocking=True) + N = trn_X.size(0) + + #use valid data + alpha_optim.zero_grad() + optimizer.zero_grad() + + logits_search, emsemble_logits_search = model(val_X, super_flag=True) + logits_main, emsemble_logits_main= model(val_X, super_flag=False) + + loss_cls = (criterion(logits_search, val_y) + criterion(logits_main, val_y)) / config.loss_alpha + loss_interactive = Loss_interactive(emsemble_logits_search, emsemble_logits_main, config.loss_T, config.interactive_type) * config.loss_alpha + loss_regular = 0 * loss_cls + + if config.regular: + coeff = max(config.regular_coeff * (1 - float(epoch-config.pretrain_epochs)/(( + config.search_iter-config.pretrain_epochs)*config.search_iter_epochs*config.regular_ratio)), 0) + # loss_regular += coeff * torch.sum(abs(model.module._arch_parameters[:, 0])) + loss_regular += coeff * model.module.l1_loss() + + loss = loss_cls + loss_interactive + loss_regular + loss.backward() + nn.utils.clip_grad_norm_(model.module.parameters(), config.w_grad_clip) + optimizer.step() + alpha_optim.step() + + prec1, prec5 = utils.accuracy(logits_search, val_y, topk=(1, 5)) + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + reduced_loss_interactive = utils.reduce_tensor(loss_interactive.data, config.world_size) + reduced_loss_cls = utils.reduce_tensor(loss_cls.data, config.world_size) + reduced_loss_reg = utils.reduce_tensor(loss_regular.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + + else: + reduced_loss = loss.data + reduced_loss_interactive = loss_interactive.data + reduced_loss_cls = loss_cls.data + reduced_loss_reg = loss_regular.data + + losses.update(reduced_loss.item(), N) + losses_interactive.update(reduced_loss_interactive.item(), N) + losses_cls.update(reduced_loss_cls.item(), N) + losses_reg.update(reduced_loss_reg.item(), N) + + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num): + logger.info( + "Train_2: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Loss_interactive {losses_interactive.avg:.3f} Losses_cls {losses_cls.avg:.3f} Losses_reg {losses_reg.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.search_iter*config.search_iter_epochs, step, + step_num, losses=losses, losses_interactive=losses_interactive, losses_cls=losses_cls, + losses_reg=losses_reg, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('retrain/loss', reduced_loss.item(), cur_step) + writer.add_scalar('retrain/top1', prec1.item(), cur_step) + writer.add_scalar('retrain/top5', prec5.item(), cur_step) + cur_step += 1 + + + w_optim.zero_grad() + logits_search_train, _ = model(trn_X, super_flag=True) + loss_cls_train = criterion(logits_search_train, trn_y) + loss_train = loss_cls_train + loss_train.backward() + # gradient clipping + nn.utils.clip_grad_norm_(model.module.parameters(), config.w_grad_clip) + # only update w + w_optim.step() + + # alpha_optim.step() + if config.distributed: + reduced_loss_cls_train = utils.reduce_tensor(loss_cls_train.data, config.world_size) + reduced_loss_train = utils.reduce_tensor(loss_train.data, config.world_size) + else: + reduced_loss_cls_train = reduced_loss_cls_train.data + reduced_loss_train = reduced_loss_train.data + + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num-1): + logger.info( + "Train_1: Loss_cls: {:.3f} Loss: {:.3f}".format( + reduced_loss_cls_train.item(), reduced_loss_train.item()) + ) + + + if config.local_rank == 0: + logger.info("Train_2: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.search_iter*config.search_iter_epochs, top1.avg)) + + +def retrain_warmup(valid_loader, model, optimizer, epoch, writer, logger, super_flag, retrain_epochs, config): + + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + step_num = len(valid_loader) + step_num = int(step_num * config.sample_ratio) + + cur_step = epoch*step_num + cur_lr = optimizer.param_groups[0]['lr'] + if config.local_rank == 0: + logger.info("Warmup Epoch {} LR {:.3f}".format(epoch+1, cur_lr)) + writer.add_scalar('warmup/lr', cur_lr, cur_step) + + model.train() + + for step, (val_X, val_y) in enumerate(valid_loader): + if step > step_num: + break + + val_X, val_y = val_X.to(device, non_blocking=True), val_y.to(device, non_blocking=True) + N = val_X.size(0) + + optimizer.zero_grad() + logits_main, _ = model(val_X, super_flag=super_flag) + loss = criterion(logits_main, val_y) + loss.backward() + + nn.utils.clip_grad_norm_(model.module.parameters(), config.w_grad_clip) + optimizer.step() + + prec1, prec5 = utils.accuracy(logits_main, val_y, topk=(1, 5)) + if config.distributed: + reduced_loss = utils.reduce_tensor(loss.data, config.world_size) + prec1 = utils.reduce_tensor(prec1, config.world_size) + prec5 = utils.reduce_tensor(prec5, config.world_size) + + else: + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + if config.local_rank == 0 and (step % config.print_freq == 0 or step == step_num): + logger.info( + "Warmup: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, retrain_epochs, step, + step_num, losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('retrain/loss', reduced_loss.item(), cur_step) + writer.add_scalar('retrain/top1', prec1.item(), cur_step) + writer.add_scalar('retrain/top5', prec5.item(), cur_step) + cur_step += 1 + + if config.local_rank == 0: + logger.info("Warmup: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, retrain_epochs, top1.avg)) + +def validate(valid_loader, model, epoch, cur_step, writer, logger, super_flag, config): + top1 = utils.AverageMeter() + top5 = utils.AverageMeter() + losses = utils.AverageMeter() + + model.eval() + device = torch.device("cuda") + criterion = nn.CrossEntropyLoss().to(device) + + with torch.no_grad(): + for step, (X, y) in enumerate(valid_loader): + X, y = X.to(device, non_blocking=True), y.to(device, non_blocking=True) + N = X.size(0) + + logits, _ = model(X, super_flag=False) + loss = criterion(logits, y) + + prec1, prec5 = utils.accuracy(logits, y, topk=(1, 5)) + + reduced_loss = loss.data + + losses.update(reduced_loss.item(), N) + top1.update(prec1.item(), N) + top5.update(prec5.item(), N) + + torch.cuda.synchronize() + step_num = len(valid_loader) + + if (step % config.print_freq == 0 or step == step_num-1) and config.local_rank == 0: + logger.info( + "Valid: Epoch {:2d}/{} Step {:03d}/{:03d} Loss {losses.avg:.3f} " + "Prec@(1,5) ({top1.avg:.1%}, {top5.avg:.1%})".format( + epoch+1, config.search_iter*config.search_iter_epochs, step, step_num, + losses=losses, top1=top1, top5=top5)) + + if config.local_rank == 0: + writer.add_scalar('val/loss', losses.avg, cur_step) + writer.add_scalar('val/top1', top1.avg, cur_step) + writer.add_scalar('val/top5', top5.avg, cur_step) + + logger.info("Valid: Epoch {:2d}/{} Final Prec@1 {:.4%}".format( + epoch+1, config.search_iter*config.search_iter_epochs, top1.avg)) + + return top1.avg \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/cifar.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/cifar.py new file mode 100644 index 000000000..5531be632 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/cifar.py @@ -0,0 +1,103 @@ +import torch +import numpy as np +import torchvision.datasets as dset +import torchvision.transforms as transforms +from datasets.data_utils import SubsetDistributedSampler +from datasets.data_utils import CIFAR10Policy, Cutout + + +def data_transforms_cifar(config, cutout=False): + CIFAR_MEAN = [0.49139968, 0.48215827, 0.44653124] + CIFAR_STD = [0.24703233, 0.24348505, 0.26158768] + + if config.use_aa: + train_transform = transforms.Compose([ + transforms.RandomCrop(32, padding=4, fill=128), + transforms.RandomHorizontalFlip(), CIFAR10Policy(), + transforms.ToTensor(), + transforms.Normalize(CIFAR_MEAN, CIFAR_STD), + ]) + else: + train_transform = transforms.Compose([ + transforms.RandomCrop(32, padding=4), + transforms.RandomHorizontalFlip(), + transforms.ToTensor(), + transforms.Normalize(CIFAR_MEAN, CIFAR_STD), + ]) + + + if cutout: + train_transform.transforms.append(Cutout(config.cutout_length)) + + valid_transform = transforms.Compose([ + transforms.ToTensor(), + transforms.Normalize(CIFAR_MEAN, CIFAR_STD), + ]) + return train_transform, valid_transform + +def get_search_datasets(config): + + dataset = config.dataset.lower() + if dataset == 'cifar10': + dset_cls = dset.CIFAR10 + n_classes = 10 + elif dataset == 'cifar100': + dset_cls = dset.CIFAR100 + n_classes = 100 + else: + raise Exception("Not support dataset!") + + train_transform, valid_transform = data_transforms_cifar(config, cutout=False) + train_data = dset_cls(root=config.data_dir, train=True, download=True, transform=train_transform) + test_data = dset_cls(root=config.data_dir, train=False, download=True, transform=valid_transform) + + num_train = len(train_data) + # num_train = 512 + indices = list(range(num_train)) + split_mid = int(np.floor(0.5 * num_train)) + + train_sampler = SubsetDistributedSampler(train_data, indices[:split_mid]) + valid_sampler = SubsetDistributedSampler(train_data, indices[split_mid:num_train]) + + train_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=train_sampler, + pin_memory=True, num_workers=config.workers) + + valid_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=valid_sampler, + pin_memory=True, num_workers=config.workers) + + return [train_loader, valid_loader], [train_sampler, valid_sampler] + +def get_augment_datasets(config): + + dataset = config.dataset.lower() + if dataset == 'cifar10': + dset_cls = dset.CIFAR10 + elif dataset == 'cifar100': + dset_cls = dset.CIFAR100 + else: + raise Exception("Not support dataset!") + + train_transform, valid_transform = data_transforms_cifar(config, cutout=True) + train_data = dset_cls(root=config.data_dir, train=True, download=True, transform=train_transform) + test_data = dset_cls(root=config.data_dir, train=False, download=True, transform=valid_transform) + + + train_sampler = torch.utils.data.distributed.DistributedSampler(train_data) + test_sampler = torch.utils.data.distributed.DistributedSampler(test_data) + + train_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=train_sampler, + pin_memory=True, num_workers=config.workers) + + test_loader = torch.utils.data.DataLoader( + test_data, batch_size=config.batch_size, + sampler=test_sampler, + pin_memory=True, num_workers=config.workers) + + return [train_loader, test_loader], [train_sampler, test_sampler] + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/data_utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/data_utils.py new file mode 100644 index 000000000..eef2575af --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/data_utils.py @@ -0,0 +1,393 @@ +import math +import torch +import random +import numpy as np +import torch.distributed as dist +from torch.utils.data import Sampler +from PIL import Image, ImageEnhance, ImageOps + +class SubsetDistributedSampler(Sampler): + """Sampler that restricts data loading to a subset of the dataset. + + It is especially useful in conjunction with + :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each + process can pass a DistributedSampler instance as a DataLoader sampler, + and load a subset of the original dataset that is exclusive to it. + + .. note:: + Dataset is assumed to be of constant size. + + Arguments: + dataset: Dataset used for sampling. + num_replicas (optional): Number of processes participating in + distributed training. + rank (optional): Rank of the current process within num_replicas. + shuffle (optional): If true (default), sampler will shuffle the indices + """ + + def __init__(self, dataset, indices, num_replicas=None, rank=None, shuffle=True): + if num_replicas is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + num_replicas = dist.get_world_size() + if rank is None: + if not dist.is_available(): + raise RuntimeError("Requires distributed package to be available") + rank = dist.get_rank() + self.dataset = dataset + self.num_replicas = num_replicas + self.rank = rank + self.epoch = 0 + self.indices = indices + self.num_samples = int(math.ceil(len(self.indices) * 1.0 / self.num_replicas)) + self.total_size = self.num_samples * self.num_replicas + self.shuffle = shuffle + + def __iter__(self): + # deterministically shuffle based on epoch + g = torch.Generator() + g.manual_seed(self.epoch) + if self.shuffle: + # indices = torch.randperm(len(self.dataset), generator=g).tolist() + indices = list(self.indices[i] for i in torch.randperm(len(self.indices))) + else: + # indices = list(range(len(self.dataset))) + indices = self.indices + + + # add extra samples to make it evenly divisible + indices += indices[:(self.total_size - len(indices))] + assert len(indices) == self.total_size + + # subsample + indices = indices[self.rank:self.total_size:self.num_replicas] + assert len(indices) == self.num_samples + + return iter(indices) + + def __len__(self): + return self.num_samples + + def set_epoch(self, epoch): + self.epoch = epoch + + +class data_prefetcher(): + def __init__(self, loader): + self.loader = iter(loader) + self.stream = torch.cuda.Stream() + self.mean = torch.tensor([0.485 * 255, 0.456 * 255, 0.406 * 255]).cuda().view(1,3,1,1) + self.std = torch.tensor([0.229 * 255, 0.224 * 255, 0.225 * 255]).cuda().view(1,3,1,1) + # With Amp, it isn't necessary to manually convert data to half. + # if args.fp16: + # self.mean = self.mean.half() + # self.std = self.std.half() + self.preload() + + def preload(self): + try: + self.next_input, self.next_target = next(self.loader) + except StopIteration: + self.next_input = None + self.next_target = None + return + with torch.cuda.stream(self.stream): + self.next_input = self.next_input.cuda(non_blocking=True) + self.next_target = self.next_target.cuda(non_blocking=True) + # With Amp, it isn't necessary to manually convert data to half. + # if args.fp16: + # self.next_input = self.next_input.half() + # else: + self.next_input = self.next_input.float() + self.next_input = self.next_input.sub_(self.mean).div_(self.std) + + def next(self): + torch.cuda.current_stream().wait_stream(self.stream) + input = self.next_input + target = self.next_target + self.preload() + return input, target + +class Cutout(object): + def __init__(self, length): + self.length = length + + def __call__(self, img): + h, w = img.size(1), img.size(2) + mask = np.ones((h, w), np.float32) + y = np.random.randint(h) + x = np.random.randint(w) + + y1 = np.clip(y - self.length // 2, 0, h) + y2 = np.clip(y + self.length // 2, 0, h) + x1 = np.clip(x - self.length // 2, 0, w) + x2 = np.clip(x + self.length // 2, 0, w) + + mask[y1: y2, x1: x2] = 0. + mask = torch.from_numpy(mask) + mask = mask.expand_as(img) + img *= mask + + return img + +class ImageNetPolicy(object): + """ Randomly choose one of the best 24 Sub-policies on ImageNet. + Example: + >>> policy = ImageNetPolicy() + >>> transformed = policy(image) + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> ImageNetPolicy(), + >>> transforms.ToTensor()]) + """ + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.4, "posterize", 8, 0.6, "rotate", 9, fillcolor), + SubPolicy(0.6, "solarize", 5, 0.6, "autocontrast", 5, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.6, "equalize", 3, fillcolor), + SubPolicy(0.6, "posterize", 7, 0.6, "posterize", 6, fillcolor), + SubPolicy(0.4, "equalize", 7, 0.2, "solarize", 4, fillcolor), + + SubPolicy(0.4, "equalize", 4, 0.8, "rotate", 8, fillcolor), + SubPolicy(0.6, "solarize", 3, 0.6, "equalize", 7, fillcolor), + SubPolicy(0.8, "posterize", 5, 1.0, "equalize", 2, fillcolor), + SubPolicy(0.2, "rotate", 3, 0.6, "solarize", 8, fillcolor), + SubPolicy(0.6, "equalize", 8, 0.4, "posterize", 6, fillcolor), + + SubPolicy(0.8, "rotate", 8, 0.4, "color", 0, fillcolor), + SubPolicy(0.4, "rotate", 9, 0.6, "equalize", 2, fillcolor), + SubPolicy(0.0, "equalize", 7, 0.8, "equalize", 8, fillcolor), + SubPolicy(0.6, "invert", 4, 1.0, "equalize", 8, fillcolor), + SubPolicy(0.6, "color", 4, 1.0, "contrast", 8, fillcolor), + + SubPolicy(0.8, "rotate", 8, 1.0, "color", 2, fillcolor), + SubPolicy(0.8, "color", 8, 0.8, "solarize", 7, fillcolor), + SubPolicy(0.4, "sharpness", 7, 0.6, "invert", 8, fillcolor), + SubPolicy(0.6, "shearX", 5, 1.0, "equalize", 9, fillcolor), + SubPolicy(0.4, "color", 0, 0.6, "equalize", 3, fillcolor), + + SubPolicy(0.4, "equalize", 7, 0.2, "solarize", 4, fillcolor), + SubPolicy(0.6, "solarize", 5, 0.6, "autocontrast", 5, fillcolor), + SubPolicy(0.6, "invert", 4, 1.0, "equalize", 8, fillcolor), + SubPolicy(0.6, "color", 4, 1.0, "contrast", 8, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.6, "equalize", 3, fillcolor) + ] + + + def __call__(self, img): + policy_idx = random.randint(0, len(self.policies) - 1) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment ImageNet Policy" + + +class CIFAR10Policy(object): + """ Randomly choose one of the best 25 Sub-policies on CIFAR10. + Example: + >>> policy = CIFAR10Policy() + >>> transformed = policy(image) + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> CIFAR10Policy(), + >>> transforms.ToTensor()]) + """ + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.1, "invert", 7, 0.2, "contrast", 6, fillcolor), + SubPolicy(0.7, "rotate", 2, 0.3, "translateX", 9, fillcolor), + SubPolicy(0.8, "sharpness", 1, 0.9, "sharpness", 3, fillcolor), + SubPolicy(0.5, "shearY", 8, 0.7, "translateY", 9, fillcolor), + SubPolicy(0.5, "autocontrast", 8, 0.9, "equalize", 2, fillcolor), + + SubPolicy(0.2, "shearY", 7, 0.3, "posterize", 7, fillcolor), + SubPolicy(0.4, "color", 3, 0.6, "brightness", 7, fillcolor), + SubPolicy(0.3, "sharpness", 9, 0.7, "brightness", 9, fillcolor), + SubPolicy(0.6, "equalize", 5, 0.5, "equalize", 1, fillcolor), + SubPolicy(0.6, "contrast", 7, 0.6, "sharpness", 5, fillcolor), + + SubPolicy(0.7, "color", 7, 0.5, "translateX", 8, fillcolor), + SubPolicy(0.3, "equalize", 7, 0.4, "autocontrast", 8, fillcolor), + SubPolicy(0.4, "translateY", 3, 0.2, "sharpness", 6, fillcolor), + SubPolicy(0.9, "brightness", 6, 0.2, "color", 8, fillcolor), + SubPolicy(0.5, "solarize", 2, 0.0, "invert", 3, fillcolor), + + SubPolicy(0.2, "equalize", 0, 0.6, "autocontrast", 0, fillcolor), + SubPolicy(0.2, "equalize", 8, 0.6, "equalize", 4, fillcolor), + SubPolicy(0.9, "color", 9, 0.6, "equalize", 6, fillcolor), + SubPolicy(0.8, "autocontrast", 4, 0.2, "solarize", 8, fillcolor), + SubPolicy(0.1, "brightness", 3, 0.7, "color", 0, fillcolor), + + SubPolicy(0.4, "solarize", 5, 0.9, "autocontrast", 3, fillcolor), + SubPolicy(0.9, "translateY", 9, 0.7, "translateY", 9, fillcolor), + SubPolicy(0.9, "autocontrast", 2, 0.8, "solarize", 3, fillcolor), + SubPolicy(0.8, "equalize", 8, 0.1, "invert", 3, fillcolor), + SubPolicy(0.7, "translateY", 9, 0.9, "autocontrast", 1, fillcolor) + ] + + + def __call__(self, img): + policy_idx = random.randint(0, len(self.policies) - 1) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment CIFAR10 Policy" + + +class SVHNPolicy(object): + """ Randomly choose one of the best 25 Sub-policies on SVHN. + Example: + >>> policy = SVHNPolicy() + >>> transformed = policy(image) + Example as a PyTorch Transform: + >>> transform=transforms.Compose([ + >>> transforms.Resize(256), + >>> SVHNPolicy(), + >>> transforms.ToTensor()]) + """ + def __init__(self, fillcolor=(128, 128, 128)): + self.policies = [ + SubPolicy(0.9, "shearX", 4, 0.2, "invert", 3, fillcolor), + SubPolicy(0.9, "shearY", 8, 0.7, "invert", 5, fillcolor), + SubPolicy(0.6, "equalize", 5, 0.6, "solarize", 6, fillcolor), + SubPolicy(0.9, "invert", 3, 0.6, "equalize", 3, fillcolor), + SubPolicy(0.6, "equalize", 1, 0.9, "rotate", 3, fillcolor), + + SubPolicy(0.9, "shearX", 4, 0.8, "autocontrast", 3, fillcolor), + SubPolicy(0.9, "shearY", 8, 0.4, "invert", 5, fillcolor), + SubPolicy(0.9, "shearY", 5, 0.2, "solarize", 6, fillcolor), + SubPolicy(0.9, "invert", 6, 0.8, "autocontrast", 1, fillcolor), + SubPolicy(0.6, "equalize", 3, 0.9, "rotate", 3, fillcolor), + + SubPolicy(0.9, "shearX", 4, 0.3, "solarize", 3, fillcolor), + SubPolicy(0.8, "shearY", 8, 0.7, "invert", 4, fillcolor), + SubPolicy(0.9, "equalize", 5, 0.6, "translateY", 6, fillcolor), + SubPolicy(0.9, "invert", 4, 0.6, "equalize", 7, fillcolor), + SubPolicy(0.3, "contrast", 3, 0.8, "rotate", 4, fillcolor), + + SubPolicy(0.8, "invert", 5, 0.0, "translateY", 2, fillcolor), + SubPolicy(0.7, "shearY", 6, 0.4, "solarize", 8, fillcolor), + SubPolicy(0.6, "invert", 4, 0.8, "rotate", 4, fillcolor), + SubPolicy(0.3, "shearY", 7, 0.9, "translateX", 3, fillcolor), + SubPolicy(0.1, "shearX", 6, 0.6, "invert", 5, fillcolor), + + SubPolicy(0.7, "solarize", 2, 0.6, "translateY", 7, fillcolor), + SubPolicy(0.8, "shearY", 4, 0.8, "invert", 8, fillcolor), + SubPolicy(0.7, "shearX", 9, 0.8, "translateY", 3, fillcolor), + SubPolicy(0.8, "shearY", 5, 0.7, "autocontrast", 3, fillcolor), + SubPolicy(0.7, "shearX", 2, 0.1, "invert", 5, fillcolor) + ] + + + def __call__(self, img): + policy_idx = random.randint(0, len(self.policies) - 1) + return self.policies[policy_idx](img) + + def __repr__(self): + return "AutoAugment SVHN Policy" + + +class SubPolicy(object): + def __init__(self, p1, operation1, magnitude_idx1, p2, operation2, magnitude_idx2, fillcolor=(128, 128, 128)): + ranges = { + "shearX": np.linspace(0, 0.3, 10), + "shearY": np.linspace(0, 0.3, 10), + "translateX": np.linspace(0, 150 / 331, 10), + "translateY": np.linspace(0, 150 / 331, 10), + "rotate": np.linspace(0, 30, 10), + "color": np.linspace(0.0, 0.9, 10), + "posterize": np.round(np.linspace(8, 4, 10), 0).astype(np.int), + "solarize": np.linspace(256, 0, 10), + "contrast": np.linspace(0.0, 0.9, 10), + "sharpness": np.linspace(0.0, 0.9, 10), + "brightness": np.linspace(0.0, 0.9, 10), + "autocontrast": [0] * 10, + "equalize": [0] * 10, + "invert": [0] * 10 + } + + # from https://stackoverflow.com/questions/5252170/specify-image-filling-color-when-rotating-in-python-with-pil-and-setting-expand + def rotate_with_fill(img, magnitude): + rot = img.convert("RGBA").rotate(magnitude) + return Image.composite(rot, Image.new("RGBA", rot.size, (128,) * 4), rot).convert(img.mode) + + func = { + "shearX": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, magnitude * random.choice([-1, 1]), 0, 0, 1, 0), + Image.BICUBIC, fillcolor=fillcolor), + "shearY": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, 0, magnitude * random.choice([-1, 1]), 1, 0), + Image.BICUBIC, fillcolor=fillcolor), + "translateX": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, magnitude * img.size[0] * random.choice([-1, 1]), 0, 1, 0), + fillcolor=fillcolor), + "translateY": lambda img, magnitude: img.transform( + img.size, Image.AFFINE, (1, 0, 0, 0, 1, magnitude * img.size[1] * random.choice([-1, 1])), + fillcolor=fillcolor), + "rotate": lambda img, magnitude: rotate_with_fill(img, magnitude), + "color": lambda img, magnitude: ImageEnhance.Color(img).enhance(1 + magnitude * random.choice([-1, 1])), + "posterize": lambda img, magnitude: ImageOps.posterize(img, magnitude), + "solarize": lambda img, magnitude: ImageOps.solarize(img, magnitude), + "contrast": lambda img, magnitude: ImageEnhance.Contrast(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "sharpness": lambda img, magnitude: ImageEnhance.Sharpness(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "brightness": lambda img, magnitude: ImageEnhance.Brightness(img).enhance( + 1 + magnitude * random.choice([-1, 1])), + "autocontrast": lambda img, magnitude: ImageOps.autocontrast(img), + "equalize": lambda img, magnitude: ImageOps.equalize(img), + "invert": lambda img, magnitude: ImageOps.invert(img) + } + + self.p1 = p1 + self.operation1 = func[operation1] + self.magnitude1 = ranges[operation1][magnitude_idx1] + self.p2 = p2 + self.operation2 = func[operation2] + self.magnitude2 = ranges[operation2][magnitude_idx2] + + + def __call__(self, img): + if random.random() < self.p1: img = self.operation1(img, self.magnitude1) + if random.random() < self.p2: img = self.operation2(img, self.magnitude2) + return img + +def fast_collate(batch): + imgs = [img[0] for img in batch] + targets = torch.tensor([target[1] for target in batch], dtype=torch.int64) + w = imgs[0].size[0] + h = imgs[0].size[1] + tensor = torch.zeros( (len(imgs), 3, h, w), dtype=torch.uint8 ) + for i, img in enumerate(imgs): + nump_array = np.asarray(img, dtype=np.uint8) + if(nump_array.ndim < 3): + nump_array = np.expand_dims(nump_array, axis=-1) + nump_array = np.rollaxis(nump_array, 2) + + tensor[i] += torch.from_numpy(nump_array) + + return tensor, targets + +def mixup_data(x, y, alpha=1.0, use_cuda=True): + '''Returns mixed inputs, pairs of targets, and lambda''' + if alpha > 0: + lam = np.random.beta(alpha, alpha) + else: + lam = 1 + + batch_size = x.size()[0] + if use_cuda: + index = torch.randperm(batch_size).cuda() + else: + index = torch.randperm(batch_size) + + mixed_x = lam * x + (1 - lam) * x[index, :] + y_a, y_b = y, y[index] + return mixed_x, y_a, y_b, lam + + +def mixup_criterion(criterion, pred, y_a, y_b, lam): + return lam * criterion(pred, y_a) + (1 - lam) * criterion(pred, y_b) + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/imagenet.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/imagenet.py new file mode 100644 index 000000000..25e989168 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/datasets/imagenet.py @@ -0,0 +1,102 @@ +import torch +import numpy as np +import torchvision.datasets as dset +import torchvision.transforms as transforms +from datasets.data_utils import SubsetDistributedSampler +from datasets.data_utils import ImageNetPolicy + +def get_search_datasets(config): + normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) + train_data = dset.ImageFolder( + config.train_dir, + transforms.Compose([ + transforms.RandomResizedCrop(224), + transforms.RandomHorizontalFlip(), + transforms.ColorJitter( + brightness=0.4, + contrast=0.4, + saturation=0.4, + hue=0.2), + transforms.ToTensor(), + normalize, + ])) + + test_data = dset.ImageFolder( + config.test_dir, + transforms.Compose([ + transforms.Resize(256), + transforms.CenterCrop(224), + transforms.ToTensor(), + normalize, + ])) + + num_train = len(train_data) + indices = list(range(num_train)) + split_mid = int(np.floor(0.5 * num_train)) + + train_sampler = SubsetDistributedSampler(train_data, indices[:split_mid]) + valid_sampler = SubsetDistributedSampler(train_data, indices[split_mid:num_train]) + + train_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=train_sampler, + pin_memory=True, num_workers=config.workers) + + valid_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=valid_sampler, + pin_memory=True, num_workers=config.workers) + + return [train_loader, valid_loader], [train_sampler, valid_sampler] + +def get_augment_datasets(config): + normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) + if config.use_aa: + train_data = dset.ImageFolder( + config.train_dir, + transforms.Compose([ + transforms.RandomResizedCrop(224), + transforms.RandomHorizontalFlip(), + ImageNetPolicy(), + transforms.ToTensor(), + normalize, + ])) + else: + train_data = dset.ImageFolder( + config.train_dir, + transforms.Compose([ + transforms.RandomResizedCrop(224), + transforms.RandomHorizontalFlip(), + transforms.ColorJitter( + brightness=0.4, + contrast=0.4, + saturation=0.4, + hue=0.2), + transforms.ToTensor(), + normalize, + ])) + + test_data = dset.ImageFolder( + config.test_dir, + transforms.Compose([ + transforms.Resize(256), + transforms.CenterCrop(224), + transforms.ToTensor(), + normalize, + ])) + + train_sampler = torch.utils.data.distributed.DistributedSampler(train_data) + test_sampler = torch.utils.data.distributed.DistributedSampler(test_data) + + train_loader = torch.utils.data.DataLoader( + train_data, batch_size=config.batch_size, + sampler=train_sampler, + pin_memory=True, num_workers=config.workers) + + test_loader = torch.utils.data.DataLoader( + test_data, batch_size=config.batch_size, + sampler=test_sampler, + pin_memory=True, num_workers=config.workers) + + return [train_loader, test_loader], [train_sampler, test_sampler] + diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search.py new file mode 100644 index 000000000..2841ba483 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search.py @@ -0,0 +1,250 @@ +""" Search cell """ +import os +import copy +import apex +import json +import torch +import time +import math +import torch.nn as nn +import numpy as np +import torch.distributed as dist + +from tensorboardX import SummaryWriter +from models.cdarts_controller import CDARTSController +from utils.visualize import plot +from utils import utils +from datasets.data_utils import SubsetDistributedSampler +from core.search_function import search, retrain_warmup, validate +from nas_201_api import NASBench201API as API + +from configs.config import SearchConfig +config = SearchConfig() + +if 'cifar' in config.dataset: + from datasets.cifar import get_search_datasets +elif 'imagenet' in config.dataset: + from datasets.imagenet import get_search_datasets + +# tensorboard +writer = SummaryWriter(log_dir=os.path.join(config.path, "tb")) +writer.add_text('config', config.as_markdown(), 0) + +logger = utils.get_logger(os.path.join(config.path, "{}.log".format(config.name))) +if config.local_rank == 0: + config.print_params(logger.info) + +try: + os.makedirs(config.plot_path) +except: + pass + +if config.use_apex: + import apex + from apex.parallel import DistributedDataParallel as DDP +else: + DDP = torch.nn.parallel.DistributedDataParallel + + +def main(): + logger.info("Logger is set - training start") + + + # set seed + np.random.seed(config.seed) + torch.manual_seed(config.seed) + torch.cuda.manual_seed_all(config.seed) + torch.backends.cudnn.deterministic = True + torch.backends.cudnn.benchmark = True + + # TODO + # api = None + api = API('/home/hongyuan/benchmark/NAS-Bench-201-v1_0-e61699.pth') + + if config.distributed: + config.gpu = config.local_rank % torch.cuda.device_count() + torch.cuda.set_device(config.gpu) + # distributed init + torch.distributed.init_process_group(backend='nccl', init_method=config.dist_url, + world_size=config.world_size, rank=config.local_rank) + + config.world_size = torch.distributed.get_world_size() + + config.total_batch_size = config.world_size * config.batch_size + else: + config.total_batch_size = config.batch_size + + + loaders, samplers = get_search_datasets(config) + train_loader, valid_loader = loaders + train_sampler, valid_sampler = samplers + + net_crit = nn.CrossEntropyLoss().cuda() + controller = CDARTSController(config, net_crit, n_nodes=4, stem_multiplier=config.stem_multiplier) + + resume_state = None + if config.resume: + resume_state = torch.load(config.resume_path, map_location='cpu') + + if config.resume: + controller.load_state_dict(resume_state['controller']) + + controller = controller.cuda() + if config.sync_bn: + if config.use_apex: + controller = apex.parallel.convert_syncbn_model(controller) + else: + controller = torch.nn.SyncBatchNorm.convert_sync_batchnorm(controller) + + if config.use_apex: + controller = DDP(controller, delay_allreduce=True) + else: + controller = DDP(controller, device_ids=[config.gpu]) + + # warm up model_search + if config.ensemble_param: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers.parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.ensemble_param}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers.parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + + + # search training loop + sta_search_iter = 0 + lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( + w_optim, config.search_iter * config.search_iter_epochs, eta_min=config.w_lr_min) + lr_scheduler_retrain = nn.ModuleList() + alpha_optim = nn.ModuleList() + optimizer = nn.ModuleList() + sub_epoch = 0 + + for search_iter in range(sta_search_iter, config.search_iter): + if search_iter < config.pretrain_epochs: + if config.local_rank == 0: + logger.info("####### Super model warmup #######") + train_sampler.set_epoch(search_iter) + retrain_warmup(train_loader, controller, w_optim, search_iter, writer, logger, True, config.pretrain_epochs, config) + #lr_scheduler.step() + else: + # build new controller + genotype = controller.module.genotype() + controller.module.build_nas_model(genotype) + + controller_b = copy.deepcopy(controller.module) + del controller + controller = controller_b.cuda() + + # sync params from super layer pool + controller.copy_params_from_super_layer() + + if config.sync_bn: + if config.use_apex: + controller = apex.parallel.convert_syncbn_model(controller) + else: + controller = torch.nn.SyncBatchNorm.convert_sync_batchnorm(controller) + + if config.use_apex: + controller = DDP(controller, delay_allreduce=True) + else: + controller = DDP(controller, device_ids=[config.gpu]) + + # weights optimizer + if config.ensemble_param: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers.parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.ensemble_param}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + w_optim = torch.optim.SGD([ {"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.super_layers.parameters()}, + {"params": controller.module.fc_super.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}], + lr=config.w_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + # arch_params optimizer + alpha_optim = torch.optim.Adam(controller.module.arch_parameters(), config.alpha_lr, betas=(0.5, 0.999), + weight_decay=config.alpha_weight_decay) + + + if config.ensemble_param: + optimizer = torch.optim.SGD([{"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.nas_layers.parameters()}, + {"params": controller.module.ensemble_param}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.fc_nas.parameters()}], + lr=config.nasnet_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + else: + optimizer = torch.optim.SGD([{"params": controller.module.feature_extractor.parameters()}, + {"params": controller.module.nas_layers.parameters()}, + {"params": controller.module.distill_aux_head1.parameters()}, + {"params": controller.module.distill_aux_head2.parameters()}, + {"params": controller.module.fc_nas.parameters()}], + lr=config.nasnet_lr, momentum=config.w_momentum, weight_decay=config.w_weight_decay) + + lr_scheduler_retrain = torch.optim.lr_scheduler.CosineAnnealingLR( + optimizer, config.search_iter_epochs, eta_min=config.w_lr_min) + lr_scheduler = torch.optim.lr_scheduler.CosineAnnealingLR( + w_optim, config.search_iter * config.search_iter_epochs, eta_min=config.w_lr_min) + + # warmup model main + if config.local_rank == 0: + logger.info("####### Sub model warmup #######") + for warmup_epoch in range(config.nasnet_warmup): + valid_sampler.set_epoch(warmup_epoch) + retrain_warmup(valid_loader, controller, optimizer, warmup_epoch, writer, logger, False, config.nasnet_warmup, config) + + + lr_search = lr_scheduler.get_lr()[0] + lr_main = lr_scheduler_retrain.get_lr()[0] + + search_epoch = search_iter + + # reset iterators + train_sampler.set_epoch(search_epoch) + valid_sampler.set_epoch(search_epoch) + + # training + search(train_loader, valid_loader, controller, optimizer, w_optim, alpha_optim, search_epoch, writer, logger, config) + + # sync params to super layer pool + controller.module.copy_params_from_nas_layer() + + # nasbench201 + if config.local_rank == 0: + logger.info('{}'.format(controller.module._arch_parameters)) + result = api.query_by_arch(controller.module.genotype()) + logger.info('{:}'.format(result)) + cifar10_train, cifar10_test, cifar100_train, cifar100_valid, \ + cifar100_test, imagenet16_train, imagenet16_valid, imagenet16_test = utils.distill(result) + + writer.add_scalars('nasbench201/cifar10', {'train':cifar10_train,'test':cifar10_test}, search_epoch) + writer.add_scalars('nasbench201/cifar100', {'train':cifar100_train,'valid':cifar100_valid, 'test':cifar100_test}, search_epoch) + writer.add_scalars('nasbench201/imagenet16', {'train':imagenet16_train,'valid':imagenet16_valid, 'test':imagenet16_test}, search_epoch) + + + #lr_scheduler.step() + #lr_scheduler_retrain.step() + torch.cuda.empty_cache() + +if __name__ == "__main__": + sta_time = time.time() + main() + search_time = time.time() - sta_time + search_hour = math.floor(search_time / 3600) + search_min = math.floor(search_time / 60 - search_hour * 60) + if config.local_rank==0: + logger.info("Search time: hour: {} minute: {}".format(search_hour, search_min)) diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/cifar10-search/tb/readme.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/cifar10-search/tb/readme.md new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/imagenet-search/tb/readme.md b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/search/imagenet-search/tb/readme.md new file mode 100644 index 000000000..e69de29bb diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/genotypes.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/genotypes.py new file mode 100644 index 000000000..987687b8a --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/genotypes.py @@ -0,0 +1,352 @@ +""" Genotypes + - Genotype: normal/reduce gene + normal/reduce cell output connection (concat) + - gene: discrete ops information (w/o output connection) + - dag: real ops (can be mixed or discrete, but Genotype has only discrete information itself) +""" +from collections import namedtuple +import torch +import torch.nn as nn +import torch.nn.functional as F +from copy import deepcopy +from models import ops + +Genotype = namedtuple('Genotype', 'normal normal_concat reduce reduce_concat') + +def to_dag(C_in, gene, reduction, bn_affine=True): + """ generate discrete ops from gene """ + dag = nn.ModuleList() + for edges in gene: + row = nn.ModuleList() + for op_name, s_idx in edges: + # reduction cell & from input nodes => stride = 2 + stride = 2 if reduction and s_idx < 2 else 1 + op = ops.OPS[op_name](C_in, stride, bn_affine) + if not isinstance(op, ops.Identity): # Identity does not use drop path + op = nn.Sequential( + op, + ops.DropPath_() + ) + op.s_idx = s_idx + row.append(op) + dag.append(row) + + return dag + + +def from_str(s): + """ generate genotype from string + e.g. "Genotype( + normal=[[('sep_conv_3x3', 0), ('sep_conv_3x3', 1)], + [('sep_conv_3x3', 1), ('dil_conv_3x3', 2)], + [('sep_conv_3x3', 1), ('sep_conv_3x3', 2)], + [('sep_conv_3x3', 1), ('dil_conv_3x3', 4)]], + normal_concat=range(2, 6), + reduce=[[('max_pool_3x3', 0), ('max_pool_3x3', 1)], + [('max_pool_3x3', 0), ('skip_connect', 2)], + [('max_pool_3x3', 0), ('skip_connect', 2)], + [('max_pool_3x3', 0), ('skip_connect', 2)]], + reduce_concat=range(2, 6))" + """ + + genotype = eval(s) + + return genotype + + +def parse(alpha, beta, k): + """ + parse continuous alpha to discrete gene. + alpha is ParameterList: + ParameterList [ + Parameter(n_edges1, n_ops), + Parameter(n_edges2, n_ops), + ... + ] + + beta is ParameterList: + ParameterList [ + Parameter(n_edges1), + Parameter(n_edges2), + ... + ] + + gene is list: + [ + [('node1_ops_1', node_idx), ..., ('node1_ops_k', node_idx)], + [('node2_ops_1', node_idx), ..., ('node2_ops_k', node_idx)], + ... + ] + each node has two edges (k=2) in CNN. + """ + + gene = [] + assert PRIMITIVES[-1] == 'none' # assume last PRIMITIVE is 'none' + + # 1) Convert the mixed op to discrete edge (single op) by choosing top-1 weight edge + # 2) Choose top-k edges per node by edge score (top-1 weight in edge) + # output the connect idx[(node_idx, connect_idx, op_idx).... () ()] + connect_idx = [] + for edges, w in zip(alpha, beta): + # edges: Tensor(n_edges, n_ops) + edge_max, primitive_indices = torch.topk((w.view(-1, 1) * edges)[:, :-1], 1) # ignore 'none' + topk_edge_values, topk_edge_indices = torch.topk(edge_max.view(-1), k) + node_gene = [] + node_idx = [] + for edge_idx in topk_edge_indices: + prim_idx = primitive_indices[edge_idx] + prim = PRIMITIVES[prim_idx] + node_gene.append((prim, edge_idx.item())) + node_idx.append((edge_idx.item(), prim_idx.item())) + + gene.append(node_gene) + connect_idx.append(node_idx) + + return gene, connect_idx + +def parse_gumbel(alpha, beta, k): + """ + parse continuous alpha to discrete gene. + alpha is ParameterList: + ParameterList [ + Parameter(n_edges1, n_ops), + Parameter(n_edges2, n_ops), + ... + ] + + beta is ParameterList: + ParameterList [ + Parameter(n_edges1), + Parameter(n_edges2), + ... + ] + + gene is list: + [ + [('node1_ops_1', node_idx), ..., ('node1_ops_k', node_idx)], + [('node2_ops_1', node_idx), ..., ('node2_ops_k', node_idx)], + ... + ] + each node has two edges (k=2) in CNN. + """ + + gene = [] + assert PRIMITIVES[-1] == 'none' # assume last PRIMITIVE is 'none' + + # 1) Convert the mixed op to discrete edge (single op) by choosing top-1 weight edge + # 2) Choose top-k edges per node by edge score (top-1 weight in edge) + # output the connect idx[(node_idx, connect_idx, op_idx).... () ()] + connect_idx = [] + for edges, w in zip(alpha, beta): + # edges: Tensor(n_edges, n_ops) + discrete_a = F.gumbel_softmax(edges[:, :-1].reshape(-1), tau=1, hard=True) + for i in range(k-1): + discrete_a = discrete_a + F.gumbel_softmax(edges[:, :-1].reshape(-1), tau=1, hard=True) + discrete_a = discrete_a.reshape(-1, len(PRIMITIVES)-1) + reserved_edge = (discrete_a>0).nonzero() + + node_gene = [] + node_idx = [] + for i in range(reserved_edge.shape[0]): + edge_idx = reserved_edge[i][0].item() + prim_idx = reserved_edge[i][1].item() + prim = PRIMITIVES[prim_idx] + node_gene.append((prim, edge_idx)) + node_idx.append((edge_idx, prim_idx)) + + gene.append(node_gene) + connect_idx.append(node_idx) + + return gene, connect_idx + + + +def get_combination(space, num): + combs = [] + for i in range(num): + if i == 0: + for func in space: + combs.append( [(func, i)] ) + else: + new_combs = [] + for string in combs: + for func in space: + xstring = string + [(func, i)] + new_combs.append( xstring ) + combs = new_combs + return combs + + +class Structure: + + def __init__(self, genotype): + assert isinstance(genotype, list) or isinstance(genotype, tuple), 'invalid class of genotype : {:}'.format(type(genotype)) + self.node_num = len(genotype) + 1 + self.nodes = [] + self.node_N = [] + for idx, node_info in enumerate(genotype): + assert isinstance(node_info, list) or isinstance(node_info, tuple), 'invalid class of node_info : {:}'.format(type(node_info)) + assert len(node_info) >= 1, 'invalid length : {:}'.format(len(node_info)) + for node_in in node_info: + assert isinstance(node_in, list) or isinstance(node_in, tuple), 'invalid class of in-node : {:}'.format(type(node_in)) + assert len(node_in) == 2 and node_in[1] <= idx, 'invalid in-node : {:}'.format(node_in) + self.node_N.append( len(node_info) ) + self.nodes.append( tuple(deepcopy(node_info)) ) + + def tolist(self, remove_str): + # convert this class to the list, if remove_str is 'none', then remove the 'none' operation. + # note that we re-order the input node in this function + # return the-genotype-list and success [if unsuccess, it is not a connectivity] + genotypes = [] + for node_info in self.nodes: + node_info = list( node_info ) + node_info = sorted(node_info, key=lambda x: (x[1], x[0])) + node_info = tuple(filter(lambda x: x[0] != remove_str, node_info)) + if len(node_info) == 0: return None, False + genotypes.append( node_info ) + return genotypes, True + + def node(self, index): + assert index > 0 and index <= len(self), 'invalid index={:} < {:}'.format(index, len(self)) + return self.nodes[index] + + def tostr(self): + strings = [] + for node_info in self.nodes: + string = '|'.join([x[0]+'~{:}'.format(x[1]) for x in node_info]) + string = '|{:}|'.format(string) + strings.append( string ) + return '+'.join(strings) + + def check_valid(self): + nodes = {0: True} + for i, node_info in enumerate(self.nodes): + sums = [] + for op, xin in node_info: + if op == 'none' or nodes[xin] is False: x = False + else: x = True + sums.append( x ) + nodes[i+1] = sum(sums) > 0 + return nodes[len(self.nodes)] + + def to_unique_str(self, consider_zero=False): + # this is used to identify the isomorphic cell, which rerquires the prior knowledge of operation + # two operations are special, i.e., none and skip_connect + nodes = {0: '0'} + for i_node, node_info in enumerate(self.nodes): + cur_node = [] + for op, xin in node_info: + if consider_zero is None: + x = '('+nodes[xin]+')' + '@{:}'.format(op) + elif consider_zero: + if op == 'none' or nodes[xin] == '#': x = '#' # zero + elif op == 'skip_connect': x = nodes[xin] + else: x = '('+nodes[xin]+')' + '@{:}'.format(op) + else: + if op == 'skip_connect': x = nodes[xin] + else: x = '('+nodes[xin]+')' + '@{:}'.format(op) + cur_node.append(x) + nodes[i_node+1] = '+'.join( sorted(cur_node) ) + return nodes[ len(self.nodes) ] + + def check_valid_op(self, op_names): + for node_info in self.nodes: + for inode_edge in node_info: + #assert inode_edge[0] in op_names, 'invalid op-name : {:}'.format(inode_edge[0]) + if inode_edge[0] not in op_names: return False + return True + + def __repr__(self): + return ('{name}({node_num} nodes with {node_info})'.format(name=self.__class__.__name__, node_info=self.tostr(), **self.__dict__)) + + def __len__(self): + return len(self.nodes) + 1 + + def __getitem__(self, index): + return self.nodes[index] + + @staticmethod + def str2structure(xstr): + assert isinstance(xstr, str), 'must take string (not {:}) as input'.format(type(xstr)) + nodestrs = xstr.split('+') + genotypes = [] + for i, node_str in enumerate(nodestrs): + inputs = list(filter(lambda x: x != '', node_str.split('|'))) + for xinput in inputs: assert len(xinput.split('~')) == 2, 'invalid input length : {:}'.format(xinput) + inputs = ( xi.split('~') for xi in inputs ) + input_infos = tuple( (op, int(IDX)) for (op, IDX) in inputs) + genotypes.append( input_infos ) + return Structure( genotypes ) + + @staticmethod + def str2fullstructure(xstr, default_name='none'): + assert isinstance(xstr, str), 'must take string (not {:}) as input'.format(type(xstr)) + nodestrs = xstr.split('+') + genotypes = [] + for i, node_str in enumerate(nodestrs): + inputs = list(filter(lambda x: x != '', node_str.split('|'))) + for xinput in inputs: assert len(xinput.split('~')) == 2, 'invalid input length : {:}'.format(xinput) + inputs = ( xi.split('~') for xi in inputs ) + input_infos = list( (op, int(IDX)) for (op, IDX) in inputs) + all_in_nodes= list(x[1] for x in input_infos) + for j in range(i): + if j not in all_in_nodes: input_infos.append((default_name, j)) + node_info = sorted(input_infos, key=lambda x: (x[1], x[0])) + genotypes.append( tuple(node_info) ) + return Structure( genotypes ) + + @staticmethod + def gen_all(search_space, num, return_ori): + assert isinstance(search_space, list) or isinstance(search_space, tuple), 'invalid class of search-space : {:}'.format(type(search_space)) + assert num >= 2, 'There should be at least two nodes in a neural cell instead of {:}'.format(num) + all_archs = get_combination(search_space, 1) + for i, arch in enumerate(all_archs): + all_archs[i] = [ tuple(arch) ] + + for inode in range(2, num): + cur_nodes = get_combination(search_space, inode) + new_all_archs = [] + for previous_arch in all_archs: + for cur_node in cur_nodes: + new_all_archs.append( previous_arch + [tuple(cur_node)] ) + all_archs = new_all_archs + if return_ori: + return all_archs + else: + return [Structure(x) for x in all_archs] + + +ResNet_CODE = Structure( + [(('nor_conv_3x3', 0), ), # node-1 + (('nor_conv_3x3', 1), ), # node-2 + (('skip_connect', 0), ('skip_connect', 2))] # node-3 + ) + +AllConv3x3_CODE = Structure( + [(('nor_conv_3x3', 0), ), # node-1 + (('nor_conv_3x3', 0), ('nor_conv_3x3', 1)), # node-2 + (('nor_conv_3x3', 0), ('nor_conv_3x3', 1), ('nor_conv_3x3', 2))] # node-3 + ) + +AllFull_CODE = Structure( + [(('skip_connect', 0), ('nor_conv_1x1', 0), ('nor_conv_3x3', 0), ('avg_pool_3x3', 0)), # node-1 + (('skip_connect', 0), ('nor_conv_1x1', 0), ('nor_conv_3x3', 0), ('avg_pool_3x3', 0), ('skip_connect', 1), ('nor_conv_1x1', 1), ('nor_conv_3x3', 1), ('avg_pool_3x3', 1)), # node-2 + (('skip_connect', 0), ('nor_conv_1x1', 0), ('nor_conv_3x3', 0), ('avg_pool_3x3', 0), ('skip_connect', 1), ('nor_conv_1x1', 1), ('nor_conv_3x3', 1), ('avg_pool_3x3', 1), ('skip_connect', 2), ('nor_conv_1x1', 2), ('nor_conv_3x3', 2), ('avg_pool_3x3', 2))] # node-3 + ) + +AllConv1x1_CODE = Structure( + [(('nor_conv_1x1', 0), ), # node-1 + (('nor_conv_1x1', 0), ('nor_conv_1x1', 1)), # node-2 + (('nor_conv_1x1', 0), ('nor_conv_1x1', 1), ('nor_conv_1x1', 2))] # node-3 + ) + +AllIdentity_CODE = Structure( + [(('skip_connect', 0), ), # node-1 + (('skip_connect', 0), ('skip_connect', 1)), # node-2 + (('skip_connect', 0), ('skip_connect', 1), ('skip_connect', 2))] # node-3 + ) + +architectures = {'resnet' : ResNet_CODE, + 'all_c3x3': AllConv3x3_CODE, + 'all_c1x1': AllConv1x1_CODE, + 'all_idnt': AllIdentity_CODE, + 'all_full': AllFull_CODE} diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/get_info.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/get_info.py new file mode 100644 index 000000000..7750a15ce --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/get_info.py @@ -0,0 +1,41 @@ +import os +import argparse + +parser = argparse.ArgumentParser(description='supernet training') +parser.add_argument('path', type=str, default='train', + help='mode') + +args = parser.parse_args() + +def main(): + file_path = args.path + info = {} + cnt = 0 + dataset_idx = 0 + dataset = ['cifar10-valid', 'cifar10', 'cifar100', 'ImageNet16-120'] + acc = [['train', 'valid'], ['train', 'test'], ['train', 'valid', 'test'], ['train', 'valid', 'test']] + with open(file_path, 'r') as f: + for line in f: + line = line.split(' ') + if 'datasets' in line: + cnt = cnt + 1 + info[cnt] = {} + dataset_idx = 0 + if line[0] in dataset: + top1 = [] + info[cnt][line[0]] = {} + for item in line: + if '%' in item: + item = item.split("%")[0] + top1.append(float(item)) + if len(top1) > 0: + for value, name in zip(top1, acc[dataset_idx]): + info[cnt][line[0]][name] = value + + dataset_idx = dataset_idx + 1 + + for key in info.keys(): + print(key, info[key]) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/utils.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/utils.py new file mode 100644 index 000000000..4c223fc25 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/utils.py @@ -0,0 +1,134 @@ +""" Utilities """ +import os +import torch +import torch.nn as nn +import torch.nn.functional as F +import logging +import shutil +import torch +import torch.distributed as dist +import numpy as np + +def distill(result): + result = result.split('\n') + cifar10 = result[5].replace(' ', '').split(':') + cifar100 = result[7].replace(' ', '').split(':') + imagenet16 = result[9].replace(' ', '').split(':') + + cifar10_train = float(cifar10[1].strip(',test')[-7:-2].strip('=')) + cifar10_test = float(cifar10[2][-7:-2].strip('=')) + cifar100_train = float(cifar100[1].strip(',valid')[-7:-2].strip('=')) + cifar100_valid = float(cifar100[2].strip(',test')[-7:-2].strip('=')) + cifar100_test = float(cifar100[3][-7:-2].strip('=')) + imagenet16_train = float(imagenet16[1].strip(',valid')[-7:-2].strip('=')) + imagenet16_valid = float(imagenet16[2].strip(',test')[-7:-2].strip('=')) + imagenet16_test = float(imagenet16[3][-7:-2].strip('=')) + + return cifar10_train, cifar10_test, cifar100_train, cifar100_valid, \ + cifar100_test, imagenet16_train, imagenet16_valid, imagenet16_test + +class AverageMeter(): + """ Computes and stores the average and current value """ + def __init__(self): + self.reset() + + def reset(self): + """ Reset all statistics """ + self.val = 0 + self.avg = 0 + self.sum = 0 + self.count = 0 + + def update(self, val, n=1): + """ Update statistics """ + self.val = val + self.sum += val * n + self.count += n + self.avg = self.sum / self.count + +def get_logger(file_path): + """ Make python logger """ + logger = logging.getLogger('cdarts') + log_format = '%(asctime)s | %(message)s' + formatter = logging.Formatter(log_format, datefmt='%m/%d %I:%M:%S %p') + file_handler = logging.FileHandler(file_path) + file_handler.setFormatter(formatter) + stream_handler = logging.StreamHandler() + stream_handler.setFormatter(formatter) + + logger.addHandler(file_handler) + logger.addHandler(stream_handler) + logger.setLevel(logging.INFO) + + return logger + + +def param_size(model): + """ Compute parameter size in MB """ + n_params = sum( + np.prod(v.size()) for k, v in model.named_parameters() if not k.startswith('aux_head')) + return n_params / 1e6 + +def print_speed(i, i_time, n, logger): + """print_speed(index, index_time, total_iteration)""" + average_time = i_time + remaining_time = (n - i) * average_time + remaining_day = math.floor(remaining_time / 86400) + remaining_hour = math.floor(remaining_time / 3600 - remaining_day * 24) + remaining_min = math.floor(remaining_time / 60 - remaining_day * 1440 - remaining_hour * 60) + logger.info('Progress: %d / %d [%d%%], Speed: %.3f s/iter, ETA %d:%02d:%02d (D:H:M)\n' % (i, n, i/n*100, average_time, remaining_day, remaining_hour, remaining_min)) + logger.info('\nPROGRESS: {:.2f}%\n'.format(100 * i / n)) + + +def accuracy(output, target, topk=(1,)): + """ Computes the precision@k for the specified values of k """ + maxk = max(topk) + batch_size = target.size(0) + + _, pred = output.topk(maxk, 1, True, True) + pred = pred.t() + # one-hot case + if target.ndimension() > 1: + target = target.max(1)[1] + + correct = pred.eq(target.view(1, -1).expand_as(pred)) + + res = [] + for k in topk: + correct_k = correct[:k].view(-1).float().sum(0) + res.append(correct_k.mul_(1.0 / batch_size)) + + return res + +def save_checkpoint(state, ckpt_dir, is_best=False): + filename = os.path.join(ckpt_dir, 'checkpoint.pth.tar') + torch.save(state, filename) + if is_best: + best_filename = os.path.join(ckpt_dir, 'best.pth.tar') + torch.save(state, best_filename) + # shutil.copyfile(filename, best_filename) + +def reduce_tensor(tensor, world_size): + rt = tensor.clone() + dist.all_reduce(rt, op=dist.ReduceOp.SUM) + rt /= world_size + return rt + +def drop_path_(x, drop_prob, training): + if training and drop_prob > 0.: + keep_prob = 1. - drop_prob + # per data point mask; assuming x in cuda. + mask = torch.cuda.FloatTensor(x.size(0), 1, 1, 1).bernoulli_(keep_prob) + x.div_(keep_prob).mul_(mask) + + return x + +def adjust_lr(optimizer, epoch, config): + # Smaller slope for the last 5 epochs because lr * 1/250 is relatively large + if config.epochs - epoch > 5: + lr = config.lr * (config.epochs - 5 - epoch) / (config.epochs - 5) + else: + lr = config.lr * (config.epochs - epoch) / ((config.epochs - 5) * 5) + for param_group in optimizer.param_groups: + param_group['lr'] = lr + return lr diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/visualize.py b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/visualize.py new file mode 100644 index 000000000..aaa67d6e0 --- /dev/null +++ b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/benchmark201/utils/visualize.py @@ -0,0 +1,74 @@ +""" Network architecture visualizer using graphviz """ +import sys +from graphviz import Digraph +import utils.genotypes as gt + + +def plot(genotype, file_path, caption=None): + """ make DAG plot and save to file_path as .png """ + edge_attr = { + 'fontsize': '20', + 'fontname': 'times' + } + node_attr = { + 'style': 'filled', + 'shape': 'rect', + 'align': 'center', + 'fontsize': '20', + 'height': '0.5', + 'width': '0.5', + 'penwidth': '2', + 'fontname': 'times' + } + g = Digraph( + format='png', + edge_attr=edge_attr, + node_attr=node_attr, + engine='dot') + g.body.extend(['rankdir=LR']) + + # input nodes + g.node("c_{k-2}", fillcolor='darkseagreen2') + g.node("c_{k-1}", fillcolor='darkseagreen2') + + # intermediate nodes + n_nodes = len(genotype) + for i in range(n_nodes): + g.node(str(i), fillcolor='lightblue') + + for i, edges in enumerate(genotype): + for op, j in edges: + if j == 0: + u = "c_{k-2}" + elif j == 1: + u = "c_{k-1}" + else: + u = str(j-2) + + v = str(i) + g.edge(u, v, label=op, fillcolor="gray") + + # output node + g.node("c_{k}", fillcolor='palegoldenrod') + for i in range(n_nodes): + g.edge(str(i), "c_{k}", fillcolor="gray") + + # add image caption + if caption: + g.attr(label=caption, overlap='false', fontsize='20', fontname='times') + + g.render(file_path, view=False) + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise ValueError("usage:\n python {} GENOTYPE".format(sys.argv[0])) + + genotype_str = sys.argv[1] + try: + genotype = gt.from_str(genotype_str) + except AttributeError: + raise ValueError("Cannot parse {}".format(genotype_str)) + + plot(genotype.normal, "normal") + plot(genotype.reduce, "reduction") diff --git a/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/NATS_bench.png b/PyTorch/build-in/Classification/SwinS3/Cream/CDARTS/demo/NATS_bench.png new file mode 100644 index 0000000000000000000000000000000000000000..d1a0cd9da5549dd2b57c1b3c4493cd9ccabef4fc GIT binary patch literal 316887 zcmdqJg;QKx)ICUWcb5>{-6aq_xVuAecZcBa?iSpGyE`<&2~Okg&_Sp3-qi1VQ#Ico zFmtLXsvA!Cz2}_0_TFo+eIu0=q)-qE5g{NTP^7<#t3W`&0w5qD^Wb5@@4$3kXoG)! za8Z#Gg{TD(AA?^&TZqVuKtMFaBfS{IfL|jxe${q?fFKF~`|}}w|Jn=!;=M##Ttv;& z;A{g<3456o&har0N*P;?@w~(- z!*T-$Brt+C<-@_n!SmMcL!3YxqJ>CL{(Dzu!1l_TzQ^O^=5x0n3tYs12fSPk#(zg- z1}_Eqe+DL-lce~62Birw=D+j54h<3fcYb0-B*%ZIlapg$S^Q_ZxHvgA;J@=D#Q#5c z0nVO4MyWVr#{YHXmwbc8viM*BY$!jDObyWb-$qYX5`kP!L;e3Ue7UGNGI&jm|CjN{ zTE?7L@c+4IDLDT>*~D)eDhnKX0@niEwK`ESjTS~XL*ww7y~tHO7ejBwG)~t5o1w}d zXco#&EDpe%S9nU$BI%xxW4GvmGA)D@dVO5~efk2E{mOEU8hU!o%J0tpJ+!Kolu>y1 zBIEu(7~$XavJCJf{Gy7qB9mzKM>JouZ_2eQ*ef-v!YbA23r)O)L8(l!DpXO$86XcK zq0Ors`XF+Nu5JA$UKyD!)#l;#l->Hs69ily*U;)OcxN$cvcgSbKxJeWmWyc6E0s*D zq_&}ON|h2uYSoXAHeSNQDNOo^R8i4~gKJ2k(VzmkeI3iy4vr_3{J7=-VR2X39zrFG zgB>zPMEf9T`2%2@%2Pwlf|IAeIm1EBSu~&qN~uo454!0%XnVZMY0m)rr)Mh*M&d4I z&q#poq0v`?0MK5N2x~-O)`}%Io=b$V3o}IT6A6Z(8J~MzSNK;uqZFVXn_brxLpUN% z3BG1KCVk3nutTN_ZAByw)w8if4t0uxls?-g4vwkS_?+1`!<+n{s8pqPYc91a9hg-5 zwD5dG?G$Ep$l>V7fWuuV2No7KX57GZ4`pl?IzPol+zg-JON<$ainu%>Rn-t3XEE3m zvE7(XuAW{_hC`Pu%7`VC*1+~sR3)l=Efk=avOFV;9<-1deX+*;($TsDZ)x2t5gG?B zeqo$fgjjUY><>Mxsb*nT@{2zN4XB)$egdtMU%L6rNq@oW2ho_`C;CME=7CWuF%54rqq<>a8zaQsGYxb`iaqIQ@CV?sqX0)v& zD&>HeUQY*yuhRU{2yeqGZ+5Cc%MyB%HHDbYtN=|mjdXNV`_$Rd5;P05Ok2e)tanHY z?wP*#RXAf%lq&qIr4!5Ub3W(<(w!wcWSiLzeWe`LdeJJx+^)m;Dy3w_?>e?caZtln zGobk&OfSMd8AH3C@A*X5j3Q&=Y^R% z$A(AhO?0UE7W=xUVWNjbN_)44vkg2(dZ(_Lt&rupJ6a_2^L7(cdS0^ps6@*3(v_%5 zcGP;gerGX_x0d=3bSmxRFK%i>sOZwX0jS>Fwg*X-%X-vL8}v zb?^euJ52i`t~2=e;gHXl32F$_#6ASi?4x5}S#y32=x(`ROGbCMA}V!zh0U9D&!Lz5 zKJ8ajG-LtCTIhs9i=9`#>JBj?mlqXD@%-r*585}N7asN|e1*yB3*V>PtI<9fqK3;Wgq-dhXyw(uh_ypS;N|ODy|Z34C))^C&ztBb;H7PZ1!o4Psf}>Xx}j_kYyO zu5i~d^jxR3?5cghIzx)#Wi4cjqQ$((U6qn~B9RqC{+X?+bBJ}bQjpbGS+%jU z?}CbSoF|_VY~lpRwm&J$vNybsvp8Am*rbfxIrf$^1u;Z%WrqaM)RfJv)V_86VQUQk>B#zXFN!aB@t4A**(*2WVLg8+$MGC7T zCb}?uIhCJstt#Pem1GO6y6BaB-o&DFElz%XUH>f%+w3e*xbh2YPO&C(P&hbBB=3d< z5<8W8N5-5GsS++jSC#DC1(nu%W>hR$phog;!w>#=8%Z;Ga+bX)W(xh(zV0rr7~ zAoO7ov0oc~`-kJ42m9*$FJ+;%m`|iMV>dkFW0@Xw(z4w@4p%t((D=BXsoMGjZuq|K zQ-R+Q@!-0aRBW z`^Vf}hr|!>S(Lwz$LuQZ?zO$AAA2$ogXe*zzx-iQX-xb3_K)w$%(bh@ysAQj2cJlJ z$8U;_#|XMOP-8rMEFfN-tsi8+XTN{T;lRTuX(l0`@SYPaHrwp4pIa}C2Lr~fP1&2S zWz@C?mgekSWc)5_fS#o-+==z>x0^&eE5STb?6 zGee*FO2QXqa$bKY)8te#1A9_`Z@GIBqvJxFA?G-3XNQKTPo;K^B3eCNjNXcKuJ4+v zaT?i(J$}eqT8&hx&`bB)$9}(N2R~6q@R`;xejN@9)vT1CD4OY9|8A{uwW7i|4uu3! zr1aUJ3{B@9H|=e`YHRxuqj|gJ4-Y0bty(t{wL{1EL#eQW@`ZLQ7crV+e)DDb;7_+- z8dDYJ^5=(;GL)1BObnIOM)nxo<<&&QQ}&1TbR!GcSNkc0ittyNx=r3Kt=#aJTAjjO zYT7-G_*n^u+Z{yhwFyv2!)qRfGO)*ac}f}eDiucMb)V`M92%Ht1FZEX$iip7i)Ef1 zMQ)hjzfaQuno>M_3ZW3kUAI_1DV}bjrwOqFr!Og#CS`9OD3|mR)uqzMvmJN-U?9`c zFTd4HM>bOG`?m zCguX`Yl^wUPTxK^NhcVr*xe$NhNZM|mtbPw%z@sfr2MU`Hg}gUU1obll-u}mhLv=s zy0v!49=;KdD?XZNp`eWooj*a#4Fp<{l9`?rylVF9g^d7!hoS3Nr<^2f03lH=IZU-{ zhwGyWCtIZB7-ui!CphOZrGj1a3}37K^Ap>^zZpi6EdxQk|0z5v%{e?nrWD1CD?>2O z#*but19F~KhuBnqBSvFI&9-AncRFk1+HnJMC*535|POQr^11(XRM; zWGUZ@iyPMMN%a;M$8!d09|TGYZ~T0r&d`?T}UCreuK!20A_u zv@sOzPuk)dy=JxOP#YS?tfi$3T5+dK1LVu0=8inwmX*T`6JeW>X zkF36<@^f@$jno4IJNsYIevk+&YfNa+5+rv=J4hD#$a78ign&V=&Mlw{@M4Nki8pl+ zBug;H_?zs{gt%J5ss|r77u#V^F*CVTGfgbjx_)>8CL+8jvl{#x35&4K&lR@kd|!9Y z3Epw#u4Vf!b{A``k9Hz6Nfq-_NYu~FE42XTf9<(6$$nbwvwm4_HH6Ol)0DUK1hG7@ z`WxAufMtgdo3R7WUPIX~qcKazeglV7sc*zIg*W-$kE>(95~xH{XF_Ogr6SW4ehWv2Wbt6#muWMrQm$(Lo%Ihe{(;Li<&m|lw6QG! zQn2Hq1q2)TbWaa0GjBG2<1uO=OG-`tq(iwe(B<6`r$~U<^oBFT{t@5F*;5+(#N(GM zaQcEbJrEy?>ZAR~z&tXk>rHDZd2&G9LuhglVd+~te5~7P69RMj=gXed)}5(Ffw$;q zrz3&j)`r|{)0*Qx+BcTiy=c&E?NBD>LsC*ur=<8D1RroGiZD}wuHT9uVlegXf^BWh3>uEA2 zz_xUxb7MnE=_0Jp(BKO}J5(-L@sMiIBtlQ|jQQ1h5He>57s4oTu1O^;%Hy${dMScq zdNVBOWSo4#V<|`V+85C1ER?#;RujbuG`t8F8Re~k#_&5=^K4;9_i}@x!^UAHa|y(# zQ>Yz%3NXy{-}Fx!$~<4VbT8Hw;ai6c=tnZ6ba!PgxU_V=A&G4y@Fm-L8_J~K(bCfi zP)m+DiR*5GlYGXssHD+SGn~IJ;mg0R&QYYQRjeYfS*8x3DKM>=XZ#z?r-ZUOJ?wv# z&#{ZbC7rEvFOq6lXs&l26P)!O))&a@&S!QiMb(dlm{tn{`cEL<4F@8R80ebuI;Hu- zMHAXA@!}O+5yb@*olS`I$M`+h>3eW_bcdRks&XfQc!K;~?Ob6hr&;q9vd>S>g8zjw z+UqlXkWA_naS#KfzkjCxUJI0;awNy1Dx+Nv(v9fn1{RsyV9y+U9hEI zv249LCqzew*4YOhs57~oiovBKi3wWAX|?fy2#b}UE4jJ%qeYfYasht4e^)Q{@9MEC zKf0vf(CI;F)3Af4FkW>kOb zxbS`cy&Cy&-i!Iz`WAs8@R5M3Uk-fkfUq4_#q-nvFi0r;3li>_*O&DRv+G%0qX&L_ z(jZ}Xpd5)ie4|v&usRX_v$P3JXIC=T1YwtUX%|k=3F7fHG!LilJv&q+zYo!rb(hW> z<^|oM#P^~zN8(n~6WC`$#MNeZmAC2K38Onc8yb27ypccsbo*L+v}`YwQbSm?noQSQ z#c*zzhoH}wb*=w9~WWw=^+~KABH|GAy zE|5PfjnU?0L`8jv_@&Y6@Q1fM`(}=Q>})QSa#<9M%(J>!H*Pnp)2nuu!sCH5^2NIl z)~ha$XsmNjxl$(|KN@lTzEs|dpiijeOCy#RhZRInk6pyc{=`6?w^-BJI%)C2Szq&4 zpN~)0zHI^U!iva}@$T}ET80&;fbDA9nTsjF6Prg>$92afygbJH)HM%>}3mPbCX35BW zsV&e4&SGHr)g(E2iNaKT6ykF99#x9_RLI{ zbCnzGdi@bS{9N@XrRS^zsaHN$7?ksS|#f1{E4?}~p}$)cotjBE)KG(QFewy?)!{)d zL@qn5L~35qg4o4{B8-O#fu|K{xgJ2DR=XC2GFfVD*%{@S9{J3$7v!*<+Gg(l%Ay*{ zk@!UN_EA~H+rTD%b~=C^ppC)_4zbu9FHer(KsNTeub)0@_pBa0@AAfcWW(;?x|gW4 z7da9%?#(@I)HV+QN^@*Ds?+|+(DXWSt75w}eX@*f{IQEqF26|I2D^QT2dhc9w)h+I z9~SxdbmzS#6O&RE9U!m@{UPxX3Dg$J!9~u~B4$t*$ZK5^pmhIY0lk;jUwj_sI{LB` zze&rO{Ge<=92`F^-P@2Fo12Be;%G8#wD35`nE}(5W*Z-hS2R>yAFq!Bv+pKX!x)>T zx-eQ)rUB@swf19Z`wI40-k;gIrSUM7HLg%kbvsY;xA=0P8cufMM&h%0Ri*63JG%_< zEkCmY55KP`cr^`&-34NFBb_cmq!xp=P3r~NSFzu*u7E>`$hDWLa|ASPY2weJct(#& zbnaAuls2K}p9_g4UtT2?YjOgV7rdLC6XS+UxR%QPb3%r0C)w%^N$-x7;D((~^4{68 zFM46ZsTab+iy(TAd9hV-Yy0aaOHIB|kkW~e;r1hxguld=qop^rrGjqtsAiik(K7CD z`K$AIU`0~7PUWTZQ}?ANn`fqkqKo2UM27|0+d%ij9Y`!!Lfp8CESEbI6@FU8dUytO zHau33)4OYnp7sxgr2~`Q{pCm0UoPf9R5^^w2&ao1j#d^VRg5N-T5i#EkA12rcCvF* zOz}t-QD%p?u`h|`b!ubp6k1nZwE=qBbfT6T;&UYP&VTKSrTXwkbtcu*Ao_6yfn(BD z*7j?TnfcaYAur(^M(Pbg^`QAraL7NC51i$T+lVY1n#Why(RrR6$1{CTe*1I{qfnC{ ziQyOYtHn(h`kpW(QucA%IinfH955=AL-qO?+@w#?<^3Ax5q6IO1{IutL4{yHH?y29 z)^#by+Zkomcsb=GL1Oz*Cb3W;1*_kI?UZgkylmQQOe%w>(QjZr*dmZ$cxmC?q7Fh- z8;n8Az%ID)HuefkY-dtr-ft$B#z4N9#X1KHv7Uk&PaDm$+(=lL8y~&rSDtF!ZsL#DnWs>!R{iBzoyTQ>hJ z9wH8Z;*bJkxygW;q@6>sWhUhJ;c=+-|@87z5 z9|Zh$TM1>&<@+Mu^k*k}Y4u<}IJXv+Z z-EY@r16AkxI}~_ByNvO(Wm8?SX|5=$RWc5zkXTZ_hR^%hty7pvjIOLy~iV$6?-13!yL9nUgqiAVp8vMrg$keta2 zQoZwN^ahA-0#-iyd&##^$KL!i?Q$e3?;SKKJoiML$Kei3#U!@*%2cQpz*>Gxf5N_+{r;Ecg^-rIr6p#@k0M17`cM4!>tvWEdy*1TNpz(i@$p_Oy zgktRa@PT{0 zzBA0_6Q$}`?$!q_XddWu*3^fH{=!S&rg32jrYWvYw!!;c=)H@2^%%k9io9ykXy2@s zC{QM@4I?G4nkR2vn*XXmdMU#d`-TM*4S>^xCA6SLL|66pVXaSCo@$4akp@8AemT)u z0j0-flcSBigKA_5l(uDvJKchI{%sXq`ykBc!yK8XSLW{2PCoC)FuPQuzVp1k`s&YrD*t zoen|}gFUvVLMPkYZ&5FVy@SdWKLR(;iQ2r6iQhKci75ziLyFo;cmNBY?Hw>TW6p)+ z?6>o@6@%PGx#4OUxV^0}plEl-O`FpGYVR=l+%B?ZlHLTY)X}^lxN}mo48O?6;3FC) zV2;=hzR>xe)#z8!{NzYPRutH1mG^X8oBei=3Vv6{Zad@S~m zIV=b9FrU}+QT}5f6 znQt~^e3O0>z~59Mk{DZq>748SVf)#s^be0`4;Ae`6We+FA|-3K@oy57#v62 z74kQlQUgvomsQhVpxxcvwbYMj|8x%w(Ei~1o4|_g);aE~W+QrpFqlg>_f&AG{X3-$6`i z6D`4QiTrq_((cVP>N5>LM6C6t(|U21gt+plU#=dFQrwejG5QJaaZfh2-sPShVxLIj zP_IKpl?q(*KOZc2n|AW+8vny`bV>^beRvvvbBTzJDh2&X-IuX4_d6TPES=MNjieCl2s}wI-C4r(*a;%y41Rh%E$*wH6PP(UG`N+};1Yr)Z`X=<~TA1 zqnh*&=YL4LA&BWU$Q#k})d5$*h4i$yt0l!w%1;heZrn6&j3e)$$qeOr`2e{rF2k(4 zw)~#pB@Oplr!;=Q49L_{y+%;lm#7dDc<04Dxb`Agog88uT8)!Ee=DDc>oJp6v=?+MxBLUaX(M`JHqmpRONRb?Hm!0xp_QRCX zK7oVFJ&Vry@_nZub+@(Zb46Du!J=y<2La-}07NuHQe~czwAh9};@E~g)@Iqu3&(k{ z1VUSPH6P-{9__j_jJ@uJZG(Pp4eMV)M9M}vMMGgMr$cuseEaozor91y+|EBqe7wo# z%9i7Xnwd69lv~ZvNWQ8_O5HL93ZWLmz4EX?bJFFRFp)>~a=642;naBBy9>u&da2bf zTLI13anQ^{$2xa?RiP0tq&hSAkM{-x{eVYZ*|r~NWsoS0Tyv2TKLx=lN|T7ae$Jfh zmG3iy&_K0lh0tHhBChy$1jsWVh*5Z|LsmD105iGFfdMz4{-oY@kF=Cd%IT|I8J~T<4y@sYZI1g)rcnE?0?s~9P@r8(&?~#RGl?K$SWg`DsB-I z*VbK<$r%>ri)sH{IjBk&G2^PJX3qsrR^<*nDv^qiQ=@Q~^{F5+qIRNgp=pIVEe5U$9uBq}uE6wqQy5BRNMkfs~_PKAF8DdI(RXPxmP*AZljpj_he!2;`BA*0Z zbU&GntyE-m`jWU4w}mVpy945eGQW~I!3V#nSisIU#oEa6+tlM`hYn>1KW?NAW!^lg zsj=yaO{rl#mP{@Wa)7C^HZ!w=h@F&t;AgUyip$7=tKSb>j5r3D zr{U~~*MxSQM0hpR#bfSnEdzg*N6Ib5k}Dk=6(rhOdrJ2NZHa|ZrFP)8ox+?>!CxGn z@XEurF*=QQyY%n~E@SSeVu?*Gv&~fM4})zy!D;chXVbcr3!H;`oBBoQ^1y`+tgmWp zau8*9T{o{$oin<&(DuK3OU9BxpIw$GX+f>IbCOCXu8bofRl#e+-B0?bU@LA+!({0*q&Vq!Y^WuK`(X^z^} z6B3Y4Nld4p$`jl?zNrSh{1aB2X;V4j#_RS%7p5H4Xf}|jbPZzWpvb=SRYh_r0~fW+ zi=$10i0B{w;P4=0sk5~tre)shZWl9d* z|FQgGc&Jki#fu}+dd^bfV#nunFy_|^j#LqQLz742cUIVt_Cb7tF+V>_ofAb^@v0X? zaviR>syMLKLeW-+Z@1iVT=Ys?`|=9FG~Y}ljs^(6$@9pU(Sf}pnAB6|E*8~0TfR?F z86N)GAR+z`{YDflBje&yrUpbTnv9Exe^~l`D4R39b15?XDIG_$ZcAPc#YEvn7++7$ z!~fgWSqswA>1+#E#^Pn1QAEDzdpq$@QOoC3QwEBMxyHJ}gcyco`jfJxO8(cd)Jxfc z3JfaMC0h(VNTDaSJaO@S!zO%|rkT$hjlD+cBoQFb!0SdT0PyW&h>0@+;^PxZi`0nc z3x`%r+1%r#V5f093W*%|aKOC)F##~0U;d}(1yb`X*R+~8cRdG~$2G&GmvK^4cH_6# z`qT46l|o5{V>oR)2qL&b@Sk$$1UQ0cyg1WJQS@4q`d)P7nZuKO*Z^KkX?}5i?Z}Tf zH(!GxhwZ#mzBE(Y{i@ZL2YDX^Nrft8be!Tc9(bW*PvLyLGtn)>On^ zt{JDo&Gh*^)lFtIS{6wo5k5Tz)P6(bmJ4DqVS<2VahIw}#(ee>K)M;WpZr`bkvcG@Z%-`r zptD7qOwWw`2p}D4*-yUi#Z6VFZN=|mG24M6FPae#O+VG4$nS3obgqkAF)|L^ngZ$l zW$$2{ZWAI=;uCqzdL*nx*_joqKdDCy%h+E)RI~EEN06-%O*I^r6-d@Dgk>g_p_&^+ zru*9v`4AyC^gfCQrUW>A@CtH|kS9f2FxJ93N^)k5B5ZVg+||Pcm&LFbC*3S_XN-p0 z*O5qg1e<+~g5`xYfpWe*4wi=>GP|%P!I^8KuNOJ}S0^csRQ0|n3k}o8>1*K!!P14X z65$?V(T@w6UNG(wk^)#3CPv~jkgEX>WQyqSTBtGb^ELCu<$>B^fwRhMWJQdO43q$q zYbggS-5?G^CO>0$-4-f|?6Pf2)n8Pw@ zfe!6a<$BFv-54X>7CUezN@FA;nDhslxx!q@ak*wStxU>8sA1?txlS`8ecGc~X40^7 z(W0|p3zZgs#?!R9>-{(ijo+{2kELd#+d0MgOZh>d`i;41xONoDz8}~$!Y__O3?Kg% z1hR$`ba9giO|r=QrUQuM0z!7~5qvrbU2_%(1gjz&KOb5DD%7$uki@i*SNm^u?JUG@lixX4=&iL%F4bTS;}Lqzp!0^q&z9s zE_f{zW7rhEJh-j-kxbSzA{ZXvB*EG7`HS?iQZ?te^;rYW8_kA(P-&Q|8Q-(<%B)9A zzK;)<#mQG&YnoiucC;WSI7#A<+f+-LL%X$U2Q}>f#6PS)d9(R+PNiMZ+FY)^EZ=+J zru?cf<8hB3W^{mZp**7&pMI@DElQG%|GK-)G8Gh}ypJ{S?}l0G8vF8nUbb)Z!i%h} zsbA8kQ!rKWO81#u(jos4O)H{%eu@%6+;u4#*_cG(bP_F-6PeG0|D_m24c*E(!b(*u zUs2s1mou^b9G?I)WeJq~<4fb6?jAN!MzQp{KA;zzT?%FJKA%wSo(CiG-aq==>I)Id zcjw#%>dmi=FFLY)G^74#Rla3nu^a?TQumL@==)!h(O55U0L%KsQA#`|9q}WxeqZSA zXoHs$*Q?2rHn$UX-td)Ay5r7(7x9)L{vxM~iVc7V%%-LwoRq8L8xBs>a_=#&!Bo|* zaS19Wh5V}0yj~v?6ZY4YdUfFqFX9)y0IL#59K=R*DoCOh#V%G1$76&83$u=CxwgtO zl{O4cG(jcW_OI=UILEQVi~uW~csmlVXhR#}y3ElHpmC*vkqb>77!y8)d;G#(SzVHO zb71s!LkV>j1{O6d6`&3t#QkZ$)-ga1e&ZH~3m6a%R#vNxJgm9aE#Jke0D}Xg8@57h zoiQs=5H2LgY}Rbi?Het7n8C36eBdmA*TN!(jqW2&m~|=AobT2-vg>B~^+~$<+>ukm zSX2SHjB07|qPa7Cpl~%OXPV)h1G%>;vSQ+6G^Ayy53DBkZ~BOj(b7(FQ${JXPs@Ge zkP#b$@NVR&+@L^q`{i^?be{5-_^-sJdMle#1B}l^e%>rWdZl}_1@$9_l8kJ zD34z(riBFSm1R~9y+c{GL*|W-$cOje9`ZwhlwBZGR{CR$kzbSmh3w;b*@2o=J0&%; zFIPu#eh1mO8dSOSO*SgM^HsZ&f{nsorGX8_$qdkk2U^cdZ)Md_8*DL^8BY!se3~$b z-e1hkzl2dd>U(+MzLX4QZqGtJpJgWu*}J#Wq&~8?rny7J7L9 z>Z>_M6r8r*YD93q?EOmOjxI*uA!<-gkfzt_8nmcHJwov?=+lLQHeAJ{T=Dn;j74DW z^6x0jR&%xFphmU564n=S>Z0tgULL5{$C7(x*nGaQucl;I0$OuKdYvy?$gu}hhI!v_ zI>N2eslNTz{(ThcB_|lSG5st1Z+IG5mI3UqhevojKi?&f`m9v-#+|UYgY>i1ZcABrUGm z>m)%PX=5bC1e`b2@apMQGMNrRgwzr@lpE*_FABYTVjG>PSTQo5momej_=b@YJu;Q7Iq+5= z@>32=?tF3ew)Gu8rM zj9g)f#80l=EGsURaJF?^aP2d}vHEDhbiq_G)Fgh5$HD9o&3Y3PYf*gJ-AGn7YfmE+ ztBH!49Wm|=v{5@)d~*oC8aKob?XP9KNfk(afBjYUc&$Z~@m3DR^r6I>!B- zLkehD!x`WMc?%O?8 zVw&V%GD2qzVTJm99Qp=u?EHVv+% zrSZ8&26Rcw!dEuIilAq_-PhZQ$M4_ugi@7?z17uf3vyFy+TwW-@fab{Jb3n;mA^2L zoTLQ6Rah>uc3U~#f|I<@tWIguUGFs|oQeh5Lnbz`8_5H?=H`tp98sVs8XTkTTG zTHdsiSEd)CR$)SHw@}sDLSExSl+rFCb>9N3$IGg(Idl$2Iye=gf4ds^f=ZJe6=*>1 zld8$QCK!A6R~2tePqEq2`O9|w7sBztq25tP&v$#v(GA}!#H}ctS=Ee zV=h#fLLocX`}+9W6!+6i@>HGT>4uIcn+#pivP(QmoGA#T=no)v_t@%0{vv(G8%+JH z$qFCOduG&eT+=i{>Dd{_r)9EoI{8ORhIL4ehrHqLUzU`=@h=yo8$6%y5FZq6zjvva z37YA8y|Q_4>5C5$EyScEfY2ZC(>-FvW7lDEY`qX%|LkL5bbE*MA_;YX!~%qP{1h2Sv&)y2|^KuEFQCT$eH{WGpj@+vHSbj zknKk)HqW=vS(6cioNl}*%QYwplP#g))K{$8Pjw;|MT{&jQkR1p5uU*rW&tlen75?V z&wpE{Na^Iu-ywYTWX0r15!Ke<$l!Uv_jXD5ZCOQcvxTmdnsLR zFXVb!F@CrhaUtEhK4ZH`3v{7kNE;?~|47+)r-rACjw=Gy{ z#U1HlWaQTh+-8gg%KouK?oW=a&`nR{auw?-e01%mEWQFR$0zcK$& zD$;>?YrUe}%s633?QqE96aw$MU-ze+6R$K+Zvi^# zTe_TJy( zzKoN7(Ed{*(>Sj{M~wWTlxj#0Qv+aqfzrhE@af42beJxN{%uUP10(2-2VV@%UChV} zjh9YP*=OjZ;2SR#6qw|}T@+Yf|BTgrnjREx443tre1tImr{#(ZB6ltt7rwlGK#q%e z%xtyQfrD``j0BEcBbYGI5U%;rUgT#3cmp};+`QtzPoIDUJz*6qdkUrJ0|0)Y0 zpYvwfJR7Rn^caUBz~m>M)zciN6X(jL=P$`s^0rS#`!>5D;K9M_0{NKWb#HLTp@QIr zJxQ2%C`u9s@OGudQ#Rz~RwqV{P-b0DKsOacpdHx5YJkgxfc6+8mfZv;SB=x~dbHv6 zIWOa6P}VnWkV9Z#M&6t{F5)?{la~-pJN6c%qCu9V2X>linC^OgNf)#N@Sot-%hTp@ zLoaFWX+^&1WaHY*M-*u+f>o7>k{H{KN1##NLY=~wYN6TMon!G+o)(+WbCoQtwEOk` zjDRm(gr~E_h~N>5c1|U0vWTV zS2mTA7utUvmr1}o&comk2zH)*e^q^_2Cm}^|5Y`=W|7ue)X2566JNScVd@(*>?Ak)SVhvjmM!^(EauJKh-l zSm={sKp-6uy{3L)+U$P+p3w$PNnKT-QB@!(^F_~=vuIO-T=Zq?^y~Q#7-`Z0^e1X! zhpq0>@C;r`N@}qZ4Y3kAQBgg{qT)?5_J97bah{k`O3JeLRty=a@@5eFZF+rgR+%o~ znVNic>aA2|R3hpbBP`)1_ zO?I&oe(;q6-_<6*QBn`tJYL%IZiYyb17!3x{X8QAmO_p8JT_(vCGPV)@6;#ufe~uBYFW)pXqZOu!2*(Ht^%!wG=F zM$JcvLAO;AIlS7dNkv0$fEBI^)P^pqfs+&m-ytqW#YViRm9WZ#04(XI4X_>LV`tPP z@Rp7BE`;n*Y?4rb{mxCMvA*RfP6#)Wa*Ksa=BH^Zh?&HBsJ0Hqdny|0PeNwzo8&L@ zwB+E=6nwED5tZ~0zaUvH&_C?K=XB@h&hxhC?zc$#%bFT;gOyj6E3GQX5u#0?E*UTG z${~K=F3^jjS6mo5x#Sv0{?!}GW{AYLzFL#kq2le7UzuNNH<$0nQYG?-8qm5gX)K7+ zY@$(!S*KA*6@RnLOIiAUhmQHJ5sgT*u0O38uxr(HeXBfQiWnawDi;KjQ>P*`SXU7D zRC}VMQcrB_@c&e~KOGr_Ls(qAl7}yJ;}b)|^AT$#zCS|bb+$^DVSz4lnRkcmR-Kp{8VrI^P;$c z-A1^E`@`QLrz@rE4(smA=?gy|stW>U;?-D`UdGXhtq0%~$EY}(6ga0y^lCzZ#>G9m6j=V?S z;7;On3tzz(4~Q7>xi*MKzs%oC zv1D;a_ZM9+a+FN6-|CC_=?J=FG_7r@xVfI#= zM58(UdDL)0J-4?x_qFdd`F3_rww3Wa@o@O74L61exJAq8FCNI}P<`?8V76{QO44@* z-Mvo&b#+Hl+6Yug06$-jny83RLKO3PkqmKYsQ^QMq`p%oeP;jD@Jh?E;Q1(J2pS7b zp+oP@^yYfawxq7Owl;&%Q{5EAN@#sHAbO9BIJ*7&U2JkWA|#Re`bZ~ulGx5X{p`uf z$k|sr5Kmr{J9|91hn#iZW}HrG#DNR~2S%QCEtV>SXeE=z?}63f)b2sF_Yc zIgWh)FiZ=!$9fNM7S1YFm>#o`!vX6eDW5ZYL-2T8{V@EG<_Tl1H3AJQ zl4y0uN$+(Z1~T$nc5;SI*(m;?FxzK`2HKqzW*HKI)T`ogbKy)64(2`IcKH91R{hhX zdxy|HnuhA7vPq1UlMOsv=2j41>p|{<%bBmaJ02yI?4Ozh{Q-4Ow_o9=wI+PQJus2;8Hl3$!OdA(A^8V$fgp5L&xzw046f}oVC z`(M~A_D;+}wOP?xO{D^1(lDof-|5)yvN0D=N8VxlKgYH}N z*=%e{Ij@`)HVZYQYUIfraQ82r4&N?5m$^|!j z47djA8WgU6x}IasMN8|QPa$d3;F=zT?Ik^|jL7$*7t5SEDzK?`aO0?#@a%kp394t( zlOYY&@5__dZLrxQ)taBdQ=r?T3D^9^PW;&&dDL|uGh{=oSH$4DQ?+IMKS#lpUQkDkl#k0HZv3Y3 zJWT1;RxxczKM(a?4>BYt^?H|}kzxYO8{o_3m~nt*T1uY>ieTGSw)hzqNIEH|L%R2> zGE^i!X!qN%n1KkgF~R(>_9EmTP6Sdi9-Zn2bUk%6wz{;Yu=MSqQU(K=-e1c9G+6xb z&A)F?M8UGi(j4ft4KRC%YEbnCnPPPYY}CWw^f0wDHC&9rih$64|7jPSu4RHLk#&M`CA@#PuGo5 zw7EJ?RUvz{xt@LMHqQPiO^sISivbk5Dsph$8iV(so-e$}B9HzCO#aY6fP45XFf!PXd-(v;+7ysfOOAsRc_?;omC z_MP#C1XcPS`lOZU*ND8&Mb3-=kc6(Y(f>RaVb&r!=1NwVwM5r1g+&9RJqH@z8LzEl zj11m+@1ZuPbYsM5I5GScD9O>n*8XHnBd^IaozX7@(_XwMr>1=N&!kvxdbHMqgvmn7p(#;D2`J4MQc2 zux|znt$%hCD=ipO+DROmQUj2;+*J!6UcyI4Z~UQF_fp~(!D1BVm82#W3Rg3T9JkTS zb?C{GJyYOp;8hZ!v#1|aP|*h{_m9Zp-={zHU`x-!`?G!3~bAIx2S&zFDVQAAb!0?TmfaCU@jTHlbK3L`8&5G9S>Hy&TV{#VILREu_ zhW5o+-$X?jg~Q&u65U$-Z50wgw^icR828^NSQO2K{yi5aKxBGBLjri74PE7*zLve$ z@)IwE(s-lAL85Ww-S2%q=i#xxQ+S`bxttDGG1lh0Tg>BU(s@-ka{{fw;8+b0OWa^q zDf#J7Zv*Wq+R- zw^W$bAKljv%)mS8MefHZMt?miDjIKtD+Xt~M)|+rEv=4rydHWQk6ob6f1lScvo%$y zsBlsY$T$ZLivcdkhr;@rD8-irGw9 zB2Gw2*H(#~*=2FexMh~Vd(!c+z=4F}>j?}T00x+LJbyl307iB^;X$-gkLZ6f^B(ZG z&F=7%T3ZH~Bii(2S=!4Td;A=F>qxv~a|}eb9BQVE-_{T_1vTb)Q~8?^1}R>U=%}#- zk73cQgWF?*g80x3E@_syo+#MqAK&ugJ`igki>lo3y~~~}hVN{?2&}NU`|(&NVt_uN z`4$Zu8yG;GUlZ)vB5N>AayH*K_)cQQ~k$pP% zUoCdrXPg1pO~czOdI(xSK&5)AoHU=$r}CvziE-WBHWNJ4Au0hOBERT;oa!ranIx6f zi}XUU%;Q91RY8i&KblN&RO%QC&Sn)1TSVP-TY_+YFe9Z84r}3(TvA03>L|5+N)BDn zKlQ2Oo}kVx~f7piOIm#^HEoUI`EnK-0b#E&G{zg$d5g{iJ+oSZz1%q2--ycbu}j zB-2q}(NY+0QjZ0Q)}cZ_lT^imxCgZ*Q$L*UR*dRVxSUT*6i_x#ll|rB4pin!q)w+k zd|a;hlu8)app~>1ASyLMK06^kQzAj$R??ou8eH*7Mhvt&w~3!VEx~<60J|EOcxtao^EHdW#c?4qi~ z16hF4d_Mz^lJ1MV=R4+=;;(|Y%~If-^xm^!UwLVcxkst5sh=-FKx`rcu}Sl)m%$3b zhhgJwD8RMTgp6 zLURA?2r)i!5?+Yn;Kq^Xu;-_WHEGx|1*3`c#>j-5d35G>tA%|!=h+$y+UYS=845bl z-LYClV!~7Dm<7A{P(1bfZ%0xOTUmmTW!}(z?oU4;-&I`J)^nUsIoA|Izz)3cYv$JL zjJYfnbeJN3pP-PFhDE{f{_E$T6an)rTihC}Joq&{p&9+vnu!=|sps?f=ULdU9pJY> zga&g?wMIRAvZe!^_pM-zYAXlRkhPE*JabjXvE&~b<5oA56eGV@G&;9>0T{*f;AQsIaM=K_9M3110XvJpNdc!`!@4a>4= zoK@>-KMr$f$p*WVJ~h=l;;2%^0-8W)m?sAo8dX5Hpxx62JK=h+hoYh0$uvAbQ@HrF z8O(xr+#l(%BupeS6Uw4m8ZJczP3W6?ZLwHHVP4=IqWnym2!Y!TsX3-BF582Z#ECE&s%3&dvdf)+oNUBpVr)X| zo8ABwX2tRkpVyC8arkLh{5%3>!9%Uk6&BO(VFyYOX|NRN#tq0E(wqLQlMG7Z%?@Ok z0@2X^9wBYZs)(a)WT3)+eJZrm^67&<|;YE{oOVr_Q>*7*-p6XOK`f3<^M>Dc<05$okWR7maEAsy4fzTA6oF_#=Z z&A@*Imo&T4sAmOjAF;M0#EIeu=qJZ(WCOeQmbnYQOa4RonV1t&v3IVYwf>?Vk-J@z=6H zvwFTRNz{3CM!5QtTy(T$2TvG%s;H|l5GK6^8Mlf>)n^L((qpq4qUMDW1rSOPv~@0H zm3Yqi{Q>i-##{>WFlZKKmsdAWksOLEgqdPtZ90@MQJt6S8O zRrd`L2QR-6c<9;foD`oU8p5ESGiGZ66bnH3+PoNgs{tgmV1leHeU$VZKeZA;TRk2< zz9z9B!q|eVJ<0Vp*)}eVYN;@6cItmNka6yz)~#|aDE?M#<5GkCK-lgWp({)_4$fD?P?8bwPu&j-5pdKsT$vhX`phoQ_ zxD4P)1Ur#Y?g)wWz)?}QhmxPjx^fBKgsb~yPP+=M{lr9x*#&sWzoUZnvygEJ11MRl zn0lIdB6$bNb;VapcgGqq7M%9Ny|eRlyVI(iAKRa2+kWvkbu|y>TRWc^7Hic*sUxMe z`#J?IN^}GUSqqDHlMt&y)==XF+l)J7onej-rHm_g12n-651hV6E&!)%iR|~u9NwN~JW{~TI2g9a0 zw36;#sGc(Tkn|Qlm}MpAvZmj5mi580lIK-}wF?&ytY`u8$5e?fB@IBmnP}RRykr}& zoo!xM`@@XB>-MHeaZl>k6RJ@Y#hzKrRjG-?uH<`8vlBM}ebB*(Z=sxL{O4DXlMPp8 z;(K2g>K^TtK(!zL&%4}#xFu-cNE=M^0jSC)2Y@S3^rcWp5iz~Jw<{lGJb{#(e8gFH zVwUVcb8`RmJ4`GW>lUAHJ2kC`JaC1un@=7Fl}l{HEx&1j(HiiWkO=RKpv!A z6g+={sk095Rsrb{ZV$n>hZV*!QT@O=#u-6QwuZ#Z11xlKSeT5SWmT$oDTdNn(1<6= z^#>MShQ1P^MH*4e=uG_l=)PFaH4t|tbQM51UjITlG;f0tt+YsU4b+H&TwHP0cMwGy z?>#EkYfAp$P;3l$TO_iTBkX^_5W;CSEm+NBff`*3n;hj|Ygi7h`btLgEw~j0uSZX|3jY*wA2e~@H zHeT*R;m%=01$cl(I+0tsZXgaTWXn{=@TJI!rF9MT$1obW!WfRE1wz7M>7R8#CUO{I z3L1XJ*f520#DSL8m}i8H$scJO`h0OVnI&>-@{B(OpA^uqI0NQqVX5un=k{icf%>?+ z7*L>9O8Z#EAv`$p#AG^xs8L18b0nEMPb5_RYgMDGRuy7APmAp~?o6oWo^H(L^s71F z6FyPtVmjyG64RoWtl=gIO)ItYT7*AC_CT~iwHql{GG2u2<=%MS4Bm6WapaywEEd`I zgIhwFz-*5N6F-|Xcx7d8ce)s{=r&%!M(a?XW?HiL}z+rw*JTv^4Am|NV8#R(NqW+QL9nPlGk(5;i5C7s=VylpElwXN>(2+b7G9W3O6}rXNz~cu(Bi zXKN6WXNtlqbKT|Z4TV@wE(yr#mxE(&R+Ek?288hvTHs&nCk9fcP23l7JxC|s4J)uP z$zReGepoZC!aj+Gwcn~foVJzw$2cRTP()(jt%u9e=0}~o2&{)U@CN8UmSIhN8bLjK z+~v6}&_ae4s5@d6k;@PsbLA^+^&r3qW_YPOZ^ueJ7(bOXff^T?xH333e)GtcsxpKn zw!q`nnzx1Ew8PNGKr;`wz}3rD&PUGOe3Hgs-iBqD!S%CToe^+h;NX<#-TUSUKN8#< zd+Q7h^=-()nimJX9jAMdzL#y8D^{3`UHisF?SzS=!p2!K*4|F&tmlczVGp2hl*3PU z^>~Un4f7IzOt4ZeZZa%_5Dl-R*dZ>+f=<2oE}B1XcX|2{@4^ zmj#PYW|oRx`nEFGS=jU`@&Pj0|F_b5TnfLuN&LguYr|Z-eyX(y0(qQ)Y7Zhw3 zPt5Dr46w+9qu(9inyokCK-Tl_q=A>w{ILuawSE58-4p%7^_!T0ugVXNF6ZwgFb8zd zvNQl$IY2)sfchM_Ho^*Gl?S{^wY08S%Nhd0nIe1t`5gURm|ims=)*w(adMSyX-^3w zbXw9hCnER>E|oc@oP}=|{n}fJpkA)q4gVfGUZPOU_?ktz-|*IEHHMXdkqK03g9_#F zfax&c);=u3C6ix?osEz-$CN>0n^MdTV@xCv#I(!T;ZG#*8hm=(G$%0Ne7kjJiPD&$4LW7ZW~*6r|DpRQyhvd$jNBGz2Z*2 zGvEohDS)%;+yM;{Y^h)M1~F|gnXN)(1N`Hf;Y1!sPFFT+a!qBh-AW_9D?DDL_9VcT z{XGjY4ToE+8XlTK>78+fM2loy{fkpEFuh~I1_BvsP07Z1 zkMd-^Lfdjatt6HWO92H;)DG4AQH_S3*0`=Dh=}zYxNaKIM8e(a}2`yjqLy27{_Ip;6b<==*M4PLAH>OK&E93yu4% zSG7>=um}->AF9F@XQ*7m1ZCu!wM-o zJ1WD8W_zJWD2m1`+(?6{-w?!Vsi$RT)qo`U>lMBmg;$_wb7PiB?qk$Jtr?&dh5Mkgka396V(DgW}5io`7a+k|KKu zL)Dw_mPNpS$Bkm6(X)BHMucoL;Q$vSp6g}G+07kwe;W&rsT6~0_Xcb4*pT;MvL;i2W}plf`K;f<)_yY(=yXs#}@c z-Y6?U$gEPfkqbv3IvGm!wo-!`_3?oDl+&zZL?3KjcLPPhGTWE)BY$JcXDy`+NTuZc zFj?my>18QFVo>IwBgc)G{%?oDT2H*`Ad0tYGO9O?j3{UjNeLW z7N&kB6HUA%p0&q3OYBT*towbG--bwiL$$Sw8&BVz=(VZ( z+GnjofDZR4r8v^rG1<|*7%c0$B^7_4eQ*X9a!XRb z2RY2sJtqhggk%#F$W#5N$uhsB^DDkYvQ{?)hi=a!g zSJ!IFM#YuRB{g~lGT{hRAz2m6De{-ViWV8USUlgVvx!moLT!B!MWa3`gzk!|R4M9; zERP@M=~FhJ+Ui#XdDs`RD?Exs9p+3~XTxtRq5x~ed7rcvy$z9VZ*sU&_1)dCZQ090 zXVO}QuT{PHJ$)t8!wy38g$B5XXBA&h@SXIXOg)xQJVAGbe(&Yh?H!Pj@ndrkJNLI6 z>hy=wvo{0H#)>kWX$57b5^aWsI~23rUxnZ~qGg7$UfPFnQv9&g$2VGf`Vtp76&(qK zXpnG90;eH2c0y?X+<%Od7^3KBTJbz`^aF7@!z zk>=Ot%+;8+b%vztl=pq&b$sL@#9J=7ypjj6EU8&X<93~+3fXkno_2ZZcbkdIBkF&J zmTl4+M;|#?z&7QITKjA4z?JZR$5q9c&sj|(6{nmjAgCQp-SxiXdsKUN|2vJkG3B^Z zV~zmN80D8G4q#sX$YgYzR(%DEA<~on;{&dM=~LB*DosL4bFM8!Ys&E!Pv&@ge+-8f z`7s={I!@F2tt@KG$Ee+>0JRCjX#!dn;Hioe8L|0Va#^~hc)DFq_m8oaxcVPydVIv{ za#g<@=QQAAB-vZ|_ATz1Le=}DIScmIv#ymBI&v9D((D&}HX`gZWiKMY<&BZeG2~{# zpEsr4VV3W)B9F-ZclB)X5)I5?1n%KU#RlgKXTa>KvW$xrKrInJVsiNaUxSa`ZMda! zmMovKlvu^MT&&@pHv;HsU1=Q{ecoOHYlTA!gl)7`d8>8(Dhm;_;HqzWPxcOWPk8a$ z`UR-6wU>Tne?Hb)CF^(tR&alT>1CE>K``xPZ|b_+#LR}we=u$yOkyL1Ax5ItUwehP zp>RwLwe}j3_EO?(ZkrQIODKitM|~(&$gtH-kkY5P&U(3 z+=AIK%PO#i^Y1*{&9q5%74ukuOjW6X;#x$am07^Wfti|$XUy>_g*8q!moo-)w|%G+)FN-Nz%xD$^z$u8xiiB@68WMCbB*})xgf{^f|^IUh)zDcNqlCRJi zuC=hkxpfY#r0+e%a=oNz0h_a<>^&fb z*hd4TQK~{}FLG7aLpT?UnPu_!!>-j1v%HJ2nfY65!ToXQr^bzhR=^waj|0Y<_uUtt znpMfkby!OnW+EO7+0=Pdp{_nBFB3&)W3K*GGriiYwcs2(eL1BN6rfHY!ENYvBB36k z9zGU+6eVj%=+9$ZwK8z|r^rZUTEjJ4tk{V2E<*ApUgccmahJj&Bj{mo(tukliQ93S zl-4xEO-dl3W0in8eK)@>s${krR#vGds&sP6xPpA@(V@sS$fYJng$9(d7m_f+@XK1y zcsy1>@f?-Zdca+$YXkC1PH&8#{6@sZiQH7&M!D)bY#Jz;cuZN9x0EzK*MBeA;Y*AR zlhpXF@c}lnR>g{oF+{o;!B`o@hna|k3ZwZ@!a7~@rY?iP5b9g-p~?pBnGV0RT5x9n zO+r>-Ac(gehs|geC9)?Z#|~Rj$@Tfwu;DcEsF}jzv*llsL;mN;cjwirRtERqG15v* z>6^z%XNXhXnW%wLw43ND=eib@&Zk+v4BTzD2*PDmM<1*gG&@ZdmU@}Vbj){SV$J+| z^Yz=;tl;PYj5Y2q0+N@^5}+%5&nYgk+0M`(`2s#X(P0SP5qGhG zrIsQM!w8Sxqw(GD2Cuz@h%Zhxk9~Nl?pvo{YB|_2ml#($UjLh8c)P?UY8F??I8S zfhsW^yl6%_D851v?w3}(+bDS3+n5uw4UCAMBV>$Swx{SDLET?`+^U{(4`cud)6J0M z6ky{~g();;RYyu`;8*u1ft==aAOIS4-oyGWTFHJnb`d@jg^2HHUc{@+UbeFsq)@dcxRK5QgG6X<_@yE{7j!8zlR|on7Q5DDe*$Am z>J&~{fp=0oM7BV)+Lsmj#+-BtaHJODf|;fkJg;M`j2FN7w=;QXBQC~;WeHjB{6ry$ zwQRQsc3HS$CL(O6kx?A70Q@SR=?ZL8TG3#)s&xiUC)k&H#?|6#QXBFfIR+`FZ%>$u zzSUL|z*}A3QQH<|@;zs#_4N_#haCSt!mUOFJMawIzVE{0o2ysyLV1H;Frr5qx9KWM z8+Gt;axL;6wGdBqCWBoFrbBa$b5bhDKO_Ia#;(FxEZzH|feTPydZ^{}^R~Kbb$_b@ z-Xw+6JzA&Y^)p+PGx{7u95@>&SM)RXfHi`VD&cF4eUj{nlfY2SM=k!0=OjH%4~`%K z70{Rt*PB(G>jpD#vmK|-`|D2IBLtpfd-ZE{wgdY5nx3e+w)rv9WFt-U;z#FkL4A?Y zw5}urf-hMfB_MBD|+7*$LL)*;76?2Qu&z;mlvFR9>-h=q*k=$_iSY-I3 zRGjYecl`&iRTz=fVGAqr5pkNkfluG2WXV*}s-&T1@e$}@XVvV!_A04U>Yv_^;2h#A zNfX5kM7I85C!Ys^Fd&$m8#BYJuXC}Xy_$>_@vA9p4C6I>%};nunmu*rKI^;Ob3xcZ zkC(}rLT3W^p1oVx6j2BeDF7g~0-q<^Im2q;(uL|J!U1y)#n*^kZ;`E}iCb#bJFOF7 z<)|TsfiTX)tEJD9O+nvYE>c+RZ<4lEmEPCfk96g=T78_lZZozY1#}AGWZLaHA%%(` zW>PI0ma&~!u|+h^bY*$~(TUb-dy;0SoHUlzKxE*ZVeU~diy06-jt~pt2Wnh*PcVzg zaR9e(sPg1BQI*UPz#kka<&{Zc1OjH)5@$-TQbU}K;QMcy;Gqu&y{T0iqvAY2Tax!K zSkslK+TTI-n0M!ysWr(M?LpD*Sc_iN#OF6Ct-!W(Ot9Ng;_B_e9kJy$eHQXcH%T)P zF}>;@lJ?pVHBLS9{h7o$c>c%JrnHJ!9dAMq1`5jVv9o?`-6Cpfn|`-&MThio!& z^VnPy;w|jX*q}t}EyLkRP8m$ww>_i zqMYePV-@>sANh{e7-_p>@t|k-MD%tAZ!lRN8i(QYq5DEP3LSM!q*PBdXXbWHve7Bd zB2Hik{FHjjKXt%}jFw>Dy~?qoqH+=)%<`)sO;0sO$$z(tF#r}_`imQ~;gZY>|ucmMO zeT}cZ$j>!}H=b8qI%{2IbN4q0O%>%oFo0Z3Hd7VPCP2S@QFUmXW2My6TUwe%Ic7p* zZl&beHVOAo;kXTB4_EBX45>+sg?@TUm8H!+1a{bI11dHDJkL8I*l+-gyz@kYG)}kH zw-)whA)&pDBR~Qhi+g)tmv6_((QdoZW(@St?rH`5HVdO64ZG&#ht}+T*2W-mPt4*8 z{3G9nETh#EWFC9;o{03I;Ei70!`*0XK6_*+$3Nj66Y7z|SfpgKAuKpYPm};E8PUPeu9_xy_*n7%;tLBU90>S^iaq+{vpPk1&Ae z3qe&jno$vS;el#U?;7_tKR}ce=Lvi3??6Ba`z^&rkq5632>QUvy#}v92fAE0%D^}N z%53l7Ly?S?vzi59(y3=__I|YATY-BD4C|h%AFQzKeXHSWQ7(Pv;^gY-78^H1z^eKl z687$><4AmDbgcr+C~|rzcA+Xv zy72~0vG)#p5n4}yI)_vBDlL}Kh#IbR79v9K@xRj|uMKk9Af+*xt})NWTGJW8&A~qa z=YX8-h^1iqhMIf>|M6Z<#*pCwHsf_I%xrUDlLwwU=pr}jk1!*r#Y?chf=aqO<5JG( zNiYtFnAJ}IdW5$|!;Y-2R<|gCzY>?B7{$mpB!yX|k@d~c3Sb9<3f0eV{Bw`C<-T>o zZvcUSGe4APcE8M39ea!yIB$?1;kkkk4@ zk95yu;%ZBAbza6E2_*^@Tn2V9wCcgVG-PrX5g;++crObU(NyUf`#`mqGq*EuW zpZ+t{`Db;fQgVf{B5sf(HufsEn7VuW(CNfBnD;En`=~}Tag29GbQm6;pJxGoKYW*= z2$@tIX(}_)06;}>BO&o}KlIR!#Q_Ul+ZXf zXt)dkQ6>0#b&k^ty@CB)$n&X~CqN|Nv1EqCBPJRkEdHfTO6E5Csy-|1RIK@MT@Z*X@Y@P zqQ~FHQvo^=a8vV*e0`Cw%!p4cvcozyCL7D`-L2l=x)`7A#h(1ie%;R_&>lEfNOCD@i@|{r&bp9=2r0*m z<@iK^Qa%UIQ5`WYh?^U8OL0aLEu(;kaA&ysjNb(e&os9nz=4tbQ^SIzBX8G57ymIw zhS@HdrI+wETbVX#MK3TFC8?SETePF)i^a!sg&Le5y1fw{j|pa}OtP4@?^vkCEb4rb*Bq{cW3D@l-Eg}$oRg}!%%-YCA3=mK@i zCkoI>iKtGP`h#Y(l4$60Oe^kDw_U+3(p8ndp45`W%Ib47#Z5nLJSQ@QfqQ}`dc7xr z*Qo%VWtw-ct;-YF3N)BlRt_tt^7cGd&#)vAW{$6;g4;MBbGNn0QzLN2+aE=SstKG*(h)8=6(tuZ_$7|9EPUmFD z=4)VM_>s120lc7Tmd6V+=7U<<^69n#Z|?@{-#ayW0;TwW{ZjOUC-m{$xy04?Xq(jSG(>n z0h;_@k}6ajKvJE<#2#N3y7y!WW)b__je0s=Iz-F&?aa>CD-5D`2e16rMpjT?^JFcn zh4nxED9UmSa|*LyDbyPI;lsM~<8FA8z_?mbkk?sutL4ummgEw|1W!_3Fzw*qz6=u~ z`ohmpC`fxF`r<23HEH6^s%e?IAuZ+N6yHKZN;8H9Jv6+M;qC|NU{UymlhKCU@*vg| z-5C+49#3c8qw{WhQnC3K!Qv7wH$^7(^J8K-wK5sgd29{9Xs|xJKqI9B}{)vea1f`6DD zXvV1daHPNm1G#zBAa@ppH~y0JeuJrD`U8iwdc=BZfnI_t$B z-zQ*v(Z2A0ABj0tL-lzR)RlA_tXN3eZ3k074&1YiEUjE~o0WwEmLf+Ir`;{nqMPi3 zTx-xuDB(TVPk8_P!@%j?BzMRdYE$UFz9v^)?fW%A`Z3?vW5xxLYtbhie!y8q^4LRy5j1K51M+!0fQC zQt-!Wt&y;ZOaiEv&wrN|vjkZcbz-LO2^jkj2g3tDG?Ko_bH5SW_6ORv<+WYsM{3Qu zPS3Wc!yeFEH?=MF zLWlJB<4ppeK$+divlB=TtiSP|6-c#zibZ<#OjgL(#@gHP3`mWNwDTfA`GjPPk9w5j z^2XJnC}=u8(X8=5lsfz8#`$4+!HbeDFA}~!wjp;tS|q$Misp{;fS3HeW2aRGA#a)`3bxVBgMKHy8rH9T6jovD0t3b$=q}0y|R-H!Jd_$ zJ^+0iSU2rptzYpcbQ^)Bf_@&LeCH3tt^S7e()>M_4P6Y-t_~9HQGiYzr6Qlhru&S`kQSH2w$*dw1I!q$+usSRWg{?Vdp(p*xY&l^C#zCUGJX!d5{JhNYx zW2omh=m2i)Q#wnk!{l$SxbC@2@A38jJk2uk`enh?)j*fZtZ{JM+vxxHG@v4>;$WMW z%NwN?Y!1oP=`M}e74D1~*WQxKEm!UgQ8SmN-;;C?G3Bv^NBH8Lrlx|SIqH&{j`Tg? z(6fr@Ve)rLYyT}0D?8J$;yE@XK!uor553nS_>AcxOw?${j2RAV<$xNgAEp&VNQxUP zP_tskl$G|)I|@shAFEmm@OIrIW`jpBAhca{7yHsd1bjWJ0t}2SQ*Lv(U;}-ma!WNo zakkUwz#{T6@o*YL>a^s^o&V|*;JArS*upcBfQ1Rg^GMGbxoAb0y39cWwg z8{7c8`~!1tZ-Nkv&LZUTWtZz0eCJw-CTdlqQ_9<8=g>el=LWq4l>Kj-` zh(b^6^oYl|SY>k&qn_U)D?pis0$xWB(L!4ILKbjob4Hv#+}dbE4X0X71J%De8T6il zpePkfIJP4SC>)BCf+c?W0k*Y5Ar2w?#EclIHRhqj@_|0`lC3S#Zz#&%eEkgY5M$)- zj=9*8${xvm2Mk8c#+n0jfffDA` z^{E%ZS&z$E&mIRTg+TiP42_L0)oBw@`&v@?oTv1kPRFd2I*pe@lqKq{6DtlKF6NM% zi=*YlnOrnOVDqBKt5zSmSR6l6%o+V}d=Cf~yxsSib}sJeK*jcEQ1Z#6ENP|s)oErF z<{zgSW=2CHfU3TPT-s2ZaEs5tcL|E~Mo?pVfHxZI3nZ_i|5y`@5fOSImLZU2y36bI zeqVxMFK;8fE50_XD;~Qjg3E7Bq3{6jgNznTqV1cW;Q=R5iwmcz3#LGfNh70_@+{jV zrv2sLvE-W*^1)%F8|E~{fdRlsp8^Wdf20ZICE_m)n7ok$OYZ%Ldxf_l|E9RA+V-w9WlNphxtAxKsx$;oH5h^N?@^|p9 zHCN~do+FemPyLrRv&St2_Y;2&P4@~{_0*$Eg$6%hkZWQ7sjdy`?3ec}3@*ffrva-h zILU4?R$YX2j#(5a-$?jT>k2*;Z&!2$lp)h+&=k&5d|4EYe?wSiX(`e=0c9mQogRS} z*@^PoSgu))g7o-_W@!l+?+`>=r_(*(MRsQE-j1W6)s;6HL{CY^s=OEByPbK$B=B7z z&JeZPw6PW1@?Jcnln)jIHh+tF{KJaxwc_Sm@V?W-VT$R%IPXt^UNx^sTE{6B7}2Pn z;$6a0EUK1cDk%bB?j>8sz}{1hASxgaU$XOC&^cLC+|>m}->g9>eh_JSc1fI{E{^#v z(F#x7I@9W|m?~^Y2zKoYy!GDckoO$cfMRW5k#_~+Q-)_?Rxn?`A3pBxwVsec2eoEjX z20gN`?AHI0iRgS#=BTLAHu2@i-PgYl?uChzVKq)TS{R38Lb;_V*!E{e42R+{dM zOfX09Of#GbDL~%|gN`CmGu>HGeq%5vEl~ODBcR_Nwn(ttnrR z!=JaZ{%EkQnn5YRBIZwu$qIEGu~#$GoC_)QFmE0XOfBN-_kM&V6)*FbLFq}e7UMjU zl3&TD+1NS8y?6S70 zgac8>FPL?XvOPOf1Bp?<`Y5~P7PEbKQlLLmah6tn1Dcl4XKMEJ>{Hl30yANmg}dZ; zO!9F20^A{0rtA}l6SSRP2?zk#3f<&ljji7@-aJij`3KB+*ov2&*KE-SOq(}Fn+w6M z`oi#Y#Y5zW!7NM(6(8FsGgig^KMZ`nB80(cFVp6>3dOe)_8c~OUrP6cs@!N|Y{myW zbY8c%*~g5hvD16}XOHd}@Lxq|Ui349;S#f=4I9}reJ$djzz!$`59!=i=Rst^zQvRh zhi)UD-9Ob1Y<*OVE`kb8{ zD=hgGX6Z4U;|0~;%UBUt8nkFuiO(>N6HYAQOuXWxS%eiJwa^NPij5Ea?>R~l@-L+6 zk`XH;Kv^d&!;egO6|S;|m!R%l7dJRj*7N8H^+(S-RO2xN^Q^V=f9cDs;9KoPtwcrdp5DxsSoVYmZq*kpMQvIY&}R zQDKpjmL%EZ&sOK2jHt~zV*2*b%q79l^-wD1fbJ;qPzOH4vDYzZ7^&_mWVQi?U3ht5~k z)^GgNxrHP%G^RsMG0!ggiJUBy%w^s>Rm|MwEF+)zI@gm3)_2Geeo88{TC{_Wd48~s z;6aOOBq@Bp!kzAtO&=(jE#_^oKMFFuqVA-q!>9K*%UYe7EMNLjogXfx4Y&pb1@*By zytho}iP$hYR!tlk!pGp_X%6zbw&>btQ$L-(%MW5-5M|CH?Lfi7@b&wF@lE0^$dkzX zl=8?qrK^Ck=|d>87g6}!t?;KmQ*tyhQOH=nNGGeW&N3@KradiWB-Dop9l)0N7zClW zT|Ww@Oetefk+Ck`o~#CJNbjoWxKG7yB00O9Fv}3Egbx2v)*GJj<-Az?Ef2}N=L^z~ zmJgC1GgtTD?BWz|4Q*T8oq~!`+K%|#%*oSe4b#Z+=(9!R)w#kl8YX(P;2H5X$SwH7 zEnasbs%3W}lTEGW#AgLUOm`uKm-FG)_YT;h<-bWwUd1iK3WE6mSKLCHl{+G%A1uFK zxFa9ucbiBl91z%kxUR@*B|ZRp7+p(yYDX&q0G+dRk2#PlLhYjip=>zBhhNz>OjM#bwBeqSK|sSB zPj^xJHIMUTXCo8fMG7;`VDn|K2DA$7F3!b9ZzP2fgB71U2i-vK`;6C?TH$eKwcxcR zXlEmQp6(}9eLHi(f!go=!9k&(fkAb9`oeh;^Y5i@er!i@BQlJhv{y<9jn$b!S6faK zYPuqI6`0VJ?;Ps8GZOKjprIryD7(B6L)mjVRpw8LC5vMILJiAyA$OvR@%)$OxiBIFT7|H_76VtfB>@tM>5iB== z?W1ADK17<nZ)UQdVlAGt!;A#v0~M+`-g44Bo-c2iY(9u9;Pz~Y3;X$#blB?% ze{M!=b6w$wp;Iv@nj(dR79em$l~Z);ayu$ z-$Q=6n*od`HrJbG?mDr9+TY_=bIyLWTA@c`rJdL0*}nlEuHN5C?q6e?zaO7oNqql0 z#9vJs|8+zM{ad&X7z6hqe-lZb(Th7OYwd)}e~XH~lb)#fU7?+bSwhtLJf-iWh!5djU5$bEny3 zqCJLYsst-gE&h=!gf061ha@fE_LN2umMjEAByPMn7s+c~uQp4FUK9NFXO_wvQHJFR zh~80fM>mbL`At7ccWYbHFw1G{wE%Vt7+vuD#Hh5myTjYY1ZhF*1a=tnZ_qXStb$eS z%Z$zg3WqJXP!bb6U*%if{06Z`H-;)8=4zceab36t#>hsNe9B3c?mv!GpgtV3);_U9 zJ#p0tPd3!Z^Ow^#K*_f6w^|Y_PLWoMY`_Szm@9&1L53u8WxTEh0QR8P}za~OQA$@Z{_S<-3|(UuoJF8BDXb|tF!0=;)4ec$)+^@l)w zGgkN~@U$0qxpT)Cdzs+QE0noRET|`BpE&4~&Yt8$vEVXc#9R}iw3VTf7@DkfED0nSuv8p(i%C(dI1tD136WoMx`kodgQ1Mi6M@ zg2ift1_W$>D!AIU)K0wmSQJ2NEV#dG1hU;GdaOS(dK?>qh84Kkj(C&sE?2(B^5cR7 z(NC0(e7ylAq46?18dh56wl%xYA1Ry0j32d~pU8Tc3_cNR@q~LlFGa*{sI`ej-v`8f zyba2}Q7b$Wqf%9jG7B%)~P+T?}uHNbjz}VppEzFY6-3mQ$&E z0pB5OjN57oL!o7u3NJrH@FSQ6!``6-@)Cd1W(wWmXy_pJn)b~EPSz5(flcbQF`Xh^E0u*v`!|6XOf}cJlGaA zW@&LUlxsv`2plCwc4+AYZGJr>8FJ29ri*W}SzM^eBMyDPtnx$!&(>v}ineWbI>+s? zyYmnpMDZQJVD z9jjy8w$m{?wr$(Cld1l_nYCu-y}xSJx^?e8=hQwM-`;0`?^V5}9~;y<;ml7e3VR#A z($jz9A@?C}x@(|-ZmLffVH$X%z>BT5Ljwpeal46I43*Y;K&Ww3l!jHnZ(vHjX8 zfM^jp6Xu!JtxuL|HKWAmi7@$B1sGy$8VAMjwpuay;Kg6cO`EiXRPP^&XfDue#m)ol z*)SKms3kC|_A4rofH>na(#6~~r}VdhXp((fe^dEcRt}V$9pL-``3l|jmfCPwEZEAF z(IPnl`uoUxnh1j5uYQkkWTtJGwFktW!X&(zR6%jB8CSGs+$x{5#DQx*>LvE`uLm&6 zdc`VJG-02)2z_0Z7#-f%VlB5qdks9c68Wg_tZo@D6aio_w1UQYo{$E&JL)c!d!cxHV;z_Y`UJfVi>9$_GF_3yP*nrd*0X{d=SHes zeZJCv^WsBvzKr}GkcpgV0+RP!{B(J8Fj38N!cKd1=2ebup};Mte9d1kAe>n*FJT2C z^_S)|B!`3SigoM-AZNr2Jwjg^qi{R?wPj^^b7n-;c@Q3HpwhOZC%FrXa=fi2-JC9% z3AlGfDDnFY2wNX@hQkfE5MAOFeD9lBh*X-FHW0F0#~x`F*NVIu>0A2Mj!>X^-`;( zS9%5CGD%+OY|r)m6)%8nnDx)@l%l7d%no8XQuh=M&XOJC=hXfnK3h4#GrGB6!4raf z_VEYeeX%V69Qzxusc+8*^ZnG{Z9fwn=nHz3oe7;RS5r8~c4l#KWjY)l%O2B)<10NF z!guXx1?&BR6zYrJH5*TJYASdwDS6K&emS!uc7nR>;=YBZ8Dx; zBM}HaH*ojPKr-vW_?yQ;A6o1Mf&~~(VWiAl``L%HWgw^B?#dz2Ge?-sR4_4z@%uOA zj9yR1ZU!@{4Q>0oArlC(SGdl3Pepe-x>d{s2w^GF*byZNy|Yhk{r+d&{2_$Y^K`|o zA^w7jZrNAvo+6~tC7bAIL7SPHI>g)KE1Lj5+CVx%paV_)^$FKg~MC_^Smg@LYt0-B*(xmFG6qYa-8Cb^~?D)1zopol{H?oc1^VM`g2oOiLobWN|*(rE(T}=Kx z3N?G4Y3l>jxv7nQ*i;2YZDJH)ox_XNVD|T$Bg)+P;yE5yQd)Nt`jJ0k&ySOULP@bP znB28Xz{wHU&2xRV*=UD;;f;oME8b65@&c|~61B&wP#z^_ZXgX)`zztNNL>t|9!Mcy zOWNMgLA+lT(Ryg7v7WArTV)g=IIM}UEW2KF{?)l%e_N|J-=0)8{hou5}Ed# zh}@fHx)$s8VbT48q+?ws`O)0O#EapMX@27<9mj7JlYA+GyvOC90o}kZ6?_hbZ4N-< zgZB^VDg_DyyJnu?OjB-hcL&Kt^KJMW-&f%LCULJa~2PDxk5F1 z2g6Ll%>IkDOyF5%W2@NW3BYEI_hSa3c^N`qHC+)lp$Yhmw`)4KRw!RS!;_xO;L42Y zHW@>-UYmZ}Ntb+g0UfU*Gx<&Bi`@5cEvLAq2sYq}AwbEsNJgXl_-1o?iPel0>XmX6 zX~0r{=;fsie1Bheb6|^psr8Ht!~x1 zA;&;ZD&E%mN$n@HSgOC1@>^%Mxoe%vz-kqg z9-V0LPOANd70Ef+quRvJV(cH)(zwL!WyGYG`)k=sD&P)Fymegc>?DZW#^3{a=>+5aid8Q8n+50ur2lk@$hnc~ z|M-@eb%x&if#H{Aayuq!O_ytD;$s_-EGK#Bto$E^&&4-=%-V~}FKY22_52vJ9TEyv zXW^h)v+K`c0k;#bl?vG*SrOy34z|HyWBNVcqj$3NSCRmp@zZXMK& z2k;8AA>N;to}3xb-Z=XA9as?;S&n^0k31TeMp3;v-W^5Ff&*^JciQhbhHju0*IpLF z`{f+a$!%_l{|+d89$=^Zz@@3LL1Af+E#Ehd(sINB~uZGG4drO8?iTrN(U0*4nk7qBUrSFcfOe2l&2`nRxzcNrX zcCGEnx8Q&u;#Yh$!BKT%Y^HEr(l-AIg9sYtORCZQneIlXmf;}Hvv!D0K1prnc#jr` zemX2`P8pTze2X9PRoMik#61&~NmsL&8=vn{2lc=f1wO&znw?};fb#R`3wEB3B|u@90c3uLCgwA3Ti#PW^vH`8^qY#4qbP zfp*p`H~Jl&&QWy`EklfBU^}OWoEXR@xRhm4WwC%tTV9R*i)65VRc$xT%~vN!P1JIK zY=`AI^+UP8EIWLwMp)(%iwg$IGmTlkSDF?&VyuXeB?f<1;)k0vBaZ?7~XiV*p_)`v@U_tTn!q^E(G*GOO#7Ni^9PZ3p>NrreK-N?y{EELI9N zRDTd2)yB$~J&~fdS6_lE>zT~ABX98)d{zUXzRdBY4*3}U-g89FFKPX)x^Hz(OcJ3p zrWG4OGyKfDjEh|rP-h=Q${y5bx5)h}t|yh8L~rmS(xnWxY@D1S6WCSzQ9|58{$pdPX?U3bMqgn!wiU_F)ZZ?-#8w7ZYPYY%{kSv zr$-F&c;gG{hVWxROeR7v&ntGoCf%Gv-W6Z_1X{c&#S2vCqmq)xP+ivne8V>qN(^#l z>d)#G+x4Q=(yawrLCmBix{7}1M3gjp5MX*5#}0_mivrBI&piz-wq;%jGW>bxM`=iV z5DVyU*XZe_`#Zevn96pP6b%qXrdIuFuEqx{&?S7_kYI-p#N3vE4e6gC zRm$`*qd>WGm$u6^TECdHeV8aNT0zaM8IQK;hyev*?Wjfi=Nq71o%<|~nm8N@#5bFK z_7Tb_*BEnL6bPI+D@{CjZ@ifl0FllH?PGersFM4J$qEIl2w1*t}x+*AswM%fBFBKxUL2=hf zq1%W2@aoQ#{a1OY3V`I?$f3*Wy6e+AaJ$x4(W#M3enk0aK(dhT5D6_@rm5~AKuw=w ztGVI_!lA5T)}8x65@WbrWMX@v!kCdQnw^?Cs9B^m)Od?VRBV_uspeM_6v21tJECW~ z9a#8GZw6YJOw*m0MS^us6_S>>scz?b#dBTj?+h+kQb|F!>LO;4K_QH*T!o<(q@l|&OWi@ zBC7=>fW4T4PfzPi<97E)HhgyLtNajr{Zt>n{o}=sOQfYXc2yPn43{H?n(a!EO~p?` z5eXZ&P>Bqd$x?z({&n{2?a}HfdrLuf8z~vZn_?_hca*^>0>9&)faxxIKyNW#^R?Fx ze^Eb{AB|$(5-K)if*Waww60)ULW`nsM@nqWa)KHaX@-#kpk|5hWM``yDhK+_}7`6}kskKRdaLCpI~W_tkc3cGMBvs%vb`ppr#uJPF=XHn{k!ZqTcoiVjl>g6XTga3Qiv|yah^zZJB72T&@!mp>Pp=@pnJ$$x-qq} zJf9mrvDdz2W+xN$zjUIbi!Qb|?P-0+%7zcy|1FDAIik6q_SAPXQ)vbBBwpII6L)r~hxE50Z$0W2f<;Z$mIL+mt!YFy-H~l2PBdI6 zevZotD`>=pTq>b7TkYJ9^Ww;%mF4VGWt}6u9|59)@u2b=#{!fZC>#lT15-Gp!t8|Y z_jFb7T$lxr!TH)Lwon)RXv*pYy&GW4)bZ|hwsQMwq~Y5eU!{IYfv?lu*yQ|*gVo~P z;b zhqDhCc&+Y}F*~Shm5AJl8UJ_b#LsobBBXQ9so*}(c8|aNBPrE^lS^WH` zGQiE@FZBv9Q%?7N4<{5IVv0L%uSX_|RNFs!OfSvB3suQS)C{uG3(e`+U!P7c#{*N@ zQgR!c5vzbpmGm+4r`(h-R>a`aeAIey7yMw&oib&v0`2}9dE||AfbY3C@0;Y*$mTC(z0|V+pq4YDh0PoR zLO8ngvGf+LaEG!xXz#0AbVx0=;*3o%+)fo-uDR0dWm`F3gYTx$a5ZX+|dgMW`8 z7}NsBtFsX!;MBd`1*W_zj}A`cvT@q(1JtLC+bLgWu-5ND<>XAnRJb-`NDAVg6{YD9 z)teP^8Uz7t8&%}6q5WGSBeZTnk6%!}TrhV?*4RE;WmfIcXcxdnI4`pfo~ zJ3M}f15TsV4Z*os!8-rD|q|{)>Z7Im!Sb zB{UO7LepC&ING7pT9QQgjR8{9a1gsH{N5eZ5__*F%W(p1e=PzM#>oeyjt|84y3OGt zD6oH~7!GW5pGqBRZdg^E3O!FGB&g+)udm&xQphjmj60u$8^B0^+`_c^e1$euTNC#4 ztPymz%6;gA7`7`0P^~mNkR-MjKBF>djZ=?N%6i`(=j1B`^yX(T`}511;5GK1Aw{yb zK{Q(#@i~;+bz-6iR#Z^nbhvC;ceW{D-g_z5EqNgjY?k)90GgjuI;^{Ddo^a6x~L>s zELYuWAX6BulX8lR+%ORojegAq+~p9##?Skjsk~G$yr7o3WSGw?=y90-O9_1ax=Xr6ptzZIA=lm%uMr5qP+&wq@!5+AuZYt$1pY@7%q#d3ijz5!X0?O07mFJwrzQL^ zmmv8>idP2S5OX{FjYw~8AHVuO?}m`_wdO4Y_i!~j$M)4l&`l%!v<0e2Y1LopUf<-$ zt0H6f9IS;ep2<;=gQT9cBEgDq#SKn^Tq)owVaOR2efWM~&!*4I!SxsUUyn74Ft?q= z2Q3W^7Nn)1;x!7IBDWVz;y851ZGLfJz_U@6NNg?XOY{mT{beFa*6Ze`;quj6&;&Y4 ziZDdClw(K&_x80b`p}l5=d9}=p$AG{A5ik{bsC!Z9&KL0ClQ_;<{&0l?VkI+ zHSR4o(^b>)HNd~r#Iw@FT0-;(I!D5e zoD962MQrZO`Va-Egr!gTjK^0BXs*1(U%o@Ws_svI7{h`} zLhFOwM+%Lvw}yrxh-z=`+LtfmkGTwW>+k6_+XbPgXEM%mh`2cfw-ur%-wl6|@bU?C zAo;xy5}TAbw{dmx_E!sM{z*>=N%+UCt)gi9a%LlSFVAy%AcXpD& zpe|+h=h!90QB4W#-mP)8Ig|K%)wy0X$A?30JofGia0QXTNqKQhBceNFxH870T*DuS zm8Q0);-W@PH+2FoRggDQF2o|c1{G?=X(rMFA%_2Uf+?adZSUvU#br{7i|snC^R=O) z26)vCL5TT>=dE4$?oQ^gJ1+|TGtt4j=s#-AjF~6RTkq4t_-I9S0x?TcP7C>e1l@B$ zlw#D!ZE*w|loTbDymKN9(hsB|7GEZYy>+pU$py)nZ25K`j+gw$I%~ny(Uw04hjbx` z&M~8KsGSDCIH=p37?Novxz3(uo%RZ-P2X}y( ziLZx`BIaKXig>fkmkAG46rHfMn9JM^#NoKBjRThrmTcf=e8UfDq-|QtdHD2o^hR#( z^r{7g&=|KI=s)i4^;;?iDIjcjLWWC!VviQyrS4BIxGWsJN&LpFV`L-2V} z;bC*IrABKHIxXUe#<_jpd#}sFBAKFJzMTZ=DOLaz4af8h$v1Qmu9#cdF#N-KFb+9f zWQJU{0xfm;RJI6~hz3kEO)_Z5Ai3v{CA+F|tlid3{sU+f05^ta3=49$4g=E8UeIVY;Rmr`IfOQA^OBM%t$K<1_j zL6iXHr)*PLss$edG1J5hDd0&dSDZB=9?$4a<5*wPrK^v`?L7fXQer+?gk_@sq>-C5 zG?t_)9MAnGj5aGJ44EDlB>#oK6*5no^>^o+eSTK^#|}mu4&#yT4bG@~bw!l#R4az? z+37R*EHRG(C5P<0N~KGA+(LbChSS^Tk_5@O;G%?bicL8VGT?~l zQXJF`K_79Eb^MjJ8iT&?DWG)Hc@SBi!kqIxVe+MCa=SxJYM1~Crj@B|*mj9l?{0;hJVLJ=9C_)M)(1mJr`Yng-&Lc zql(;_aj)|wI-`{#(P=P3(P6*n-0H?}`0$YayoEySr4up|tR(6Ab&2b~JlAQHbk8sL zVo+%@o#Nx2QDr{TCK6PuI-kawY76tFq>ZD-1P>yxLENB%=+_x)P}o?^9(417rYmuT z?gMm-;e}U*4?!Qbqn`saCRc+V_{2|T>5&Akxo+&DZ+S92{@?jT^sv+$bU$Xtd5HV| zNa74-f;sG5D4ts!M8ct(G28<*?lp0LpVqe(RoB`l*EpYxz?>0C7R(pke z?=|6CUA%kKI2Dy_j#O&Gpk`aJ34Sd8=TwVL3~~4}Mwv6_ud;;>zCZd?=z8p@p%VLX zeFQJ2tFmk@Vjl4WX2=UEg*=}`zlL{G8J)hX*{y^mxboSn8!D2VoRa+d>KW)RXOuNm z4|yRqy09U`y}#B%;vfZ}${UwfcSPSUgGUwXia*NBf=zZ>3)Tc2x}vzffgiYCx|nZu zlKQs==9-z?-Cq!f?V$cN>N%xbcD+U5+n@g4X}5jOFkV#+ohiA^eiSzYEdaknUw)Mk z*6mA>o%-$vLKrQQn=TT#>vw0r7LNb)PZiVv^b8bPoRPxgSi3X3esPuTQXR4%nn>#) z%p6U?KBoLhXHqqC_?x=F2dXG1bGm~Sn#AdU#~H_`>DNS%J^=F%UhXMp!7n^Qp5QW2 zSwij`I>t^!lM)p0!;DBT%d#=Kv}HVEV7bepD&!!%C}5-R=M(M`?*G$0`XAxQ&6Vj% zJEpE7_14gFCi7u8)hJciKJl7ZX){WUIAp5!S}9)`BmbkOf!}{9JQ&xxDjE>~7f0Nn zr-~&gKRA zg6XDS9hS}ppMrzV+vsO7*b3)UstLMKp(ga=XsSSboBDgH79FUV!b|REH1_tWF(-uO zKmGsoAe3L#58;`|@aHO67l)4I?}A2)sE|GYqPyLjCI1A9dhp@!r4P&)5yDO2lBO7e z{Daz4VKb4@uAWHN#gE!qfC`M$(2KG+g)XZO)J%@Ic4=RYoWO*9_sVIl_WH;k>^1o} zFZ=Q_x+3(iO%uS-UsFGp@y zx}2z8Wy6Q;Z2^tOHoIRpo)pgOt_RNy@Q-u?mD8xR1%SWx@u(tzN$!F3C>csPxLVp= zl)G0BwY4BsW*(Q8N+QhX7WI8MFOm>(D+4AI1Ri-A;0WD4=psEvG-& zHB-b3;z!fEyKCn#%1=n(XVkYH`m7aADA9xhP59ABh+>!`rJZ>G^r$AzAR^({ii5M}^O zR0<=htc9-tdVRq5I;ItjMz@kev7KaUel$&sq~KUh^vH#Y9^v*S+=FK2`~ z^rXw+iC0dz#$yPDaLIJT8(2PS4*h+JmnUk3%E+GIMEY*0^O8D-U_MjiZOM?6!?C%1 zJQ_|vG2hw==oqgEaG_X|$`!llGU$AI#-14mfiA}m?qi5UYhf6Oisx!hF*=d|{jWl5 zc0Ny=w@2JKbCVi5-x|CNsjwXtPYyY94gUOpI#nS5{kP4=JS0{GkCw4})t?mR^^9U@ zIY|ZIrq-lN%@*drb(WB@dq{zeS9G!1EBG>HBU~fc91p8jTpQFO=dT(ns+?aU0Ce}& zzxZaOt{MxgdgK|_<%8Wxtg56%x%vGeHX90=S#2T&<{j^0Q8Z&oZq4Ov=c>08-Ng2$ z1m{?_dH?YwpiDM#8EfOkMa$?-Zt2 zpF|vQ5o})Z#X!E?SC}Crunr!?a!IY>)ABIY-~XKM_yK^6F*o!JJi8g%t+%N2~O8jyX9;-GRTi*g;%Cx z;v_%*HPy!FThH-mr3`8ZmpL6RQxFwe0vfia%uv9=g@V+1;A)?I4+Lg~Wa5=tUSr4K z&q!e+wb_lF7leOKs2eyiguWh%6tiCh>mTkvShS|U#8#*|Ks@S}M-BVQgZy{t-9kNh z`2C(i&x^H)m?qZEg84nG^>wXzC|IYWw-P$D)~jy<`;+UajVV?IH*yb}dC!mKML5f; z2g@z^^1xv-#Q~_TW&F%wGwdr4R~Gz+CaMr*wlHBZRXtbo4imW{&?!#lCXRQEA>YbD zYrdjvilP1mqy#YSn~R{Pp*<6!(s^@#OCS!2F3kB8O`;rK@ZdMhJk(Q|zn`s@A@ZcK zzJh;g%udzQ8z!E%lS4#rxZbStQnaB4q*v-NA(%JnWT70L4QN7Pdk>p4@?ft1#y>kY z4=b7~Qxc_01?brc$1s!3ZVdnyEOakfbh`BVD}l|J`@8O}vb@eG?~c;h7w-WZ`i1%co|5JNfG>Lkk4n(RWsKDw%X?1Xl_>_Yj&ZBkT(KP$*BL?xb z=t9zH4?LDxyOaPRr1S0);1`iBi`8xo`jXC4s)O)(#gIrwFhIN&a&e1Nut5Jaug6-d zQ@O@eF}x(hvwLWgKo#;F(iihgT_+RWewCGvfr$ zcCTSpASpb4^^1)W>O|;mSKeajj4X9yyMwxx0XG3A!?lJW7@9;96$0{xRj{~(mIW}}&S**of6kqA!q?kuKkSkqaAK>NL_WlEeQ z8POsZpFSkJ#n6=Qsq@PQJV3UgA!=iLJ+n2Bx8;wKHqYKH=TFY2UdPE7$}cCb)0U=Q z=Ipi*bUQVY?ra`HQn8?64%o~XG^x)#nU0|4@-(M`j9Ly}jN8!4eq<=Y?qRhOsstg$siezN- z+^iwlkk(d5fC#e^OaN`X zB%3F3N#S>+7pl7BlgZQEXds?Wer1q50Yvgh7)9Cbi$!Lmk!+8mu=r+GiZG*H3)oA{bB|obQ)9s^O#qEjFZws}Oku4x3 zd-3j&>wsS1EVd#dd5=$0@j0xp-j)lE)oxrUJ>0GQjVh-Tg^#P6ITL4T*HaaAorh~q zJ&o+{*FRU8Ll{~I2X@dEZHKX0%6ez*bJ;VLV*RX!qMl==Jy>e0Q&6$q5S9x$?Ylt| z_35{dR--NZe$z#QkxL^Nt%mkdoehGiEET(<^|c+jv^P2Wq=P(l^^jUEW>ip$Z<6(Rtk{T|; zmXMYmJd(e0`(hd}-%k7oxI!9z)5#7?9$5L7LW2{@U(LJKPc#a4ey-_{byWC;GGKhn zxyNnAGKDDY?!Xkv(`I1R?iW$K(RW(Ib$tr}?IK*-^V=+{n-gM2n5bD^uOm8uw7wYS z`Z`x|Kh`w&2GnI>eFgBAi)H=z(4j7DVQHi%g9Cj#6?UK=xphbp8nH^0Okt`g&rnJl z*MuM3YoCdx>zlaY@9wljle?QHE_5x