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.
- export/__init__.py +9 -0
- export/ort_runtime.py +67 -0
- export/postprocess.py +151 -0
- export/scripts/__init__.py +6 -0
- export/scripts/build_faster_rcnn_savedmodel.py +104 -0
- export/scripts/export_onnx.py +210 -0
- export/scripts/onnx_to_savedmodel.py +35 -0
- export/scripts/predict_savedmodel.py +94 -0
- export/scripts/save_predictions_tf.py +447 -0
- export/scripts/to_tflite.py +32 -0
- export/tests/test_export_onnx_optional.py +82 -0
- export/tests/test_export_wrappers.py +105 -0
- export/tests/test_faster_rcnn_export_parity.py +201 -0
- export/tests/test_ort_runtime.py +41 -0
- export/tf_serving_model.py +96 -0
- export/val_dataset.py +116 -0
- export/wrappers.py +161 -0
- oriented_det/__init__.py +77 -0
- oriented_det/cli/__init__.py +92 -0
- oriented_det/cli/train.py +18 -0
- oriented_det/configs/_base_/augmentation.json +21 -0
- oriented_det/configs/_base_/datasets/dota_le90.json +21 -0
- oriented_det/configs/_base_/fp16.json +5 -0
- oriented_det/configs/_base_/models/oriented_rcnn_r50.json +26 -0
- oriented_det/configs/_base_/models/rotated_faster_rcnn_r50.json +53 -0
- oriented_det/configs/_base_/models/rotated_retinanet_r50.json +30 -0
- oriented_det/configs/_base_/preprocessing.json +8 -0
- oriented_det/configs/_base_/schedules/1x.json +33 -0
- oriented_det/configs/config.schema.json +404 -0
- oriented_det/configs/oriented_rcnn/dota_le90_1x.json +121 -0
- oriented_det/configs/oriented_rcnn/dota_le90_3x.json +11 -0
- oriented_det/configs/rotated_faster_rcnn/dota_le90_1x.json +119 -0
- oriented_det/configs/rotated_faster_rcnn/dota_le90_3x.json +9 -0
- oriented_det/configs/rotated_retinanet/dota_le90_1x.json +107 -0
- oriented_det/configs/rotated_retinanet/dota_le90_3x.json +30 -0
- oriented_det/data/__init__.py +89 -0
- oriented_det/data/airbus_playground.py +611 -0
- oriented_det/data/dota.py +741 -0
- oriented_det/data/dota_classes.py +26 -0
- oriented_det/data/evaluation.py +648 -0
- oriented_det/data/flips.py +115 -0
- oriented_det/data/preprocessing.py +335 -0
- oriented_det/data/tiling.py +399 -0
- oriented_det/data/transforms.py +377 -0
- oriented_det/geometry/__init__.py +8 -0
- oriented_det/geometry/poly.py +127 -0
- oriented_det/geometry/qbox.py +63 -0
- oriented_det/geometry/rbox.py +250 -0
- oriented_det/geometry/transforms.py +266 -0
- oriented_det/models/__init__.py +36 -0
- oriented_det/models/backbones/__init__.py +11 -0
- oriented_det/models/backbones/resnet_fpn.py +79 -0
- oriented_det/models/backbones/utils.py +81 -0
- oriented_det/models/bbox_coder.py +355 -0
- oriented_det/models/faster_rcnn_inference.py +494 -0
- oriented_det/models/horizontal_roi_coder.py +155 -0
- oriented_det/models/oriented_rcnn.py +1256 -0
- oriented_det/models/oriented_roi.py +1664 -0
- oriented_det/models/oriented_rpn.py +2104 -0
- oriented_det/models/rotated_retinanet.py +1030 -0
- oriented_det/models/utils.py +590 -0
- oriented_det/ops/__init__.py +58 -0
- oriented_det/ops/gpu_ops.py +1109 -0
- oriented_det/ops/iou.py +172 -0
- oriented_det/ops/kfiou.py +275 -0
- oriented_det/ops/nms.py +202 -0
- oriented_det/ops/probiou.py +165 -0
- oriented_det/ops/rotated_ops.py +122 -0
- oriented_det/ops/utils.py +257 -0
- oriented_det/pretrained/__init__.py +23 -0
- oriented_det/pretrained/hub.py +249 -0
- oriented_det/pretrained/manifest.json +46 -0
- oriented_det/runtime/__init__.py +29 -0
- oriented_det/runtime/checkpoint.py +274 -0
- oriented_det/runtime/collate.py +348 -0
- oriented_det/runtime/inference.py +1286 -0
- oriented_det/train/__init__.py +102 -0
- oriented_det/train/config.py +872 -0
- oriented_det/train/engine.py +2933 -0
- oriented_det/train/grouped_ce.py +139 -0
- oriented_det/train/piecewise_schedule.py +33 -0
- oriented_det/train/profiler.py +287 -0
- oriented_det/train/utils.py +999 -0
- oriented_det/utils/__init__.py +31 -0
- oriented_det/utils/config.py +376 -0
- oriented_det/utils/device.py +35 -0
- oriented_det/utils/logging.py +163 -0
- oriented_det/utils/progress.py +62 -0
- oriented_det/utils/viz.py +181 -0
- oriented_det-0.1.0.dist-info/METADATA +313 -0
- oriented_det-0.1.0.dist-info/RECORD +115 -0
- oriented_det-0.1.0.dist-info/WHEEL +5 -0
- oriented_det-0.1.0.dist-info/entry_points.txt +2 -0
- oriented_det-0.1.0.dist-info/licenses/LICENSE +202 -0
- oriented_det-0.1.0.dist-info/top_level.txt +3 -0
- tools/__init__.py +1 -0
- tools/app.py +1284 -0
- tools/dataset_stats.py +389 -0
- tools/dota_labels_to_comma.py +132 -0
- tools/free_gpu.py +142 -0
- tools/generate_airbus_playground_csv.py +154 -0
- tools/image_demo.py +200 -0
- tools/lr_finder.py +771 -0
- tools/measure_sampled_riou_error.py +483 -0
- tools/playground_to_dota.py +290 -0
- tools/pretrained_download.py +49 -0
- tools/preview_augmentation.py +510 -0
- tools/publish_checkpoint.py +96 -0
- tools/save_predictions.py +2350 -0
- tools/sync_vendored_configs.py +94 -0
- tools/tile_dota.py +447 -0
- tools/train.py +2324 -0
- tools/train_example.py +244 -0
- tools/train_multi_gpu.py +367 -0
- tools/visualize_boxes.py +183 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""``odet`` unified command-line interface."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Dict, List, Optional, Tuple
|
|
9
|
+
|
|
10
|
+
# Maps subcommand name -> (module path, argv[0] for the target script)
|
|
11
|
+
_COMMANDS: Dict[str, Tuple[str, str]] = {
|
|
12
|
+
"train": ("tools.train", "odet-train"),
|
|
13
|
+
"train-multi-gpu": ("tools.train_multi_gpu", "odet-train-multi-gpu"),
|
|
14
|
+
"preds": ("tools.save_predictions", "odet-preds"),
|
|
15
|
+
"metrics": ("tools.save_predictions", "odet-metrics"),
|
|
16
|
+
"lr-finder": ("tools.lr_finder", "odet-lr-finder"),
|
|
17
|
+
"stats": ("tools.dataset_stats", "odet-stats"),
|
|
18
|
+
"tile-dota": ("tools.tile_dota", "odet-tile-dota"),
|
|
19
|
+
"image-demo": ("tools.image_demo", "odet-image-demo"),
|
|
20
|
+
"viewer": ("tools.app", "odet-viewer"),
|
|
21
|
+
"playground-csv": ("tools.generate_airbus_playground_csv", "odet-playground-csv"),
|
|
22
|
+
"playground-to-dota": ("tools.playground_to_dota", "odet-playground-to-dota"),
|
|
23
|
+
"export-onnx": ("export.scripts.export_onnx", "odet-export-onnx"),
|
|
24
|
+
"labels-to-comma": ("tools.dota_labels_to_comma", "odet-labels-to-comma"),
|
|
25
|
+
"free-gpu": ("tools.free_gpu", "odet-free-gpu"),
|
|
26
|
+
"visualize-boxes": ("tools.visualize_boxes", "odet-visualize-boxes"),
|
|
27
|
+
"pretrained": ("tools.pretrained_download", "odet-pretrained"),
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_EXPORT_TF_ALIASES = frozenset({"export-tf", "export-detect", "export-preds"})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _print_help() -> None:
|
|
34
|
+
print("Usage: odet <command> [options]")
|
|
35
|
+
print("")
|
|
36
|
+
print("Commands:")
|
|
37
|
+
for name in sorted(_COMMANDS):
|
|
38
|
+
print(f" {name}")
|
|
39
|
+
print(" pretrained Download registered checkpoints from Hugging Face Hub")
|
|
40
|
+
print(" export-tf Run export/Makefile export-tf (pass MAKE_ARGS='...')")
|
|
41
|
+
print(" export-onnx (alias above) ONNX export via export/scripts/export_onnx.py")
|
|
42
|
+
print("")
|
|
43
|
+
print("Examples:")
|
|
44
|
+
print(" odet train --config configs/rotated_faster_rcnn/dota_le90_3x.json")
|
|
45
|
+
print(" odet train-multi-gpu --config configs/rotated_faster_rcnn/dota_le90_3x.json")
|
|
46
|
+
print(" odet preds --experiment-dir runs/rotated_faster_rcnn/<id>")
|
|
47
|
+
print(" odet playground-csv --data-root /path/to/export")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _invoke(module_path: str, prog: str, args: List[str]) -> None:
|
|
51
|
+
repo_root = Path(__file__).resolve().parents[2]
|
|
52
|
+
if str(repo_root) not in sys.path:
|
|
53
|
+
sys.path.insert(0, str(repo_root))
|
|
54
|
+
mod = importlib.import_module(module_path)
|
|
55
|
+
if not hasattr(mod, "main"):
|
|
56
|
+
raise SystemExit(f"{module_path} has no main()")
|
|
57
|
+
sys.argv = [prog] + args
|
|
58
|
+
mod.main()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _run_export_tf(args: List[str]) -> None:
|
|
62
|
+
import subprocess
|
|
63
|
+
from pathlib import Path
|
|
64
|
+
|
|
65
|
+
repo_root = Path(__file__).resolve().parents[2]
|
|
66
|
+
make_args = " ".join(args) if args else ""
|
|
67
|
+
cmd = f"make -C {repo_root / 'export'} export-tf {make_args}"
|
|
68
|
+
raise SystemExit(subprocess.call(cmd, shell=True))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main(argv: Optional[List[str]] = None) -> None:
|
|
72
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
73
|
+
if not argv or argv[0] in ("-h", "--help"):
|
|
74
|
+
_print_help()
|
|
75
|
+
return
|
|
76
|
+
cmd, rest = argv[0], argv[1:]
|
|
77
|
+
if cmd in ("-h", "--help"):
|
|
78
|
+
_print_help()
|
|
79
|
+
return
|
|
80
|
+
if cmd == "export-tf":
|
|
81
|
+
_run_export_tf(rest)
|
|
82
|
+
return
|
|
83
|
+
if cmd not in _COMMANDS:
|
|
84
|
+
print(f"Unknown command: {cmd}", file=sys.stderr)
|
|
85
|
+
_print_help()
|
|
86
|
+
raise SystemExit(2)
|
|
87
|
+
module_path, prog = _COMMANDS[cmd]
|
|
88
|
+
_invoke(module_path, prog, rest)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
main()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""``odet train`` / ``torchrun -m oriented_det.cli.train`` entry point."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
# tools/ lives at the oriented-det repo root (editable install); same bootstrap as oriented_det.cli._invoke
|
|
9
|
+
_repo_root = Path(__file__).resolve().parents[2]
|
|
10
|
+
if str(_repo_root) not in sys.path:
|
|
11
|
+
sys.path.insert(0, str(_repo_root))
|
|
12
|
+
|
|
13
|
+
from tools.train import main
|
|
14
|
+
|
|
15
|
+
__all__ = ["main"]
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
main()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"augmentation": {
|
|
3
|
+
"p_brightness_contrast": 0.5,
|
|
4
|
+
"brightness_limit": 0.2,
|
|
5
|
+
"contrast_limit": 0.2,
|
|
6
|
+
"p_gamma": 0.3,
|
|
7
|
+
"gamma_limit": [
|
|
8
|
+
80,
|
|
9
|
+
120
|
|
10
|
+
],
|
|
11
|
+
"p_noise": 0.2,
|
|
12
|
+
"gauss_noise_var_limit": [
|
|
13
|
+
10.0,
|
|
14
|
+
50.0
|
|
15
|
+
],
|
|
16
|
+
"p_blur": 0.2,
|
|
17
|
+
"blur_limit": 3,
|
|
18
|
+
"p_clahe": 0.3,
|
|
19
|
+
"clahe_clip_limit": 4.0
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dataset": {
|
|
3
|
+
"data_root": "/path/to/data/DOTA-v1.0-tiled",
|
|
4
|
+
"train_tiles_dir": "/path/to/data/DOTA-v1.0-tiled/train",
|
|
5
|
+
"val_tiles_dir": "/path/to/data/DOTA-v1.0-tiled/val",
|
|
6
|
+
"overlap": 200,
|
|
7
|
+
"difficult_strategy": "keep"
|
|
8
|
+
},
|
|
9
|
+
"preprocessing": {
|
|
10
|
+
"normalize_mean": [
|
|
11
|
+
0.307941,
|
|
12
|
+
0.311986,
|
|
13
|
+
0.297761
|
|
14
|
+
],
|
|
15
|
+
"normalize_std": [
|
|
16
|
+
0.192315,
|
|
17
|
+
0.187769,
|
|
18
|
+
0.181551
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "oriented_rcnn",
|
|
3
|
+
"model": {
|
|
4
|
+
"backbone": "resnet50",
|
|
5
|
+
"pretrained_backbone": true,
|
|
6
|
+
"fpn_returned_layers": [1, 2, 3, 4],
|
|
7
|
+
"fpn_strides": [4, 8, 16, 32, 64],
|
|
8
|
+
"trainable_layers": 5,
|
|
9
|
+
"anchor_scales": [8],
|
|
10
|
+
"anchor_ratios": [0.5, 1.0, 2.0],
|
|
11
|
+
"target_means": [0.0, 0.0, 0.0, 0.0, 0.0],
|
|
12
|
+
"target_stds": [0.1, 0.1, 0.2, 0.2, 0.1],
|
|
13
|
+
"roi_loss_type": "cross_entropy",
|
|
14
|
+
"roi_focal_alpha": 1.0,
|
|
15
|
+
"roi_focal_gamma": 2.0,
|
|
16
|
+
"roi_norm_factor": null,
|
|
17
|
+
"roi_edge_swap": true,
|
|
18
|
+
"roi_proj_xy": true,
|
|
19
|
+
"inference_pre_nms_score_threshold": 0.05,
|
|
20
|
+
"use_hbb_for_matching": true
|
|
21
|
+
},
|
|
22
|
+
"loss": {
|
|
23
|
+
"_muted_comment": "Plain ROI cross-entropy by default. Schedules might override with class_weighted or focal.",
|
|
24
|
+
"loss_type": "cross_entropy"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "rotated_faster_rcnn",
|
|
3
|
+
"model": {
|
|
4
|
+
"backbone": "resnet50",
|
|
5
|
+
"pretrained_backbone": true,
|
|
6
|
+
"fpn_returned_layers": [1, 2, 3, 4],
|
|
7
|
+
"fpn_strides": [4, 8, 16, 32, 64],
|
|
8
|
+
"trainable_layers": 5,
|
|
9
|
+
"anchor_scales": [
|
|
10
|
+
8
|
|
11
|
+
],
|
|
12
|
+
"anchor_ratios": [
|
|
13
|
+
0.5,
|
|
14
|
+
1.0,
|
|
15
|
+
2.0
|
|
16
|
+
],
|
|
17
|
+
"target_means": [
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
0,
|
|
22
|
+
0
|
|
23
|
+
],
|
|
24
|
+
"target_stds": [
|
|
25
|
+
0.1,
|
|
26
|
+
0.1,
|
|
27
|
+
0.2,
|
|
28
|
+
0.2,
|
|
29
|
+
0.1
|
|
30
|
+
],
|
|
31
|
+
"roi_loss_type": "cross_entropy",
|
|
32
|
+
"roi_focal_alpha": 1,
|
|
33
|
+
"roi_focal_gamma": 2,
|
|
34
|
+
"roi_norm_factor": 2,
|
|
35
|
+
"roi_edge_swap": true,
|
|
36
|
+
"roi_box_reg_angle_weight": 1.0,
|
|
37
|
+
"use_hbb_for_matching": true,
|
|
38
|
+
"inference_pre_nms_score_threshold": 0.1,
|
|
39
|
+
"rpn_min_size": 0,
|
|
40
|
+
"rpn_pre_nms_top_n": 5000,
|
|
41
|
+
"rpn_post_nms_top_n": 3000,
|
|
42
|
+
"rpn_batch_size_per_image": 256,
|
|
43
|
+
"rpn_nms_threshold": 0.7,
|
|
44
|
+
"final_nms_iou_threshold": 0.5,
|
|
45
|
+
"max_detections_per_image": 2000,
|
|
46
|
+
"roi_batch_size_per_image": 512,
|
|
47
|
+
"rpn_positive_iou_threshold": 0.7,
|
|
48
|
+
"rpn_negative_iou_threshold": 0.3,
|
|
49
|
+
"roi_positive_iou_threshold": 0.5,
|
|
50
|
+
"roi_negative_iou_threshold": 0.5,
|
|
51
|
+
"add_gt_as_proposals": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "rotated_retinanet",
|
|
3
|
+
"model": {
|
|
4
|
+
"backbone": "resnet50",
|
|
5
|
+
"pretrained_backbone": true,
|
|
6
|
+
"trainable_layers": 5,
|
|
7
|
+
"anchor_scales": [8],
|
|
8
|
+
"anchor_ratios": [0.5, 1.0, 2.0],
|
|
9
|
+
"target_means": [0.0, 0.0, 0.0, 0.0, 0.0],
|
|
10
|
+
"target_stds": [1.0, 1.0, 1.0, 1.0, 1.0],
|
|
11
|
+
"roi_loss_type": "focal",
|
|
12
|
+
"roi_focal_alpha": 0.25,
|
|
13
|
+
"roi_focal_gamma": 2.0,
|
|
14
|
+
"roi_norm_factor": null,
|
|
15
|
+
"roi_edge_swap": true,
|
|
16
|
+
"use_hbb_for_matching": false,
|
|
17
|
+
"rpn_min_size": 2,
|
|
18
|
+
"rpn_pre_nms_top_n": 6000,
|
|
19
|
+
"rpn_post_nms_top_n": 3000,
|
|
20
|
+
"max_detections_per_image": 3000
|
|
21
|
+
},
|
|
22
|
+
"tensorboard": {
|
|
23
|
+
"log_debug_anchors_proposals": true
|
|
24
|
+
},
|
|
25
|
+
"loss": {
|
|
26
|
+
"loss_type": "focal",
|
|
27
|
+
"focal_alpha": 0.25,
|
|
28
|
+
"focal_gamma": 2.0
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"training": {
|
|
3
|
+
"num_epochs": 12,
|
|
4
|
+
"learning_rate": 0.02,
|
|
5
|
+
"momentum": 0.9,
|
|
6
|
+
"weight_decay": 0.0001,
|
|
7
|
+
"use_amp": false,
|
|
8
|
+
"gradient_accumulation_steps": 1,
|
|
9
|
+
"max_grad_norm": 5.0,
|
|
10
|
+
"lr_scheduler_step_epochs": 8,
|
|
11
|
+
"lr_scheduler_milestones": [8, 11],
|
|
12
|
+
"lr_scheduler_gamma": 0.1,
|
|
13
|
+
"lr_warmup_steps": 500,
|
|
14
|
+
"lr_scaling_with_accumulation": "linear",
|
|
15
|
+
"use_lr_param_groups": false
|
|
16
|
+
},
|
|
17
|
+
"evaluation": {
|
|
18
|
+
"score_threshold": 0.3,
|
|
19
|
+
"iou_threshold": 0.5,
|
|
20
|
+
"compute_map_final": true
|
|
21
|
+
},
|
|
22
|
+
"data_loader": {
|
|
23
|
+
"batch_size": 50,
|
|
24
|
+
"num_workers": 4,
|
|
25
|
+
"shuffle": true,
|
|
26
|
+
"pin_memory": true
|
|
27
|
+
},
|
|
28
|
+
"loss": {
|
|
29
|
+
"loss_type": "cross_entropy"
|
|
30
|
+
},
|
|
31
|
+
"enable_albumentation": false,
|
|
32
|
+
"enable_profiling": false
|
|
33
|
+
}
|