(dataset,
video_ids,
dataset_splits,
download_dir,
keep_zip,
raw_dataset_assets,
should_download_laser_scanner_point_cloud,
)
| 150 | |
| 151 | |
| 152 | def download_data(dataset, |
| 153 | video_ids, |
| 154 | dataset_splits, |
| 155 | download_dir, |
| 156 | keep_zip, |
| 157 | raw_dataset_assets, |
| 158 | should_download_laser_scanner_point_cloud, |
| 159 | ): |
| 160 | metadata = get_metadata(dataset, download_dir) |
| 161 | if None is metadata: |
| 162 | print(f"Error retrieving metadata for dataset {dataset}") |
| 163 | return |
| 164 | |
| 165 | download_dir = os.path.abspath(download_dir) |
| 166 | for video_id in sorted(set(video_ids)): |
| 167 | split = dataset_splits[video_ids.index(video_id)] |
| 168 | dst_dir = os.path.join(download_dir, dataset, split) |
| 169 | if dataset == 'raw': |
| 170 | url_prefix = "" |
| 171 | file_names = [] |
| 172 | if not raw_dataset_assets: |
| 173 | print(f"Warning: No raw assets given for video id {video_id}") |
| 174 | else: |
| 175 | dst_dir = os.path.join(dst_dir, str(video_id)) |
| 176 | url_prefix = f"{ARkitscense_url}/raw/{split}/{video_id}" + "/{}" |
| 177 | file_names = raw_files(video_id, raw_dataset_assets, metadata) |
| 178 | elif dataset == '3dod': |
| 179 | url_prefix = f"{ARkitscense_url}/threedod/{split}" + "/{}" |
| 180 | file_names = [f"{video_id}.zip", ] |
| 181 | elif dataset == 'upsampling': |
| 182 | url_prefix = f"{ARkitscense_url}/upsampling/{split}" + "/{}" |
| 183 | file_names = [f"{video_id}.zip", ] |
| 184 | else: |
| 185 | raise Exception(f'No such dataset = {dataset}') |
| 186 | |
| 187 | if should_download_laser_scanner_point_cloud and dataset == 'raw': |
| 188 | # Point clouds only available for the raw dataset |
| 189 | download_laser_scanner_point_clouds_for_video(video_id, metadata, download_dir) |
| 190 | |
| 191 | for file_name in file_names: |
| 192 | dst_path = os.path.join(dst_dir, file_name) |
| 193 | url = url_prefix.format(file_name) |
| 194 | |
| 195 | if not file_name.endswith('.zip') or not os.path.isdir(dst_path[:-len('.zip')]): |
| 196 | download_file(url, dst_path, dst_dir) |
| 197 | else: |
| 198 | print(f'WARNING: skipping download of existing zip file: {dst_path}') |
| 199 | if file_name.endswith('.zip') and os.path.isfile(dst_path): |
| 200 | unzip_file(file_name, dst_dir, keep_zip) |
| 201 | |
| 202 | if dataset == 'upsampling' and VALIDATION in dataset_splits: |
| 203 | val_attributes_file = "val_attributes.csv" |
| 204 | url = f"{ARkitscense_url}/upsampling/{VALIDATION}/{val_attributes_file}" |
| 205 | dst_file = os.path.join(download_dir, dataset, VALIDATION) |
| 206 | download_file(url, val_attributes_file, dst_file) |
| 207 | |
| 208 | |
| 209 | if __name__ == "__main__": |
no test coverage detected