From e8657f1e6555c4e8572e3e526b2e0a7bb8dde229 Mon Sep 17 00:00:00 2001 From: Johan MEJIA Date: Tue, 7 Sep 2021 16:27:28 +0200 Subject: [PATCH 1/4] Update dataset demo with samples and download links --- alodataset/base_dataset.py | 18 ++++++++++-------- alodataset/flying_chairs2_dataset.py | 2 ++ alodataset/merge_dataset.py | 4 ++-- alodataset/sintel_base_dataset.py | 5 +++++ alodataset/sintel_disparity_dataset.py | 4 ++-- alodataset/sintel_flow_dataset.py | 4 ++-- alodataset/sintel_multi_dataset.py | 4 ++-- alodataset/waymo_dataset.py | 1 - 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/alodataset/base_dataset.py b/alodataset/base_dataset.py index a56ab78e..5d514f62 100644 --- a/alodataset/base_dataset.py +++ b/alodataset/base_dataset.py @@ -12,14 +12,16 @@ import aloscene DATASETS_DOWNLOAD_PATHS = { - "coco": "https://storage.googleapis.com/visualbehavior-sample/coco_sample.pkl", - "waymo": "https://storage.googleapis.com/visualbehavior-sample/waymo_sample.pkl", - "mot17": "https://storage.googleapis.com/visualbehavior-sample/mot17_sample.pkl", - "chairsSDHom": "https://storage.googleapis.com/visualbehavior-sample/chairsSDHom_sample.pkl", - "crowdhuman": "https://storage.googleapis.com/visualbehavior-sample/crowdhuman_sample.pkl", - "flyingChairs2": "https://storage.googleapis.com/visualbehavior-sample/flyingChairs2_sample.pkl", - "flyingThings": "https://storage.googleapis.com/visualbehavior-sample/flyingThings_sample.pkl", - "Sintel": "https://storage.googleapis.com/visualbehavior-sample/Sintel_sample.pkl", + "coco": "https://storage.googleapis.com/visualbehavior-sample/coco.pkl", + "waymo": "https://storage.googleapis.com/visualbehavior-sample/waymo.pkl", + "mot17": "https://storage.googleapis.com/visualbehavior-sample/mot17.pkl", + "chairsSDHom": "https://storage.googleapis.com/visualbehavior-sample/chairsSDHom.pkl", + "crowdhuman": "https://storage.googleapis.com/visualbehavior-sample/crowdhuman.pkl", + "FlyingChairs2": "https://storage.googleapis.com/visualbehavior-sample/FlyingChairs2.pkl", + "FlyingThings3DSubset": "https://storage.googleapis.com/visualbehavior-sample/FlyingThings3DSubset.pkl", + "SintelDisparity": "https://storage.googleapis.com/visualbehavior-sample/SintelDisparity.pkl", + "SintelFlow": "https://storage.googleapis.com/visualbehavior-sample/SintelFlow.pkl", + "SintelMulti": "https://storage.googleapis.com/visualbehavior-sample/SintelMulti.pkl", } diff --git a/alodataset/flying_chairs2_dataset.py b/alodataset/flying_chairs2_dataset.py index 438efa0d..643b8a8c 100644 --- a/alodataset/flying_chairs2_dataset.py +++ b/alodataset/flying_chairs2_dataset.py @@ -22,6 +22,8 @@ class FlyingChairs2Dataset(BaseDataset, SplitMixin): def __init__(self, **kwargs): super(FlyingChairs2Dataset, self).__init__(name="FlyingChairs2", **kwargs) + if self.sample: + return self.dir_path = self._dir_path() self.items = self._get_sequences() diff --git a/alodataset/merge_dataset.py b/alodataset/merge_dataset.py index 5d74e08f..e0f5827c 100644 --- a/alodataset/merge_dataset.py +++ b/alodataset/merge_dataset.py @@ -72,8 +72,8 @@ def train_loader(self, batch_size=1, num_workers=2, sampler=torch.utils.data.Ran if __name__ == "__main__": from alodataset import ChairsSDHomDataset, FlyingThings3DSubsetDataset, Split - chairs = ChairsSDHomDataset(split=Split.VAL) - flying = FlyingThings3DSubsetDataset(split=Split.VAL, sequence_size=2, transform_fn=lambda f: f["left"]) + chairs = ChairsSDHomDataset(sample=True) + flying = FlyingThings3DSubsetDataset(sample=True, transform_fn=lambda f: f["left"]) multi = MergeDataset([chairs, flying]) diff --git a/alodataset/sintel_base_dataset.py b/alodataset/sintel_base_dataset.py index ade6695d..27f652c4 100644 --- a/alodataset/sintel_base_dataset.py +++ b/alodataset/sintel_base_dataset.py @@ -65,6 +65,9 @@ def __init__(self, cameras=None, labels=None, passes=None, sintel_sequences=None self.labels = labels if labels is not None else self.LABELS self.passes = passes if passes is not None else self.PASSES self.sintel_sequences = sintel_sequences if sintel_sequences is not None else self.SINTEL_SEQUENCES + if self.sample: + return + self._assert_inputs() self.items = self._get_sequences() @@ -154,5 +157,7 @@ def _get_frames(self, sequence_data): return frames def getitem(self, idx): + if self.sample: + return BaseDataset.__getitem__(self, idx) sequence_data = self.items[idx] return self._get_frames(sequence_data) diff --git a/alodataset/sintel_disparity_dataset.py b/alodataset/sintel_disparity_dataset.py index 396dbb82..49a057a0 100644 --- a/alodataset/sintel_disparity_dataset.py +++ b/alodataset/sintel_disparity_dataset.py @@ -105,8 +105,8 @@ def _get_camera_frames(self, sequence_data, camera): if __name__ == "__main__": - dataset = SintelDisparityDataset(sequence_size=2) + dataset = SintelDisparityDataset(sample=True) # show some frames at various indices - for idx in [1, 15, 64]: + for idx in [1, 2, 5]: frames = dataset.getitem(idx)["left"] frames.get_view().render() diff --git a/alodataset/sintel_flow_dataset.py b/alodataset/sintel_flow_dataset.py index e76f666b..e47548c4 100644 --- a/alodataset/sintel_flow_dataset.py +++ b/alodataset/sintel_flow_dataset.py @@ -95,8 +95,8 @@ def _get_camera_frames(self, sequence_data, camera): if __name__ == "__main__": - dataset = SintelFlowDataset(sequence_size=2) + dataset = SintelFlowDataset(sample=True) # show some frames at various indices - for idx in [1, 15, 64]: + for idx in [1, 2, 5]: frames = dataset.getitem(idx)["left"] frames.get_view().render() diff --git a/alodataset/sintel_multi_dataset.py b/alodataset/sintel_multi_dataset.py index f08831cb..6df1a384 100644 --- a/alodataset/sintel_multi_dataset.py +++ b/alodataset/sintel_multi_dataset.py @@ -117,9 +117,9 @@ def set_dataset_dir(self, dataset_dir: str): if __name__ == "__main__": - dataset = SintelMultiDataset(sequence_size=2) + dataset = SintelMultiDataset(sample=True) # show some frames at various indices - for idx in [1, 15, 64]: + for idx in [1, 2, 5]: frames = dataset.getitem(idx) frames["left"].get_view().render() frames["right"].get_view().render() diff --git a/alodataset/waymo_dataset.py b/alodataset/waymo_dataset.py index 525b346c..60b634cf 100644 --- a/alodataset/waymo_dataset.py +++ b/alodataset/waymo_dataset.py @@ -503,7 +503,6 @@ def main(): """Main""" waymo_dataset = WaymoDataset(sample=True) waymo_dataset.prepare() - print(waymo_dataset.dataset_dir) for frames in waymo_dataset.train_loader(batch_size=2): frames = Frame.batch_list([frame["front"] for frame in frames]) From d762662c1bbdfaab70a5fef4538b02e567e67992 Mon Sep 17 00:00:00 2001 From: Johan MEJIA Date: Tue, 7 Sep 2021 16:30:40 +0200 Subject: [PATCH 2/4] unittest with samples --- unittest/test_frame.py | 4 ++-- unittest/test_train.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unittest/test_frame.py b/unittest/test_frame.py index ed4e317c..2558398c 100644 --- a/unittest/test_frame.py +++ b/unittest/test_frame.py @@ -6,8 +6,8 @@ import torch import numpy as np -# waymo_dataset = WaymoDataset(sample=True) -waymo_dataset = WaymoDataset(split=Split.VAL, labels=["gt_boxes_2d", "gt_boxes_3d"], sequence_size=2) +waymo_dataset = WaymoDataset(sample=True) +# waymo_dataset = WaymoDataset(split=Split.VAL, labels=["gt_boxes_2d", "gt_boxes_3d"], sequence_size=2) TEST_FRAME = 0 diff --git a/unittest/test_train.py b/unittest/test_train.py index a1c3a7c8..73c03441 100644 --- a/unittest/test_train.py +++ b/unittest/test_train.py @@ -58,11 +58,11 @@ def test_deformable_detr(mock_args): @mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(**raft_args)) -def _test_raft(mock_args): +def test_raft(mock_args): raft_train_on_chairs() if __name__ == "__main__": test_deformable_detr() test_detr() - # test_raft() + test_raft() From 775bab35e9179ac47c9d4352b1cacee16c7a233e Mon Sep 17 00:00:00 2001 From: Johan MEJIA Date: Wed, 8 Sep 2021 09:16:00 +0200 Subject: [PATCH 3/4] Update demo with sample --- alodataset/mot17.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/alodataset/mot17.py b/alodataset/mot17.py index af24a618..948fd5f7 100644 --- a/alodataset/mot17.py +++ b/alodataset/mot17.py @@ -219,9 +219,7 @@ def getitem(self, idx): def main(): """Main""" - mot_dataset = Mot17( - split=Split.TRAIN, validation_sequences=["MOT17-05"], detections_set=["FRCNN"], sequence_size=2, random_step=30 - ) + mot_dataset = Mot17(sample=True) for frames in mot_dataset.stream_loader(): frames.names From fbec64f3ccf1d96e71fca0d611141b8d95abbf21 Mon Sep 17 00:00:00 2001 From: Johansmm Date: Wed, 8 Sep 2021 17:41:10 +0200 Subject: [PATCH 4/4] fix bug in get function in some datasets --- alodataset/chairssdhom_dataset.py | 2 ++ alodataset/crowd_human_dataset.py | 4 +++- alodataset/flying_chairs2_dataset.py | 2 ++ alodataset/flyingthings3D_subset_dataset.py | 2 ++ alodataset/mot17.py | 4 +++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/alodataset/chairssdhom_dataset.py b/alodataset/chairssdhom_dataset.py index e56edb0d..a42c5549 100644 --- a/alodataset/chairssdhom_dataset.py +++ b/alodataset/chairssdhom_dataset.py @@ -59,6 +59,8 @@ def getitem(self, idx): """ Return frames corresponding to a sequence """ + if self.sample: + return BaseDataset.__getitem__(self, idx) sequence_data = self.items[idx] return self.get_frames(sequence_data) diff --git a/alodataset/crowd_human_dataset.py b/alodataset/crowd_human_dataset.py index fd9f5b9b..191fc08c 100644 --- a/alodataset/crowd_human_dataset.py +++ b/alodataset/crowd_human_dataset.py @@ -93,6 +93,9 @@ def load_gt(self, dict_input): return bboxes, classes def getitem(self, idx): + if self.sample: + return BaseDataset.__getitem__(self, idx) + record = self.items[idx] image_id = record["ID"] @@ -256,7 +259,6 @@ def main(): crowd_human_dataset = CrowdHumanDataset(sample=True) crowd_human_dataset.prepare() - for i, frames in enumerate(crowd_human_dataset.train_loader(batch_size=2, sampler=None, num_workers=0)): frames = Frame.batch_list(frames) frames.get_view().render(figsize=(20, 10)) diff --git a/alodataset/flying_chairs2_dataset.py b/alodataset/flying_chairs2_dataset.py index 643b8a8c..a48e162e 100644 --- a/alodataset/flying_chairs2_dataset.py +++ b/alodataset/flying_chairs2_dataset.py @@ -75,6 +75,8 @@ def getitem(self, idx): idx : int index of the sequence """ + if self.sample: + return BaseDataset.__getitem__(self, idx) sequence_data = self.items[idx] return self._get_frames(sequence_data) diff --git a/alodataset/flyingthings3D_subset_dataset.py b/alodataset/flyingthings3D_subset_dataset.py index b4b93545..a697538e 100644 --- a/alodataset/flyingthings3D_subset_dataset.py +++ b/alodataset/flyingthings3D_subset_dataset.py @@ -359,6 +359,8 @@ def get_frames(self, sequence_data): return frames def getitem(self, idx): + if self.sample: + return BaseDataset.__getitem__(self, idx) sequence_data = self.items[idx] return self.get_frames(sequence_data) diff --git a/alodataset/mot17.py b/alodataset/mot17.py index 948fd5f7..5d2e1169 100644 --- a/alodataset/mot17.py +++ b/alodataset/mot17.py @@ -163,6 +163,9 @@ def _add_line(self, sequence: str, line: str, config: configparser.ConfigParser) ) def getitem(self, idx): + if self.sample: + return BaseDataset.__getitem__(self, idx) + seq = list(self.items[idx]["seq"]) sequence_name = self.items[idx]["mot_sequence"] @@ -220,7 +223,6 @@ def getitem(self, idx): def main(): """Main""" mot_dataset = Mot17(sample=True) - for frames in mot_dataset.stream_loader(): frames.names frames.get_view(