yfcc15m / build_yfcc15m.py
Mehdi Cherti
put back the building script
7ef74d0
raw
history blame contribute delete
No virus
1.48 kB
import pandas as pd
import sqlite3
from yfcc100m.convert_metadata import generate_rows_from_db
from datadings.tools import yield_threaded
from tqdm import tqdm
df = pd.read_table(
"yfcc100m_subset_data.tsv", header=None, names=["line_number", "identifier", "hash"]
)
clip_photoids = df["identifier"].tolist() # 15 million ids
rows = generate_rows_from_db("yfcc100m_dataset.sql", "yfcc100m_dataset")
gen = yield_threaded(rows)
dfs = []
chunk = []
for i, row in enumerate(tqdm(gen, total=100000000)):
chunk.append(row)
if (i + 1) % 10_000_000 == 0:
df = pd.DataFrame(
chunk,
columns=[
"photoid",
"uid",
"unickname",
"datetaken",
"dateuploaded",
"capturedevice",
"title",
"description",
"usertags",
"machinetags",
"longitude",
"latitude",
"accuracy",
"pageurl",
"downloadurl",
"licensename",
"licenseurl",
"serverid",
"farmid",
"secret",
"secretoriginal",
"ext",
"marker",
],
)
df = df[df["photoid"].isin(clip_photoids)].reset_index(drop=True)
dfs.append(df)
chunk = []
df = pd.concat(dfs)
df.to_csv("yfcc15m.csv", index=False)