File size: 1,684 Bytes
0b33900
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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"