Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#622 Hotfix/sg 000 transform backward compatibility

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:hotfix/SG-000-transform_backward_compatibility
@@ -13,7 +13,7 @@ import super_gradients
 from super_gradients.training.dataloaders.dataloaders import _process_dataset_params
 from super_gradients.training.dataloaders.dataloaders import _process_dataset_params
 from super_gradients.training.datasets import PascalVOCDetectionDataset, COCODetectionDataset
 from super_gradients.training.datasets import PascalVOCDetectionDataset, COCODetectionDataset
 from super_gradients.training.transforms import DetectionMosaic, DetectionPaddedRescale, DetectionTargetsFormatTransform
 from super_gradients.training.transforms import DetectionMosaic, DetectionPaddedRescale, DetectionTargetsFormatTransform
-from super_gradients.training.utils.detection_utils import DetectionTargetsFormat
+from super_gradients.training.datasets.data_formats.default_formats import XYXY_LABEL
 from super_gradients.training.exceptions.dataset_exceptions import EmptyDatasetException
 from super_gradients.training.exceptions.dataset_exceptions import EmptyDatasetException
 from super_gradients.training.utils.hydra_utils import normalize_path
 from super_gradients.training.utils.hydra_utils import normalize_path
 
 
@@ -35,7 +35,7 @@ class DatasetIntegrationTest(unittest.TestCase):
         transforms = [
         transforms = [
             DetectionMosaic(input_dim=(640, 640), prob=0.8),
             DetectionMosaic(input_dim=(640, 640), prob=0.8),
             DetectionPaddedRescale(input_dim=(640, 640), max_targets=120),
             DetectionPaddedRescale(input_dim=(640, 640), max_targets=120),
-            DetectionTargetsFormatTransform(output_format=DetectionTargetsFormat.XYXY_LABEL),
+            DetectionTargetsFormatTransform(input_dim=(640, 640), output_format=XYXY_LABEL),
         ]
         ]
 
 
         self.test_dir = tempfile.TemporaryDirectory().name
         self.test_dir = tempfile.TemporaryDirectory().name
Discard
@@ -21,7 +21,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         output = np.array([[50, 10, 20, 30, 40]], dtype=np.float32)
         output = np.array([[50, 10, 20, 30, 40]], dtype=np.float32)
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
-        transform = DetectionTargetsFormatTransform(image_shape=self.image.shape[1:], max_targets=1, input_format=XYXY_LABEL, output_format=LABEL_XYXY)
+        transform = DetectionTargetsFormatTransform(input_dim=self.image.shape[1:], max_targets=1, input_format=XYXY_LABEL, output_format=LABEL_XYXY)
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
 
 
@@ -31,9 +31,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         output = np.array([[10, 20 / w, 30 / h, 40 / w, 50 / h]], dtype=np.float32)
         output = np.array([[10, 20 / w, 30 / h, 40 / w, 50 / h]], dtype=np.float32)
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
-        transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_NORMALIZED_XYXY
-        )
+        transform = DetectionTargetsFormatTransform(input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_NORMALIZED_XYXY)
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
 
 
@@ -43,7 +41,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         output = np.array([[10, 30, 40, 20, 20]], dtype=np.float32)
         output = np.array([[10, 30, 40, 20, 20]], dtype=np.float32)
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
-        transform = DetectionTargetsFormatTransform(image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_CXCYWH)
+        transform = DetectionTargetsFormatTransform(input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_CXCYWH)
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
 
 
@@ -54,7 +52,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_NORMALIZED_CXCYWH
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_XYXY, output_format=LABEL_NORMALIZED_CXCYWH
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
@@ -66,7 +64,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_XYXY, output_format=LABEL_CXCYWH
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_XYXY, output_format=LABEL_CXCYWH
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
@@ -78,7 +76,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_XYXY, output_format=LABEL_NORMALIZED_CXCYWH
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_XYXY, output_format=LABEL_NORMALIZED_CXCYWH
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
@@ -88,7 +86,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         input = np.array([[10, 30, 40, 20, 20]], dtype=np.float32)
         input = np.array([[10, 30, 40, 20, 20]], dtype=np.float32)
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
-        transform = DetectionTargetsFormatTransform(image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_CXCYWH, output_format=LABEL_XYXY)
+        transform = DetectionTargetsFormatTransform(input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_CXCYWH, output_format=LABEL_XYXY)
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
 
 
@@ -99,7 +97,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_CXCYWH, output_format=LABEL_NORMALIZED_XYXY
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_CXCYWH, output_format=LABEL_NORMALIZED_XYXY
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
@@ -111,7 +109,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_CXCYWH, output_format=LABEL_XYXY
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_CXCYWH, output_format=LABEL_XYXY
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
@@ -123,7 +121,7 @@ class DetectionTargetsTransformTest(unittest.TestCase):
         sample = {"image": self.image, "target": input}
         sample = {"image": self.image, "target": input}
 
 
         transform = DetectionTargetsFormatTransform(
         transform = DetectionTargetsFormatTransform(
-            image_shape=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_CXCYWH, output_format=LABEL_NORMALIZED_XYXY
+            input_dim=self.image.shape[1:], max_targets=1, input_format=LABEL_NORMALIZED_CXCYWH, output_format=LABEL_NORMALIZED_XYXY
         )
         )
         t_output = transform(sample)["target"]
         t_output = transform(sample)["target"]
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
         self.assertTrue(np.allclose(output, t_output, atol=1e-6))
Discard