Datasets:
Commit
·
4ee31f3
1
Parent(s):
14e1381
add csvs and downloader script
Browse files- image_downloader.py +28 -0
- jafacility20.csv +0 -0
- jaflower30.csv +0 -0
- jafood101.csv +0 -0
- jalandmark10.csv +0 -0
image_downloader.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import csv
|
3 |
+
import time
|
4 |
+
from pathlib import Path
|
5 |
+
from urllib.request import urlretrieve
|
6 |
+
|
7 |
+
wait_time = 1.0
|
8 |
+
|
9 |
+
|
10 |
+
if __name__ == "__main__":
|
11 |
+
parser = argparse.ArgumentParser("Image Downloader")
|
12 |
+
parser.add_argument("--csv", type=str, required=True, help="Path to CSV file of images to download")
|
13 |
+
parser.add_argument("--output", type=str, required=True, help="Path to output directory")
|
14 |
+
args = parser.parse_args()
|
15 |
+
|
16 |
+
output_dir = Path(args.output)
|
17 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
18 |
+
|
19 |
+
with open(args.csv, "r") as f:
|
20 |
+
reader = csv.reader(f)
|
21 |
+
for i, row in enumerate(reader):
|
22 |
+
url = row[3]
|
23 |
+
id_ = row[0]
|
24 |
+
try:
|
25 |
+
urlretrieve(url, output_dir / id_)
|
26 |
+
except:
|
27 |
+
print(f"Failed to download {url}")
|
28 |
+
time.sleep(wait_time)
|
jafacility20.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
jaflower30.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
jafood101.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
jalandmark10.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|