Download a single image. Args: test_set: The test set name. index: The download image index. src_url: The download URL. dst_path: The destination file path.
(test_set: str, index: int, src_url: str, dst_path: Path)
| 31 | |
| 32 | |
| 33 | def download(test_set: str, index: int, src_url: str, dst_path: Path) -> None: |
| 34 | ''' |
| 35 | Download a single image. |
| 36 | |
| 37 | Args: |
| 38 | test_set: The test set name. |
| 39 | index: The download image index. |
| 40 | src_url: The download URL. |
| 41 | dst_path: The destination file path. |
| 42 | ''' |
| 43 | # Skip downloads if the file already exists |
| 44 | if dst_path.exists(): |
| 45 | print(f'{test_set} image {index}: Skipping') |
| 46 | return |
| 47 | |
| 48 | dir_name = dst_path.parent |
| 49 | dir_name.mkdir(parents=True, exist_ok=True) |
| 50 | |
| 51 | print(f'{test_set} image {index}: Downloading') |
| 52 | urllib.request.urlretrieve(src_url, dst_path) |
| 53 | |
| 54 | |
| 55 | def make_landscape(file_path: Path) -> None: |
no test coverage detected