matter / sync.sh
ashu1069's picture
Matter - initial gradio space
0b33900
#!/usr/bin/env bash
# Sync upstream `matter/` package, `spec/` directory, and curated example images
# into the Space directory. Run this BEFORE `git push` to ashu-1069/matter.
set -euo pipefail
SPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "$SPACE_DIR/.." && pwd)"
echo "==> Syncing matter/ β†’ space/matter/"
rm -rf "$SPACE_DIR/matter"
rsync -a --exclude="__pycache__" --exclude="*.pyc" "$REPO_DIR/matter/" "$SPACE_DIR/matter/"
echo "==> Syncing spec/ β†’ space/spec/"
rm -rf "$SPACE_DIR/spec"
rsync -a --exclude="__pycache__" "$REPO_DIR/spec/" "$SPACE_DIR/spec/"
echo "==> Resizing + converting example images β†’ space/examples/ (JPEG, max 1280px)"
mkdir -p "$SPACE_DIR/examples"
python3 - <<PY
from PIL import Image
from pathlib import Path
src_dir = Path("$REPO_DIR/data/eval_seed/images")
out_dir = Path("$SPACE_DIR/examples")
out_dir.mkdir(parents=True, exist_ok=True)
for f in [
"domestic_pet_bottle.png",
"ewaste_dead_laptop.png",
"ev_pouch_cell.png",
"medical_glucose_strip.png",
"cd_brick.png",
"textile_cotton_tshirt.png",
]:
src = src_dir / f
if not src.exists():
print(f" ⚠️ missing: {src}")
continue
img = Image.open(src).convert("RGB")
w, h = img.size
m = max(w, h)
if m > 1280:
r = 1280 / m
img = img.resize((int(w * r), int(h * r)), Image.LANCZOS)
out = out_dir / (src.stem + ".jpg")
img.save(out, "JPEG", quality=85, optimize=True)
print(f" βœ“ {out.name} ({out.stat().st_size // 1024} KB)")
PY
echo "βœ… Space directory ready at: $SPACE_DIR"
echo " Push with: cd $SPACE_DIR && git add -A && git commit -m 'sync' && git push"