Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YoloNAS-R #1983

Closed
wants to merge 151 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
271f948
OBB loss
BloodAxe Apr 19, 2024
602a033
DOTA dataset
BloodAxe Apr 23, 2024
fd94586
Adding loss, postprocessing & visualization
BloodAxe Apr 23, 2024
7e25364
Visualization callback
BloodAxe Apr 23, 2024
d30790a
Visualization callback
BloodAxe Apr 23, 2024
b1ce298
YoloNAS-R
BloodAxe Apr 24, 2024
fc1cc93
YoloNAS-R
BloodAxe Apr 25, 2024
77ae38e
YoloNAS-R
BloodAxe Apr 25, 2024
13db92a
optimized_rboxes_nms
BloodAxe Apr 25, 2024
cf07405
optimized_rboxes_nms
BloodAxe Apr 25, 2024
5500717
optimized_rboxes_nms
BloodAxe Apr 25, 2024
8fda825
optimized_rboxes_nms
BloodAxe Apr 26, 2024
ed9f98f
optimized_rboxes_nms
BloodAxe Apr 26, 2024
d425476
Rename variables for better clarity
BloodAxe Apr 26, 2024
14a3501
Optimize loss weights
BloodAxe Apr 26, 2024
118271a
Prepare data script
BloodAxe Apr 26, 2024
2df4172
Prepare data script
BloodAxe Apr 26, 2024
93092b3
Reduce batch size & topk
BloodAxe Apr 27, 2024
88e3fe5
Remove unused arg
BloodAxe Apr 27, 2024
79c86d9
Remove unused arg
BloodAxe Apr 27, 2024
693121f
Remove unused arg
BloodAxe Apr 27, 2024
08c1b1f
Remove unused arg
BloodAxe Apr 27, 2024
c9de816
Increase topk
BloodAxe Apr 27, 2024
a758278
Increase topk
BloodAxe Apr 27, 2024
6bbba2f
Increase topk
BloodAxe Apr 27, 2024
ae4aa2f
Increase topk
BloodAxe Apr 27, 2024
5723734
Increase topk
BloodAxe Apr 27, 2024
52896bf
Increase topk
BloodAxe Apr 27, 2024
5f55552
Increase topk
BloodAxe Apr 27, 2024
e8ca4f6
Increase topk
BloodAxe Apr 27, 2024
2076952
Increase topk
BloodAxe Apr 27, 2024
62fa15e
Increase topk
BloodAxe Apr 27, 2024
02ef836
Increase topk
BloodAxe Apr 27, 2024
5c7dc87
Increase topk
BloodAxe Apr 27, 2024
1cc9eb5
Increase topk
BloodAxe Apr 27, 2024
b28f938
Increase topk
BloodAxe Apr 27, 2024
ca99a2e
RAdam
BloodAxe Apr 27, 2024
d68eab6
RAdam
BloodAxe Apr 27, 2024
eae4dbd
RAdam
BloodAxe Apr 27, 2024
ac0a0aa
CIou=False
BloodAxe Apr 27, 2024
aed9756
Disable check_points_inside_rboxes
BloodAxe Apr 27, 2024
9ad5455
Disable check_points_inside_rboxes
BloodAxe Apr 27, 2024
b51cd5f
Disable check_points_inside_rboxes
BloodAxe Apr 27, 2024
9f682c7
Tune weights
BloodAxe Apr 27, 2024
563a180
set_anomaly_enabled
BloodAxe Apr 27, 2024
5875f47
set_anomaly_enabled
BloodAxe Apr 27, 2024
75ce8d8
Increase eps
BloodAxe Apr 27, 2024
57df5e2
Multiply by scalar
BloodAxe Apr 27, 2024
e664135
Multiply by scalar
BloodAxe Apr 27, 2024
b938d4b
average_losses_in_ddp
BloodAxe Apr 28, 2024
21a4e53
yolo_nas_r_balanced
BloodAxe Apr 28, 2024
e42f586
Limit angle
BloodAxe Apr 28, 2024
ddab40d
Optimize image slicing
BloodAxe Apr 29, 2024
5c54b77
Do not reduce losses, reduce only scores sum
BloodAxe Apr 29, 2024
b07e3be
Do not reduce losses, reduce only scores sum
BloodAxe Apr 29, 2024
b37b735
Do not reduce losses, reduce only scores sum
BloodAxe Apr 29, 2024
48ae752
Clip grad
BloodAxe Apr 29, 2024
c2e972a
Disable L1 components
BloodAxe Apr 30, 2024
6937d29
Disable L1 components
BloodAxe Apr 30, 2024
1a0aaf0
Disable L1 components
BloodAxe Apr 30, 2024
e1c6687
Disable L1 components
BloodAxe Apr 30, 2024
1b7dfef
predict() support for YoloNAS-R
BloodAxe Apr 30, 2024
7fb7980
Comment saving of visualization
BloodAxe Apr 30, 2024
6a4daa2
yolo_nas_r_tzag
BloodAxe Apr 30, 2024
7a84b5b
Remove parameter
BloodAxe Apr 30, 2024
17f63d4
Fixed newline
BloodAxe May 1, 2024
d7c27a0
Merge remote-tracking branch 'origin/feature/SG-1448-OBB' into featur…
BloodAxe May 1, 2024
3670679
Increase min confidence
BloodAxe May 1, 2024
07b50d4
Added missing ReverseImageChannels
BloodAxe May 1, 2024
de6ad74
yolo_nas_r_tzag_balanced
BloodAxe May 1, 2024
23f2510
Merge remote-tracking branch 'origin/feature/SG-1448-OBB' into featur…
BloodAxe May 1, 2024
d1360c7
Added OBB transforms
BloodAxe May 1, 2024
a01a1ff
Added OBB transforms
BloodAxe May 1, 2024
503d586
get_dataset_preprocessing_params
BloodAxe May 1, 2024
dca0577
Added removal of small boxes during training
BloodAxe May 2, 2024
d86481f
Added removal of small boxes during training
BloodAxe May 2, 2024
d79ebc8
Added removal of invalid boxes
BloodAxe May 2, 2024
844e790
Added augmentations
BloodAxe May 2, 2024
5be4fe0
Increase bs
BloodAxe May 2, 2024
91bc4aa
Ensure that poly_to_cxcywhr always return boxes with w > h
BloodAxe May 2, 2024
7fa35df
Enabled anomaly detection
BloodAxe May 2, 2024
2602027
Added eps
BloodAxe May 2, 2024
38f6bbd
Undo anomaly
BloodAxe May 2, 2024
9c45e20
dota_yolo_nas_r_balanced_no_mixup
BloodAxe May 3, 2024
f9e01c9
Added logging of non-finite IoU results
BloodAxe May 4, 2024
68452b9
Merge remote-tracking branch 'origin/feature/SG-1448-OBB' into featur…
BloodAxe May 4, 2024
723db01
Added sanitize sample call after applying albumentations transforms
BloodAxe May 4, 2024
f4b427c
Replaced atan2() with atan() in CIoU loss because gt boxes can be zeros
BloodAxe May 4, 2024
015f5d7
MOAR Augs
BloodAxe May 5, 2024
0ab3347
MOAR Augs
BloodAxe May 5, 2024
3adac8f
RAdam -> AdamW
BloodAxe May 6, 2024
b05d07c
dota_yolo_nas_r_balanced_pretrain
BloodAxe May 6, 2024
eaf7fee
Tune augs
BloodAxe May 6, 2024
222e7c0
Fixed issue of logging wrong config
BloodAxe May 7, 2024
ebea29f
Revert file
BloodAxe May 7, 2024
67c2008
Cleanup
BloodAxe May 7, 2024
1d252a2
Added docs
BloodAxe May 7, 2024
754c02b
Remove non-existing params
BloodAxe May 8, 2024
874642f
YoloNAS-R M&L variants
BloodAxe May 9, 2024
aa5350d
Merge remote-tracking branch 'origin/feature/SG-1448-OBB' into featur…
BloodAxe May 9, 2024
8adb0a6
Export support for YoloNAS R
BloodAxe May 10, 2024
b91551f
Temporary comment matrix nms
BloodAxe May 10, 2024
2c8fafe
PrefetchIterator
BloodAxe May 10, 2024
e1855a2
Remove gs import
BloodAxe May 10, 2024
ab986d5
dota_yolo_nas_r_s
BloodAxe May 11, 2024
43deb07
Increase BS
BloodAxe May 11, 2024
fed740b
Enable anomaly detection
BloodAxe May 11, 2024
c82cba6
Rewrite t3
BloodAxe May 11, 2024
5d6063d
Rewrite t3
BloodAxe May 11, 2024
c55c698
Rewrite t3
BloodAxe May 11, 2024
2b3a705
dota_yolo_nas_r_s_1_gpu
BloodAxe May 11, 2024
9add044
M & L
BloodAxe May 11, 2024
0e10b1a
Increase numerical stability
BloodAxe May 11, 2024
134e008
Remove prefetch
BloodAxe May 11, 2024
81e05cc
Increase BS for L
BloodAxe May 11, 2024
99a676c
Increase BS for L
BloodAxe May 11, 2024
28cc08b
Disable fp16
BloodAxe May 11, 2024
7edf5c0
RM anomaly
BloodAxe May 11, 2024
72afa29
RM anomaly
BloodAxe May 11, 2024
f963043
fp32
BloodAxe May 11, 2024
1623579
Increase batch size
BloodAxe May 11, 2024
4db50c6
Increase batch size
BloodAxe May 11, 2024
85e23ff
Increase batch size
BloodAxe May 11, 2024
4a30fdc
dota_yolo_nas_r_l_fp32
BloodAxe May 12, 2024
b2961b8
Switch to use of matrix nms in post-prediction callback and exact pol…
BloodAxe May 13, 2024
d73224e
Switch to use of matrix nms in post-prediction callback and exact pol…
BloodAxe May 13, 2024
d0d8975
Added docs for rboxes_matrix_nms
BloodAxe May 14, 2024
395097e
Update script
BloodAxe May 14, 2024
51599a9
Improve auto-generated submission name
BloodAxe May 14, 2024
f6ecc5f
Added positional args
BloodAxe May 14, 2024
6985113
Added positional args
BloodAxe May 14, 2024
4999f83
dota_yolo_nas_r_l_fp32_mixup
BloodAxe May 14, 2024
6c5d912
dota_yolo_nas_r_l_fp32_mixup
BloodAxe May 14, 2024
fd68c7a
dota_yolo_nas_r_l_fp32_mixup
BloodAxe May 14, 2024
8d7db99
dota_yolo_nas_r_l_fp32_mixup
BloodAxe May 14, 2024
98a9fc2
Update recipes
BloodAxe May 16, 2024
3ff845e
Update recipes
BloodAxe May 16, 2024
37665a2
Added license support for YoloNAS-R
BloodAxe May 16, 2024
d81d939
Merge branch 'refs/heads/master' into feature/SG-1448-OBB
BloodAxe May 16, 2024
9783861
Improve docstrings
BloodAxe May 16, 2024
1f69534
Remove max gradient debugging
BloodAxe May 16, 2024
03c876b
Improve docstrings
BloodAxe May 16, 2024
86cbee3
Split processing and default preprocesisng params into separate files…
BloodAxe May 17, 2024
5729722
Merge branch 'refs/heads/feature/SG-1488-YoloNAS-R-integration' into …
BloodAxe May 17, 2024
2882b1f
Cherry-pick commits related to OBBSample & Transforms
BloodAxe May 17, 2024
abc4e8d
Remove random rotate90
BloodAxe May 20, 2024
874119c
Move OBBSample to samples
BloodAxe May 20, 2024
fad0d2b
Added license support for YoloNAS-R
BloodAxe May 16, 2024
3013463
Feature/sg 1488 yolo nas r integration sample and transforms (#1995)
BloodAxe May 21, 2024
9ed51bc
Merge branch 'refs/heads/feature/SG-1488-YoloNAS-R-integration' into …
BloodAxe May 21, 2024
f5383d2
Merge branch 'master' into feature/SG-1448-OBB
BloodAxe Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions LICENSE.YOLONAS-R.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# YOLO-NAS-R License

These model weights or any components comprising the model and the associated documentation (the "Software") is licensed to you by Deci.AI, Inc. ("Deci") under the following terms:
© 2023 – Deci.AI, Inc.

Subject to your full compliance with all of the terms herein, Deci hereby grants you a non-exclusive, revocable, non-sublicensable, non-transferable worldwide and limited right and license to use the Software. If you are using the Deci platform for model optimization, your use of the Software is subject to the Terms of Use available here (the "Terms of Use").

You shall not, without Deci's prior written consent:
(i) resell, lease, sublicense or distribute the Software to any person;
(ii) use the Software to provide third parties with managed services or provide remote access to the Software to any person or compete with Deci in any way;
(iii) represent that you possess any proprietary interest in the Software;
(iv) directly or indirectly, take any action to contest Deci's intellectual property rights or infringe them in any way;
(V) reverse-engineer, decompile, disassemble, alter, enhance, improve, add to, delete from, or otherwise modify, or derive (or attempt to derive) the technology or source code underlying any part of the Software;
(vi) use the Software (or any part thereof) in any illegal, indecent, misleading, harmful, abusive, harassing and/or disparaging manner or for any such purposes. Except as provided under the terms of any separate agreement between you and Deci, including the Terms of Use to the extent applicable, you may not use the Software for any commercial use, including in connection with any models used in a production environment.

DECI PROVIDES THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import cv2
import numpy as np


def cxcywhr_to_poly(boxes: np.ndarray) -> np.ndarray:
"""
Convert oriented bounding boxes in CX-CY-W-H-R format to a polygon format
:param boxes: [N,...,5] oriented bounding boxes in CX-CY-W-H-R format
:return: [N,...,4, 2] oriented bounding boxes in polygon format
"""
shape = boxes.shape
if shape[-1] != 5:
raise ValueError(f"Expected last dimension to be 5, got {shape[-1]}")

flat_rboxes = boxes.reshape(-1, 5).astype(np.float32)
polys = np.zeros((flat_rboxes.shape[0], 4, 2), dtype=np.float32)
for i, box in enumerate(flat_rboxes):
cx, cy, w, h, r = box
rect = ((cx, cy), (w, h), np.rad2deg(r))
poly = cv2.boxPoints(rect)
polys[i] = poly

return polys.reshape(*shape[:-1], 4, 2)


def poly_to_cxcywhr(poly: np.ndarray) -> np.ndarray:
shape = poly.shape
if shape[-2:] != (4, 2):
raise ValueError(f"Expected last two dimensions to be (4, 2), got {shape[-2:]}")

flat_polys = poly.reshape(-1, 4, 2)
rboxes = np.zeros((flat_polys.shape[0], 5), dtype=np.float32)
for i, poly in enumerate(flat_polys):
hull = cv2.convexHull(np.reshape(poly, [-1, 2]).astype(np.float32))
rect = cv2.minAreaRect(hull)
cx, cy = rect[0]
w, h = rect[1]
angle = rect[2]
if h > w:
w, h = h, w
angle += 90
angle = np.deg2rad(angle)
rboxes[i] = [cx, cy, w, h, angle]

return rboxes.reshape(*shape[:-2], 5)


def poly_to_xyxy(poly: np.ndarray) -> np.ndarray:
"""
Convert oriented bounding boxes in polygon format to XYXY format
:param poly: [..., 4, 2]
:return: [..., 4]
"""
x1 = poly[..., :, 0].min(axis=-1)
y1 = poly[..., :, 1].min(axis=-1)
x2 = poly[..., :, 0].max(axis=-1)
y2 = poly[..., :, 1].max(axis=-1)
return np.stack([x1, y1, x2, y2], axis=-1)
2 changes: 1 addition & 1 deletion src/super_gradients/training/models/model_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from super_gradients.common.abstractions.abstract_logger import get_logger
from super_gradients.training.utils.sg_trainer_utils import get_callable_param_names
from super_gradients.training.processing.processing import get_pretrained_processing_params
from super_gradients.training.processing import get_pretrained_processing_params

logger = get_logger(__name__)

Expand Down
5 changes: 5 additions & 0 deletions src/super_gradients/training/pretrained_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"yolo_nas_pose_s_coco_pose": "https://sghub.deci.ai/models/yolo_nas_pose_s_coco_pose.pth",
"yolo_nas_pose_m_coco_pose": "https://sghub.deci.ai/models/yolo_nas_pose_m_coco_pose.pth",
"yolo_nas_pose_l_coco_pose": "https://sghub.deci.ai/models/yolo_nas_pose_l_coco_pose.pth",
"yolo_nas_r_s_dota2": "https://sghub.deci.ai/models/yolo_nas_r_s_dota2.pth",
"yolo_nas_r_m_dota2": "https://sghub.deci.ai/models/yolo_nas_r_m_dota2.pth",
"yolo_nas_r_l_dota2": "https://sghub.deci.ai/models/yolo_nas_r_l_dota2.pth",
}

PRETRAINED_NUM_CLASSES = {
Expand All @@ -69,6 +72,7 @@
"coco": 80,
"coco_pose": 17,
"cifar10": 10,
"dota2": 18,
}

DATASET_LICENSES = {
Expand All @@ -79,4 +83,5 @@
"coco_pose": "https://cocodataset.org/#termsofuse",
"cityscapes": "https://www.cs.toronto.edu/~kriz/cifar.html",
"objects365": "https://www.objects365.org/download.html",
"dota2": "https://captain-whu.github.io/DOTA/dataset.html",
}
4 changes: 4 additions & 0 deletions src/super_gradients/training/processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .processing import (
Processing,
StandardizeImage,
DetectionRescale,
DetectionLongestMaxSizeRescale,
Expand All @@ -14,8 +15,10 @@
SegmentationPadShortToCropSize,
SegmentationPadToDivisible,
)
from .defaults import get_pretrained_processing_params

__all__ = [
"Processing",
"StandardizeImage",
"DetectionRescale",
"DetectionLongestMaxSizeRescale",
Expand All @@ -30,4 +33,5 @@
"SegmentationResize",
"SegmentationPadShortToCropSize",
"SegmentationPadToDivisible",
"get_pretrained_processing_params",
]
Loading
Loading