Spaces:
Sleeping
Sleeping
Update SynthScope Space from the GitHub repository
Browse filesFiles changed (3)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465"""Build SynthScope's online-demo data pack: a few files per generator from several openly licensed benchmarks, in thelayout the web app reads (<Folder>/test/<generator>/{0_real,1_fake} or EvalCrafter's test/1_fake/<generator>), plus aREADME with sources and licenses. Files are picked evenly across each folder (deterministic)."""import shutilimport sysfrom pathlib import Path
S = Path("/ssdstore/ssalehi/SynthScope")OUT = S / "_demo_pack"EXT = {".jpg", ".jpeg", ".png", ".webp", ".mp4", ".gif", ".mov"}
def pick(folder: Path, k: int) -> list[Path]: files = sorted(p for p in folder.iterdir() if p.suffix.lower() in EXT and not p.name.startswith("._")) if len(files) <= k: return files return [files[round(i * (len(files) - 1) / (k - 1))] for i in range(k)] if k > 1 else files[:1]
def copy(files, dest: Path): dest.mkdir(parents=True, exist_ok=True) for p in files: shutil.copy2(p, dest / p.name)
PLAN = [ # (folder, per-class count, classes) ("CommGen15", 6, ("0_real", "1_fake")), ("RRDataset", 12, ("0_real", "1_fake")), ("EvalGEN", 8, ("1_fake",)), ("VideoPhy", 3, ("1_fake",)),]shutil.rmtree(OUT, ignore_errors=True)for folder, k, classes in PLAN: for gen in sorted(p for p in (S / folder / "test").iterdir() if p.is_dir()): for c in classes: copy(pick(gen / c, k), OUT / folder / "test" / gen.name / c)for gen in sorted(p for p in (S / "EvalCrafter" / "test" / "1_fake").iterdir() if p.is_dir()): copy(pick(gen, 3), OUT / "EvalCrafter" / "test" / "1_fake" / gen.name)
(OUT / "README.md").write_text("""---license: otherpretty_name: SynthScope online-demo data---# SynthScope online-demo data
A small sample of public AI-generated-image and -video benchmarks for the dataset browser of the SynthScope online demo.A local SynthScope install downloads the full datasets with one command each.
| Folder | Source | License | Sample ||---|---|---|---|| CommGen15 | PGC (Zhou et al.), Hugging Face `xiaoyuzhou68/CommGen15` | Apache-2.0 | 6 real + 6 generated per generator || RRDataset | "Bridging the Gap Between Ideal and Real-world Evaluation" (ICCV 2025), Zenodo record 14963880 | CC BY 4.0 | 12 real + 12 generated per scenario || EvalGEN | DDA (Chen et al., NeurIPS 2025), Hugging Face `Junwei-Xi/EvalGEN` | Apache-2.0 | 8 generated images per generator || EvalCrafter | EvalCrafter (Liu et al., CVPR 2024), Hugging Face `RaphaelLiu/EvalCrafter_T2V_Dataset` | Apache-2.0 | 3 generated clips per generator || VideoPhy | VideoPhy (Bansal et al., 2024), `videophysics/videophy_test_public` | MIT | 3 generated clips per generator |
All files are unchanged copies from those sources; credit belongs to their authors.""")n = sum(1 for p in OUT.rglob("*") if p.is_file())size = sum(p.stat().st_size for p in OUT.rglob("*") if p.is_file())print(f"demo pack: {n} files, {size / 1e6:.0f} MB at {OUT}")for d in sorted(OUT.iterdir()): if d.is_dir(): print(f" {d.name}: {sum(1 for p in d.rglob('*') if p.is_file())} files, " f"{sum(p.stat().st_size for p in d.rglob('*') if p.is_file()) / 1e6:.0f} MB")1 unmodified line234567891011121314151 unmodified line# Space entry point: fetch the approved detector weights, then serve the page on the port Spaces expect (7860).set -epython deploy/hf-space/fetch_weights.py# Openly licensed datasets for the "Browse datasets" tab, downloaded in the background (the tab appears once one is ready).# SYNTHSCOPE_SPACE_DATASETS="" turns this off.export SYNTHSCOPE_DATA_DIR=${SYNTHSCOPE_DATA_DIR:-$HOME/data}(for spec in ${SYNTHSCOPE_SPACE_DATASETS-image:commgen15:CommGen15 video:evalcrafter:EvalCrafter}; doIFS=: read -r modality name folder <<< "$spec"python benchmark/download_dataset.py "$name" --modality "$modality" --root "$SYNTHSCOPE_DATA_DIR/$folder" \> "$HOME/download_$name.log" 2>&1 && echo "[data] $name ready" || echo "[data] $name failed (see $HOME/download_$name.log)"done) &exec python -m uvicorn interface.backend.app:app --host 0.0.0.0 --port 78601 unmodified line23456789101112131415161718192021221 unmodified line# Space entry point: fetch the approved detector weights, then serve the page on the port Spaces expect (7860).set -epython deploy/hf-space/fetch_weights.py# Data for the "Browse datasets" tab. By default a small demo pack (a few files per generator from several openly licensed# benchmarks, ~a few hundred MB) is fetched from the Hugging Face dataset repo SYNTHSCOPE_DEMO_DATA_REPO. Setting# SYNTHSCOPE_SPACE_DATASETS (e.g. "image:commgen15:CommGen15") instead downloads those full datasets with their loaders.# Both run in the background; the tab appears once a dataset is ready.export SYNTHSCOPE_DATA_DIR=${SYNTHSCOPE_DATA_DIR:-$HOME/data}(if [ -n "${SYNTHSCOPE_SPACE_DATASETS:-}" ]; thenfor spec in $SYNTHSCOPE_SPACE_DATASETS; doIFS=: read -r modality name folder <<< "$spec"python benchmark/download_dataset.py "$name" --modality "$modality" --root "$SYNTHSCOPE_DATA_DIR/$folder" \> "$HOME/download_$name.log" 2>&1 && echo "[data] $name ready" || echo "[data] $name failed (see $HOME/download_$name.log)"doneelif [ -n "${SYNTHSCOPE_DEMO_DATA_REPO-SMSD75/synthscope-demo-data}" ]; thenpython -c "import os; from huggingface_hub import snapshot_download; snapshot_download(os.environ.get('SYNTHSCOPE_DEMO_DATA_REPO', 'SMSD75/synthscope-demo-data'), repo_type='dataset', local_dir=os.environ['SYNTHSCOPE_DATA_DIR'], token=os.environ.get('HF_TOKEN'))" \> "$HOME/download_demo_data.log" 2>&1 && echo "[data] demo pack ready" || echo "[data] demo pack failed (see $HOME/download_demo_data.log)"fi) &exec python -m uvicorn interface.backend.app:app --host 0.0.0.0 --port 7860
558 unmodified lines559560561562563564601 unmodified lines1166116711681169117011711172558 unmodified lines// SOTA generator vs detector: pick/upload a real image -> a generator makes a new image ONCE -> any number of// detectors score the pair. Ticking another detector only scores it (no regeneration).const SETUP_URL = "https://github.com/SMSD75/SynthScope#readme";// Shown instead of "Test a generator" when no generator can run on this server (no GPU and no API key).function GeneratorOff({ demo }) {601 unmodified linesreturn html`<div class="explore">${demo && html`<div class="card notice slim"><b>Demo subset.</b> To keep this online demo light it includes only ${datasets.map(d => d.name).join(" and ")}.${" "}Run SynthScope on your own computer and it downloads and browses every supported benchmark${supported ? ` (${supported.image} image and ${supported.video} video datasets)` : ""}, each with one command;see the <a href=${SETUP_URL} target="_blank" rel="noopener">setup guide</a>.558 unmodified lines559560561562563564565601 unmodified lines11671168116911701171117211731174558 unmodified lines// SOTA generator vs detector: pick/upload a real image -> a generator makes a new image ONCE -> any number of// detectors score the pair. Ticking another detector only scores it (no regeneration).const SETUP_URL = "https://github.com/SMSD75/SynthScope#readme";const listNames = xs => xs.length < 2 ? (xs[0] || "") : xs.slice(0, -1).join(", ") + " and " + xs[xs.length - 1];// Shown instead of "Test a generator" when no generator can run on this server (no GPU and no API key).function GeneratorOff({ demo }) {601 unmodified linesreturn html`<div class="explore">${demo && html`<div class="card notice slim"><b>Demo subset.</b> To keep this online demo light it includes a few files per generator from${" "}${listNames(datasets.map(d => d.name.split(" (")[0]))}.${" "}Run SynthScope on your own computer and it downloads and browses every supported benchmark${supported ? ` (${supported.image} image and ${supported.video} video datasets)` : ""}, each with one command;see the <a href=${SETUP_URL} target="_blank" rel="noopener">setup guide</a>.
deploy/hf-space/build_demo_pack.pyAdded+65
deploy/hf-space/start.sh+14-7
interface/static/index.html+3-1