Mehdi Cherti commited on
Commit
7ef74d0
1 Parent(s): e7fb26f

put back the building script

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. build_yfcc15m.py +49 -0
README.md CHANGED
@@ -3,5 +3,5 @@ license: cc
3
  ---
4
 
5
  YFCC15m dataset from <https://github.com/openai/CLIP/blob/main/data/yfcc100m.md>.
6
- The subset is obtained by filtering the original YFCC100m (yfcc100m_dataset.sql) usin the photo ids from <https://github.com/openai/CLIP/blob/main/data/yfcc100m.md>.
7
  The script to rebuild the data from the original YFCC100m is provided at [build_yfcc15m.py](build_yfcc15m.py).
 
3
  ---
4
 
5
  YFCC15m dataset from <https://github.com/openai/CLIP/blob/main/data/yfcc100m.md>.
6
+ The subset is obtained by filtering the original YFCC100m (yfcc100m_dataset.sql) using the photo ids from <https://github.com/openai/CLIP/blob/main/data/yfcc100m.md>.
7
  The script to rebuild the data from the original YFCC100m is provided at [build_yfcc15m.py](build_yfcc15m.py).
build_yfcc15m.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import sqlite3
3
+ from yfcc100m.convert_metadata import generate_rows_from_db
4
+ from datadings.tools import yield_threaded
5
+ from tqdm import tqdm
6
+ df = pd.read_table(
7
+ "yfcc100m_subset_data.tsv", header=None, names=["line_number", "identifier", "hash"]
8
+ )
9
+ clip_photoids = df["identifier"].tolist() # 15 million ids
10
+ rows = generate_rows_from_db("yfcc100m_dataset.sql", "yfcc100m_dataset")
11
+ gen = yield_threaded(rows)
12
+ dfs = []
13
+ chunk = []
14
+ for i, row in enumerate(tqdm(gen, total=100000000)):
15
+ chunk.append(row)
16
+ if (i + 1) % 10_000_000 == 0:
17
+ df = pd.DataFrame(
18
+ chunk,
19
+ columns=[
20
+ "photoid",
21
+ "uid",
22
+ "unickname",
23
+ "datetaken",
24
+ "dateuploaded",
25
+ "capturedevice",
26
+ "title",
27
+ "description",
28
+ "usertags",
29
+ "machinetags",
30
+ "longitude",
31
+ "latitude",
32
+ "accuracy",
33
+ "pageurl",
34
+ "downloadurl",
35
+ "licensename",
36
+ "licenseurl",
37
+ "serverid",
38
+ "farmid",
39
+ "secret",
40
+ "secretoriginal",
41
+ "ext",
42
+ "marker",
43
+ ],
44
+ )
45
+ df = df[df["photoid"].isin(clip_photoids)].reset_index(drop=True)
46
+ dfs.append(df)
47
+ chunk = []
48
+ df = pd.concat(dfs)
49
+ df.to_csv("yfcc15m.csv", index=False)