oriented-det 0.4.0__tar.gz → 0.4.2__tar.gz
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.
- {oriented_det-0.4.0 → oriented_det-0.4.2}/PKG-INFO +22 -11
- {oriented_det-0.4.0 → oriented_det-0.4.2}/README.md +17 -7
- oriented_det-0.4.2/export/preprocess.py +281 -0
- oriented_det-0.4.2/export/runtime.py +457 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/export_onnx.py +26 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/infer_onnx.py +90 -8
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/save_predictions_onnx.py +38 -3
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/preprocessing.json +2 -1
- oriented_det-0.4.2/oriented_det/configs/_base_/schedules/12x.json +8 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/schedules/1x.json +1 -2
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/config.schema.json +30 -10
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/hrsc2016_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/hrsid_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/hrsc2016_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/hrsid_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/ssdd_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/hrsc2016_le90_1x.json +1 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/hrsid_le90_1x.json +1 -0
- oriented_det-0.4.2/oriented_det/configs/yolo_obb/coco_300e_s.json +116 -0
- oriented_det-0.4.0/oriented_det/configs/yolo_obb/dota_le90_1x_s.json → oriented_det-0.4.2/oriented_det/configs/yolo_obb/dota_le90_12x_s_coco.json +50 -16
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/evaluation.py +82 -10
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/flips.py +17 -32
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/mosaic.py +244 -33
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/preprocessing.py +16 -2
- oriented_det-0.4.2/oriented_det/data/scale_translate.py +106 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/transforms.py +75 -2
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/rotated_rtmdet.py +85 -11
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/yolo_obb.py +289 -52
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/__init__.py +2 -0
- oriented_det-0.4.2/oriented_det/ops/ciou.py +70 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/gpu_ops.py +28 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/pretrained/manifest.json +16 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/runtime/collate.py +123 -14
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/runtime/inference.py +111 -20
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/config.py +265 -7
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/engine.py +15 -18
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/utils.py +144 -23
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/viz.py +2 -1
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/PKG-INFO +22 -11
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/SOURCES.txt +9 -3
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/requires.txt +3 -1
- {oriented_det-0.4.0 → oriented_det-0.4.2}/pyproject.toml +7 -3
- oriented_det-0.4.2/tests/test_ciou.py +179 -0
- oriented_det-0.4.2/tests/test_coco_train_affine.py +316 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_coco_yolo_pretrain.py +51 -11
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_config_behavior.py +18 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_evaluation.py +204 -0
- oriented_det-0.4.2/tests/test_linear_lr_scheduler.py +270 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_mosaic.py +128 -14
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_preprocessing.py +1 -0
- oriented_det-0.4.2/tests/test_rotated_rtmdet.py +373 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_sliding_window_margin.py +133 -0
- oriented_det-0.4.2/tests/test_train_flips.py +145 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_training_config_strict.py +139 -0
- oriented_det-0.4.2/tests/test_viewer_gradio_compat.py +36 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_wizard.py +41 -0
- oriented_det-0.4.2/tests/test_yolo_obb.py +502 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/app.py +91 -20
- oriented_det-0.4.2/tools/diagnose_coco_gap.py +447 -0
- oriented_det-0.4.2/tools/diagnose_mosaic_gap.py +423 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/image_demo.py +20 -7
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/lr_finder.py +10 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/preview_augmentation.py +14 -6
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/save_predictions.py +9 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/train.py +108 -13
- oriented_det-0.4.0/export/preprocess.py +0 -130
- oriented_det-0.4.0/export/runtime.py +0 -222
- oriented_det-0.4.0/oriented_det/configs/yolo_obb/coco_300e_s.json +0 -75
- oriented_det-0.4.0/oriented_det/configs/yolo_obb/dota_le90_6x_s.json +0 -23
- oriented_det-0.4.0/oriented_det/configs/yolo_obb/dota_le90_6x_s_coco.json +0 -18
- oriented_det-0.4.0/tests/test_rotated_rtmdet.py +0 -193
- oriented_det-0.4.0/tests/test_train_flips.py +0 -80
- oriented_det-0.4.0/tests/test_viewer_gradio_compat.py +0 -13
- oriented_det-0.4.0/tests/test_yolo_obb.py +0 -140
- {oriented_det-0.4.0 → oriented_det-0.4.2}/LICENSE +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/__main__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/cli.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/nms.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/ort_runtime.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/postprocess.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/demo.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/scripts/zip_bundle.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/val_dataset.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/export/wrappers.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/cli/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/cli/__main__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/cli/train.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/augmentation.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/dota_le90.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/fair1m.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/hrsc2016.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/hrsid.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/ossdd.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/datasets/ssdd.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/fp16.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/oriented_rcnn_r50.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/rotated_faster_rcnn_r50.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/rotated_fcos_r50.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/rotated_retinanet_r50.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/rotated_rtmdet_cspnext_s.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/rotated_rtmdet_cspnext_tiny.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/yolo_obb_n.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/_base_/models/yolo_obb_s.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/dota_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/dota_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/fair1m_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/oriented_rcnn/hrsc2016_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/dota_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/dota_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/fair1m_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/hrsc2016_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/ossdd_le90_vh_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_faster_rcnn/ossdd_le90_vh_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/dota_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/dota_le90_1x_l1_kfiou_aux.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/dota_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/fair1m_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/hrsc2016_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/ossdd_le90_vh_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_fcos/ossdd_le90_vh_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_retinanet/dota_le90_1x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_retinanet/dota_le90_1x_hbb.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_retinanet/dota_le90_3x.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_retinanet/dota_le90_3x_hbb.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_rtmdet/dota_le90_3x_s.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/configs/rotated_rtmdet/ossdd_le90_vh_1x_s.json +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/airbus_playground.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/build.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/coco.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/coco_obb.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/dota_classes.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/dota_task1.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/fair1m.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/fair1m_classes.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/hrsc2016.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/hrsid.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/lookalike.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/rotates.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/ssdd.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/tiling.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/data/yolo_obb.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/geometry/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/geometry/poly.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/geometry/qbox.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/geometry/rbox.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/geometry/transforms.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/backbones/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/backbones/cspnext.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/backbones/resnet_fpn.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/backbones/utils.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/backbones/yolo_obb.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/bbox_coder.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/faster_rcnn_inference.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/horizontal_roi_coder.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/oriented_rcnn.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/oriented_rcnn_inference.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/oriented_roi.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/oriented_rpn.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/retinanet_assign.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/rotated_fcos.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/rotated_retinanet.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/models/utils.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/diff_iou_rotated.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/gaussian_angle.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/iou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/kfiou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/nms.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/probiou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/rotated_ops.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/ops/utils.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/pretrained/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/pretrained/hub.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/runtime/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/runtime/checkpoint.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/ema.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/grouped_ce.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/piecewise_schedule.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/train/profiler.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/config.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/device.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/logging.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det/utils/progress.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/dependency_links.txt +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/entry_points.txt +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/oriented_det.egg-info/top_level.txt +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/setup.cfg +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_airbus_playground.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_annotation_csv.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_bbox_coder.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_class_tile_oversampling.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_coco_obb.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_config_model_wiring.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_cosine_tail_scheduler.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_deploy_generate_description.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_diff_iou_rotated.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_dota_task1.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_dota_tile_roots.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_exact_rotated_iou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_fair1m.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_gaussian_angle.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_geometry.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_geometry_transforms.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_gpu_ops.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_grouped_ce.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_hard_tile_oversampling.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_hrsc2016.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_hrsid.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_iou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_kfiou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_lookalike.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_metrics_margin_filter.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_models.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_nms.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_ops_utils.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_optimizer_param_groups.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_ossdd_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_piecewise_schedule.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_pretrained_hub.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_probiou.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_retinanet_assign.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_roi.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_rpn.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_rtmdet_rr_recipe.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_score_thresholds.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_sigmoid_focal_class_weights.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_source_provenance.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_ssdd.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_tile_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_tiling.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_train.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_train_rotates.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_utils_config.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_utils_viz.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_vendored_configs_sync.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tests/test_yolo_obb_dataset.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/__init__.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/annotation_csv.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/bench_latency.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/coco_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/compare_hbb_obb_counts.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/dataset_stats.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/dota_labels_to_comma.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/dota_task1_submit.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/fair1m_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/filter_predictions_by_gt.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/free_gpu.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/generate_airbus_playground_csv.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/generate_oriented_annotations.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/hbb_to_obb.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/hrsc_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/measure_sampled_riou_error.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/ossdd_fix_tiff.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/ossdd_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/playground_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/pretrained_download.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/publish_checkpoint.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/ssdd_to_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/sync_vendored_configs.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/tile_dota.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/train_example.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/train_multi_gpu.py +0 -0
- {oriented_det-0.4.0 → oriented_det-0.4.2}/tools/viewer_annotations.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: oriented-det
|
|
3
|
-
Version: 0.4.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: Open-source PyTorch framework for oriented and rotated object detection in aerial and satellite images
|
|
5
5
|
Author: Jeff Faudi, DL4EO
|
|
6
6
|
Maintainer: Jeff Faudi, DL4EO
|
|
7
7
|
License-Expression: Apache-2.0
|
|
@@ -12,7 +12,7 @@ Project-URL: Issues, https://github.com/DL4EO/oriented-det/issues
|
|
|
12
12
|
Project-URL: Bug Tracker, https://github.com/DL4EO/oriented-det/issues
|
|
13
13
|
Project-URL: DL4EO, https://dl4eo.com
|
|
14
14
|
Project-URL: Blog, https://deeplearning.earth
|
|
15
|
-
Keywords: computer-vision,object-detection,rotated-detection,oriented-detection,pytorch,aerial-imagery,satellite-imagery,remote-sensing,dota,geospatial
|
|
15
|
+
Keywords: computer-vision,object-detection,rotated-detection,oriented-detection,pytorch,aerial-imagery,aerial-images,satellite-imagery,satellite-images,remote-sensing,dota,geospatial
|
|
16
16
|
Classifier: Development Status :: 3 - Alpha
|
|
17
17
|
Classifier: Intended Audience :: Developers
|
|
18
18
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -31,12 +31,13 @@ Requires-Dist: torch>=2.4.0
|
|
|
31
31
|
Requires-Dist: torchvision>=0.19.0
|
|
32
32
|
Requires-Dist: numpy>=1.24
|
|
33
33
|
Requires-Dist: Pillow>=9.0
|
|
34
|
-
Requires-Dist: albumentations>=1.3.0
|
|
35
34
|
Requires-Dist: tqdm>=4.65.0
|
|
36
35
|
Requires-Dist: tensorboard>=2.10
|
|
37
36
|
Requires-Dist: matplotlib>=3.5.0
|
|
38
37
|
Requires-Dist: huggingface_hub>=0.20.0
|
|
39
38
|
Requires-Dist: shapely>=2.0.0
|
|
39
|
+
Provides-Extra: albumentations
|
|
40
|
+
Requires-Dist: albumentations<=2.0.8,>=1.3.0; extra == "albumentations"
|
|
40
41
|
Provides-Extra: viewer
|
|
41
42
|
Requires-Dist: gradio==6.8.0; extra == "viewer"
|
|
42
43
|
Provides-Extra: export
|
|
@@ -60,7 +61,7 @@ Dynamic: license-file
|
|
|
60
61
|
|
|
61
62
|
# OrientedDet
|
|
62
63
|
|
|
63
|
-
**OrientedDet** is
|
|
64
|
+
**OrientedDet** (**oriented-det**) is an open-source PyTorch framework for **oriented and rotated object detection** in aerial and satellite images. It focuses on clean geometry, reliable operators, simple datasets, and practical baseline models—without the complexity of large detection frameworks. OrientedDet is designed for researchers, practitioners, and geospatial developers who need accurate rotation-aware detectors with a minimal API.
|
|
64
65
|
|
|
65
66
|
<p align="center">
|
|
66
67
|
<img src="demo/out/demo_detections.png" alt="Oriented R-CNN detections on diagonally parked buses in an aerial parking lot" width="720">
|
|
@@ -75,7 +76,7 @@ Dynamic: license-file
|
|
|
75
76
|
- **Geometry**: Rotated bounding boxes (rbox: cx, cy, w, h, angle), quadrilateral boxes (qbox), polygon ↔ rbox ↔ hbox conversions, angle normalization (le90, 0–180°), flip/rotate/scale transforms, visualization helpers
|
|
76
77
|
- **IoU & NMS**: Rotated IoU and oriented NMS (CPU with optional GPU kernels when available); AABB pre-filtering; `obb_to_xyxy` / HBB conversion
|
|
77
78
|
- **Datasets**: DOTA polygon loader (pattern, split file, or separate folders), **HRSC2016** native XML loader, **FAIR1M** 37-class XML loader (+ convert/tile tutorial), **SSDD** and **HRSID** SAR ship loaders (finetune DOTA 1× Hub locally; no SAR zoo), image tiling, label filtering, ignore masks, oriented mAP evaluation
|
|
78
|
-
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss), **Rotated FCOS** (anchor-free single-stage; distance-angle coder, centerness, L1 / KFIoU / decoded rIoU), **Rotated RTMDet** (CSPNeXt + PAFPN single-stage speed tier; SepBN head, dynamic soft-label assigner, decoded rIoU); ResNet + FPN and CSPNeXt backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
|
|
79
|
+
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss), **Rotated FCOS** (anchor-free single-stage; distance-angle coder, centerness, L1 / KFIoU / decoded rIoU), **Rotated RTMDet** (CSPNeXt + PAFPN single-stage speed tier; SepBN head, dynamic soft-label assigner, decoded rIoU), **YOLO-OBB** (C2f CSP + PAFPN; DFL box head, task-aligned assigner; Hub Task 1 **77.80%**); ResNet + FPN and CSPNeXt / C2f backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
|
|
79
80
|
- **Training**: JSON configs + **`odet train`**, mixed precision (AMP), gradient accumulation, checkpointing, best-metric tracking, TensorBoard, optional curriculum learning and profiling
|
|
80
81
|
- **ONNX export**: pre-NMS ONNX + Python NMS (`odet export` / `make export-onnx`); consumers run ONNX Runtime only
|
|
81
82
|
|
|
@@ -106,6 +107,7 @@ uv pip install -e .
|
|
|
106
107
|
- To auto-activate `.venv` when entering this repo, install the [`direnv`](https://direnv.net/) shell hook and run `direnv allow` from the repo root. The local `.envrc` is intentionally gitignored so each developer can opt in on their machine.
|
|
107
108
|
- From PyPI: `pip install oriented-det`
|
|
108
109
|
- For development and tests: `uv pip install -e ".[dev]"`
|
|
110
|
+
- For photometric Albumentations (optional; no Hub recipe enables it): `uv pip install -e ".[albumentations]"` or `pip install "oriented-det[albumentations]"`. The extra is capped at the last MIT release (`albumentations<=2.0.8`). [AlbumentationsX](https://albumentations.ai/docs/license/) is AGPL-3.0.
|
|
109
111
|
- For the Gradio prediction viewer: `uv pip install -e ".[viewer]"` or `pip install "oriented-det[viewer]"`
|
|
110
112
|
- For **ONNX export**: `uv pip install -e ".[export]"` then `odet export --help` (see [ONNX export](docs/examples/export.md))
|
|
111
113
|
- For **macOS Apple Silicon** or **CPU-only**, see [Installation](docs/getting-started/installation.md) and the [macOS walkthrough](https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/) (`odet image-demo` on MPS, no CUDA toolchain).
|
|
@@ -170,6 +172,7 @@ Full documentation is in the **docs/** folder and can be built and served with M
|
|
|
170
172
|
|
|
171
173
|
| Topic | Post |
|
|
172
174
|
|-------|------|
|
|
175
|
+
| Oriented detection in aerial and satellite images | [https://deeplearning.earth/oriented-detection-in-satellite-images/](https://deeplearning.earth/oriented-detection-in-satellite-images/) |
|
|
173
176
|
| Why OrientedDet / Apache 2.0 stack | [https://deeplearning.earth/posts/2026-06-22_oriented-det_v0_1_0_sovereign_oriented_object_detection_for_eo/](https://deeplearning.earth/posts/2026-06-22_oriented-det_v0_1_0_sovereign_oriented_object_detection_for_eo/) |
|
|
174
177
|
| Visual detections (15 DOTA classes) | [https://deeplearning.earth/posts/2026-06-23_oriented_rcnn_detections_for_the_15_dota_classes/](https://deeplearning.earth/posts/2026-06-23_oriented_rcnn_detections_for_the_15_dota_classes/) |
|
|
175
178
|
| `odet image-demo` on Apple Silicon | [https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/](https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/) |
|
|
@@ -217,7 +220,7 @@ DOTA configs: per-model `dota_le90_1x.json` under [configs/](configs/) (3× wher
|
|
|
217
220
|
|
|
218
221
|
## Pretrained weights and evaluation
|
|
219
222
|
|
|
220
|
-
- Place exported best checkpoints under **`pretrained/`** or use Hub slugs (`odet pretrained download
|
|
223
|
+
- Place exported best checkpoints under **`pretrained/`** or use Hub slugs (`odet pretrained download yolo_obb_dota_le90_12x`, `rotated_rtmdet_dota_le90_3x`, `oriented_rcnn_dota_le90_1x`, `rotated_faster_rcnn_dota_le90_1x`, `rotated_fcos_dota_le90_1x`, or `oriented_rcnn_hrsc2016_le90_3x` / `rotated_faster_rcnn_hrsc2016_le90_3x` / `rotated_fcos_hrsc2016_le90_3x`). See [pretrained/README.md](pretrained/README.md) and [configs/README.md](configs/README.md#dota-pretrained-models-model-zoo). Zoo write-ups: [v0.1.1](https://deeplearning.earth/posts/2026-07-11_oriented-det_v0_1_1_prob_iou_mmrotate_parity_and_the_updated_zoo/) · [v0.2.0 FCOS](https://deeplearning.earth/posts/2026-08-28_oriented-det_v0_2_0_rotated_fcos_decoded_riou_and_the_updated_zoo/) · [optical satellite demo](https://deeplearning.earth/posts/2026-09-06_oriented_det_optical_satellite_demo/).
|
|
221
224
|
- **Tiled validation:** after training, run `make preds` then `make metrics`. Published mAP reports: [`docs/eval-reports/`](docs/eval-reports/) (git). Raw detections for the viewer: gitignored [`predictions/`](predictions/).
|
|
222
225
|
|
|
223
226
|
## Important notes
|
|
@@ -235,8 +238,12 @@ See **[docs/roadmap.md](docs/roadmap.md)** for the full public plan. Summary:
|
|
|
235
238
|
- **v0.2** (shipped): Rotated FCOS (anchor-free single-stage); Hub `rotated_fcos_dota_le90_1x` (73.07% official Task 1)
|
|
236
239
|
- **v0.3** (shipped): HRSC2016 loader + Hub 3× zoo (Oriented R-CNN 90.41%, Faster R-CNN 88.77%, FCOS 88.34% eval-val); FAIR1M loader + 1× recipes; SSDD + HRSID SAR loaders + 1× recipes (SSDD Faster R-CNN held-out **90.34%**, HRSID **78.55%**; train locally, no SAR Hub)
|
|
237
240
|
- **v0.4.0** (shipped): Rotated RTMDet; Hub `rotated_rtmdet_dota_le90_3x` (**77.60%** official Task 1)
|
|
238
|
-
- **v0.4.1
|
|
239
|
-
- **v0.
|
|
241
|
+
- **v0.4.1** (shipped): Citation and discoverability (`CITATION.cff`, oriented/rotated + aerial/satellite copy)
|
|
242
|
+
- **v0.4.2** (shipped): native YOLO-OBB; Hub `yolo_obb_dota_le90_12x` (**77.80%** official Task 1; COCO trunk `yolo_obb_coco_300e`)
|
|
243
|
+
- **v0.5–v0.5.2**: Swin-T + FPN — Oriented R-CNN (1× and 3× Hub in one release), then Faster R-CNN (v0.5.1), FCOS if latency allows (v0.5.2). Swin stays off RTMDet and YOLO-OBB
|
|
244
|
+
- **Optional, not a release:** DOTA multi-scale training (patch 1024, overlap 500, resize rates 0.5 / 1.0 / 1.5); recipe work on the six current models judged by AP75 or a weak class on a held-out split at the operating resolution
|
|
245
|
+
- **v1.0**: stable API, hosted docs, complete model zoo
|
|
246
|
+
- **v1.1**: oriented DINO in this repo (DOTA; Hub only if it beats Swin Oriented R-CNN)
|
|
240
247
|
|
|
241
248
|
## Contributing
|
|
242
249
|
|
|
@@ -248,7 +255,7 @@ OrientedDet is Apache-2.0 open source. For **consulting, training workshops, or
|
|
|
248
255
|
|
|
249
256
|
## Publishing to PyPI
|
|
250
257
|
|
|
251
|
-
Version **0.4.
|
|
258
|
+
Version **0.4.2** — tag releases as **`v0.4.2`** (git) matching `version` in `pyproject.toml`.
|
|
252
259
|
|
|
253
260
|
Configs: edit **`configs/`** at the repo root, then **`make sync-configs`** so **`oriented_det/configs/`** stays in sync (see **`oriented_det/configs/vendored_manifest.txt`**). CI runs **`make check-configs`**.
|
|
254
261
|
|
|
@@ -279,7 +286,7 @@ make check-configs
|
|
|
279
286
|
pytest tests/ -q
|
|
280
287
|
```
|
|
281
288
|
|
|
282
|
-
Bump version in `pyproject.toml` and `docs/changelog.md` if needed (currently **0.4.
|
|
289
|
+
Bump version in `pyproject.toml` and `docs/changelog.md` if needed (currently **0.4.2**).
|
|
283
290
|
|
|
284
291
|
#### 3. Build locally
|
|
285
292
|
|
|
@@ -350,6 +357,10 @@ Notes:
|
|
|
350
357
|
|
|
351
358
|
- **Trusted Publishing** avoids long-lived tokens; keep `make publish-*` for manual releases. Details: [.github/workflows/README.md](.github/workflows/README.md).
|
|
352
359
|
|
|
360
|
+
## Citation
|
|
361
|
+
|
|
362
|
+
If you use OrientedDet in research or production, cite this repository via [CITATION.cff](CITATION.cff) ([DOI: 10.5281/zenodo.23273307](https://doi.org/10.5281/zenodo.23273307)). Overview: [oriented detection in aerial and satellite images](https://deeplearning.earth/oriented-detection-in-satellite-images/).
|
|
363
|
+
|
|
353
364
|
## License
|
|
354
365
|
|
|
355
366
|
**Apache-2.0** — Copyright © Jeff Faudi and [DL4EO](https://dl4eo.com). See [LICENSE](LICENSE) for details.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OrientedDet
|
|
2
2
|
|
|
3
|
-
**OrientedDet** is
|
|
3
|
+
**OrientedDet** (**oriented-det**) is an open-source PyTorch framework for **oriented and rotated object detection** in aerial and satellite images. It focuses on clean geometry, reliable operators, simple datasets, and practical baseline models—without the complexity of large detection frameworks. OrientedDet is designed for researchers, practitioners, and geospatial developers who need accurate rotation-aware detectors with a minimal API.
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="demo/out/demo_detections.png" alt="Oriented R-CNN detections on diagonally parked buses in an aerial parking lot" width="720">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
- **Geometry**: Rotated bounding boxes (rbox: cx, cy, w, h, angle), quadrilateral boxes (qbox), polygon ↔ rbox ↔ hbox conversions, angle normalization (le90, 0–180°), flip/rotate/scale transforms, visualization helpers
|
|
16
16
|
- **IoU & NMS**: Rotated IoU and oriented NMS (CPU with optional GPU kernels when available); AABB pre-filtering; `obb_to_xyxy` / HBB conversion
|
|
17
17
|
- **Datasets**: DOTA polygon loader (pattern, split file, or separate folders), **HRSC2016** native XML loader, **FAIR1M** 37-class XML loader (+ convert/tile tutorial), **SSDD** and **HRSID** SAR ship loaders (finetune DOTA 1× Hub locally; no SAR zoo), image tiling, label filtering, ignore masks, oriented mAP evaluation
|
|
18
|
-
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss), **Rotated FCOS** (anchor-free single-stage; distance-angle coder, centerness, L1 / KFIoU / decoded rIoU), **Rotated RTMDet** (CSPNeXt + PAFPN single-stage speed tier; SepBN head, dynamic soft-label assigner, decoded rIoU); ResNet + FPN and CSPNeXt backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
|
|
18
|
+
- **Models**: **Oriented R-CNN** ([Xie et al., ICCV 2021](https://openaccess.thecvf.com/content/ICCV2021/html/Xie_Oriented_R-CNN_for_Object_Detection_ICCV_2021_paper.html); horizontal RPN + MidpointOffset → oriented RoIAlign + oriented ROI head), **Rotated Faster R-CNN** (Ren et al., NeurIPS 2015 two-stage baseline with horizontal RPN + horizontal RoIAlign + rotated ROI head; MMRotate reference), **Rotated RetinaNet** ([Lin et al., ICCV 2017](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf); oriented anchors, sigmoid focal loss), **Rotated FCOS** (anchor-free single-stage; distance-angle coder, centerness, L1 / KFIoU / decoded rIoU), **Rotated RTMDet** (CSPNeXt + PAFPN single-stage speed tier; SepBN head, dynamic soft-label assigner, decoded rIoU), **YOLO-OBB** (C2f CSP + PAFPN; DFL box head, task-aligned assigner; Hub Task 1 **77.80%**); ResNet + FPN and CSPNeXt / C2f backbones; selective loading of external checkpoints where configs wire `checkpoint.load_from_checkpoint`
|
|
19
19
|
- **Training**: JSON configs + **`odet train`**, mixed precision (AMP), gradient accumulation, checkpointing, best-metric tracking, TensorBoard, optional curriculum learning and profiling
|
|
20
20
|
- **ONNX export**: pre-NMS ONNX + Python NMS (`odet export` / `make export-onnx`); consumers run ONNX Runtime only
|
|
21
21
|
|
|
@@ -46,6 +46,7 @@ uv pip install -e .
|
|
|
46
46
|
- To auto-activate `.venv` when entering this repo, install the [`direnv`](https://direnv.net/) shell hook and run `direnv allow` from the repo root. The local `.envrc` is intentionally gitignored so each developer can opt in on their machine.
|
|
47
47
|
- From PyPI: `pip install oriented-det`
|
|
48
48
|
- For development and tests: `uv pip install -e ".[dev]"`
|
|
49
|
+
- For photometric Albumentations (optional; no Hub recipe enables it): `uv pip install -e ".[albumentations]"` or `pip install "oriented-det[albumentations]"`. The extra is capped at the last MIT release (`albumentations<=2.0.8`). [AlbumentationsX](https://albumentations.ai/docs/license/) is AGPL-3.0.
|
|
49
50
|
- For the Gradio prediction viewer: `uv pip install -e ".[viewer]"` or `pip install "oriented-det[viewer]"`
|
|
50
51
|
- For **ONNX export**: `uv pip install -e ".[export]"` then `odet export --help` (see [ONNX export](docs/examples/export.md))
|
|
51
52
|
- For **macOS Apple Silicon** or **CPU-only**, see [Installation](docs/getting-started/installation.md) and the [macOS walkthrough](https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/) (`odet image-demo` on MPS, no CUDA toolchain).
|
|
@@ -110,6 +111,7 @@ Full documentation is in the **docs/** folder and can be built and served with M
|
|
|
110
111
|
|
|
111
112
|
| Topic | Post |
|
|
112
113
|
|-------|------|
|
|
114
|
+
| Oriented detection in aerial and satellite images | [https://deeplearning.earth/oriented-detection-in-satellite-images/](https://deeplearning.earth/oriented-detection-in-satellite-images/) |
|
|
113
115
|
| Why OrientedDet / Apache 2.0 stack | [https://deeplearning.earth/posts/2026-06-22_oriented-det_v0_1_0_sovereign_oriented_object_detection_for_eo/](https://deeplearning.earth/posts/2026-06-22_oriented-det_v0_1_0_sovereign_oriented_object_detection_for_eo/) |
|
|
114
116
|
| Visual detections (15 DOTA classes) | [https://deeplearning.earth/posts/2026-06-23_oriented_rcnn_detections_for_the_15_dota_classes/](https://deeplearning.earth/posts/2026-06-23_oriented_rcnn_detections_for_the_15_dota_classes/) |
|
|
115
117
|
| `odet image-demo` on Apple Silicon | [https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/](https://deeplearning.earth/posts/2026-06-25_oriented_object_detection_on_macos_in_pure_python/) |
|
|
@@ -157,7 +159,7 @@ DOTA configs: per-model `dota_le90_1x.json` under [configs/](configs/) (3× wher
|
|
|
157
159
|
|
|
158
160
|
## Pretrained weights and evaluation
|
|
159
161
|
|
|
160
|
-
- Place exported best checkpoints under **`pretrained/`** or use Hub slugs (`odet pretrained download
|
|
162
|
+
- Place exported best checkpoints under **`pretrained/`** or use Hub slugs (`odet pretrained download yolo_obb_dota_le90_12x`, `rotated_rtmdet_dota_le90_3x`, `oriented_rcnn_dota_le90_1x`, `rotated_faster_rcnn_dota_le90_1x`, `rotated_fcos_dota_le90_1x`, or `oriented_rcnn_hrsc2016_le90_3x` / `rotated_faster_rcnn_hrsc2016_le90_3x` / `rotated_fcos_hrsc2016_le90_3x`). See [pretrained/README.md](pretrained/README.md) and [configs/README.md](configs/README.md#dota-pretrained-models-model-zoo). Zoo write-ups: [v0.1.1](https://deeplearning.earth/posts/2026-07-11_oriented-det_v0_1_1_prob_iou_mmrotate_parity_and_the_updated_zoo/) · [v0.2.0 FCOS](https://deeplearning.earth/posts/2026-08-28_oriented-det_v0_2_0_rotated_fcos_decoded_riou_and_the_updated_zoo/) · [optical satellite demo](https://deeplearning.earth/posts/2026-09-06_oriented_det_optical_satellite_demo/).
|
|
161
163
|
- **Tiled validation:** after training, run `make preds` then `make metrics`. Published mAP reports: [`docs/eval-reports/`](docs/eval-reports/) (git). Raw detections for the viewer: gitignored [`predictions/`](predictions/).
|
|
162
164
|
|
|
163
165
|
## Important notes
|
|
@@ -175,8 +177,12 @@ See **[docs/roadmap.md](docs/roadmap.md)** for the full public plan. Summary:
|
|
|
175
177
|
- **v0.2** (shipped): Rotated FCOS (anchor-free single-stage); Hub `rotated_fcos_dota_le90_1x` (73.07% official Task 1)
|
|
176
178
|
- **v0.3** (shipped): HRSC2016 loader + Hub 3× zoo (Oriented R-CNN 90.41%, Faster R-CNN 88.77%, FCOS 88.34% eval-val); FAIR1M loader + 1× recipes; SSDD + HRSID SAR loaders + 1× recipes (SSDD Faster R-CNN held-out **90.34%**, HRSID **78.55%**; train locally, no SAR Hub)
|
|
177
179
|
- **v0.4.0** (shipped): Rotated RTMDet; Hub `rotated_rtmdet_dota_le90_3x` (**77.60%** official Task 1)
|
|
178
|
-
- **v0.4.1
|
|
179
|
-
- **v0.
|
|
180
|
+
- **v0.4.1** (shipped): Citation and discoverability (`CITATION.cff`, oriented/rotated + aerial/satellite copy)
|
|
181
|
+
- **v0.4.2** (shipped): native YOLO-OBB; Hub `yolo_obb_dota_le90_12x` (**77.80%** official Task 1; COCO trunk `yolo_obb_coco_300e`)
|
|
182
|
+
- **v0.5–v0.5.2**: Swin-T + FPN — Oriented R-CNN (1× and 3× Hub in one release), then Faster R-CNN (v0.5.1), FCOS if latency allows (v0.5.2). Swin stays off RTMDet and YOLO-OBB
|
|
183
|
+
- **Optional, not a release:** DOTA multi-scale training (patch 1024, overlap 500, resize rates 0.5 / 1.0 / 1.5); recipe work on the six current models judged by AP75 or a weak class on a held-out split at the operating resolution
|
|
184
|
+
- **v1.0**: stable API, hosted docs, complete model zoo
|
|
185
|
+
- **v1.1**: oriented DINO in this repo (DOTA; Hub only if it beats Swin Oriented R-CNN)
|
|
180
186
|
|
|
181
187
|
## Contributing
|
|
182
188
|
|
|
@@ -188,7 +194,7 @@ OrientedDet is Apache-2.0 open source. For **consulting, training workshops, or
|
|
|
188
194
|
|
|
189
195
|
## Publishing to PyPI
|
|
190
196
|
|
|
191
|
-
Version **0.4.
|
|
197
|
+
Version **0.4.2** — tag releases as **`v0.4.2`** (git) matching `version` in `pyproject.toml`.
|
|
192
198
|
|
|
193
199
|
Configs: edit **`configs/`** at the repo root, then **`make sync-configs`** so **`oriented_det/configs/`** stays in sync (see **`oriented_det/configs/vendored_manifest.txt`**). CI runs **`make check-configs`**.
|
|
194
200
|
|
|
@@ -219,7 +225,7 @@ make check-configs
|
|
|
219
225
|
pytest tests/ -q
|
|
220
226
|
```
|
|
221
227
|
|
|
222
|
-
Bump version in `pyproject.toml` and `docs/changelog.md` if needed (currently **0.4.
|
|
228
|
+
Bump version in `pyproject.toml` and `docs/changelog.md` if needed (currently **0.4.2**).
|
|
223
229
|
|
|
224
230
|
#### 3. Build locally
|
|
225
231
|
|
|
@@ -290,6 +296,10 @@ Notes:
|
|
|
290
296
|
|
|
291
297
|
- **Trusted Publishing** avoids long-lived tokens; keep `make publish-*` for manual releases. Details: [.github/workflows/README.md](.github/workflows/README.md).
|
|
292
298
|
|
|
299
|
+
## Citation
|
|
300
|
+
|
|
301
|
+
If you use OrientedDet in research or production, cite this repository via [CITATION.cff](CITATION.cff) ([DOI: 10.5281/zenodo.23273307](https://doi.org/10.5281/zenodo.23273307)). Overview: [oriented detection in aerial and satellite images](https://deeplearning.earth/oriented-detection-in-satellite-images/).
|
|
302
|
+
|
|
293
303
|
## License
|
|
294
304
|
|
|
295
305
|
**Apache-2.0** — Copyright © Jeff Faudi and [DL4EO](https://dl4eo.com). See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"""Image → ONNX input tensor (training-style resize + RGB mean/std).
|
|
2
|
+
|
|
3
|
+
The ONNX graph expects ``[1, 3, H, W]`` float32 RGB, already normalized:
|
|
4
|
+
``(x / 255 - mean) / std``. Resize is bilinear (PIL), matching oriented-det
|
|
5
|
+
``resize_mode=fixed``.
|
|
6
|
+
|
|
7
|
+
Images larger than the sliding-window slice are tiled here. The slice is
|
|
8
|
+
``window_size`` in source pixels when set, otherwise ``target_size``. Each
|
|
9
|
+
window is resized onto ``target_size`` before normalization. ``pad`` and
|
|
10
|
+
``keep_ratio`` stay a single full-image resize.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any, Mapping, Sequence, Union
|
|
17
|
+
|
|
18
|
+
import numpy as np
|
|
19
|
+
from PIL import Image
|
|
20
|
+
|
|
21
|
+
_DEFAULT_MEAN = (0.485, 0.456, 0.406)
|
|
22
|
+
_DEFAULT_STD = (0.229, 0.224, 0.225)
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
_RESAMPLE = Image.Resampling.BILINEAR
|
|
26
|
+
except AttributeError: # pragma: no cover - Pillow < 9.1
|
|
27
|
+
_RESAMPLE = Image.BILINEAR
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _as_float3(values: Sequence[float] | None, default: Sequence[float]) -> np.ndarray:
|
|
31
|
+
src = default if values is None else values
|
|
32
|
+
arr = np.asarray(list(src), dtype=np.float32).reshape(-1)
|
|
33
|
+
if arr.size != 3:
|
|
34
|
+
raise ValueError(f"expected 3-channel mean/std, got {arr.size}")
|
|
35
|
+
return arr
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def canvas_size_from_meta(meta: Mapping[str, Any]) -> tuple[int, int]:
|
|
39
|
+
"""Return ``(height, width)`` from export meta."""
|
|
40
|
+
prep = meta.get("preprocess") or {}
|
|
41
|
+
ts = prep.get("target_size")
|
|
42
|
+
if isinstance(ts, (list, tuple)) and len(ts) >= 2:
|
|
43
|
+
return int(ts[0]), int(ts[1])
|
|
44
|
+
shape = (meta.get("input") or {}).get("shape") or []
|
|
45
|
+
if len(shape) >= 4:
|
|
46
|
+
return int(shape[2]), int(shape[3])
|
|
47
|
+
size = int(meta.get("image_size") or 1024)
|
|
48
|
+
return size, size
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def mean_std_from_meta(meta: Mapping[str, Any]) -> tuple[np.ndarray, np.ndarray]:
|
|
52
|
+
prep = meta.get("preprocess") or {}
|
|
53
|
+
mean = prep.get("normalize_mean") or meta.get("normalize_mean") or _DEFAULT_MEAN
|
|
54
|
+
std = prep.get("normalize_std") or meta.get("normalize_std") or _DEFAULT_STD
|
|
55
|
+
return _as_float3(mean, _DEFAULT_MEAN), _as_float3(std, _DEFAULT_STD)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def to_rgb_uint8(image: Union[Image.Image, np.ndarray], *, bgr: bool = False) -> np.ndarray:
|
|
59
|
+
"""Return HWC uint8 RGB."""
|
|
60
|
+
if isinstance(image, Image.Image):
|
|
61
|
+
return np.asarray(image.convert("RGB"), dtype=np.uint8)
|
|
62
|
+
arr = np.asarray(image)
|
|
63
|
+
if arr.ndim != 3 or arr.shape[2] not in (3, 4):
|
|
64
|
+
raise ValueError(f"expected HWC image with 3 or 4 channels, got {arr.shape}")
|
|
65
|
+
if arr.shape[2] == 4:
|
|
66
|
+
arr = arr[:, :, :3]
|
|
67
|
+
if arr.dtype != np.uint8:
|
|
68
|
+
if np.issubdtype(arr.dtype, np.floating) and arr.max() <= 1.0:
|
|
69
|
+
arr = np.clip(arr * 255.0, 0, 255).astype(np.uint8)
|
|
70
|
+
else:
|
|
71
|
+
arr = np.clip(arr, 0, 255).astype(np.uint8)
|
|
72
|
+
if bgr:
|
|
73
|
+
arr = arr[:, :, ::-1]
|
|
74
|
+
return np.ascontiguousarray(arr)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def preprocess_rgb(
|
|
78
|
+
image: Union[Image.Image, np.ndarray],
|
|
79
|
+
height: int,
|
|
80
|
+
width: int,
|
|
81
|
+
mean: Sequence[float] | None = None,
|
|
82
|
+
std: Sequence[float] | None = None,
|
|
83
|
+
*,
|
|
84
|
+
bgr: bool = False,
|
|
85
|
+
) -> tuple[np.ndarray, int, int]:
|
|
86
|
+
"""RGB (or BGR) image → ``[1, 3, H, W]`` float32 plus original ``(h, w)``."""
|
|
87
|
+
rgb = to_rgb_uint8(image, bgr=bgr)
|
|
88
|
+
orig_h, orig_w = int(rgb.shape[0]), int(rgb.shape[1])
|
|
89
|
+
pil = Image.fromarray(rgb, mode="RGB")
|
|
90
|
+
if pil.size != (int(width), int(height)):
|
|
91
|
+
pil = pil.resize((int(width), int(height)), _RESAMPLE)
|
|
92
|
+
chw = np.asarray(pil, dtype=np.float32).transpose(2, 0, 1) / 255.0
|
|
93
|
+
mean_a = _as_float3(mean, _DEFAULT_MEAN).reshape(3, 1, 1)
|
|
94
|
+
std_a = _as_float3(std, _DEFAULT_STD).reshape(3, 1, 1)
|
|
95
|
+
out = (chw - mean_a) / std_a
|
|
96
|
+
return out[np.newaxis, ...], orig_h, orig_w
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def preprocess_from_meta(
|
|
100
|
+
image: Union[Image.Image, np.ndarray],
|
|
101
|
+
meta: Mapping[str, Any],
|
|
102
|
+
*,
|
|
103
|
+
bgr: bool = False,
|
|
104
|
+
) -> tuple[np.ndarray, int, int]:
|
|
105
|
+
"""Preprocess using ``normalize_mean`` / ``target_size`` from export meta."""
|
|
106
|
+
height, width = canvas_size_from_meta(meta)
|
|
107
|
+
mean, std = mean_std_from_meta(meta)
|
|
108
|
+
return preprocess_rgb(image, height, width, mean, std, bgr=bgr)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def preprocess_path(
|
|
112
|
+
path: Union[str, Path],
|
|
113
|
+
meta: Mapping[str, Any],
|
|
114
|
+
) -> tuple[np.ndarray, int, int]:
|
|
115
|
+
"""Load a file as RGB and preprocess."""
|
|
116
|
+
img = Image.open(path).convert("RGB")
|
|
117
|
+
return preprocess_from_meta(img, meta)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def scale_obb_to_original(
|
|
121
|
+
boxes: np.ndarray,
|
|
122
|
+
orig_w: int,
|
|
123
|
+
orig_h: int,
|
|
124
|
+
canvas_w: int,
|
|
125
|
+
canvas_h: int,
|
|
126
|
+
) -> np.ndarray:
|
|
127
|
+
"""Scale ``(cx, cy, w, h, angle)`` from canvas pixels to original image pixels."""
|
|
128
|
+
if boxes.size == 0:
|
|
129
|
+
return boxes.reshape(0, 5)
|
|
130
|
+
out = np.array(boxes, dtype=np.float32, copy=True)
|
|
131
|
+
out[:, 0] *= float(orig_w) / float(canvas_w)
|
|
132
|
+
out[:, 1] *= float(orig_h) / float(canvas_h)
|
|
133
|
+
out[:, 2] *= float(orig_w) / float(canvas_w)
|
|
134
|
+
out[:, 3] *= float(orig_h) / float(canvas_h)
|
|
135
|
+
return out
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _prep(meta: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
139
|
+
prep = meta.get("preprocess")
|
|
140
|
+
return prep if isinstance(prep, Mapping) else {}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def resize_mode_from_meta(meta: Mapping[str, Any]) -> str:
|
|
144
|
+
"""Return the sidecar resize mode (default ``fixed``)."""
|
|
145
|
+
return str(_prep(meta).get("resize_mode") or "fixed").strip().lower()
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _size_pair(value: Any) -> tuple[int, int] | None:
|
|
149
|
+
"""Return ``(h, w)`` from a scalar or a 1- or 2-length sequence."""
|
|
150
|
+
if value is None or isinstance(value, bool):
|
|
151
|
+
return None
|
|
152
|
+
if isinstance(value, (int, float)):
|
|
153
|
+
n = int(value)
|
|
154
|
+
return (n, n)
|
|
155
|
+
if isinstance(value, (list, tuple)):
|
|
156
|
+
if len(value) == 1:
|
|
157
|
+
n = int(value[0])
|
|
158
|
+
return (n, n)
|
|
159
|
+
if len(value) >= 2:
|
|
160
|
+
return (int(value[0]), int(value[1]))
|
|
161
|
+
return None
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def window_size_from_meta(meta: Mapping[str, Any]) -> tuple[int, int] | None:
|
|
165
|
+
"""Source-pixel slice from ``preprocess.window_size``, or None.
|
|
166
|
+
|
|
167
|
+
``pad`` and ``keep_ratio`` ignore ``window_size``.
|
|
168
|
+
"""
|
|
169
|
+
if resize_mode_from_meta(meta) in {"pad", "keep_ratio"}:
|
|
170
|
+
return None
|
|
171
|
+
return _size_pair(_prep(meta).get("window_size"))
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def slice_size_from_meta(meta: Mapping[str, Any]) -> tuple[int, int]:
|
|
175
|
+
"""Sliding-window slice ``(h, w)`` in source pixels.
|
|
176
|
+
|
|
177
|
+
``window_size`` when set, otherwise the ONNX canvas (``target_size``).
|
|
178
|
+
"""
|
|
179
|
+
window = window_size_from_meta(meta)
|
|
180
|
+
if window is not None:
|
|
181
|
+
return window
|
|
182
|
+
return canvas_size_from_meta(meta)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def overlap_pixels_from_meta(meta: Mapping[str, Any]) -> int:
|
|
186
|
+
"""Per-axis overlap in source pixels (default 200)."""
|
|
187
|
+
prep = _prep(meta)
|
|
188
|
+
raw = prep.get("overlap_pixels")
|
|
189
|
+
if raw is None:
|
|
190
|
+
prod = meta.get("production")
|
|
191
|
+
if isinstance(prod, Mapping):
|
|
192
|
+
raw = prod.get("overlap_pixels")
|
|
193
|
+
if raw is None:
|
|
194
|
+
return 200
|
|
195
|
+
return max(0, int(raw))
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def uses_sliding_window(image_height: int, image_width: int, meta: Mapping[str, Any]) -> bool:
|
|
199
|
+
"""True when ``fixed`` / ``crop`` should tile an image larger than the slice.
|
|
200
|
+
|
|
201
|
+
The slice is ``window_size`` when set, otherwise ``target_size``. An image
|
|
202
|
+
that fits in the slice is one forward. ``pad`` and ``keep_ratio`` never tile.
|
|
203
|
+
"""
|
|
204
|
+
if resize_mode_from_meta(meta) in {"pad", "keep_ratio"}:
|
|
205
|
+
return False
|
|
206
|
+
slice_h, slice_w = slice_size_from_meta(meta)
|
|
207
|
+
return int(image_height) > int(slice_h) or int(image_width) > int(slice_w)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _sliding_window_axis_origins(length: int, slice_size: int, stride: int) -> list[int]:
|
|
211
|
+
"""Top-left origins along one axis. The last window flushes to the image edge."""
|
|
212
|
+
if length <= slice_size:
|
|
213
|
+
return [0]
|
|
214
|
+
origins: list[int] = []
|
|
215
|
+
pos = 0
|
|
216
|
+
while pos < length:
|
|
217
|
+
origins.append(pos)
|
|
218
|
+
pos += stride
|
|
219
|
+
if pos >= length:
|
|
220
|
+
break
|
|
221
|
+
origins[-1] = max(0, length - slice_size)
|
|
222
|
+
out: list[int] = []
|
|
223
|
+
seen: set[int] = set()
|
|
224
|
+
for origin in origins:
|
|
225
|
+
if origin not in seen:
|
|
226
|
+
out.append(origin)
|
|
227
|
+
seen.add(origin)
|
|
228
|
+
return out
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def sliding_window_grid(
|
|
232
|
+
image_height: int,
|
|
233
|
+
image_width: int,
|
|
234
|
+
slice_h: int,
|
|
235
|
+
slice_w: int,
|
|
236
|
+
overlap_pixels: int | None = None,
|
|
237
|
+
) -> list[tuple[int, int]]:
|
|
238
|
+
"""``(x0, y0)`` windows. Stride is ``slice - overlap``. Default overlap is 200 px.
|
|
239
|
+
|
|
240
|
+
The last row and column flush to the image edge so that window is a full
|
|
241
|
+
slice of real pixels. Images that fit in one slice return ``[(0, 0)]``.
|
|
242
|
+
"""
|
|
243
|
+
if image_height <= slice_h and image_width <= slice_w:
|
|
244
|
+
return [(0, 0)]
|
|
245
|
+
op = 200 if overlap_pixels is None else int(overlap_pixels)
|
|
246
|
+
if op < 0:
|
|
247
|
+
raise ValueError("overlap_pixels must be >= 0")
|
|
248
|
+
oh = min(op, max(0, int(slice_h) - 1))
|
|
249
|
+
ow = min(op, max(0, int(slice_w) - 1))
|
|
250
|
+
stride_y = max(1, int(round(slice_h - oh)))
|
|
251
|
+
stride_x = max(1, int(round(slice_w - ow)))
|
|
252
|
+
xs = _sliding_window_axis_origins(int(image_width), int(slice_w), stride_x)
|
|
253
|
+
ys = _sliding_window_axis_origins(int(image_height), int(slice_h), stride_y)
|
|
254
|
+
return [(x0, y0) for y0 in ys for x0 in xs]
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def crop_or_pad(
|
|
258
|
+
rgb: np.ndarray,
|
|
259
|
+
x0: int,
|
|
260
|
+
y0: int,
|
|
261
|
+
slice_w: int,
|
|
262
|
+
slice_h: int,
|
|
263
|
+
image_width: int,
|
|
264
|
+
image_height: int,
|
|
265
|
+
) -> np.ndarray:
|
|
266
|
+
"""Copy a source window onto a ``slice_h × slice_w`` uint8 canvas.
|
|
267
|
+
|
|
268
|
+
Regions past the image border stay zero. ``rgb`` is HWC RGB.
|
|
269
|
+
"""
|
|
270
|
+
x1 = min(int(x0) + int(slice_w), int(image_width))
|
|
271
|
+
y1 = min(int(y0) + int(slice_h), int(image_height))
|
|
272
|
+
src_x0 = max(0, int(x0))
|
|
273
|
+
src_y0 = max(0, int(y0))
|
|
274
|
+
crop_w = x1 - src_x0
|
|
275
|
+
crop_h = y1 - src_y0
|
|
276
|
+
canvas = np.zeros((int(slice_h), int(slice_w), 3), dtype=np.uint8)
|
|
277
|
+
if crop_w > 0 and crop_h > 0:
|
|
278
|
+
dx = src_x0 - int(x0)
|
|
279
|
+
dy = src_y0 - int(y0)
|
|
280
|
+
canvas[dy : dy + crop_h, dx : dx + crop_w, :] = rgb[src_y0:y1, src_x0:x1]
|
|
281
|
+
return canvas
|