oriented-det 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. export/__init__.py +9 -0
  2. export/ort_runtime.py +67 -0
  3. export/postprocess.py +151 -0
  4. export/scripts/__init__.py +6 -0
  5. export/scripts/build_faster_rcnn_savedmodel.py +104 -0
  6. export/scripts/export_onnx.py +210 -0
  7. export/scripts/onnx_to_savedmodel.py +35 -0
  8. export/scripts/predict_savedmodel.py +94 -0
  9. export/scripts/save_predictions_tf.py +447 -0
  10. export/scripts/to_tflite.py +32 -0
  11. export/tests/test_export_onnx_optional.py +82 -0
  12. export/tests/test_export_wrappers.py +105 -0
  13. export/tests/test_faster_rcnn_export_parity.py +201 -0
  14. export/tests/test_ort_runtime.py +41 -0
  15. export/tf_serving_model.py +96 -0
  16. export/val_dataset.py +116 -0
  17. export/wrappers.py +161 -0
  18. oriented_det/__init__.py +77 -0
  19. oriented_det/cli/__init__.py +92 -0
  20. oriented_det/cli/train.py +18 -0
  21. oriented_det/configs/_base_/augmentation.json +21 -0
  22. oriented_det/configs/_base_/datasets/dota_le90.json +21 -0
  23. oriented_det/configs/_base_/fp16.json +5 -0
  24. oriented_det/configs/_base_/models/oriented_rcnn_r50.json +26 -0
  25. oriented_det/configs/_base_/models/rotated_faster_rcnn_r50.json +53 -0
  26. oriented_det/configs/_base_/models/rotated_retinanet_r50.json +30 -0
  27. oriented_det/configs/_base_/preprocessing.json +8 -0
  28. oriented_det/configs/_base_/schedules/1x.json +33 -0
  29. oriented_det/configs/config.schema.json +404 -0
  30. oriented_det/configs/oriented_rcnn/dota_le90_1x.json +121 -0
  31. oriented_det/configs/oriented_rcnn/dota_le90_3x.json +11 -0
  32. oriented_det/configs/rotated_faster_rcnn/dota_le90_1x.json +119 -0
  33. oriented_det/configs/rotated_faster_rcnn/dota_le90_3x.json +9 -0
  34. oriented_det/configs/rotated_retinanet/dota_le90_1x.json +107 -0
  35. oriented_det/configs/rotated_retinanet/dota_le90_3x.json +30 -0
  36. oriented_det/data/__init__.py +89 -0
  37. oriented_det/data/airbus_playground.py +611 -0
  38. oriented_det/data/dota.py +741 -0
  39. oriented_det/data/dota_classes.py +26 -0
  40. oriented_det/data/evaluation.py +648 -0
  41. oriented_det/data/flips.py +115 -0
  42. oriented_det/data/preprocessing.py +335 -0
  43. oriented_det/data/tiling.py +399 -0
  44. oriented_det/data/transforms.py +377 -0
  45. oriented_det/geometry/__init__.py +8 -0
  46. oriented_det/geometry/poly.py +127 -0
  47. oriented_det/geometry/qbox.py +63 -0
  48. oriented_det/geometry/rbox.py +250 -0
  49. oriented_det/geometry/transforms.py +266 -0
  50. oriented_det/models/__init__.py +36 -0
  51. oriented_det/models/backbones/__init__.py +11 -0
  52. oriented_det/models/backbones/resnet_fpn.py +79 -0
  53. oriented_det/models/backbones/utils.py +81 -0
  54. oriented_det/models/bbox_coder.py +355 -0
  55. oriented_det/models/faster_rcnn_inference.py +494 -0
  56. oriented_det/models/horizontal_roi_coder.py +155 -0
  57. oriented_det/models/oriented_rcnn.py +1256 -0
  58. oriented_det/models/oriented_roi.py +1664 -0
  59. oriented_det/models/oriented_rpn.py +2104 -0
  60. oriented_det/models/rotated_retinanet.py +1030 -0
  61. oriented_det/models/utils.py +590 -0
  62. oriented_det/ops/__init__.py +58 -0
  63. oriented_det/ops/gpu_ops.py +1109 -0
  64. oriented_det/ops/iou.py +172 -0
  65. oriented_det/ops/kfiou.py +275 -0
  66. oriented_det/ops/nms.py +202 -0
  67. oriented_det/ops/probiou.py +165 -0
  68. oriented_det/ops/rotated_ops.py +122 -0
  69. oriented_det/ops/utils.py +257 -0
  70. oriented_det/pretrained/__init__.py +23 -0
  71. oriented_det/pretrained/hub.py +249 -0
  72. oriented_det/pretrained/manifest.json +46 -0
  73. oriented_det/runtime/__init__.py +29 -0
  74. oriented_det/runtime/checkpoint.py +274 -0
  75. oriented_det/runtime/collate.py +348 -0
  76. oriented_det/runtime/inference.py +1286 -0
  77. oriented_det/train/__init__.py +102 -0
  78. oriented_det/train/config.py +872 -0
  79. oriented_det/train/engine.py +2933 -0
  80. oriented_det/train/grouped_ce.py +139 -0
  81. oriented_det/train/piecewise_schedule.py +33 -0
  82. oriented_det/train/profiler.py +287 -0
  83. oriented_det/train/utils.py +999 -0
  84. oriented_det/utils/__init__.py +31 -0
  85. oriented_det/utils/config.py +376 -0
  86. oriented_det/utils/device.py +35 -0
  87. oriented_det/utils/logging.py +163 -0
  88. oriented_det/utils/progress.py +62 -0
  89. oriented_det/utils/viz.py +181 -0
  90. oriented_det-0.1.0.dist-info/METADATA +313 -0
  91. oriented_det-0.1.0.dist-info/RECORD +115 -0
  92. oriented_det-0.1.0.dist-info/WHEEL +5 -0
  93. oriented_det-0.1.0.dist-info/entry_points.txt +2 -0
  94. oriented_det-0.1.0.dist-info/licenses/LICENSE +202 -0
  95. oriented_det-0.1.0.dist-info/top_level.txt +3 -0
  96. tools/__init__.py +1 -0
  97. tools/app.py +1284 -0
  98. tools/dataset_stats.py +389 -0
  99. tools/dota_labels_to_comma.py +132 -0
  100. tools/free_gpu.py +142 -0
  101. tools/generate_airbus_playground_csv.py +154 -0
  102. tools/image_demo.py +200 -0
  103. tools/lr_finder.py +771 -0
  104. tools/measure_sampled_riou_error.py +483 -0
  105. tools/playground_to_dota.py +290 -0
  106. tools/pretrained_download.py +49 -0
  107. tools/preview_augmentation.py +510 -0
  108. tools/publish_checkpoint.py +96 -0
  109. tools/save_predictions.py +2350 -0
  110. tools/sync_vendored_configs.py +94 -0
  111. tools/tile_dota.py +447 -0
  112. tools/train.py +2324 -0
  113. tools/train_example.py +244 -0
  114. tools/train_multi_gpu.py +367 -0
  115. tools/visualize_boxes.py +183 -0
@@ -0,0 +1,119 @@
1
+ {
2
+ "_base_": [
3
+ "../_base_/datasets/dota_le90.json",
4
+ "../_base_/models/rotated_faster_rcnn_r50.json",
5
+ "../_base_/schedules/1x.json",
6
+ "../_base_/preprocessing.json"
7
+ ],
8
+ "enable_albumentation": false,
9
+ "data_loader": {
10
+ "batch_size": 2,
11
+ "num_workers": 4,
12
+ "shuffle": true,
13
+ "pin_memory": true
14
+ },
15
+ "checkpoint": {
16
+ "load_from_checkpoint": null,
17
+ "load_from_experiment": null,
18
+ "load_include_prefixes": null,
19
+ "load_exclude_prefixes": null,
20
+ "discover_previous_run": false,
21
+ "resume_from_checkpoint_epoch": false,
22
+ "load_optimizer_state": false,
23
+ "load_scheduler_state": false,
24
+ "start_epoch": 0,
25
+ "best_metric": "mAP",
26
+ "higher_is_better": true
27
+ },
28
+ "training": {
29
+ "num_epochs": 12,
30
+ "learning_rate": 0.005,
31
+ "momentum": 0.9,
32
+ "weight_decay": 0.0001,
33
+ "use_amp": false,
34
+ "gradient_accumulation_steps": 1,
35
+ "max_grad_norm": 35.0,
36
+ "lr_scheduler_milestones": [8, 11],
37
+ "lr_scheduler_gamma": 0.1,
38
+ "lr_warmup_steps": 500,
39
+ "lr_scaling_with_accumulation": "linear",
40
+ "lr_scale_with_world_size": false,
41
+ "use_lr_param_groups": false
42
+ },
43
+ "loss": {
44
+ "loss_type": "cross_entropy",
45
+ "label_smoothing": 0.0
46
+ },
47
+ "dataset": {
48
+ "train_tiles_dirs": [
49
+ "/path/to/data/DOTA-v1.0-tiled/train",
50
+ "/path/to/data/DOTA-v1.0-tiled/val"
51
+ ],
52
+ "val_tiles_dirs": [
53
+ "/path/to/data/DOTA-v1.0-tiled/val"
54
+ ],
55
+ "filter_empty_gt": true,
56
+ "overlap": 200,
57
+ "difficult_strategy": "keep",
58
+ "ignore_labels": [
59
+ "container-crane",
60
+ "airport",
61
+ "helipad"
62
+ ]
63
+ },
64
+ "preprocessing": {
65
+ "enable_flip_diagonal": true
66
+ },
67
+ "evaluation": {
68
+ "score_threshold": 0.05,
69
+ "iou_threshold": 0.5,
70
+ "compute_map_final": false,
71
+ "compute_map_every_n_epochs": 4,
72
+ "extended_gt_metrics": true
73
+ },
74
+ "tensorboard": {
75
+ "log_debug_anchors_proposals": true,
76
+ "vis_score_threshold": 0.5
77
+ },
78
+ "model": {
79
+ "pretrained_backbone": true,
80
+ "frozen_stages": 1,
81
+ "inference_pre_nms_score_threshold": 0.05,
82
+ "rpn_pre_nms_top_n": 2000,
83
+ "rpn_post_nms_top_n": 2000,
84
+ "rpn_min_size": 0,
85
+ "rpn_nms_threshold": 0.7,
86
+ "final_nms_iou_threshold": 0.3,
87
+ "roi_box_reg_angle_weight": 1.0,
88
+ "roi_box_reg_iou_weight": 0.1,
89
+ "roi_box_reg_iou_loss_type": "probiou",
90
+ "roi_box_reg_probiou_mode": "l1",
91
+ "final_nms_use_cpu": true,
92
+ "nms_class_agnostic": false,
93
+ "max_detections_per_image": 2000,
94
+ "rpn_positive_iou_threshold": 0.7,
95
+ "rpn_negative_iou_threshold": 0.3,
96
+ "rpn_min_pos_iou": 0.3,
97
+ "rpn_match_low_quality": true,
98
+ "roi_positive_iou_threshold": 0.5,
99
+ "roi_negative_iou_threshold": 0.5,
100
+ "roi_match_low_quality": false,
101
+ "roi_batch_size_per_image": 512,
102
+ "add_gt_as_proposals": true,
103
+ "roi_inference_top_class_only": true
104
+ },
105
+ "production": {
106
+ "score_threshold": 0.05,
107
+ "inference_pre_nms_score_threshold": 0.05,
108
+ "final_nms_iou_threshold": 0.1,
109
+ "rpn_pre_nms_top_n": 6000,
110
+ "rpn_post_nms_top_n": 6000,
111
+ "max_detections_per_image": 2000,
112
+ "roi_inference_top_class_only": true,
113
+ "overlap_pixels": 200,
114
+ "ignore_margin_pixels": 0,
115
+ "use_first_image_canvas": false,
116
+ "stick_to_model_canvas": true,
117
+ "final_nms_use_cpu": true
118
+ }
119
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_base_": ["./dota_le90_1x.json"],
3
+ "training": {
4
+ "num_epochs": 36,
5
+ "learning_rate": 0.005,
6
+ "lr_scheduler_milestones": [24, 33],
7
+ "lr_scheduler_gamma": 0.1
8
+ }
9
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "_base_": [
3
+ "../_base_/models/rotated_retinanet_r50.json",
4
+ "../_base_/schedules/1x.json",
5
+ "../_base_/preprocessing.json"
6
+ ],
7
+ "data_loader": {
8
+ "batch_size": 2,
9
+ "num_workers": 4,
10
+ "shuffle": true,
11
+ "pin_memory": true
12
+ },
13
+ "checkpoint": {
14
+ "load_from_checkpoint": null,
15
+ "load_from_experiment": null,
16
+ "discover_previous_run": false,
17
+ "resume_from_checkpoint_epoch": false,
18
+ "load_optimizer_state": false,
19
+ "load_scheduler_state": false,
20
+ "start_epoch": 0,
21
+ "best_metric": "mAP",
22
+ "higher_is_better": true
23
+ },
24
+ "training": {
25
+ "num_epochs": 12,
26
+ "learning_rate": 0.0025,
27
+ "momentum": 0.9,
28
+ "weight_decay": 0.0001,
29
+ "use_amp": false,
30
+ "gradient_accumulation_steps": 1,
31
+ "max_grad_norm": 35.0,
32
+ "lr_scheduler_milestones": [8, 11],
33
+ "lr_scheduler_gamma": 0.1,
34
+ "lr_warmup_steps": 500,
35
+ "lr_scaling_with_accumulation": "linear",
36
+ "lr_scale_with_world_size": false,
37
+ "use_lr_param_groups": false
38
+ },
39
+ "loss": {
40
+ "loss_type": "focal",
41
+ "focal_alpha": 0.25,
42
+ "focal_gamma": 2.0
43
+ },
44
+ "dataset": {
45
+ "data_root": "/path/to/data/DOTA-v1.0-tiled",
46
+ "train_tiles_dirs": [
47
+ "/path/to/data/DOTA-v1.0-tiled/train",
48
+ "/path/to/data/DOTA-v1.0-tiled/val"
49
+ ],
50
+ "val_tiles_dirs": [
51
+ "/path/to/data/DOTA-v1.0-tiled/val"
52
+ ],
53
+ "overlap": 200,
54
+ "difficult_strategy": "keep",
55
+ "filter_empty_gt": true,
56
+ "ignore_labels": [
57
+ "container-crane",
58
+ "airport",
59
+ "helipad"
60
+ ]
61
+ },
62
+ "preprocessing": {
63
+ "enable_flip_diagonal": true
64
+ },
65
+ "evaluation": {
66
+ "score_threshold": 0.05,
67
+ "iou_threshold": 0.5,
68
+ "compute_map_final": false,
69
+ "compute_map_every_n_epochs": 4,
70
+ "extended_gt_metrics": true,
71
+ "use_exact_rotated_iou": false
72
+ },
73
+ "tensorboard": {
74
+ "log_debug_anchors_proposals": true,
75
+ "vis_score_threshold": 0.5
76
+ },
77
+ "model": {
78
+ "pretrained_backbone": true,
79
+ "frozen_stages": 1,
80
+ "fpn_returned_layers": [2, 3, 4],
81
+ "fpn_strides": [8, 16, 32, 64, 128],
82
+ "fpn_extra_level": true,
83
+ "anchor_octave_base_scale": 4,
84
+ "anchor_scales_per_octave": 3,
85
+ "anchor_ratios": [0.5, 1.0, 2.0],
86
+ "retinanet_stacked_convs": 4,
87
+ "box_reg_loss_type": "l1",
88
+ "use_hbb_for_matching": true,
89
+ "final_nms_use_cpu": false,
90
+ "inference_pre_nms_score_threshold": 0.05,
91
+ "final_nms_iou_threshold": 0.1,
92
+ "max_detections_per_image": 2000,
93
+ "rpn_positive_iou_threshold": 0.5,
94
+ "rpn_negative_iou_threshold": 0.4
95
+ },
96
+ "production": {
97
+ "score_threshold": 0.05,
98
+ "inference_pre_nms_score_threshold": 0.05,
99
+ "final_nms_iou_threshold": 0.5,
100
+ "max_detections_per_image": 3000,
101
+ "overlap_pixels": 200,
102
+ "ignore_margin_pixels": 0,
103
+ "use_first_image_canvas": false,
104
+ "stick_to_model_canvas": true,
105
+ "final_nms_use_cpu": true
106
+ }
107
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "_base_": ["./dota_le90_1x.json"],
3
+ "training": {
4
+ "num_epochs": 36,
5
+ "lr_scheduler_milestones": [24, 33],
6
+ "lr_warmup_steps": 500
7
+ },
8
+ "evaluation": {
9
+ "score_threshold": 0.3,
10
+ "compute_map_final": true,
11
+ "compute_map_every_n_epochs": 4,
12
+ "use_exact_rotated_iou": false,
13
+ "use_exact_rotated_iou_for_final_map": true
14
+ },
15
+ "production": {
16
+ "score_threshold": null
17
+ },
18
+ "model": {
19
+ "max_detections_per_image": 300
20
+ },
21
+ "checkpoint": {
22
+ "load_from_checkpoint": null,
23
+ "load_from_experiment": null,
24
+ "discover_previous_run": false,
25
+ "resume_from_checkpoint_epoch": false,
26
+ "load_optimizer_state": false,
27
+ "load_scheduler_state": false,
28
+ "start_epoch": 0
29
+ }
30
+ }
@@ -0,0 +1,89 @@
1
+ """Data loading, tiling, transforms, and evaluation for oriented detection."""
2
+
3
+ from .dota import (
4
+ DOTAAnnotation,
5
+ DOTADataset,
6
+ DOTASample,
7
+ build_dota_loader,
8
+ build_dota_split_dataset,
9
+ collect_dota_image_paths,
10
+ collect_dota_split_image_paths,
11
+ dota_dataset_class_names,
12
+ dota_label_path_for_image,
13
+ format_dota_empty_gt_filter_log,
14
+ format_dota_line,
15
+ resolve_dota_tile_roots,
16
+ )
17
+ from .airbus_playground import (
18
+ AirbusPlaygroundCSVDataset,
19
+ detect_airbus_split_csv_format,
20
+ format_airbus_empty_gt_filter_log,
21
+ generate_airbus_playground_csvs,
22
+ )
23
+ from .evaluation import (
24
+ APCalculator,
25
+ ClassEvalMetrics,
26
+ Detection,
27
+ GroundTruth,
28
+ compute_oriented_map,
29
+ format_mmrotate_class_metrics_table,
30
+ )
31
+ from .tiling import (
32
+ ImageTiler,
33
+ Tile,
34
+ TiledSample,
35
+ visualize_tiles,
36
+ )
37
+ from .flips import apply_random_train_flips
38
+ from .transforms import (
39
+ AlbumentationsTransform,
40
+ Compose,
41
+ DiagonalFlip,
42
+ HorizontalFlip,
43
+ OrientedTransform,
44
+ Rotate,
45
+ VerticalFlip,
46
+ create_albumentations_augmentation,
47
+ )
48
+
49
+ __all__ = [
50
+ # DOTA dataset
51
+ "DOTAAnnotation",
52
+ "DOTADataset",
53
+ "DOTASample",
54
+ "build_dota_loader",
55
+ "build_dota_split_dataset",
56
+ "collect_dota_image_paths",
57
+ "collect_dota_split_image_paths",
58
+ "dota_dataset_class_names",
59
+ "dota_label_path_for_image",
60
+ "format_dota_empty_gt_filter_log",
61
+ "format_dota_line",
62
+ "resolve_dota_tile_roots",
63
+ "AirbusPlaygroundCSVDataset",
64
+ "detect_airbus_split_csv_format",
65
+ "format_airbus_empty_gt_filter_log",
66
+ "generate_airbus_playground_csvs",
67
+ # Tiling
68
+ "ImageTiler",
69
+ "Tile",
70
+ "TiledSample",
71
+ "visualize_tiles",
72
+ # Transforms
73
+ "AlbumentationsTransform",
74
+ "Compose",
75
+ "create_albumentations_augmentation",
76
+ "apply_random_train_flips",
77
+ "HorizontalFlip",
78
+ "DiagonalFlip",
79
+ "OrientedTransform",
80
+ "Rotate",
81
+ "VerticalFlip",
82
+ # Evaluation
83
+ "APCalculator",
84
+ "ClassEvalMetrics",
85
+ "Detection",
86
+ "GroundTruth",
87
+ "compute_oriented_map",
88
+ "format_mmrotate_class_metrics_table",
89
+ ]