Repository: twosixlabs/armory
Issue: Separate CARLA dev and test preprocessing

Since the new dev set is of a different shape than the test set, these 2 datasets should have different preprocessing functions at least until we receive the new test set.

When trying to `get_batch()` from the test set, this is the error you'll get:

```
ValueError: shape (1, 600, 800, 3) does not match shape (None, 960, 1280, 3)

```

Note: this applies to both object detection and video tracking datasets

Changed files:
armory/data/adversarial_datasets.py

diff --git a/armory/data/adversarial_datasets.py b/armory/data/adversarial_datasets.py
index 4929a1e8..35ce2ca2 100644
--- a/armory/data/adversarial_datasets.py
+++ b/armory/data/adversarial_datasets.py
@@ -34,11 +34,16 @@ resisc45_adversarial_context = datasets.ImageContext(x_shape=(224, 224, 3))
 ucf101_adversarial_context = datasets.ImageContext(x_shape=(None, 112, 112, 3))
 apricot_adversarial_context = datasets.ImageContext(x_shape=(None, None, 3))
 dapricot_adversarial_context = datasets.ImageContext(x_shape=(3, None, None, 3))
-carla_obj_det_single_modal_context = datasets.ImageContext(x_shape=(960, 1280, 3))
-carla_obj_det_multimodal_context = datasets.ImageContext(x_shape=(960, 1280, 6))
-carla_video_tracking_context = datasets.VideoContext(
+carla_obj_det_dev_single_modal_context = datasets.ImageContext(x_shape=(960, 1280, 3))
+carla_obj_det_dev_multimodal_context = datasets.ImageContext(x_shape=(960, 1280, 6))
+carla_video_tracking_dev_context = datasets.VideoContext(
     x_shape=(None, 960, 1280, 3), frame_rate=10
 )
+carla_obj_det_test_single_modal_context = datasets.ImageContext(x_shape=(600, 800, 3))
+carla_obj_det_test_multimodal_context = datasets.ImageContext(x_shape=(600, 800, 6))
+carla_video_tracking_test_context = datasets.VideoContext(
+    x_shape=(None, 600, 800, 3), frame_rate=10
+)
 
 
 def imagenet_adversarial_canonical_preprocessing(batch):
@@ -72,9 +77,15 @@ def dapricot_canonical_preprocessing(batch):
     )
 
 
-def carla_video_tracking_canonical_preprocessing(batch):
+def carla_video_tracking_dev_canonical_preprocessing(batch):
+    return datasets.canonical_variable_image_preprocess(
+        carla_video_tracking_dev_context, batch
+    )
+
+
+def carla_video_tracking_test_canonical_preprocessing(batch):
     return datasets.canonical_variable_image_preprocess(
-        carla_video_tracking_context, batch
+        carla_video_tracking_test_context, batch
     )
 
 
@@ -572,11 +583,19 @@ def carla_obj_det_label_preprocessing(x, y):
     return (y_object, y_patch_metadata)
 
 
-def carla_obj_det_canonical_preprocessing(batch):
+def carla_obj_det_dev_canonical_preprocessing(batch):
+    if batch.shape[-1] == 6:
+        context = carla_obj_det_dev_multimodal_context
+    else:
+        context = carla_obj_det_dev_single_modal_context
+    return datasets.canonical_image_preprocess(context, batch)
+
+
+def carla_obj_det_test_canonical_preprocessing(batch):
     if batch.shape[-1] == 6:
-        context = carla_obj_det_multimodal_context
+        context = carla_obj_det_test_multimodal_context
     else:
-        context = carla_obj_det_single_modal_context
+        context = carla_obj_det_test_single_modal_context
     return datasets.canonical_image_preprocess(context, batch)
 
 
@@ -585,7 +604,7 @@ def carla_obj_det_dev(
     epochs: int = 1,
     batch_size: int = 1,
     dataset_dir: str = None,
-    preprocessing_fn: Callable = carla_obj_det_canonical_preprocessing,
+    preprocessing_fn: Callable = carla_obj_det_dev_canonical_preprocessing,
     label_preprocessing_fn=carla_obj_det_label_preprocessing,
     cache_dataset: bool = True,
     framework: str = "numpy",
@@ -625,9 +644,9 @@ def carla_obj_det_dev(
     preprocessing_fn = datasets.preprocessing_chain(mode_split_fn, preprocessing_fn)
 
     context = (
-        carla_obj_det_multimodal_context
+        carla_obj_det_dev_multimodal_context
         if modality == "both"
-        else carla_obj_det_single_modal_context
+        else carla_obj_det_dev_single_modal_context
     )
 
     return datasets._generator_from_tfds(
@@ -653,7 +672,7 @@ def carla_obj_det_test(
     epochs: int = 1,
     batch_size: int = 1,
     dataset_dir: str = None,
-    preprocessing_fn: Callable = carla_obj_det_canonical_preprocessing,
+    preprocessing_fn: Callable = carla_obj_det_test_canonical_preprocessing,
     label_preprocessing_fn=carla_obj_det_label_preprocessing,
     cache_dataset: bool = True,
     framework: str = "numpy",
@@ -696,9 +715,9 @@ def carla_obj_det_test(
     preprocessing_fn = datasets.preprocessing_chain(mode_split_fn, preprocessing_fn)
 
     context = (
-        carla_obj_det_multimodal_context
+        carla_obj_det_test_multimodal_context
         if modality == "both"
-        else carla_obj_det_single_modal_context
+        else carla_obj_det_test_single_modal_context
     )
 
     return datasets._generator_from_tfds(
@@ -732,7 +751,7 @@ def carla_video_tracking_dev(
     epochs: int = 1,
     batch_size: int = 1,
     dataset_dir: str = None,
-    preprocessing_fn: Callable = carla_video_tracking_canonical_preprocessing,
+    preprocessing_fn: Callable = carla_video_tracking_dev_canonical_preprocessing,
     label_preprocessing_fn=carla_video_tracking_label_preprocessing,
     cache_dataset: bool = True,
     framework: str = "numpy",
@@ -761,7 +780,7 @@ def carla_video_tracking_dev(
         cache_dataset=cache_dataset,
         framework=framework,
         shuffle_files=shuffle_files,
-        context=carla_video_tracking_context,
+        context=carla_video_tracking_dev_context,
         as_supervised=False,
         supervised_xy_keys=("video", ("bboxes", "patch_metadata")),
         **kwargs,
@@ -773,7 +792,7 @@ def carla_video_tracking_test(
     epochs: int = 1,
     batch_size: int = 1,
     dataset_dir: str = None,
-    preprocessing_fn: Callable = carla_video_tracking_canonical_preprocessing,
+    preprocessing_fn: Callable = carla_video_tracking_test_canonical_preprocessing,
     label_preprocessing_fn=carla_video_tracking_label_preprocessing,
     cache_dataset: bool = True,
     framework: str = "numpy",
@@ -802,7 +821,7 @@ def carla_video_tracking_test(
         cache_dataset=cache_dataset,
         framework=framework,
         shuffle_files=shuffle_files,
-        context=carla_video_tracking_context,
+        context=carla_video_tracking_test_context,
         as_supervised=False,
         supervised_xy_keys=("video", ("bboxes", "patch_metadata")),
         **kwargs,