Ground Truth Spreadsheets and Code used to move all pictures into a folder

This commit is contained in:
prabhaavp
2026-03-26 01:18:43 -04:00
parent 233fa3df17
commit 24e0d2cc21
11 changed files with 6080 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
import os
import shutil
from tqdm import tqdm
from collections import defaultdict
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SOURCE_DIR = os.path.abspath(os.path.join(BASE_DIR, "../data/processed/wikipedia_html"))
DEST_DIR = os.path.abspath(os.path.join(BASE_DIR, "../data/processed/wikipedia_images"))
os.makedirs(DEST_DIR, exist_ok=True)
IMAGE_EXTS = (".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg")
all_images = []
for movie_folder in os.listdir(SOURCE_DIR):
folder_path = os.path.join(SOURCE_DIR, movie_folder)
if not os.path.isdir(folder_path):
continue
for fname in os.listdir(folder_path):
if fname.lower().endswith(IMAGE_EXTS):
all_images.append(os.path.join(folder_path, fname))
skipped = 0
copied = 0
for src_path in tqdm(all_images, desc="Copying images", unit="file"):
fname = os.path.basename(src_path)
dest_path = os.path.join(DEST_DIR, fname)
if os.path.exists(dest_path):
skipped += 1
continue
shutil.copy2(src_path, dest_path)
copied += 1