chore: deploy private lightloom build
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitignore +0 -81
- app.py +9 -3
- benchmarks/results/g1.json +153 -0
- benchmarks/results/g1.md +17 -0
- frontend/assets/scroll/section-0-depth.png +0 -0
- frontend/assets/scroll/section-1-depth.png +0 -0
- frontend/assets/scroll/section-2-depth.png +0 -0
- frontend/assets/scroll/section-3-depth.png +0 -0
- frontend/assets/scroll/section-4-depth.png +0 -0
- frontend/assets/scroll/section-5-depth.png +0 -0
- frontend/js/controller.js +6 -1
- package-lock.json +0 -56
- package.json +0 -5
- pyproject.toml +0 -21
- scripts/_debug_asr.py +0 -44
- scripts/asr-feasibility.cjs +0 -12
- scripts/asr-feasibility.html +0 -41
- scripts/build_corridor_showcase.py +0 -95
- scripts/build_scroll_showcase.py +0 -89
- scripts/build_showcase.py +0 -91
- scripts/deploy_private_space.py +0 -114
- scripts/fetch_gate_g1.py +0 -57
- scripts/fetch_gate_g2_g3.py +0 -52
- scripts/preflight.py +0 -395
- scripts/release_check.py +0 -84
- scripts/set_hf_env.ps1 +0 -55
- scripts/shoot-app.cjs +0 -90
- scripts/shoot-corridor.cjs +0 -57
- scripts/shoot-immersive.cjs +0 -68
- scripts/shoot-intro-local.cjs +0 -68
- scripts/shoot-live-phrases.cjs +0 -72
- scripts/shoot-live.cjs +0 -65
- scripts/shoot-mic-live.cjs +0 -115
- scripts/shoot-motion.cjs +0 -36
- scripts/shoot-pano.cjs +0 -58
- scripts/shoot-scroll.cjs +0 -45
- scripts/shoot-showcase.cjs +0 -72
- scripts/shoot-voice-live.cjs +0 -65
- scripts/shoot-voice.cjs +0 -96
- scripts/shoot.cjs +0 -88
- src/lightloom/depth/depth.py +13 -9
- src/lightloom/paint/scroll.py +4 -2
- tests/test_audio.py +0 -18
- tests/test_beats.py +0 -57
- tests/test_budget.py +0 -48
- tests/test_compliance.py +0 -53
- tests/test_depth.py +0 -31
- tests/test_director_parse.py +0 -68
- tests/test_gate_g1.py +0 -21
- tests/test_gate_g2_g3.py +0 -19
.gitignore
DELETED
|
@@ -1,81 +0,0 @@
|
|
| 1 |
-
.env
|
| 2 |
-
.env.*
|
| 3 |
-
!.env.example
|
| 4 |
-
*.token
|
| 5 |
-
*.secret
|
| 6 |
-
secrets/
|
| 7 |
-
weights/
|
| 8 |
-
models/
|
| 9 |
-
checkpoints/
|
| 10 |
-
*.safetensors
|
| 11 |
-
*.ckpt
|
| 12 |
-
*.pt
|
| 13 |
-
*.pth
|
| 14 |
-
*.onnx
|
| 15 |
-
*.gguf
|
| 16 |
-
*.zip
|
| 17 |
-
*.7z
|
| 18 |
-
*.tar
|
| 19 |
-
*.tar.gz
|
| 20 |
-
*.mp4
|
| 21 |
-
*.mov
|
| 22 |
-
*.wav
|
| 23 |
-
*.flac
|
| 24 |
-
*.png
|
| 25 |
-
*.jpg
|
| 26 |
-
*.jpeg
|
| 27 |
-
*.webp
|
| 28 |
-
*.log
|
| 29 |
-
|
| 30 |
-
.venv/
|
| 31 |
-
node_modules/
|
| 32 |
-
.shots/
|
| 33 |
-
VideosExamples/
|
| 34 |
-
*.pdf
|
| 35 |
-
__pycache__/
|
| 36 |
-
*.py[cod]
|
| 37 |
-
.pytest_cache/
|
| 38 |
-
.mypy_cache/
|
| 39 |
-
.ruff_cache/
|
| 40 |
-
.coverage
|
| 41 |
-
htmlcov/
|
| 42 |
-
|
| 43 |
-
benchmarks/results/*
|
| 44 |
-
!benchmarks/results/.gitkeep
|
| 45 |
-
!benchmarks/results/*.json
|
| 46 |
-
!benchmarks/results/*.md
|
| 47 |
-
|
| 48 |
-
assets/showcase/*
|
| 49 |
-
!assets/showcase/.gitkeep
|
| 50 |
-
assets/anchors/generated/*
|
| 51 |
-
frontend/.cache/
|
| 52 |
-
|
| 53 |
-
# Showcase reel assets ARE part of the product: pre-rendered by the app's own
|
| 54 |
-
# endpoints (scripts/build_*.py), bundled so anon-quota visitors see the full
|
| 55 |
-
# experience instantly. Un-ignore them despite the blanket *.webp/*.png.
|
| 56 |
-
!frontend/assets/showcase/
|
| 57 |
-
!frontend/assets/showcase/*.webp
|
| 58 |
-
!frontend/assets/showcase/*.png
|
| 59 |
-
!frontend/assets/showcase/manifest.json
|
| 60 |
-
!frontend/assets/corridor/
|
| 61 |
-
!frontend/assets/corridor/*.webp
|
| 62 |
-
!frontend/assets/corridor/*.png
|
| 63 |
-
!frontend/assets/corridor/manifest.json
|
| 64 |
-
!frontend/assets/scroll/
|
| 65 |
-
!frontend/assets/scroll/*.webp
|
| 66 |
-
!frontend/assets/scroll/*.png
|
| 67 |
-
!frontend/assets/scroll/manifest.json
|
| 68 |
-
!frontend/assets/scroll/variants.json
|
| 69 |
-
!frontend/assets/scroll/v_*/
|
| 70 |
-
!frontend/assets/scroll/v_*/*.webp
|
| 71 |
-
!frontend/assets/scroll/v_*/*.png
|
| 72 |
-
!frontend/assets/scroll/v_*/manifest.json
|
| 73 |
-
|
| 74 |
-
vonfig.py
|
| 75 |
-
lightloom-docs/
|
| 76 |
-
|
| 77 |
-
# Modal LoRA scratch (the harness training/modal_lora/launch.py IS committed; these
|
| 78 |
-
# are local run artifacts: downloaded dataset samples, the fetched ref script, logs).
|
| 79 |
-
.modal_dataset_sample/
|
| 80 |
-
.train_script_ref.py
|
| 81 |
-
.modal_*.log
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -891,7 +891,7 @@ def _scroll_world(text: str, session: str):
|
|
| 891 |
"stage": "section",
|
| 892 |
"index": g,
|
| 893 |
"image": f"/frames-scroll/{session}/section-{g}.webp",
|
| 894 |
-
"caption": phrase[:160]
|
| 895 |
"w": sec.width,
|
| 896 |
}
|
| 897 |
dmap = estimate_depth(depth_pipe, sec)
|
|
@@ -1049,7 +1049,10 @@ def _depth_global_norm(raw: Any, state: dict[str, Any], out_dir: Path) -> Any:
|
|
| 1049 |
state["depth_lo"], state["depth_hi"] = lo, hi
|
| 1050 |
_live_save_state(out_dir, depth_lo=lo, depth_hi=hi)
|
| 1051 |
norm = np.clip((raw - lo) / (hi - lo), 0.0, 1.0)
|
| 1052 |
-
|
|
|
|
|
|
|
|
|
|
| 1053 |
|
| 1054 |
|
| 1055 |
def _scroll_transition_prompt(prev_subject: str, subject: str) -> str:
|
|
@@ -1208,7 +1211,10 @@ def _scroll_live_phrase(session: str, text: str, audio_b64: str, lang: str):
|
|
| 1208 |
"stage": "section",
|
| 1209 |
"index": g,
|
| 1210 |
"image": f"/frames-scroll/{session}/section-{g}.webp",
|
| 1211 |
-
|
|
|
|
|
|
|
|
|
|
| 1212 |
"w": sec.width,
|
| 1213 |
}
|
| 1214 |
raw_d = estimate_depth(depth_pipe, sec, normalize=False) # RAW disparity (un-scaled)
|
|
|
|
| 891 |
"stage": "section",
|
| 892 |
"index": g,
|
| 893 |
"image": f"/frames-scroll/{session}/section-{g}.webp",
|
| 894 |
+
"caption": phrase[:160], # every strip carries the caption (onFocus pins it; no flicker)
|
| 895 |
"w": sec.width,
|
| 896 |
}
|
| 897 |
dmap = estimate_depth(depth_pipe, sec)
|
|
|
|
| 1049 |
state["depth_lo"], state["depth_hi"] = lo, hi
|
| 1050 |
_live_save_state(out_dir, depth_lo=lo, depth_hi=hi)
|
| 1051 |
norm = np.clip((raw - lo) / (hi - lo), 0.0, 1.0)
|
| 1052 |
+
# raw is DA-V2 DISPARITY (near=HIGH) -> norm already has 1=near/0=far (the renderer convention).
|
| 1053 |
+
# The old `1.0 - norm` flipped it inside-out (near read as far) -> inverted parallax + aerial on
|
| 1054 |
+
# the wrong regions + disocclusion streaks. Return norm as-is.
|
| 1055 |
+
return norm # 1 = near, 0 = far
|
| 1056 |
|
| 1057 |
|
| 1058 |
def _scroll_transition_prompt(prev_subject: str, subject: str) -> str:
|
|
|
|
| 1211 |
"stage": "section",
|
| 1212 |
"index": g,
|
| 1213 |
"image": f"/frames-scroll/{session}/section-{g}.webp",
|
| 1214 |
+
# stamp EVERY strip of the phrase (not just k==0): the caption is shown by onFocus when
|
| 1215 |
+
# the strip is under the view centre, so a blank on the 2nd strip made the words flicker
|
| 1216 |
+
# off mid-clause. Same phrase across both strips -> the caption stays pinned.
|
| 1217 |
+
"caption": phrase[:160],
|
| 1218 |
"w": sec.width,
|
| 1219 |
}
|
| 1220 |
raw_d = estimate_depth(depth_pipe, sec, normalize=False) # RAW disparity (un-scaled)
|
benchmarks/results/g1.json
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"authoritative": true,
|
| 3 |
+
"decision": {
|
| 4 |
+
"reason": "fp8 unavailable; selected fastest successful dtype",
|
| 5 |
+
"resolution": [
|
| 6 |
+
1024,
|
| 7 |
+
576
|
| 8 |
+
],
|
| 9 |
+
"selected": {
|
| 10 |
+
"aot": false,
|
| 11 |
+
"authoritative": true,
|
| 12 |
+
"compile_mode": "off",
|
| 13 |
+
"dtype": "bf16",
|
| 14 |
+
"height": 576,
|
| 15 |
+
"p50_ms": 646.434,
|
| 16 |
+
"p95_ms": 652.067,
|
| 17 |
+
"status": "ok",
|
| 18 |
+
"timings_ms": [
|
| 19 |
+
635.961,
|
| 20 |
+
639.458,
|
| 21 |
+
649.857,
|
| 22 |
+
652.067,
|
| 23 |
+
646.434
|
| 24 |
+
],
|
| 25 |
+
"width": 1024
|
| 26 |
+
},
|
| 27 |
+
"status": "pass"
|
| 28 |
+
},
|
| 29 |
+
"gate": "G1",
|
| 30 |
+
"generated_at": "2026-06-11T20:18:00Z",
|
| 31 |
+
"hardware_profile": {
|
| 32 |
+
"arch_list": [
|
| 33 |
+
"sm_75",
|
| 34 |
+
"sm_80",
|
| 35 |
+
"sm_86",
|
| 36 |
+
"sm_90",
|
| 37 |
+
"sm_100",
|
| 38 |
+
"sm_120"
|
| 39 |
+
],
|
| 40 |
+
"cuda": "13.0",
|
| 41 |
+
"cuda_available": true,
|
| 42 |
+
"device": "NVIDIA RTX PRO 6000 Blackwell Server Edition MIG 2g.48gb",
|
| 43 |
+
"lightloom_profile": "space",
|
| 44 |
+
"platform": "Linux-6.12.80-106.156.amzn2023.x86_64-x86_64-with-glibc2.36",
|
| 45 |
+
"space_id": "Efradeca/lightloom-dev",
|
| 46 |
+
"torch": "2.11.0+cu130"
|
| 47 |
+
},
|
| 48 |
+
"prompt": "cinematic illustrated film still, an old lighthouse at the edge of the world, stormy dusk, warm lantern glow, painterly texture, volumetric light, 2.39:1 frame",
|
| 49 |
+
"reps": 5,
|
| 50 |
+
"results": [
|
| 51 |
+
{
|
| 52 |
+
"aot": false,
|
| 53 |
+
"authoritative": true,
|
| 54 |
+
"dtype": "fp8",
|
| 55 |
+
"error": "load failed: TypeError: couldn't find storage object Float8_e4m3fnStorage",
|
| 56 |
+
"height": 432,
|
| 57 |
+
"status": "failed",
|
| 58 |
+
"width": 768
|
| 59 |
+
},
|
| 60 |
+
{
|
| 61 |
+
"aot": true,
|
| 62 |
+
"authoritative": true,
|
| 63 |
+
"dtype": "fp8",
|
| 64 |
+
"error": "load failed: TypeError: couldn't find storage object Float8_e4m3fnStorage",
|
| 65 |
+
"height": 432,
|
| 66 |
+
"status": "failed",
|
| 67 |
+
"width": 768
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"aot": false,
|
| 71 |
+
"authoritative": true,
|
| 72 |
+
"dtype": "fp8",
|
| 73 |
+
"error": "load failed: TypeError: couldn't find storage object Float8_e4m3fnStorage",
|
| 74 |
+
"height": 576,
|
| 75 |
+
"status": "failed",
|
| 76 |
+
"width": 1024
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"aot": true,
|
| 80 |
+
"authoritative": true,
|
| 81 |
+
"dtype": "fp8",
|
| 82 |
+
"error": "load failed: TypeError: couldn't find storage object Float8_e4m3fnStorage",
|
| 83 |
+
"height": 576,
|
| 84 |
+
"status": "failed",
|
| 85 |
+
"width": 1024
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"aot": false,
|
| 89 |
+
"authoritative": true,
|
| 90 |
+
"compile_mode": "off",
|
| 91 |
+
"dtype": "bf16",
|
| 92 |
+
"height": 432,
|
| 93 |
+
"p50_ms": 546.845,
|
| 94 |
+
"p95_ms": 548.098,
|
| 95 |
+
"status": "ok",
|
| 96 |
+
"timings_ms": [
|
| 97 |
+
548.098,
|
| 98 |
+
543.092,
|
| 99 |
+
545.796,
|
| 100 |
+
546.845,
|
| 101 |
+
547.591
|
| 102 |
+
],
|
| 103 |
+
"width": 768
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"aot": true,
|
| 107 |
+
"authoritative": true,
|
| 108 |
+
"compile_mode": "torch.compile(reduce-overhead)",
|
| 109 |
+
"dtype": "bf16",
|
| 110 |
+
"height": 432,
|
| 111 |
+
"p50_ms": 463.283,
|
| 112 |
+
"p95_ms": 467.914,
|
| 113 |
+
"status": "ok",
|
| 114 |
+
"timings_ms": [
|
| 115 |
+
463.283,
|
| 116 |
+
465.276,
|
| 117 |
+
467.914,
|
| 118 |
+
462.731,
|
| 119 |
+
462.571
|
| 120 |
+
],
|
| 121 |
+
"width": 768
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"aot": false,
|
| 125 |
+
"authoritative": true,
|
| 126 |
+
"compile_mode": "off",
|
| 127 |
+
"dtype": "bf16",
|
| 128 |
+
"height": 576,
|
| 129 |
+
"p50_ms": 646.434,
|
| 130 |
+
"p95_ms": 652.067,
|
| 131 |
+
"status": "ok",
|
| 132 |
+
"timings_ms": [
|
| 133 |
+
635.961,
|
| 134 |
+
639.458,
|
| 135 |
+
649.857,
|
| 136 |
+
652.067,
|
| 137 |
+
646.434
|
| 138 |
+
],
|
| 139 |
+
"width": 1024
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"aot": true,
|
| 143 |
+
"authoritative": true,
|
| 144 |
+
"compile_mode": "torch.compile(reduce-overhead)",
|
| 145 |
+
"dtype": "bf16",
|
| 146 |
+
"error": "AttributeError: 'function' object has no attribute 'config'",
|
| 147 |
+
"height": 576,
|
| 148 |
+
"status": "failed",
|
| 149 |
+
"width": 1024
|
| 150 |
+
}
|
| 151 |
+
],
|
| 152 |
+
"schema_version": 1
|
| 153 |
+
}
|
benchmarks/results/g1.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gate G1 Results
|
| 2 |
+
|
| 3 |
+
Authoritative: `True`
|
| 4 |
+
Hardware profile: `space`
|
| 5 |
+
|
| 6 |
+
| Resolution | dtype | AoT | status | p50 ms | p95 ms |
|
| 7 |
+
|---|---|---:|---|---:|---:|
|
| 8 |
+
| 768x432 | fp8 | no | failed | | |
|
| 9 |
+
| 768x432 | fp8 | yes | failed | | |
|
| 10 |
+
| 1024x576 | fp8 | no | failed | | |
|
| 11 |
+
| 1024x576 | fp8 | yes | failed | | |
|
| 12 |
+
| 768x432 | bf16 | no | ok | 546.845 | 548.098 |
|
| 13 |
+
| 768x432 | bf16 | yes | ok | 463.283 | 467.914 |
|
| 14 |
+
| 1024x576 | bf16 | no | ok | 646.434 | 652.067 |
|
| 15 |
+
| 1024x576 | bf16 | yes | failed | | |
|
| 16 |
+
|
| 17 |
+
Decision: `pass`
|
frontend/assets/scroll/section-0-depth.png
CHANGED
|
|
frontend/assets/scroll/section-1-depth.png
CHANGED
|
|
frontend/assets/scroll/section-2-depth.png
CHANGED
|
|
frontend/assets/scroll/section-3-depth.png
CHANGED
|
|
frontend/assets/scroll/section-4-depth.png
CHANGED
|
|
frontend/assets/scroll/section-5-depth.png
CHANGED
|
|
frontend/js/controller.js
CHANGED
|
@@ -269,7 +269,12 @@ const controller = {
|
|
| 269 |
switch (ev.stage) {
|
| 270 |
case "transcript": // the words you just spoke, becoming the world
|
| 271 |
this._orch("director", true);
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
this._status(t(COPY.building, this.lang), 0);
|
| 274 |
break;
|
| 275 |
case "silent": // a segment with nothing intelligible — keep listening
|
|
|
|
| 269 |
switch (ev.stage) {
|
| 270 |
case "transcript": // the words you just spoke, becoming the world
|
| 271 |
this._orch("director", true);
|
| 272 |
+
// Do NOT write the caption here. The spoken words are buffered ~768px ahead but the strip
|
| 273 |
+
// scrolls ~110px/s, so a phrase's IMAGE reaches the view centre seconds AFTER it is spoken.
|
| 274 |
+
// Writing the transcript immediately clobbered the onFocus caption and showed words that did
|
| 275 |
+
// not match the on-screen scene ("the image has nothing to do with what I said"). The caption
|
| 276 |
+
// now comes solely from onFocus (controller.js:45) — the section actually under the centre —
|
| 277 |
+
// so caption and image always describe the SAME clause and the words move WITH the scene.
|
| 278 |
this._status(t(COPY.building, this.lang), 0);
|
| 279 |
break;
|
| 280 |
case "silent": // a segment with nothing intelligible — keep listening
|
package-lock.json
DELETED
|
@@ -1,56 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "Lightloom",
|
| 3 |
-
"lockfileVersion": 3,
|
| 4 |
-
"requires": true,
|
| 5 |
-
"packages": {
|
| 6 |
-
"": {
|
| 7 |
-
"dependencies": {
|
| 8 |
-
"playwright": "^1.60.0"
|
| 9 |
-
}
|
| 10 |
-
},
|
| 11 |
-
"node_modules/fsevents": {
|
| 12 |
-
"version": "2.3.2",
|
| 13 |
-
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
| 14 |
-
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
| 15 |
-
"hasInstallScript": true,
|
| 16 |
-
"license": "MIT",
|
| 17 |
-
"optional": true,
|
| 18 |
-
"os": [
|
| 19 |
-
"darwin"
|
| 20 |
-
],
|
| 21 |
-
"engines": {
|
| 22 |
-
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
| 23 |
-
}
|
| 24 |
-
},
|
| 25 |
-
"node_modules/playwright": {
|
| 26 |
-
"version": "1.60.0",
|
| 27 |
-
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz",
|
| 28 |
-
"integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==",
|
| 29 |
-
"license": "Apache-2.0",
|
| 30 |
-
"dependencies": {
|
| 31 |
-
"playwright-core": "1.60.0"
|
| 32 |
-
},
|
| 33 |
-
"bin": {
|
| 34 |
-
"playwright": "cli.js"
|
| 35 |
-
},
|
| 36 |
-
"engines": {
|
| 37 |
-
"node": ">=18"
|
| 38 |
-
},
|
| 39 |
-
"optionalDependencies": {
|
| 40 |
-
"fsevents": "2.3.2"
|
| 41 |
-
}
|
| 42 |
-
},
|
| 43 |
-
"node_modules/playwright-core": {
|
| 44 |
-
"version": "1.60.0",
|
| 45 |
-
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz",
|
| 46 |
-
"integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==",
|
| 47 |
-
"license": "Apache-2.0",
|
| 48 |
-
"bin": {
|
| 49 |
-
"playwright-core": "cli.js"
|
| 50 |
-
},
|
| 51 |
-
"engines": {
|
| 52 |
-
"node": ">=18"
|
| 53 |
-
}
|
| 54 |
-
}
|
| 55 |
-
}
|
| 56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.json
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"dependencies": {
|
| 3 |
-
"playwright": "^1.60.0"
|
| 4 |
-
}
|
| 5 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pyproject.toml
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
[build-system]
|
| 2 |
-
requires = ["setuptools>=69", "wheel"]
|
| 3 |
-
build-backend = "setuptools.build_meta"
|
| 4 |
-
|
| 5 |
-
[project]
|
| 6 |
-
name = "lightloom"
|
| 7 |
-
version = "0.1.0"
|
| 8 |
-
description = "Voice-driven live-cinema Gradio app for the Build Small hackathon."
|
| 9 |
-
requires-python = ">=3.10"
|
| 10 |
-
readme = "README.md"
|
| 11 |
-
|
| 12 |
-
[tool.setuptools.packages.find]
|
| 13 |
-
where = ["src"]
|
| 14 |
-
|
| 15 |
-
[tool.pytest.ini_options]
|
| 16 |
-
pythonpath = ["src"]
|
| 17 |
-
testpaths = ["tests"]
|
| 18 |
-
|
| 19 |
-
[tool.ruff]
|
| 20 |
-
line-length = 100
|
| 21 |
-
target-version = "py310"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/_debug_asr.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
"""Local definitive debug of Cohere Transcribe: does it load all weights, and does
|
| 2 |
-
it transcribe the demo clip correctly on CPU? Prints missing/unexpected keys."""
|
| 3 |
-
import os, sys
|
| 4 |
-
sys.path.insert(0, "src")
|
| 5 |
-
os.environ.setdefault("HF_TOKEN", "")
|
| 6 |
-
import torch
|
| 7 |
-
from huggingface_hub import hf_hub_download
|
| 8 |
-
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
|
| 9 |
-
from lightloom.audio_in.asr import _patch_keys_to_ignore_coercion
|
| 10 |
-
|
| 11 |
-
REPO = "CohereLabs/cohere-transcribe-03-2026"
|
| 12 |
-
TOK = os.environ["HF_TOKEN"]
|
| 13 |
-
_patch_keys_to_ignore_coercion()
|
| 14 |
-
print("loading processor…", flush=True)
|
| 15 |
-
proc = AutoProcessor.from_pretrained(REPO, trust_remote_code=True, token=TOK)
|
| 16 |
-
print("loading model (fp32, cpu)…", flush=True)
|
| 17 |
-
model, info = AutoModelForSpeechSeq2Seq.from_pretrained(
|
| 18 |
-
REPO, trust_remote_code=True, token=TOK, output_loading_info=True
|
| 19 |
-
)
|
| 20 |
-
mk = list(info.get("missing_keys", []))
|
| 21 |
-
uk = list(info.get("unexpected_keys", []))
|
| 22 |
-
print(f"MISSING_KEYS: {len(mk)} (first 10: {mk[:10]})", flush=True)
|
| 23 |
-
print(f"UNEXPECTED_KEYS: {len(uk)} (first 10: {uk[:10]})", flush=True)
|
| 24 |
-
model.eval()
|
| 25 |
-
|
| 26 |
-
wav = hf_hub_download(REPO, "demo/voxpopuli_test_en_demo.wav", token=TOK)
|
| 27 |
-
try:
|
| 28 |
-
from transformers.audio_utils import load_audio
|
| 29 |
-
audio = load_audio(wav, sampling_rate=16000)
|
| 30 |
-
print("loaded audio via transformers.audio_utils.load_audio", flush=True)
|
| 31 |
-
except Exception as e:
|
| 32 |
-
from lightloom.audio_in.asr import read_wav
|
| 33 |
-
audio, _sr = read_wav(wav)
|
| 34 |
-
print("loaded audio via read_wav:", repr(e)[:80], flush=True)
|
| 35 |
-
|
| 36 |
-
inputs = proc(audio, sampling_rate=16000, return_tensors="pt", language="en")
|
| 37 |
-
print("processor output keys:", list(inputs.keys()), flush=True)
|
| 38 |
-
aci = inputs.get("audio_chunk_index")
|
| 39 |
-
with torch.inference_mode():
|
| 40 |
-
out = model.generate(**inputs, max_new_tokens=120)
|
| 41 |
-
txt = proc.decode(out, skip_special_tokens=True, audio_chunk_index=aci, language="en")
|
| 42 |
-
if isinstance(txt, list):
|
| 43 |
-
txt = txt[0] if txt else ""
|
| 44 |
-
sys.stdout.buffer.write(("LOCAL_TRANSCRIPT: " + txt[:300] + "\n").encode("utf-8", "replace"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/asr-feasibility.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
const { chromium } = require("playwright");
|
| 2 |
-
(async () => {
|
| 3 |
-
const browser = await chromium.launch({ headless: false, args: ["--enable-unsafe-webgpu", "--enable-features=Vulkan", "--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist"] });
|
| 4 |
-
const page = await browser.newPage();
|
| 5 |
-
page.on("console", (m) => console.log("PAGE:", m.text().slice(0, 200)));
|
| 6 |
-
await page.goto("http://127.0.0.1:8842/scripts/asr-feasibility.html", { waitUntil: "domcontentloaded" });
|
| 7 |
-
for (let i = 0; i < 150; i++) { const done = await page.evaluate(() => window.__done).catch(() => false); if (done) break; await page.waitForTimeout(2000); }
|
| 8 |
-
const r = await page.evaluate(() => ({ log: window.__log, device: window.__device, text: window.__text, rt: window.__rt, err: window.__err }));
|
| 9 |
-
console.log("=== RESULT ===" + (r.log || ""));
|
| 10 |
-
console.log("DEVICE:", r.device, "| RTfactor:", r.rt, "| ERR:", r.err || "none");
|
| 11 |
-
await browser.close();
|
| 12 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/asr-feasibility.html
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
<!doctype html><html><head><meta charset="utf-8"><title>ASR feasibility</title></head>
|
| 2 |
-
<body><pre id="log">loading…</pre>
|
| 3 |
-
<script type="module">
|
| 4 |
-
const log = (m) => { document.getElementById("log").textContent += "\n" + m; window.__log = (window.__log||"") + "\n" + m; };
|
| 5 |
-
window.__done = false;
|
| 6 |
-
try {
|
| 7 |
-
const t0 = performance.now();
|
| 8 |
-
const { pipeline, env } = await import("https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.5");
|
| 9 |
-
env.allowLocalModels = false;
|
| 10 |
-
log("transformers.js loaded");
|
| 11 |
-
// try WebGPU, fall back to wasm
|
| 12 |
-
let device = "webgpu";
|
| 13 |
-
let transcriber;
|
| 14 |
-
try {
|
| 15 |
-
transcriber = await pipeline("automatic-speech-recognition", "onnx-community/whisper-base.en", { device: "webgpu", dtype: "fp32" });
|
| 16 |
-
log("model loaded on WEBGPU in " + Math.round(performance.now()-t0) + "ms");
|
| 17 |
-
} catch (e) {
|
| 18 |
-
device = "wasm";
|
| 19 |
-
log("webgpu failed (" + String(e).slice(0,80) + "), trying wasm…");
|
| 20 |
-
transcriber = await pipeline("automatic-speech-recognition", "onnx-community/whisper-base.en", { device: "wasm" });
|
| 21 |
-
log("model loaded on WASM in " + Math.round(performance.now()-t0) + "ms");
|
| 22 |
-
}
|
| 23 |
-
// fetch + decode the test wav to 16k mono Float32
|
| 24 |
-
const resp = await fetch("/.shots/cont_en.wav");
|
| 25 |
-
const buf = await resp.arrayBuffer();
|
| 26 |
-
const ac = new (window.AudioContext||window.webkitAudioContext)({ sampleRate: 16000 });
|
| 27 |
-
const decoded = await ac.decodeAudioData(buf);
|
| 28 |
-
const audio = decoded.getChannelData(0);
|
| 29 |
-
log("audio decoded: " + (audio.length/16000).toFixed(1) + "s @ " + decoded.sampleRate + "Hz");
|
| 30 |
-
const t1 = performance.now();
|
| 31 |
-
const out = await transcriber(audio, { language: "en", task: "transcribe", return_timestamps: false });
|
| 32 |
-
const dt = performance.now()-t1;
|
| 33 |
-
log("TRANSCRIBED in " + Math.round(dt) + "ms (" + (dt/(audio.length/16000)).toFixed(2) + "x realtime, " + device + ")");
|
| 34 |
-
log("TEXT: " + (out.text||"").trim());
|
| 35 |
-
window.__device = device; window.__text = (out.text||"").trim(); window.__rt = dt/(audio.length/16000);
|
| 36 |
-
} catch (e) {
|
| 37 |
-
log("FATAL: " + String(e).slice(0,300));
|
| 38 |
-
window.__err = String(e).slice(0,300);
|
| 39 |
-
}
|
| 40 |
-
window.__done = true;
|
| 41 |
-
</script></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/build_corridor_showcase.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
"""Pre-render the corridor Showcase: a vivid, diverse journey generated by the
|
| 2 |
-
SAME live /world endpoint, downloaded into frontend/assets/corridor/ with a
|
| 3 |
-
manifest. The frontend plays it back instantly (no GPU) so anon-quota judges see
|
| 4 |
-
the full immersive experience without waiting. Everything here is produced by the
|
| 5 |
-
deployed app itself. Run: HF_READ_TOKEN=... python scripts/build_corridor_showcase.py
|
| 6 |
-
"""
|
| 7 |
-
|
| 8 |
-
from __future__ import annotations
|
| 9 |
-
|
| 10 |
-
import json
|
| 11 |
-
import os
|
| 12 |
-
import time
|
| 13 |
-
import urllib.request
|
| 14 |
-
from pathlib import Path
|
| 15 |
-
|
| 16 |
-
from gradio_client import Client
|
| 17 |
-
|
| 18 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 19 |
-
OUT = ROOT / "frontend" / "assets" / "corridor"
|
| 20 |
-
SPACE_ID = os.getenv("LIGHTLOOM_DEV_SPACE_ID", "Efradeca/lightloom-dev")
|
| 21 |
-
BASE = os.getenv("SPACE_URL", "https://efradeca-lightloom-dev.hf.space")
|
| 22 |
-
|
| 23 |
-
# A vivid, diverse story that shows the full range — fantasy, cyberpunk, serene,
|
| 24 |
-
# underwater, cosmic — so the Showcase proves the worlds match what is told.
|
| 25 |
-
STORY = (
|
| 26 |
-
"A sleeping dragon curled on a mountain of gold beneath two moons. "
|
| 27 |
-
"Far below, a neon city glittered in the falling rain. "
|
| 28 |
-
"A child set paper lanterns adrift on a glowing river at dusk. "
|
| 29 |
-
"Deep in a coral reef, a great whale drifted through ruins of light. "
|
| 30 |
-
"At the edge of the galaxy, a lone ship turned slowly toward home."
|
| 31 |
-
)
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
def _token() -> str:
|
| 35 |
-
tok = os.getenv("HF_READ_TOKEN") or os.getenv("HF_TOKEN")
|
| 36 |
-
if not tok:
|
| 37 |
-
raise SystemExit("HF_READ_TOKEN/HF_TOKEN required in env.")
|
| 38 |
-
return tok
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
def _dl(rel: str, dst: Path, token: str) -> int:
|
| 42 |
-
req = urllib.request.Request(BASE + rel, headers={"Authorization": "Bearer " + token})
|
| 43 |
-
data = urllib.request.urlopen(req, timeout=90).read()
|
| 44 |
-
dst.write_bytes(data)
|
| 45 |
-
return len(data)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
def main() -> int:
|
| 49 |
-
token = _token()
|
| 50 |
-
OUT.mkdir(parents=True, exist_ok=True)
|
| 51 |
-
client = Client(SPACE_ID, token=token, verbose=False)
|
| 52 |
-
job = client.submit(STORY, "en", api_name="/world")
|
| 53 |
-
scenes: dict[int, dict] = {}
|
| 54 |
-
t0 = time.time()
|
| 55 |
-
for ev in job:
|
| 56 |
-
if not isinstance(ev, dict):
|
| 57 |
-
continue
|
| 58 |
-
st = ev.get("stage")
|
| 59 |
-
i = ev.get("index")
|
| 60 |
-
if st == "scene":
|
| 61 |
-
scenes.setdefault(i, {})["image"] = ev.get("image")
|
| 62 |
-
scenes[i]["caption"] = ev.get("caption", "")
|
| 63 |
-
print(f"[{time.time()-t0:5.1f}s] scene {i}")
|
| 64 |
-
elif st == "depth":
|
| 65 |
-
scenes.setdefault(i, {})["depth"] = ev.get("depth")
|
| 66 |
-
elif st in ("error", "quota_exceeded", "scene_error"):
|
| 67 |
-
print(f" !! {st}: {ev.get('error')}")
|
| 68 |
-
elif st == "done":
|
| 69 |
-
print(f"[{time.time()-t0:5.1f}s] done ({ev.get('count')} scenes)")
|
| 70 |
-
|
| 71 |
-
manifest = []
|
| 72 |
-
for i in sorted(scenes):
|
| 73 |
-
s = scenes[i]
|
| 74 |
-
if not s.get("image"):
|
| 75 |
-
continue
|
| 76 |
-
img_name = f"scene-{i}.webp"
|
| 77 |
-
depth_name = f"scene-{i}-depth.png"
|
| 78 |
-
n1 = _dl(s["image"], OUT / img_name, token)
|
| 79 |
-
n2 = _dl(s["depth"], OUT / depth_name, token) if s.get("depth") else 0
|
| 80 |
-
print(f" scene {i}: img={n1}B depth={n2}B {s.get('caption','')[:60]}")
|
| 81 |
-
manifest.append(
|
| 82 |
-
{
|
| 83 |
-
"index": i,
|
| 84 |
-
"caption": s.get("caption", ""),
|
| 85 |
-
"image": f"/frontend/assets/corridor/{img_name}",
|
| 86 |
-
"depth": f"/frontend/assets/corridor/{depth_name}" if s.get("depth") else None,
|
| 87 |
-
}
|
| 88 |
-
)
|
| 89 |
-
(OUT / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
| 90 |
-
print(f"WROTE manifest with {len(manifest)} scenes -> {OUT/'manifest.json'}")
|
| 91 |
-
return 0 if manifest else 1
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
if __name__ == "__main__":
|
| 95 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/build_scroll_showcase.py
DELETED
|
@@ -1,89 +0,0 @@
|
|
| 1 |
-
"""Pre-render a continuous SCROLL showcase (sections + depth) so the world flows
|
| 2 |
-
behind the intro and during the ~30s model warm-up — the user never sees a black
|
| 3 |
-
screen. Generated by the same /scroll endpoint; bundled into frontend/assets/scroll/.
|
| 4 |
-
Run: HF_READ_TOKEN=... python scripts/build_scroll_showcase.py
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import json
|
| 10 |
-
import os
|
| 11 |
-
import time
|
| 12 |
-
import urllib.request
|
| 13 |
-
from pathlib import Path
|
| 14 |
-
|
| 15 |
-
from gradio_client import Client
|
| 16 |
-
|
| 17 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 18 |
-
OUT = ROOT / "frontend" / "assets" / "scroll"
|
| 19 |
-
SPACE_ID = os.getenv("LIGHTLOOM_DEV_SPACE_ID", "Efradeca/lightloom-dev")
|
| 20 |
-
BASE = os.getenv("SPACE_URL", "https://efradeca-lightloom-dev.hf.space")
|
| 21 |
-
|
| 22 |
-
STORY = (
|
| 23 |
-
"A glowing forest came alive with drifting fireflies. "
|
| 24 |
-
"A crystal river wound between the ancient trees. "
|
| 25 |
-
"A village of lantern-lit treehouses appeared in the canopy. "
|
| 26 |
-
"A great waterfall of light poured into a glowing canyon. "
|
| 27 |
-
"A temple floated among luminous clouds. "
|
| 28 |
-
"A field of giant bioluminescent flowers stretched to the horizon."
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def _token() -> str:
|
| 33 |
-
tok = os.getenv("HF_READ_TOKEN") or os.getenv("HF_TOKEN")
|
| 34 |
-
if not tok:
|
| 35 |
-
raise SystemExit("HF_READ_TOKEN/HF_TOKEN required.")
|
| 36 |
-
return tok
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def _dl(rel: str, dst: Path, token: str) -> int:
|
| 40 |
-
req = urllib.request.Request(BASE + rel, headers={"Authorization": "Bearer " + token})
|
| 41 |
-
data = urllib.request.urlopen(req, timeout=90).read()
|
| 42 |
-
dst.write_bytes(data)
|
| 43 |
-
return len(data)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
def main() -> int:
|
| 47 |
-
token = _token()
|
| 48 |
-
OUT.mkdir(parents=True, exist_ok=True)
|
| 49 |
-
client = Client(SPACE_ID, token=token, verbose=False)
|
| 50 |
-
job = client.submit(STORY, "en", api_name="/scroll")
|
| 51 |
-
secs: dict[int, dict] = {}
|
| 52 |
-
t0 = time.time()
|
| 53 |
-
for ev in job:
|
| 54 |
-
if not isinstance(ev, dict):
|
| 55 |
-
continue
|
| 56 |
-
st, i = ev.get("stage"), ev.get("index")
|
| 57 |
-
if st == "section":
|
| 58 |
-
secs.setdefault(i, {})["image"] = ev.get("image")
|
| 59 |
-
secs[i]["caption"] = ev.get("caption", "")
|
| 60 |
-
print(f"[{time.time()-t0:5.1f}s] section {i}")
|
| 61 |
-
elif st == "depth":
|
| 62 |
-
secs.setdefault(i, {})["depth"] = ev.get("depth")
|
| 63 |
-
elif st in ("error", "quota_exceeded", "section_error"):
|
| 64 |
-
print(f" !! {st}: {ev.get('error')}")
|
| 65 |
-
|
| 66 |
-
manifest = []
|
| 67 |
-
for i in sorted(secs):
|
| 68 |
-
s = secs[i]
|
| 69 |
-
if not s.get("image"):
|
| 70 |
-
continue
|
| 71 |
-
img, dep = f"section-{i}.webp", f"section-{i}-depth.png"
|
| 72 |
-
n1 = _dl(s["image"], OUT / img, token)
|
| 73 |
-
n2 = _dl(s["depth"], OUT / dep, token) if s.get("depth") else 0
|
| 74 |
-
print(f" section {i}: img={n1}B depth={n2}B {s.get('caption','')[:50]}")
|
| 75 |
-
manifest.append(
|
| 76 |
-
{
|
| 77 |
-
"index": i,
|
| 78 |
-
"caption": s.get("caption", ""),
|
| 79 |
-
"image": f"/frontend/assets/scroll/{img}",
|
| 80 |
-
"depth": f"/frontend/assets/scroll/{dep}" if s.get("depth") else None,
|
| 81 |
-
}
|
| 82 |
-
)
|
| 83 |
-
(OUT / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
| 84 |
-
print(f"WROTE manifest with {len(manifest)} sections -> {OUT/'manifest.json'}")
|
| 85 |
-
return 0 if manifest else 1
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
if __name__ == "__main__":
|
| 89 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/build_showcase.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
| 1 |
-
"""Pre-render the Showcase journey: one immersive world per stanza of the golden
|
| 2 |
-
recital, generated by the SAME live pipeline (/panorama on the Space), downloaded
|
| 3 |
-
into frontend/assets/showcase/ with a manifest. The frontend plays these back
|
| 4 |
-
instantly (no GPU) so anon-quota judges see the full experience immediately.
|
| 5 |
-
|
| 6 |
-
Honesty: every asset here is produced by the deployed app's own /panorama
|
| 7 |
-
endpoint — nothing hand-painted. Run: python scripts/build_showcase.py
|
| 8 |
-
"""
|
| 9 |
-
|
| 10 |
-
from __future__ import annotations
|
| 11 |
-
|
| 12 |
-
import json
|
| 13 |
-
import os
|
| 14 |
-
import time
|
| 15 |
-
import urllib.request
|
| 16 |
-
from pathlib import Path
|
| 17 |
-
|
| 18 |
-
from gradio_client import Client
|
| 19 |
-
|
| 20 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 21 |
-
OUT = ROOT / "frontend" / "assets" / "showcase"
|
| 22 |
-
SPACE_ID = os.getenv("LIGHTLOOM_DEV_SPACE_ID", "Efradeca/lightloom-dev")
|
| 23 |
-
BASE = os.getenv("SPACE_URL", "https://efradeca-lightloom-dev.hf.space")
|
| 24 |
-
|
| 25 |
-
# The golden recital, one world per stanza — a journey: storm -> intimate ->
|
| 26 |
-
# warm market -> cold silence. Title each so the player can subtitle it.
|
| 27 |
-
STANZAS = [
|
| 28 |
-
("An old lighthouse keeper counted the waves at the edge of the world.", "I. The edge of the world"),
|
| 29 |
-
("Every night he climbed the spiral stairs, counting each step like a prayer.", "II. The spiral stairs"),
|
| 30 |
-
("Far away, a market woke under orange awnings and wet stone.", "III. A market wakes"),
|
| 31 |
-
("Years later, the same road lay buried under snow and silence.", "IV. Snow and silence"),
|
| 32 |
-
]
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
def _token() -> str:
|
| 36 |
-
tok = os.getenv("HF_READ_TOKEN") or os.getenv("HF_TOKEN")
|
| 37 |
-
if not tok:
|
| 38 |
-
raise SystemExit("HF_READ_TOKEN/HF_TOKEN required in env.")
|
| 39 |
-
return tok
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
def _download(rel: str, dst: Path, token: str) -> int:
|
| 43 |
-
req = urllib.request.Request(BASE + rel, headers={"Authorization": "Bearer " + token})
|
| 44 |
-
data = urllib.request.urlopen(req, timeout=90).read()
|
| 45 |
-
dst.write_bytes(data)
|
| 46 |
-
return len(data)
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def main() -> int:
|
| 50 |
-
token = _token()
|
| 51 |
-
OUT.mkdir(parents=True, exist_ok=True)
|
| 52 |
-
client = Client(SPACE_ID, token=token, verbose=False)
|
| 53 |
-
manifest = []
|
| 54 |
-
for i, (stanza, title) in enumerate(STANZAS):
|
| 55 |
-
print(f"[{i}] generating: {title!r}")
|
| 56 |
-
t0 = time.time()
|
| 57 |
-
job = client.submit(stanza, "en", api_name="/panorama")
|
| 58 |
-
pano = depth = scene = None
|
| 59 |
-
for ev in job:
|
| 60 |
-
if isinstance(ev, dict):
|
| 61 |
-
if ev.get("scene"):
|
| 62 |
-
scene = ev["scene"]
|
| 63 |
-
pano = ev.get("panorama") or pano
|
| 64 |
-
depth = ev.get("depth") or depth
|
| 65 |
-
if ev.get("stage") in ("error", "quota_exceeded"):
|
| 66 |
-
print(f" !! {ev.get('stage')}: {ev.get('error')}")
|
| 67 |
-
if not pano:
|
| 68 |
-
print(f" !! no panorama for stanza {i}; skipping")
|
| 69 |
-
continue
|
| 70 |
-
pano_name = f"world-{i}.webp"
|
| 71 |
-
depth_name = f"world-{i}-depth.png"
|
| 72 |
-
n1 = _download(pano, OUT / pano_name, token)
|
| 73 |
-
n2 = _download(depth, OUT / depth_name, token) if depth else 0
|
| 74 |
-
print(f" ok in {time.time()-t0:.0f}s pano={n1}B depth={n2}B scene={(scene or '')[:80]}")
|
| 75 |
-
manifest.append(
|
| 76 |
-
{
|
| 77 |
-
"index": i,
|
| 78 |
-
"title": title,
|
| 79 |
-
"stanza": stanza,
|
| 80 |
-
"scene": scene or "",
|
| 81 |
-
"panorama": f"/frontend/assets/showcase/{pano_name}",
|
| 82 |
-
"depth": f"/frontend/assets/showcase/{depth_name}" if depth else None,
|
| 83 |
-
}
|
| 84 |
-
)
|
| 85 |
-
(OUT / "manifest.json").write_text(json.dumps(manifest, indent=2), encoding="utf-8")
|
| 86 |
-
print(f"WROTE manifest with {len(manifest)} worlds -> {OUT/'manifest.json'}")
|
| 87 |
-
return 0 if manifest else 1
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
if __name__ == "__main__":
|
| 91 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/deploy_private_space.py
DELETED
|
@@ -1,114 +0,0 @@
|
|
| 1 |
-
"""Deploy the current private build to the personal Lightloom dev Space.
|
| 2 |
-
|
| 3 |
-
Parameter contribution: 0B. This script uses HF_WRITE_TOKEN from the process
|
| 4 |
-
environment and never prints token values.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import os
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
import sys
|
| 12 |
-
|
| 13 |
-
from huggingface_hub import HfApi, SpaceHardware
|
| 14 |
-
|
| 15 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def _token() -> str:
|
| 19 |
-
token = os.getenv("HF_WRITE_TOKEN") or os.getenv("HF_TOKEN")
|
| 20 |
-
if not token:
|
| 21 |
-
raise SystemExit("HF_WRITE_TOKEN/HF_TOKEN is required in the process environment.")
|
| 22 |
-
return token
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
def _read_token() -> str | None:
|
| 26 |
-
return os.getenv("HF_READ_TOKEN") or os.getenv("HF_TOKEN")
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
def _space_id(api: HfApi, token: str) -> str:
|
| 30 |
-
configured = os.getenv("LIGHTLOOM_DEV_SPACE_ID")
|
| 31 |
-
if configured:
|
| 32 |
-
return configured
|
| 33 |
-
info = api.whoami(token=token)
|
| 34 |
-
username = info.get("name")
|
| 35 |
-
if not username:
|
| 36 |
-
raise SystemExit("Could not infer HF username for personal dev Space.")
|
| 37 |
-
return f"{username}/lightloom-dev"
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
def _zero_hardware() -> SpaceHardware | None:
|
| 41 |
-
for candidate in SpaceHardware:
|
| 42 |
-
if "zero" in str(candidate.value).lower():
|
| 43 |
-
return candidate
|
| 44 |
-
return None
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
def main() -> int:
|
| 48 |
-
token = _token()
|
| 49 |
-
api = HfApi(token=token)
|
| 50 |
-
space_id = _space_id(api, token)
|
| 51 |
-
api.create_repo(
|
| 52 |
-
space_id,
|
| 53 |
-
repo_type="space",
|
| 54 |
-
private=True,
|
| 55 |
-
exist_ok=True,
|
| 56 |
-
space_sdk="gradio",
|
| 57 |
-
space_hardware=_zero_hardware(),
|
| 58 |
-
)
|
| 59 |
-
read_token = _read_token()
|
| 60 |
-
if read_token:
|
| 61 |
-
api.add_space_secret(space_id, "HF_TOKEN", read_token, token=token)
|
| 62 |
-
for key, value in {
|
| 63 |
-
"LIGHTLOOM_PROFILE": "space",
|
| 64 |
-
"LIGHTLOOM_PRIVACY_MODE": "1",
|
| 65 |
-
# OFF in production: this flag gates /internal/* probes AND the legacy /world + /panorama
|
| 66 |
-
# generators that load klein-BASE + a 3rd-party 360 LoRA NOT in the runtime ledger. Leaving
|
| 67 |
-
# it "1" silently re-enabled those un-ledgered endpoints for any judge -> a ledger/honesty
|
| 68 |
-
# contradiction. The live experience (/scroll_live) does not need it. Flip to "1" only for a
|
| 69 |
-
# local/offline bench run.
|
| 70 |
-
"LIGHTLOOM_ENABLE_INTERNAL_BENCH": os.getenv("LIGHTLOOM_ENABLE_INTERNAL_BENCH", "0"),
|
| 71 |
-
"LIGHTLOOM_G1_REPS": os.getenv("LIGHTLOOM_G1_REPS", "5"),
|
| 72 |
-
}.items():
|
| 73 |
-
api.add_space_variable(space_id, key, value, token=token)
|
| 74 |
-
info = api.upload_folder(
|
| 75 |
-
repo_id=space_id,
|
| 76 |
-
repo_type="space",
|
| 77 |
-
folder_path=ROOT,
|
| 78 |
-
commit_message="chore: deploy private lightloom build",
|
| 79 |
-
ignore_patterns=[
|
| 80 |
-
".git/*",
|
| 81 |
-
".venv/*",
|
| 82 |
-
".env",
|
| 83 |
-
".env.*",
|
| 84 |
-
"lightloom-docs/*",
|
| 85 |
-
"VideosExamples/*", # the user's private screen recordings + audio — NEVER ship
|
| 86 |
-
"*.zip",
|
| 87 |
-
"*.mp4",
|
| 88 |
-
"*.mp3",
|
| 89 |
-
"*.mov",
|
| 90 |
-
"__pycache__/*",
|
| 91 |
-
".pytest_cache/*",
|
| 92 |
-
"node_modules/*",
|
| 93 |
-
".shots/*",
|
| 94 |
-
"*.pdf",
|
| 95 |
-
"package.json",
|
| 96 |
-
"package-lock.json",
|
| 97 |
-
"benchmarks/results/g1.json",
|
| 98 |
-
"benchmarks/results/g1.md",
|
| 99 |
-
# session scratch (Modal renders, PDF page rasters, downloaded samples) — never ship
|
| 100 |
-
".covers_dl/*", ".stylegrid/*", ".stylegrid2/*", ".modal_dataset_sample/*",
|
| 101 |
-
".modal_validate/*", ".tut/*", ".train_script_ref.py", ".modal_*.log",
|
| 102 |
-
".tutorial_text.txt",
|
| 103 |
-
],
|
| 104 |
-
# Remove stale paths a previous (pre-ignore) deploy left on the Space — a large
|
| 105 |
-
# node_modules tree, a research PDF, and the user's private VideosExamples media.
|
| 106 |
-
delete_patterns=["node_modules/*", "*.pdf", "VideosExamples/*", "*.mp4", "*.mp3", "*.mov"],
|
| 107 |
-
token=token,
|
| 108 |
-
)
|
| 109 |
-
print(f"DEPLOYED {space_id} {info.oid}")
|
| 110 |
-
return 0
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
if __name__ == "__main__":
|
| 114 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/fetch_gate_g1.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
"""Run G1 through the private Space endpoint and save returned results locally."""
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import json
|
| 6 |
-
import os
|
| 7 |
-
from pathlib import Path
|
| 8 |
-
import sys
|
| 9 |
-
from urllib.request import Request, urlopen
|
| 10 |
-
|
| 11 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 12 |
-
sys.path.insert(0, str(ROOT))
|
| 13 |
-
OUT = ROOT / "benchmarks" / "results" / "g1.json"
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def _space_id() -> str:
|
| 17 |
-
configured = os.getenv("LIGHTLOOM_DEV_SPACE_ID")
|
| 18 |
-
if configured:
|
| 19 |
-
return configured
|
| 20 |
-
token = os.getenv("HF_WRITE_TOKEN") or os.getenv("HF_TOKEN")
|
| 21 |
-
if not token:
|
| 22 |
-
raise SystemExit("HF_WRITE_TOKEN/HF_TOKEN is required to infer the Space id.")
|
| 23 |
-
from huggingface_hub import HfApi
|
| 24 |
-
|
| 25 |
-
info = HfApi(token=token).whoami(token=token)
|
| 26 |
-
username = info.get("name")
|
| 27 |
-
if not username:
|
| 28 |
-
raise SystemExit("Could not infer HF username.")
|
| 29 |
-
return f"{username}/lightloom-dev"
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def _url(space_id: str) -> str:
|
| 33 |
-
owner, name = space_id.split("/", 1)
|
| 34 |
-
return f"https://{owner}-{name}.hf.space/internal/bench/g1"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
def main() -> int:
|
| 38 |
-
token = os.getenv("HF_WRITE_TOKEN") or os.getenv("HF_TOKEN")
|
| 39 |
-
if not token:
|
| 40 |
-
raise SystemExit("HF_WRITE_TOKEN/HF_TOKEN is required in the process environment.")
|
| 41 |
-
req = Request(_url(_space_id()), method="POST", headers={"Authorization": f"Bearer {token}"})
|
| 42 |
-
with urlopen(req, timeout=int(os.getenv("LIGHTLOOM_G1_TIMEOUT", "1800"))) as response:
|
| 43 |
-
payload = json.loads(response.read().decode("utf-8"))
|
| 44 |
-
if not payload.get("ok"):
|
| 45 |
-
raise SystemExit(f"Space G1 endpoint failed: {payload}")
|
| 46 |
-
OUT.parent.mkdir(parents=True, exist_ok=True)
|
| 47 |
-
OUT.write_text(json.dumps(payload["data"], indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 48 |
-
from benchmarks.gate_g1 import DEFAULT_MD, _write_markdown
|
| 49 |
-
|
| 50 |
-
_write_markdown(DEFAULT_MD, payload["data"])
|
| 51 |
-
print(f"WROTE {OUT}")
|
| 52 |
-
print(f"DECISION {payload['data']['decision']['status']}")
|
| 53 |
-
return 0
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
if __name__ == "__main__":
|
| 57 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/fetch_gate_g2_g3.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
| 1 |
-
"""Run G2/G3 through the private Space endpoint and save returned results locally."""
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import json
|
| 6 |
-
import os
|
| 7 |
-
from pathlib import Path
|
| 8 |
-
import sys
|
| 9 |
-
from urllib.request import Request, urlopen
|
| 10 |
-
|
| 11 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 12 |
-
OUT_DIR = ROOT / "benchmarks" / "results"
|
| 13 |
-
sys.path.insert(0, str(ROOT))
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def _space_id() -> str:
|
| 17 |
-
configured = os.getenv("LIGHTLOOM_DEV_SPACE_ID")
|
| 18 |
-
if configured:
|
| 19 |
-
return configured
|
| 20 |
-
token = os.getenv("HF_WRITE_TOKEN") or os.getenv("HF_TOKEN")
|
| 21 |
-
if not token:
|
| 22 |
-
raise SystemExit("HF_WRITE_TOKEN/HF_TOKEN is required to infer the Space id.")
|
| 23 |
-
from huggingface_hub import HfApi
|
| 24 |
-
|
| 25 |
-
info = HfApi(token=token).whoami(token=token)
|
| 26 |
-
return f"{info['name']}/lightloom-dev"
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
def main() -> int:
|
| 30 |
-
token = os.getenv("HF_WRITE_TOKEN") or os.getenv("HF_TOKEN")
|
| 31 |
-
if not token:
|
| 32 |
-
raise SystemExit("HF_WRITE_TOKEN/HF_TOKEN is required in the process environment.")
|
| 33 |
-
owner, name = _space_id().split("/", 1)
|
| 34 |
-
req = Request(
|
| 35 |
-
f"https://{owner}-{name}.hf.space/internal/bench/g2-g3",
|
| 36 |
-
method="POST",
|
| 37 |
-
headers={"Authorization": f"Bearer {token}"},
|
| 38 |
-
)
|
| 39 |
-
with urlopen(req, timeout=int(os.getenv("LIGHTLOOM_G23_TIMEOUT", "1800"))) as response:
|
| 40 |
-
payload = json.loads(response.read().decode("utf-8"))
|
| 41 |
-
if not payload.get("ok"):
|
| 42 |
-
raise SystemExit(f"Space G2/G3 endpoint failed: {payload}")
|
| 43 |
-
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 44 |
-
(OUT_DIR / "g2.json").write_text(json.dumps(payload["g2"], indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 45 |
-
(OUT_DIR / "g3.json").write_text(json.dumps(payload["g3"], indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 46 |
-
print(f"G2 {payload['g2']['decision']}")
|
| 47 |
-
print(f"G3 {payload['g3']['decision']}")
|
| 48 |
-
return 0
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
if __name__ == "__main__":
|
| 52 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/preflight.py
DELETED
|
@@ -1,395 +0,0 @@
|
|
| 1 |
-
"""Lightloom preflight checks.
|
| 2 |
-
|
| 3 |
-
Writes benchmarks/results/preflight.json and prints a redacted summary. The
|
| 4 |
-
script never prints token values and never persists secrets.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import importlib
|
| 10 |
-
import json
|
| 11 |
-
import os
|
| 12 |
-
from pathlib import Path
|
| 13 |
-
import platform
|
| 14 |
-
import sys
|
| 15 |
-
import time
|
| 16 |
-
from typing import Any
|
| 17 |
-
|
| 18 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 19 |
-
sys.path.insert(0, str(ROOT / "src"))
|
| 20 |
-
RESULTS = ROOT / "benchmarks" / "results"
|
| 21 |
-
PREFLIGHT_JSON = RESULTS / "preflight.json"
|
| 22 |
-
ORG_NAME = os.getenv("LIGHTLOOM_HF_ORG", "build-small-hackathon")
|
| 23 |
-
DEV_SPACE_ID = os.getenv("LIGHTLOOM_DEV_SPACE_ID")
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def _env_present(name: str) -> bool:
|
| 27 |
-
return bool(os.getenv(name, "").strip())
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
def _token() -> str | None:
|
| 31 |
-
for name in ("HF_WRITE_TOKEN", "HF_TOKEN"):
|
| 32 |
-
value = os.getenv(name, "").strip()
|
| 33 |
-
if value:
|
| 34 |
-
return value
|
| 35 |
-
return None
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
def _missing_token_message() -> str:
|
| 39 |
-
return (
|
| 40 |
-
"HF_WRITE_TOKEN/HF_TOKEN is not set in the process environment. "
|
| 41 |
-
"Install env vars without writing secrets to files: "
|
| 42 |
-
"PowerShell -ExecutionPolicy Bypass -File scripts/set_hf_env.ps1"
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
def _check(name: str, ok: bool, message: str, evidence: dict[str, Any] | None = None) -> dict[str, Any]:
|
| 47 |
-
return {
|
| 48 |
-
"name": name,
|
| 49 |
-
"ok": bool(ok),
|
| 50 |
-
"message": message,
|
| 51 |
-
"evidence": evidence or {},
|
| 52 |
-
}
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def _run_python_import(module: str) -> tuple[bool, str | None]:
|
| 56 |
-
try:
|
| 57 |
-
imported = importlib.import_module(module)
|
| 58 |
-
except Exception as exc: # noqa: BLE001 - preflight reports dependency health.
|
| 59 |
-
return False, f"{type(exc).__name__}: {exc}"
|
| 60 |
-
version = getattr(imported, "__version__", None)
|
| 61 |
-
return True, str(version) if version is not None else "installed"
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
def check_p1_org_membership() -> dict[str, Any]:
|
| 65 |
-
token = _token()
|
| 66 |
-
if token is None:
|
| 67 |
-
return _check(
|
| 68 |
-
"P1 org membership",
|
| 69 |
-
False,
|
| 70 |
-
_missing_token_message(),
|
| 71 |
-
{"required_org": ORG_NAME},
|
| 72 |
-
)
|
| 73 |
-
try:
|
| 74 |
-
from huggingface_hub import HfApi
|
| 75 |
-
|
| 76 |
-
info = HfApi(token=token).whoami(token=token)
|
| 77 |
-
orgs = [org.get("name") for org in info.get("orgs", [])]
|
| 78 |
-
user = info.get("name") or info.get("fullname") or "unknown"
|
| 79 |
-
ok = ORG_NAME in orgs
|
| 80 |
-
return _check(
|
| 81 |
-
"P1 org membership",
|
| 82 |
-
ok,
|
| 83 |
-
"authenticated user is a member of the hackathon org"
|
| 84 |
-
if ok
|
| 85 |
-
else "authenticated user is not a member of the hackathon org",
|
| 86 |
-
{"user": user, "required_org": ORG_NAME, "org_present": ok},
|
| 87 |
-
)
|
| 88 |
-
except Exception as exc: # noqa: BLE001
|
| 89 |
-
return _check(
|
| 90 |
-
"P1 org membership",
|
| 91 |
-
False,
|
| 92 |
-
f"whoami failed: {type(exc).__name__}",
|
| 93 |
-
{"required_org": ORG_NAME},
|
| 94 |
-
)
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
def check_p2_space() -> dict[str, Any]:
|
| 98 |
-
token = _token()
|
| 99 |
-
if token is None:
|
| 100 |
-
return _check(
|
| 101 |
-
"P2 private ZeroGPU Space",
|
| 102 |
-
False,
|
| 103 |
-
"HF_WRITE_TOKEN/HF_TOKEN is not set; cannot create or inspect private dev Space.",
|
| 104 |
-
{"space_id": DEV_SPACE_ID or "unset"},
|
| 105 |
-
)
|
| 106 |
-
try:
|
| 107 |
-
from huggingface_hub import HfApi, SpaceHardware
|
| 108 |
-
|
| 109 |
-
api = HfApi(token=token)
|
| 110 |
-
inferred_space_id = DEV_SPACE_ID
|
| 111 |
-
if inferred_space_id is None:
|
| 112 |
-
info = api.whoami(token=token)
|
| 113 |
-
username = info.get("name")
|
| 114 |
-
if not username:
|
| 115 |
-
return _check(
|
| 116 |
-
"P2 private ZeroGPU Space",
|
| 117 |
-
False,
|
| 118 |
-
"could not infer personal namespace from whoami",
|
| 119 |
-
{"privacy_mode": True},
|
| 120 |
-
)
|
| 121 |
-
inferred_space_id = f"{username}/lightloom-dev"
|
| 122 |
-
hardware = None
|
| 123 |
-
for candidate in SpaceHardware:
|
| 124 |
-
if "zero" in str(candidate.value).lower():
|
| 125 |
-
hardware = candidate
|
| 126 |
-
break
|
| 127 |
-
api.create_repo(
|
| 128 |
-
inferred_space_id,
|
| 129 |
-
repo_type="space",
|
| 130 |
-
private=True,
|
| 131 |
-
exist_ok=True,
|
| 132 |
-
space_sdk="gradio",
|
| 133 |
-
space_hardware=hardware,
|
| 134 |
-
space_secrets=[
|
| 135 |
-
{"key": "HF_TOKEN", "value": os.getenv("HF_READ_TOKEN", os.getenv("HF_TOKEN", ""))}
|
| 136 |
-
]
|
| 137 |
-
if (os.getenv("HF_READ_TOKEN") or os.getenv("HF_TOKEN"))
|
| 138 |
-
else None,
|
| 139 |
-
space_variables=[
|
| 140 |
-
{"key": "LIGHTLOOM_PROFILE", "value": "space"},
|
| 141 |
-
{"key": "LIGHTLOOM_PRIVACY_MODE", "value": "1"},
|
| 142 |
-
],
|
| 143 |
-
)
|
| 144 |
-
runtime = api.get_space_runtime(inferred_space_id, token=token)
|
| 145 |
-
runtime_hardware = getattr(runtime, "hardware", None)
|
| 146 |
-
requested = getattr(runtime, "requested_hardware", None)
|
| 147 |
-
stage = getattr(runtime, "stage", None)
|
| 148 |
-
sdk = getattr(runtime, "sdk", None)
|
| 149 |
-
zero_gpu = "zero" in str(runtime_hardware or requested or hardware).lower()
|
| 150 |
-
ok = zero_gpu and (sdk in {None, "gradio"} or "gradio" in str(sdk).lower())
|
| 151 |
-
return _check(
|
| 152 |
-
"P2 private ZeroGPU Space",
|
| 153 |
-
ok,
|
| 154 |
-
"private dev Space exists and appears to be ZeroGPU/Gradio"
|
| 155 |
-
if ok
|
| 156 |
-
else "dev Space does not show ZeroGPU/Gradio runtime metadata",
|
| 157 |
-
{
|
| 158 |
-
"space_id": inferred_space_id,
|
| 159 |
-
"privacy": "private",
|
| 160 |
-
"hardware": str(runtime_hardware),
|
| 161 |
-
"requested_hardware": str(requested),
|
| 162 |
-
"created_or_reused": True,
|
| 163 |
-
"stage": str(stage),
|
| 164 |
-
"sdk": str(sdk),
|
| 165 |
-
},
|
| 166 |
-
)
|
| 167 |
-
except Exception as exc: # noqa: BLE001
|
| 168 |
-
return _check(
|
| 169 |
-
"P2 private ZeroGPU Space",
|
| 170 |
-
False,
|
| 171 |
-
f"Space inspection failed: {type(exc).__name__}",
|
| 172 |
-
{"space_id": DEV_SPACE_ID},
|
| 173 |
-
)
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
def check_p3_secrets() -> dict[str, Any]:
|
| 177 |
-
return _check(
|
| 178 |
-
"P3 runtime secret contract",
|
| 179 |
-
_env_present("HF_READ_TOKEN") or _env_present("HF_TOKEN"),
|
| 180 |
-
"read token env var is available for configuring the Space secret"
|
| 181 |
-
if (_env_present("HF_READ_TOKEN") or _env_present("HF_TOKEN"))
|
| 182 |
-
else "HF_READ_TOKEN/HF_TOKEN is not set in this process",
|
| 183 |
-
{"secret_names_only": ["HF_TOKEN"]},
|
| 184 |
-
)
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
def check_p4_local_versions() -> dict[str, Any]:
|
| 188 |
-
from lightloom.core.config import CONFIG
|
| 189 |
-
|
| 190 |
-
imports = {}
|
| 191 |
-
for module in ("gradio", "huggingface_hub", "transformers", "diffusers", "torch", "llama_cpp"):
|
| 192 |
-
ok, detail = _run_python_import(module)
|
| 193 |
-
imports[module] = {"ok": ok, "detail": detail}
|
| 194 |
-
py_ok = sys.version_info >= (3, 10)
|
| 195 |
-
missing = [name for name, result in imports.items() if not result["ok"]]
|
| 196 |
-
torch_evidence: dict[str, Any] = {}
|
| 197 |
-
try:
|
| 198 |
-
import torch
|
| 199 |
-
|
| 200 |
-
torch_evidence = {
|
| 201 |
-
"torch": getattr(torch, "__version__", "unknown"),
|
| 202 |
-
"cuda_available": bool(torch.cuda.is_available()),
|
| 203 |
-
"cuda_version": getattr(torch.version, "cuda", None),
|
| 204 |
-
"arch_list": list(torch.cuda.get_arch_list()) if torch.cuda.is_available() else [],
|
| 205 |
-
"sm_120_supported": "sm_120" in (
|
| 206 |
-
torch.cuda.get_arch_list() if torch.cuda.is_available() else []
|
| 207 |
-
),
|
| 208 |
-
"cuda_kernel_smoke": False,
|
| 209 |
-
}
|
| 210 |
-
if torch.cuda.is_available():
|
| 211 |
-
x = torch.ones((8, 8), device="cuda")
|
| 212 |
-
torch_evidence["cuda_kernel_smoke"] = bool((x @ x).sum().item() == 512.0)
|
| 213 |
-
except Exception as exc: # noqa: BLE001
|
| 214 |
-
torch_evidence = {"torch_error": f"{type(exc).__name__}: {exc}"}
|
| 215 |
-
local_cuda_ok = True
|
| 216 |
-
if CONFIG.profile == "local":
|
| 217 |
-
local_cuda_ok = bool(
|
| 218 |
-
torch_evidence.get("cuda_available")
|
| 219 |
-
and torch_evidence.get("sm_120_supported")
|
| 220 |
-
and torch_evidence.get("cuda_kernel_smoke")
|
| 221 |
-
)
|
| 222 |
-
ok = py_ok and not missing and local_cuda_ok
|
| 223 |
-
return _check(
|
| 224 |
-
"P4 local versions",
|
| 225 |
-
ok,
|
| 226 |
-
"Python, required imports, and local CUDA smoke check are available"
|
| 227 |
-
if ok
|
| 228 |
-
else "missing packages or local CUDA/sm_120 smoke check failed",
|
| 229 |
-
{
|
| 230 |
-
"python": sys.version,
|
| 231 |
-
"executable": sys.executable,
|
| 232 |
-
"platform": platform.platform(),
|
| 233 |
-
"imports": imports,
|
| 234 |
-
"torch": torch_evidence,
|
| 235 |
-
"packages_txt_has_ffmpeg": (ROOT / "packages.txt").read_text().strip() == "ffmpeg",
|
| 236 |
-
},
|
| 237 |
-
)
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
def check_p5_models() -> dict[str, Any]:
|
| 241 |
-
from lightloom.core.config import CONFIG, MODEL_REFS
|
| 242 |
-
|
| 243 |
-
token = _token()
|
| 244 |
-
if token is None:
|
| 245 |
-
return _check(
|
| 246 |
-
"P5 model cards",
|
| 247 |
-
False,
|
| 248 |
-
"HF_WRITE_TOKEN/HF_TOKEN is not set; cannot verify private/gated model cards.",
|
| 249 |
-
{
|
| 250 |
-
"profile": CONFIG.profile,
|
| 251 |
-
"local_flux_dtype": CONFIG.flux_dtype,
|
| 252 |
-
"local_resolution": [CONFIG.width, CONFIG.height],
|
| 253 |
-
"local_aot": CONFIG.flux_aot,
|
| 254 |
-
"model_count": len(MODEL_REFS),
|
| 255 |
-
},
|
| 256 |
-
)
|
| 257 |
-
try:
|
| 258 |
-
from huggingface_hub import HfApi
|
| 259 |
-
|
| 260 |
-
api = HfApi(token=token)
|
| 261 |
-
resolved: dict[str, Any] = {}
|
| 262 |
-
failures: dict[str, str] = {}
|
| 263 |
-
for key, ref in MODEL_REFS.items():
|
| 264 |
-
if key == "rife":
|
| 265 |
-
resolved[key] = {
|
| 266 |
-
"repo_id": ref.repo_id,
|
| 267 |
-
"license": ref.license,
|
| 268 |
-
"note": "GitHub repo; checkpoint license remains VERIFY until selected.",
|
| 269 |
-
}
|
| 270 |
-
continue
|
| 271 |
-
try:
|
| 272 |
-
info = api.model_info(ref.repo_id, token=token)
|
| 273 |
-
license_name = None
|
| 274 |
-
if getattr(info, "card_data", None):
|
| 275 |
-
license_name = getattr(info.card_data, "license", None)
|
| 276 |
-
resolved[key] = {
|
| 277 |
-
"repo_id": ref.repo_id,
|
| 278 |
-
"sha": getattr(info, "sha", None),
|
| 279 |
-
"license": license_name or ref.license,
|
| 280 |
-
"private": bool(getattr(info, "private", False)),
|
| 281 |
-
}
|
| 282 |
-
except Exception as exc: # noqa: BLE001
|
| 283 |
-
failures[key] = f"{type(exc).__name__}: {exc}"
|
| 284 |
-
ok = not failures
|
| 285 |
-
return _check(
|
| 286 |
-
"P5 model cards",
|
| 287 |
-
ok,
|
| 288 |
-
"model cards resolved" if ok else "one or more model cards failed to resolve",
|
| 289 |
-
{
|
| 290 |
-
"profile": CONFIG.profile,
|
| 291 |
-
"local_flux_dtype": CONFIG.flux_dtype,
|
| 292 |
-
"local_resolution": [CONFIG.width, CONFIG.height],
|
| 293 |
-
"local_aot": CONFIG.flux_aot,
|
| 294 |
-
"resolved": resolved,
|
| 295 |
-
"failures": failures,
|
| 296 |
-
},
|
| 297 |
-
)
|
| 298 |
-
except Exception as exc: # noqa: BLE001
|
| 299 |
-
return _check("P5 model cards", False, f"Hub verification failed: {type(exc).__name__}")
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
def check_p6_disk_cache() -> dict[str, Any]:
|
| 303 |
-
usage = None
|
| 304 |
-
try:
|
| 305 |
-
usage = os.statvfs(ROOT) # type: ignore[attr-defined]
|
| 306 |
-
free_gb = usage.f_bavail * usage.f_frsize / (1024**3)
|
| 307 |
-
except AttributeError:
|
| 308 |
-
import shutil
|
| 309 |
-
|
| 310 |
-
free_gb = shutil.disk_usage(ROOT).free / (1024**3)
|
| 311 |
-
ok = free_gb >= 30
|
| 312 |
-
return _check(
|
| 313 |
-
"P6 disk/cache",
|
| 314 |
-
ok,
|
| 315 |
-
"local disk has room for iterative caches" if ok else "low free disk for model caches",
|
| 316 |
-
{"free_gb": round(free_gb, 2), "estimated_runtime_weights_gb": 20},
|
| 317 |
-
)
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
def check_p7_spaces_import() -> dict[str, Any]:
|
| 321 |
-
ok, detail = _run_python_import("spaces")
|
| 322 |
-
return _check(
|
| 323 |
-
"P7 spaces decorator",
|
| 324 |
-
ok,
|
| 325 |
-
"spaces package imports" if ok else "spaces package is missing",
|
| 326 |
-
{"detail": detail},
|
| 327 |
-
)
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
def check_secret_scan() -> dict[str, Any]:
|
| 331 |
-
token_re = __import__("re").compile(r"hf_[A-Za-z0-9]{20,}")
|
| 332 |
-
skip_parts = {".git", ".venv", "__pycache__", ".pytest_cache"}
|
| 333 |
-
skip_suffixes = {".zip", ".7z", ".tar", ".gz", ".png", ".jpg", ".jpeg", ".webp", ".mp4", ".wav"}
|
| 334 |
-
matches: list[str] = []
|
| 335 |
-
try:
|
| 336 |
-
for path in ROOT.rglob("*"):
|
| 337 |
-
if any(part in skip_parts for part in path.parts):
|
| 338 |
-
continue
|
| 339 |
-
if not path.is_file() or path.suffix.lower() in skip_suffixes:
|
| 340 |
-
continue
|
| 341 |
-
try:
|
| 342 |
-
text = path.read_text(encoding="utf-8")
|
| 343 |
-
except UnicodeDecodeError:
|
| 344 |
-
continue
|
| 345 |
-
if token_re.search(text):
|
| 346 |
-
matches.append(str(path.relative_to(ROOT)))
|
| 347 |
-
except Exception as exc: # noqa: BLE001
|
| 348 |
-
return _check("secret scan", False, f"secret scan failed: {type(exc).__name__}")
|
| 349 |
-
ok = not matches
|
| 350 |
-
return _check(
|
| 351 |
-
"secret scan",
|
| 352 |
-
ok,
|
| 353 |
-
"no HF token patterns in tracked files" if ok else "possible HF token pattern found",
|
| 354 |
-
{"match_files": sorted(set(matches))},
|
| 355 |
-
)
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
def run() -> dict[str, Any]:
|
| 359 |
-
start = time.time()
|
| 360 |
-
RESULTS.mkdir(parents=True, exist_ok=True)
|
| 361 |
-
checks = [
|
| 362 |
-
check_p1_org_membership(),
|
| 363 |
-
check_p2_space(),
|
| 364 |
-
check_p3_secrets(),
|
| 365 |
-
check_p4_local_versions(),
|
| 366 |
-
check_p5_models(),
|
| 367 |
-
check_p6_disk_cache(),
|
| 368 |
-
check_p7_spaces_import(),
|
| 369 |
-
check_secret_scan(),
|
| 370 |
-
]
|
| 371 |
-
result = {
|
| 372 |
-
"schema_version": 1,
|
| 373 |
-
"generated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
| 374 |
-
"hardware_profile": os.getenv("LIGHTLOOM_PROFILE", "local"),
|
| 375 |
-
"privacy_mode": True,
|
| 376 |
-
"all_green": all(check["ok"] for check in checks),
|
| 377 |
-
"checks": checks,
|
| 378 |
-
"elapsed_s": round(time.time() - start, 3),
|
| 379 |
-
}
|
| 380 |
-
PREFLIGHT_JSON.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
| 381 |
-
return result
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
def main() -> int:
|
| 385 |
-
result = run()
|
| 386 |
-
print("LIGHTLOOM PREFLIGHT")
|
| 387 |
-
for check in result["checks"]:
|
| 388 |
-
status = "PASS" if check["ok"] else "FAIL"
|
| 389 |
-
print(f"{status} {check['name']}: {check['message']}")
|
| 390 |
-
print(f"RESULT {'ALL GREEN' if result['all_green'] else 'BLOCKED'} -> {PREFLIGHT_JSON}")
|
| 391 |
-
return 0 if result["all_green"] else 1
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
if __name__ == "__main__":
|
| 395 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/release_check.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
"""Release gate for Lightloom.
|
| 2 |
-
|
| 3 |
-
This starts strict and becomes stricter through F4/F5. It already enforces the
|
| 4 |
-
privacy addendum's no-secret/no-placeholder posture.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import json
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
import re
|
| 12 |
-
import subprocess
|
| 13 |
-
import sys
|
| 14 |
-
|
| 15 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 16 |
-
TOKEN_RE = re.compile(r"hf_[A-Za-z0-9]{20,}")
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
def fail(message: str) -> str:
|
| 20 |
-
return f"FAIL {message}"
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def ok(message: str) -> str:
|
| 24 |
-
return f"PASS {message}"
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def secret_scan() -> tuple[bool, str]:
|
| 28 |
-
tracked = subprocess.run(
|
| 29 |
-
["git", "ls-files"],
|
| 30 |
-
cwd=ROOT,
|
| 31 |
-
text=True,
|
| 32 |
-
capture_output=True,
|
| 33 |
-
check=False,
|
| 34 |
-
)
|
| 35 |
-
if tracked.returncode != 0:
|
| 36 |
-
return False, "git ls-files failed"
|
| 37 |
-
offenders: list[str] = []
|
| 38 |
-
for rel in tracked.stdout.splitlines():
|
| 39 |
-
path = ROOT / rel
|
| 40 |
-
if not path.is_file():
|
| 41 |
-
continue
|
| 42 |
-
try:
|
| 43 |
-
text = path.read_text(encoding="utf-8")
|
| 44 |
-
except UnicodeDecodeError:
|
| 45 |
-
continue
|
| 46 |
-
if TOKEN_RE.search(text):
|
| 47 |
-
offenders.append(rel)
|
| 48 |
-
if offenders:
|
| 49 |
-
return False, "token-like secret found in tracked files: " + ", ".join(offenders)
|
| 50 |
-
return True, "no token-like secrets in tracked files"
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
def preflight_result() -> tuple[bool, str]:
|
| 54 |
-
path = ROOT / "benchmarks" / "results" / "preflight.json"
|
| 55 |
-
if not path.exists():
|
| 56 |
-
return False, "benchmarks/results/preflight.json is missing"
|
| 57 |
-
data = json.loads(path.read_text(encoding="utf-8"))
|
| 58 |
-
if not data.get("all_green"):
|
| 59 |
-
return False, "preflight is not ALL GREEN"
|
| 60 |
-
return True, "preflight ALL GREEN"
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
def h6_placeholder_gate() -> tuple[bool, str]:
|
| 64 |
-
readme = ROOT / "README.md"
|
| 65 |
-
if not readme.exists():
|
| 66 |
-
return False, "README.md is missing"
|
| 67 |
-
text = readme.read_text(encoding="utf-8")
|
| 68 |
-
release_mode = (ROOT / "docs" / "submission" / "H6_GREEN").exists()
|
| 69 |
-
if release_mode and "⟦PLACEHOLDER⟧" in text:
|
| 70 |
-
return False, "H6 release mode forbids README placeholders"
|
| 71 |
-
return True, "README placeholder state accepted for current private mode"
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
def main() -> int:
|
| 75 |
-
checks = [secret_scan(), preflight_result(), h6_placeholder_gate()]
|
| 76 |
-
for passed, message in checks:
|
| 77 |
-
print(ok(message) if passed else fail(message))
|
| 78 |
-
all_green = all(passed for passed, _ in checks)
|
| 79 |
-
print("RESULT " + ("ALL GREEN" if all_green else "BLOCKED"))
|
| 80 |
-
return 0 if all_green else 1
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
if __name__ == "__main__":
|
| 84 |
-
raise SystemExit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/set_hf_env.ps1
DELETED
|
@@ -1,55 +0,0 @@
|
|
| 1 |
-
param(
|
| 2 |
-
[switch]$PersistUser = $true,
|
| 3 |
-
[string]$DevSpaceId = ""
|
| 4 |
-
)
|
| 5 |
-
|
| 6 |
-
$ErrorActionPreference = "Stop"
|
| 7 |
-
|
| 8 |
-
function Read-SecretPlainText {
|
| 9 |
-
param([Parameter(Mandatory = $true)][string]$Name)
|
| 10 |
-
$secure = Read-Host -Prompt "Enter $Name" -AsSecureString
|
| 11 |
-
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
|
| 12 |
-
try {
|
| 13 |
-
return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
|
| 14 |
-
}
|
| 15 |
-
finally {
|
| 16 |
-
if ($bstr -ne [IntPtr]::Zero) {
|
| 17 |
-
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr)
|
| 18 |
-
}
|
| 19 |
-
}
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
function Set-EnvValue {
|
| 23 |
-
param(
|
| 24 |
-
[Parameter(Mandatory = $true)][string]$Name,
|
| 25 |
-
[Parameter(Mandatory = $true)][string]$Value
|
| 26 |
-
)
|
| 27 |
-
Set-Item -Path "Env:$Name" -Value $Value
|
| 28 |
-
if ($PersistUser) {
|
| 29 |
-
[Environment]::SetEnvironmentVariable($Name, $Value, "User")
|
| 30 |
-
}
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
$writeToken = Read-SecretPlainText -Name "HF_WRITE_TOKEN"
|
| 34 |
-
$readToken = Read-SecretPlainText -Name "HF_READ_TOKEN"
|
| 35 |
-
|
| 36 |
-
if (-not $writeToken.StartsWith("hf_")) {
|
| 37 |
-
throw "HF_WRITE_TOKEN must look like a Hugging Face token."
|
| 38 |
-
}
|
| 39 |
-
if (-not $readToken.StartsWith("hf_")) {
|
| 40 |
-
throw "HF_READ_TOKEN must look like a Hugging Face token."
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
Set-EnvValue -Name "HF_WRITE_TOKEN" -Value $writeToken
|
| 44 |
-
Set-EnvValue -Name "HF_READ_TOKEN" -Value $readToken
|
| 45 |
-
Set-EnvValue -Name "HF_TOKEN" -Value $readToken
|
| 46 |
-
|
| 47 |
-
if ($DevSpaceId.Trim().Length -gt 0) {
|
| 48 |
-
Set-EnvValue -Name "LIGHTLOOM_DEV_SPACE_ID" -Value $DevSpaceId.Trim()
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
Set-EnvValue -Name "LIGHTLOOM_PROFILE" -Value "local"
|
| 52 |
-
Set-EnvValue -Name "LIGHTLOOM_HF_ORG" -Value "build-small-hackathon"
|
| 53 |
-
|
| 54 |
-
Write-Host "HF environment variables installed. Token values were not printed."
|
| 55 |
-
Write-Host "Restart the terminal or launch Codex from this shell for persisted user env changes to apply."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-app.cjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
| 1 |
-
// Full-app visual validation: load the REAL index.html (real stage.js controller
|
| 2 |
-
// + LL.pano), stub LL.api.streamPanorama with the downloaded REAL panorama+depth,
|
| 3 |
-
// fire "Roll", and screenshot the immersive world inside the real app shell. This
|
| 4 |
-
// exercises the entire controller wiring end-to-end without spending GPU/quota.
|
| 5 |
-
// Usage: node scripts/shoot-app.cjs
|
| 6 |
-
const { chromium } = require("playwright");
|
| 7 |
-
const http = require("http");
|
| 8 |
-
const fs = require("fs");
|
| 9 |
-
const path = require("path");
|
| 10 |
-
|
| 11 |
-
const ROOT = process.cwd();
|
| 12 |
-
const PORT = 8802;
|
| 13 |
-
const CT = {
|
| 14 |
-
".html": "text/html", ".js": "application/javascript", ".mjs": "application/javascript",
|
| 15 |
-
".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png",
|
| 16 |
-
".json": "application/json", ".svg": "image/svg+xml",
|
| 17 |
-
};
|
| 18 |
-
|
| 19 |
-
const server = http.createServer((req, res) => {
|
| 20 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 21 |
-
if (p === "/") p = "/frontend/index.html";
|
| 22 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7); // downloaded real assets
|
| 23 |
-
const file = path.join(ROOT, p);
|
| 24 |
-
fs.readFile(file, (err, data) => {
|
| 25 |
-
if (err) { res.writeHead(404); res.end("not found"); return; }
|
| 26 |
-
res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" });
|
| 27 |
-
res.end(data);
|
| 28 |
-
});
|
| 29 |
-
});
|
| 30 |
-
|
| 31 |
-
(async () => {
|
| 32 |
-
const SHOTS = path.join(ROOT, ".shots");
|
| 33 |
-
fs.mkdirSync(SHOTS, { recursive: true });
|
| 34 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 35 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 36 |
-
const browser = await chromium.launch({
|
| 37 |
-
args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"],
|
| 38 |
-
});
|
| 39 |
-
const page = await browser.newPage({ viewport: { width: 1680, height: 820 }, deviceScaleFactor: 1 });
|
| 40 |
-
const errs = [];
|
| 41 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 42 |
-
page.on("pageerror", (e) => errs.push("PAGEERROR: " + e.message.slice(0, 200)));
|
| 43 |
-
|
| 44 |
-
await page.goto(`http://localhost:${PORT}/frontend/index.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto: " + e.message));
|
| 45 |
-
await page.waitForTimeout(1500);
|
| 46 |
-
await page.screenshot({ path: shot("app-lobby.png") });
|
| 47 |
-
|
| 48 |
-
// Stub the GPU stream with the REAL downloaded world, then fire a Roll exactly
|
| 49 |
-
// as a user would (controller.startRecital reads #recital-text + drives LL.pano).
|
| 50 |
-
const started = await page.evaluate(async () => {
|
| 51 |
-
const LL = window.LL;
|
| 52 |
-
if (!LL || !LL.api || !LL.controller) return { ok: false, why: "LL.api/controller missing" };
|
| 53 |
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
| 54 |
-
LL.api.streamPanorama = async (text, lang, onEvent) => {
|
| 55 |
-
onEvent({ stage: "warming" });
|
| 56 |
-
await sleep(60);
|
| 57 |
-
onEvent({ stage: "directed", shot: { shot_type: "wide", lighting: "stormy dusk", camera_move: "drift" }, scene: "an old lighthouse keeper at the edge of the world, stormy dusk" });
|
| 58 |
-
onEvent({ stage: "painting" });
|
| 59 |
-
await sleep(60);
|
| 60 |
-
onEvent({ stage: "painted", panorama: "/shots/real-pano.webp" });
|
| 61 |
-
await sleep(80);
|
| 62 |
-
onEvent({ stage: "depth", depth: "/shots/real-depth.png" });
|
| 63 |
-
onEvent({ stage: "done", session: "harness" });
|
| 64 |
-
return { session: "harness", done: true, cancelled: false };
|
| 65 |
-
};
|
| 66 |
-
const ta = document.getElementById("recital-text");
|
| 67 |
-
if (ta) ta.value = "An old lighthouse keeper counted the waves at the edge of the world.";
|
| 68 |
-
LL.controller.startRecital();
|
| 69 |
-
return { ok: true, pano: typeof (LL.pano && LL.pano.show), ready: LL.pano && LL.pano.ready };
|
| 70 |
-
}).catch((e) => ({ ok: false, why: "evaluate: " + e.message }));
|
| 71 |
-
|
| 72 |
-
// Nudge a resize so LL.pano sizes its buffer to the now-visible #set canvas.
|
| 73 |
-
await page.waitForTimeout(400);
|
| 74 |
-
await page.evaluate(() => window.dispatchEvent(new Event("resize")));
|
| 75 |
-
await page.waitForTimeout(1600);
|
| 76 |
-
await page.screenshot({ path: shot("app-world-1.png") });
|
| 77 |
-
await page.waitForTimeout(2600); // let the camera drift to a new angle
|
| 78 |
-
await page.screenshot({ path: shot("app-world-2.png") });
|
| 79 |
-
|
| 80 |
-
const st = await page.evaluate(() => ({
|
| 81 |
-
state: window.LL.controller.state,
|
| 82 |
-
activeScreen: [...document.querySelectorAll(".screen.is-active")].map((s) => s.id),
|
| 83 |
-
panoReady: window.LL.pano && window.LL.pano.ready,
|
| 84 |
-
}));
|
| 85 |
-
console.log("STARTED:", JSON.stringify(started));
|
| 86 |
-
console.log("STATE:", JSON.stringify(st));
|
| 87 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 12)));
|
| 88 |
-
await browser.close();
|
| 89 |
-
server.close();
|
| 90 |
-
})().catch((e) => { console.error("HARNESS ERROR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-corridor.cjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
// Validate the 3D corridor renderer (stage-corridor.js): feed the 4 existing
|
| 2 |
-
// showcase worlds as streamed scenes and screenshot the camera flying forward
|
| 3 |
-
// through the growing corridor. Usage: node scripts/shoot-corridor.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const ROOT = process.cwd();
|
| 9 |
-
const PORT = 8805;
|
| 10 |
-
const CT = { ".html": "text/html", ".js": "application/javascript", ".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png" };
|
| 11 |
-
|
| 12 |
-
const TEST_HTML = `<!doctype html><html><head>
|
| 13 |
-
<script type="importmap">{"imports":{"three":"/frontend/vendor/three.module.js"}}</script>
|
| 14 |
-
<style>html,body{margin:0;background:#0b0d12;overflow:hidden}#c{width:100vw;height:100vh;display:block}</style>
|
| 15 |
-
</head><body><canvas id="c"></canvas>
|
| 16 |
-
<script type="module">
|
| 17 |
-
import "/frontend/js/stage-corridor.js";
|
| 18 |
-
const SC = window.LL.corridor;
|
| 19 |
-
SC.init(document.getElementById('c'));
|
| 20 |
-
const worlds = [0,1,2,3].map(i => ({
|
| 21 |
-
imageUrl: '/shots/world/w-'+i+'.webp',
|
| 22 |
-
depthUrl: '/shots/world/w-'+i+'-depth.png',
|
| 23 |
-
}));
|
| 24 |
-
window.__added = 0;
|
| 25 |
-
(async () => {
|
| 26 |
-
for (const w of worlds) { await SC.addScene(w); window.__added++; await new Promise(r=>setTimeout(r, 4000)); }
|
| 27 |
-
window.__done = true;
|
| 28 |
-
})();
|
| 29 |
-
</script></body></html>`;
|
| 30 |
-
|
| 31 |
-
const server = http.createServer((req, res) => {
|
| 32 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 33 |
-
if (p === "/_corridor.html") { res.writeHead(200, { "content-type": "text/html" }); res.end(TEST_HTML); return; }
|
| 34 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7);
|
| 35 |
-
const file = path.join(ROOT, p);
|
| 36 |
-
fs.readFile(file, (e, d) => { if (e) { res.writeHead(404); res.end("nf"); } else { res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" }); res.end(d); } });
|
| 37 |
-
});
|
| 38 |
-
|
| 39 |
-
(async () => {
|
| 40 |
-
const SHOTS = path.join(ROOT, ".shots"); fs.mkdirSync(SHOTS, { recursive: true });
|
| 41 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 42 |
-
const browser = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"] });
|
| 43 |
-
const page = await browser.newPage({ viewport: { width: 1280, height: 720 } });
|
| 44 |
-
const errs = []; page.on("pageerror", (e) => errs.push(e.message.slice(0, 200)));
|
| 45 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 46 |
-
await page.goto(`http://localhost:${PORT}/_corridor.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto:" + e.message));
|
| 47 |
-
// capture across the fly-through (scenes stream every 1.8s; camera advances)
|
| 48 |
-
const caps = [2500, 6500, 10500, 14500, 18500];
|
| 49 |
-
let prev = 0;
|
| 50 |
-
for (let i = 0; i < caps.length; i++) {
|
| 51 |
-
await page.waitForTimeout(caps[i] - prev); prev = caps[i];
|
| 52 |
-
await page.screenshot({ path: path.join(SHOTS, `corridor-${i}.png`) });
|
| 53 |
-
}
|
| 54 |
-
const st = await page.evaluate(() => ({ ready: window.LL.corridor.ready, count: window.LL.corridor.count, added: window.__added }));
|
| 55 |
-
console.log("CORRIDOR:", JSON.stringify(st), "ERRS:", JSON.stringify(errs.slice(0, 8)));
|
| 56 |
-
await browser.close(); server.close();
|
| 57 |
-
})().catch((e) => { console.error("ERR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-immersive.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
// Validate the new immersive frontend: the intro (hero mic), then a stubbed
|
| 2 |
-
// streamWorld feeding the 4 real generated scenes into the corridor while the HUD
|
| 3 |
-
// orchestra lights up. Usage: node scripts/shoot-immersive.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const ROOT = process.cwd();
|
| 9 |
-
const PORT = 8806;
|
| 10 |
-
const CT = { ".html": "text/html", ".js": "application/javascript", ".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png", ".svg": "image/svg+xml" };
|
| 11 |
-
|
| 12 |
-
const server = http.createServer((req, res) => {
|
| 13 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 14 |
-
if (p === "/") p = "/frontend/index.html";
|
| 15 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7);
|
| 16 |
-
const file = path.join(ROOT, p);
|
| 17 |
-
fs.readFile(file, (e, d) => { if (e) { res.writeHead(404); res.end("nf"); } else { res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" }); res.end(d); } });
|
| 18 |
-
});
|
| 19 |
-
|
| 20 |
-
(async () => {
|
| 21 |
-
const SHOTS = path.join(ROOT, ".shots"); fs.mkdirSync(SHOTS, { recursive: true });
|
| 22 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 23 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 24 |
-
const browser = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"] });
|
| 25 |
-
const page = await browser.newPage({ viewport: { width: 1680, height: 900 } });
|
| 26 |
-
const errs = []; page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 27 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 28 |
-
|
| 29 |
-
await page.goto(`http://localhost:${PORT}/frontend/index.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto:" + e.message));
|
| 30 |
-
await page.waitForTimeout(1400);
|
| 31 |
-
await page.screenshot({ path: shot("imm-intro.png") });
|
| 32 |
-
|
| 33 |
-
// Stub streamWorld to feed the 4 real scenes, then start a world.
|
| 34 |
-
const started = await page.evaluate(async () => {
|
| 35 |
-
const LL = window.LL;
|
| 36 |
-
if (!LL || !LL.controller) return { ok: false, why: "no controller" };
|
| 37 |
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
| 38 |
-
const captions = ["A lighthouse keeper watched the waves at the edge of the world.", "Far away, a market woke under orange awnings.", "A child ran through a garden of impossible glowing flowers.", "Then snow buried the quiet road in silence."];
|
| 39 |
-
LL.api.streamScroll = async (text, lang, onEvent) => {
|
| 40 |
-
onEvent({ stage: "warming", sections: 4 });
|
| 41 |
-
await sleep(120);
|
| 42 |
-
for (let i = 0; i < 4; i++) {
|
| 43 |
-
onEvent({ stage: "directing", index: i, text: captions[i] });
|
| 44 |
-
await sleep(120);
|
| 45 |
-
onEvent({ stage: "painting", index: i });
|
| 46 |
-
await sleep(120);
|
| 47 |
-
onEvent({ stage: "section", index: i, image: "/shots/world/w-" + i + ".webp", caption: captions[i], w: 1024 });
|
| 48 |
-
onEvent({ stage: "depth", index: i, depth: "/shots/world/w-" + i + "-depth.png" });
|
| 49 |
-
await sleep(2600);
|
| 50 |
-
}
|
| 51 |
-
onEvent({ stage: "done", session: "imm", count: 4 });
|
| 52 |
-
return { session: "imm", done: true, cancelled: false };
|
| 53 |
-
};
|
| 54 |
-
LL.controller.startWorld("An old lighthouse keeper counted the waves...");
|
| 55 |
-
return { ok: true };
|
| 56 |
-
}).catch((e) => ({ ok: false, why: String(e).slice(0, 160) }));
|
| 57 |
-
|
| 58 |
-
await page.waitForTimeout(700);
|
| 59 |
-
await page.evaluate(() => window.dispatchEvent(new Event("resize")));
|
| 60 |
-
const caps = [1800, 4600, 7600, 10600];
|
| 61 |
-
let prev = 0;
|
| 62 |
-
for (let i = 0; i < caps.length; i++) { await page.waitForTimeout(caps[i] - prev); prev = caps[i]; await page.screenshot({ path: shot("imm-world-" + i + ".png") }); }
|
| 63 |
-
|
| 64 |
-
const st = await page.evaluate(() => ({ corridorReady: window.LL.corridor && window.LL.corridor.ready, count: window.LL.corridor && window.LL.corridor.count, inWorld: document.body.classList.contains("in-world") }));
|
| 65 |
-
console.log("STARTED:", JSON.stringify(started), "STATE:", JSON.stringify(st));
|
| 66 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 10)));
|
| 67 |
-
await browser.close(); server.close();
|
| 68 |
-
})().catch((e) => { console.error("ERR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-intro-local.cjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
// LOCAL intro/ambient check (no backend, no GPU): serves nothing itself — point it
|
| 2 |
-
// at a static server rooted at the repo (python -m http.server). Verifies the cleaned
|
| 3 |
-
// intro overlay + that the ambient world FLOWS behind it (the void-fix gap-filler) and
|
| 4 |
-
// that the JS modules load with no errors. The live mic/GPU path is NOT exercised here
|
| 5 |
-
// (that needs the Space); this is purely the visual regression for intro + flow.
|
| 6 |
-
// Usage: BASE=http://127.0.0.1:8842 node scripts/shoot-intro-local.cjs
|
| 7 |
-
const { chromium } = require("playwright");
|
| 8 |
-
const path = require("path");
|
| 9 |
-
const fs = require("fs");
|
| 10 |
-
|
| 11 |
-
const BASE = process.env.BASE || "http://127.0.0.1:8842";
|
| 12 |
-
|
| 13 |
-
(async () => {
|
| 14 |
-
const SHOTS = path.join(process.cwd(), ".shots");
|
| 15 |
-
fs.mkdirSync(SHOTS, { recursive: true });
|
| 16 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 17 |
-
const browser = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"] });
|
| 18 |
-
const ctx = await browser.newContext({ viewport: { width: 1680, height: 900 } });
|
| 19 |
-
const page = await ctx.newPage();
|
| 20 |
-
const errs = [];
|
| 21 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 22 |
-
page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 23 |
-
|
| 24 |
-
await page.goto(BASE + "/frontend/index.html", { waitUntil: "networkidle", timeout: 30000 }).catch((e) => errs.push("goto:" + e.message));
|
| 25 |
-
await page.waitForTimeout(2500); // let the ambient prime the strip
|
| 26 |
-
await page.screenshot({ path: shot("intro-clean-1.png") });
|
| 27 |
-
|
| 28 |
-
// sample the scroll state to prove the world is FLOWING + the gap-filler is feeding it
|
| 29 |
-
const s1 = await page.evaluate(() => {
|
| 30 |
-
const c = window.LL && window.LL.controller;
|
| 31 |
-
const sc = window.LL && window.LL.scroll;
|
| 32 |
-
return {
|
| 33 |
-
hasController: !!c, hasScroll: !!(sc && sc.ready),
|
| 34 |
-
pendingAhead: sc ? Math.round(sc.pendingAhead) : null,
|
| 35 |
-
introVisible: !document.getElementById("intro").classList.contains("is-gone"),
|
| 36 |
-
titleGone: !document.querySelector(".intro__title"),
|
| 37 |
-
};
|
| 38 |
-
}).catch((e) => ({ err: String(e).slice(0, 160) }));
|
| 39 |
-
|
| 40 |
-
const d1 = await page.evaluate(() => window.LL.scroll.debug).catch(() => ({}));
|
| 41 |
-
await page.waitForTimeout(4500); // let it scroll ~0.5s*9 -> content should advance
|
| 42 |
-
await page.screenshot({ path: shot("intro-clean-2.png") });
|
| 43 |
-
const s2 = await page.evaluate(() => {
|
| 44 |
-
const sc = window.LL && window.LL.scroll;
|
| 45 |
-
return { pendingAhead: sc ? Math.round(sc.pendingAhead) : null };
|
| 46 |
-
}).catch(() => ({}));
|
| 47 |
-
const d2 = await page.evaluate(() => window.LL.scroll.debug).catch(() => ({}));
|
| 48 |
-
// sample the strip canvas at the window centre: fill (~11,13,18) => not painted there;
|
| 49 |
-
// colourful => canvas painted but the texture isn't reaching the shader.
|
| 50 |
-
const px2 = await page.evaluate(() => {
|
| 51 |
-
const sc = window.LL.scroll, d = sc.debug;
|
| 52 |
-
return { center: sc.pixelAt(d.scrollX + d.viewPx / 2), left: sc.pixelAt(d.scrollX + 20), right: sc.pixelAt(d.scrollX + d.viewPx - 20) };
|
| 53 |
-
}).catch((e) => ({ err: String(e).slice(0, 120) }));
|
| 54 |
-
|
| 55 |
-
console.log("STATE1", JSON.stringify(s1));
|
| 56 |
-
console.log("DEBUG1", JSON.stringify(d1));
|
| 57 |
-
console.log("STATE2", JSON.stringify(s2));
|
| 58 |
-
console.log("DEBUG2", JSON.stringify(d2));
|
| 59 |
-
console.log("PIXELS2", JSON.stringify(px2));
|
| 60 |
-
const scan = await page.evaluate(() => {
|
| 61 |
-
const sc = window.LL.scroll;
|
| 62 |
-
const xs = [100, 400, 700, 760, 820, 900, 1100, 1400, 1800, 2400, 2500];
|
| 63 |
-
return xs.map((x) => [x, sc.pixelAt(x)]);
|
| 64 |
-
}).catch((e) => ({ err: String(e).slice(0, 120) }));
|
| 65 |
-
console.log("SCAN", JSON.stringify(scan));
|
| 66 |
-
console.log("JS_ERRORS", JSON.stringify(errs));
|
| 67 |
-
await browser.close();
|
| 68 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-live-phrases.cjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 1 |
-
// Phase A — backend per-phrase continuity for the LIVE narration endpoint.
|
| 2 |
-
// Opens the real (private) Space in a browser, then uses the SAME @gradio/client the
|
| 3 |
-
// app uses to submit /scroll_live three times with DIFFERENT text phrases but ONE
|
| 4 |
-
// session. Asserts the section indices grow monotonically across the three calls —
|
| 5 |
-
// i.e. the server kept the panorama context (_LIVE_SESS) across separate GPU calls,
|
| 6 |
-
// so each spoken phrase CONTINUES the world instead of restarting it.
|
| 7 |
-
// Usage: PANO_TOKEN=hf_xxx node scripts/shoot-live-phrases.cjs
|
| 8 |
-
const { chromium } = require("playwright");
|
| 9 |
-
|
| 10 |
-
const SPACE = process.env.SPACE_URL || "https://efradeca-lightloom-dev.hf.space";
|
| 11 |
-
const TOKEN = process.env.PANO_TOKEN || "";
|
| 12 |
-
|
| 13 |
-
(async () => {
|
| 14 |
-
if (!TOKEN) { console.error("PANO_TOKEN env required"); process.exit(2); }
|
| 15 |
-
const browser = await chromium.launch();
|
| 16 |
-
const ctx = await browser.newContext();
|
| 17 |
-
await ctx.route("**/*", (route) => {
|
| 18 |
-
const url = route.request().url();
|
| 19 |
-
if (url.startsWith(SPACE)) {
|
| 20 |
-
return route.continue({ headers: { ...route.request().headers(), authorization: "Bearer " + TOKEN } });
|
| 21 |
-
}
|
| 22 |
-
return route.continue();
|
| 23 |
-
});
|
| 24 |
-
const page = await ctx.newPage();
|
| 25 |
-
const errs = [];
|
| 26 |
-
page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 27 |
-
await page.goto(SPACE + "/", { waitUntil: "networkidle", timeout: 30000 }).catch((e) => errs.push("goto:" + e.message));
|
| 28 |
-
await page.waitForTimeout(1500);
|
| 29 |
-
|
| 30 |
-
const phrases = [
|
| 31 |
-
"A glowing forest came alive with drifting fireflies.",
|
| 32 |
-
"A crystal river wound between the ancient trees.",
|
| 33 |
-
"A village of lantern-lit treehouses appeared in the canopy.",
|
| 34 |
-
];
|
| 35 |
-
|
| 36 |
-
const result = await page.evaluate(async ({ phrases }) => {
|
| 37 |
-
const session = "feed0001";
|
| 38 |
-
const client = await window.LL.api.connect();
|
| 39 |
-
const out = [];
|
| 40 |
-
for (const text of phrases) {
|
| 41 |
-
const ev = { phrase: text, transcript: null, scene: null, sections: [], depths: [], stages: [], error: null };
|
| 42 |
-
try {
|
| 43 |
-
const job = client.submit("/scroll_live", { session, text, audio_b64: "", lang: "en" });
|
| 44 |
-
for await (const msg of job) {
|
| 45 |
-
if (!msg || msg.type !== "data") continue;
|
| 46 |
-
const d = Array.isArray(msg.data) ? msg.data[0] : msg.data;
|
| 47 |
-
if (!d || typeof d !== "object") continue;
|
| 48 |
-
ev.stages.push(d.stage);
|
| 49 |
-
if (d.stage === "transcript") ev.transcript = d.text;
|
| 50 |
-
if (d.stage === "painting") ev.scene = d.scene;
|
| 51 |
-
if (d.stage === "section") ev.sections.push(d.index);
|
| 52 |
-
if (d.stage === "depth") ev.depths.push(d.index);
|
| 53 |
-
if (d.stage === "error" || d.stage === "quota_exceeded") ev.error = d.error || d.stage;
|
| 54 |
-
}
|
| 55 |
-
} catch (e) { ev.error = String(e).slice(0, 160); }
|
| 56 |
-
out.push(ev);
|
| 57 |
-
}
|
| 58 |
-
return out;
|
| 59 |
-
}, { phrases }).catch((e) => ({ err: String(e).slice(0, 200) }));
|
| 60 |
-
|
| 61 |
-
console.log("RESULT", JSON.stringify(result, null, 2));
|
| 62 |
-
console.log("JS_ERRORS", JSON.stringify(errs));
|
| 63 |
-
|
| 64 |
-
// continuity assertion
|
| 65 |
-
if (Array.isArray(result)) {
|
| 66 |
-
const allSections = result.flatMap((r) => r.sections);
|
| 67 |
-
const monotonic = allSections.every((v, i) => i === 0 || v === allSections[i - 1] + 1);
|
| 68 |
-
const contiguousStart = allSections.length > 0 && allSections[0] === 0;
|
| 69 |
-
console.log("CONTINUITY", JSON.stringify({ allSections, monotonic, contiguousStart, count: allSections.length }));
|
| 70 |
-
}
|
| 71 |
-
await browser.close();
|
| 72 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-live.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
// Live end-to-end: drive the REAL deployed (private) Space — the immersive
|
| 2 |
-
// corridor — in a real browser via @gradio/client. Loads with an HF Bearer header
|
| 3 |
-
// (Space-origin only, so the @gradio/client CDN isn't CORS-poisoned), starts a
|
| 4 |
-
// world (text), waits for scenes to stream into the corridor, and screenshots it.
|
| 5 |
-
// Usage: PANO_TOKEN=hf_xxx [MODE=world|showcase] node scripts/shoot-live.cjs
|
| 6 |
-
const { chromium } = require("playwright");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const fs = require("fs");
|
| 9 |
-
|
| 10 |
-
const SPACE = process.env.SPACE_URL || "https://efradeca-lightloom-dev.hf.space";
|
| 11 |
-
const TOKEN = process.env.PANO_TOKEN || "";
|
| 12 |
-
const MODE = process.env.MODE || "world";
|
| 13 |
-
|
| 14 |
-
(async () => {
|
| 15 |
-
if (!TOKEN) { console.error("PANO_TOKEN env required"); process.exit(2); }
|
| 16 |
-
const SHOTS = path.join(process.cwd(), ".shots");
|
| 17 |
-
fs.mkdirSync(SHOTS, { recursive: true });
|
| 18 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 19 |
-
const browser = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"] });
|
| 20 |
-
const ctx = await browser.newContext({ viewport: { width: 1680, height: 900 } });
|
| 21 |
-
await ctx.route("**/*", (route) => {
|
| 22 |
-
const url = route.request().url();
|
| 23 |
-
if (url.startsWith(SPACE)) {
|
| 24 |
-
const headers = { ...route.request().headers(), authorization: "Bearer " + TOKEN };
|
| 25 |
-
return route.continue({ headers });
|
| 26 |
-
}
|
| 27 |
-
return route.continue();
|
| 28 |
-
});
|
| 29 |
-
const page = await ctx.newPage();
|
| 30 |
-
const errs = [];
|
| 31 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 32 |
-
page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 33 |
-
|
| 34 |
-
await page.goto(SPACE + "/", { waitUntil: "networkidle", timeout: 30000 }).catch((e) => errs.push("goto:" + e.message));
|
| 35 |
-
await page.waitForTimeout(1800);
|
| 36 |
-
await page.screenshot({ path: shot("live-intro.png") });
|
| 37 |
-
|
| 38 |
-
const started = await page.evaluate((mode) => {
|
| 39 |
-
const LL = window.LL;
|
| 40 |
-
if (!LL || !LL.controller) return { ok: false, why: "no controller" };
|
| 41 |
-
if (mode === "showcase") { LL.controller.playShowcase(); return { ok: true, mode }; }
|
| 42 |
-
LL.controller.startWorld("A glowing forest came alive with drifting fireflies. A crystal river wound between the ancient trees. A village of lantern-lit treehouses appeared. A great waterfall of light poured into a glowing canyon. A temple floated among luminous clouds.");
|
| 43 |
-
return { ok: true, mode };
|
| 44 |
-
}, MODE).catch((e) => ({ ok: false, why: String(e).slice(0, 160) }));
|
| 45 |
-
|
| 46 |
-
// Wait up to ~120s for the first scene (cold start loads models ~30s).
|
| 47 |
-
let scenes = 0;
|
| 48 |
-
for (let i = 0; i < 70; i++) {
|
| 49 |
-
const c = await page.evaluate(() => (window.LL.scroll && window.LL.controller._count) || 0).catch(() => 0);
|
| 50 |
-
if (c > scenes) { scenes = c; }
|
| 51 |
-
if (scenes >= 1 && i > 4) {
|
| 52 |
-
await page.screenshot({ path: shot("live-world-" + Math.min(scenes, 4) + ".png") });
|
| 53 |
-
}
|
| 54 |
-
if (scenes >= 3) break;
|
| 55 |
-
await page.waitForTimeout(2500);
|
| 56 |
-
}
|
| 57 |
-
await page.waitForTimeout(2500);
|
| 58 |
-
await page.screenshot({ path: shot("live-world-final.png") });
|
| 59 |
-
|
| 60 |
-
const final = await page.evaluate(() => ({ count: window.LL.scroll && window.LL.controller._count, inWorld: document.body.classList.contains("in-world") }));
|
| 61 |
-
console.log("STARTED:", JSON.stringify(started), "SCENES_SEEN:", scenes);
|
| 62 |
-
console.log("FINAL:", JSON.stringify(final));
|
| 63 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 12)));
|
| 64 |
-
await browser.close();
|
| 65 |
-
})().catch((e) => { console.error("HARNESS ERROR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-mic-live.cjs
DELETED
|
@@ -1,115 +0,0 @@
|
|
| 1 |
-
// Phase B — the REAL live-narration experience, end to end. Chromium is fed a TTS
|
| 2 |
-
// narration WAV as a fake microphone; we tap the mic and let it "speak". This exercises
|
| 3 |
-
// the whole stack: Web-Audio VAD phrase-cutting -> /scroll_live (Whisper + Director +
|
| 4 |
-
// klein paint) -> sections appended to the SAME continuous scroll, building as you talk.
|
| 5 |
-
// Asserts: phrases get transcribed, sections keep appending (continuity), the world
|
| 6 |
-
// FILLS + FLOWS (debug pixel scan), and there are no JS errors.
|
| 7 |
-
// Usage: PANO_TOKEN=hf_xxx WAV=.shots\narration.wav node scripts/shoot-mic-live.cjs
|
| 8 |
-
const { chromium } = require("playwright");
|
| 9 |
-
const path = require("path");
|
| 10 |
-
const fs = require("fs");
|
| 11 |
-
|
| 12 |
-
const SPACE = process.env.SPACE_URL || "https://efradeca-lightloom-dev.hf.space";
|
| 13 |
-
const TOKEN = process.env.PANO_TOKEN || "";
|
| 14 |
-
const WAV = path.resolve(process.env.WAV || ".shots/narration.wav");
|
| 15 |
-
|
| 16 |
-
(async () => {
|
| 17 |
-
if (!TOKEN) { console.error("PANO_TOKEN env required"); process.exit(2); }
|
| 18 |
-
if (!fs.existsSync(WAV)) { console.error("WAV not found: " + WAV); process.exit(2); }
|
| 19 |
-
const SHOTS = path.join(process.cwd(), ".shots");
|
| 20 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 21 |
-
const browser = await chromium.launch({
|
| 22 |
-
args: [
|
| 23 |
-
"--use-fake-device-for-media-stream",
|
| 24 |
-
"--use-file-for-fake-audio-capture=" + WAV, // looped by default -> sustained narration
|
| 25 |
-
"--use-fake-ui-for-media-stream",
|
| 26 |
-
"--autoplay-policy=no-user-gesture-required",
|
| 27 |
-
"--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl",
|
| 28 |
-
],
|
| 29 |
-
});
|
| 30 |
-
const ctx = await browser.newContext({ viewport: { width: 1680, height: 900 }, permissions: ["microphone"] });
|
| 31 |
-
await ctx.grantPermissions(["microphone"], { origin: SPACE });
|
| 32 |
-
await ctx.route("**/*", (route) => {
|
| 33 |
-
const url = route.request().url();
|
| 34 |
-
if (url.startsWith(SPACE)) return route.continue({ headers: { ...route.request().headers(), authorization: "Bearer " + TOKEN } });
|
| 35 |
-
return route.continue();
|
| 36 |
-
});
|
| 37 |
-
const page = await ctx.newPage();
|
| 38 |
-
const errs = [];
|
| 39 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 40 |
-
page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 41 |
-
|
| 42 |
-
await page.goto(SPACE + "/", { waitUntil: "networkidle", timeout: 30000 }).catch((e) => errs.push("goto:" + e.message));
|
| 43 |
-
await page.waitForTimeout(1500);
|
| 44 |
-
|
| 45 |
-
// instrument the live event stream so we can see transcripts + sections as they arrive
|
| 46 |
-
await page.evaluate(() => {
|
| 47 |
-
window.__ev = [];
|
| 48 |
-
const c = window.LL.controller;
|
| 49 |
-
const orig = c._onEvent.bind(c);
|
| 50 |
-
c._onEvent = (ev) => { try { window.__ev.push({ s: ev.stage, i: ev.index, t: ev.text, sc: ev.scene, img: ev.image, session: ev.session, at: performance.now() }); } catch (_) {} return orig(ev); };
|
| 51 |
-
});
|
| 52 |
-
|
| 53 |
-
// tap the mic — start live narration
|
| 54 |
-
await page.click("#mic-btn").catch((e) => errs.push("click:" + e.message));
|
| 55 |
-
await page.evaluate(() => { window.__t0 = performance.now(); });
|
| 56 |
-
|
| 57 |
-
let lastCount = 0;
|
| 58 |
-
for (let i = 0; i < 60; i++) { // ~120s: cold warm (~30s) + the whole 39s audio + paints
|
| 59 |
-
await page.waitForTimeout(2000);
|
| 60 |
-
const st = await page.evaluate(() => {
|
| 61 |
-
const c = window.LL.controller, sc = window.LL.scroll;
|
| 62 |
-
const evs = window.__ev || [];
|
| 63 |
-
return {
|
| 64 |
-
count: c._count || 0,
|
| 65 |
-
transcripts: evs.filter((e) => e.s === "transcript").map((e) => e.t),
|
| 66 |
-
sections: evs.filter((e) => e.s === "section").map((e) => e.i),
|
| 67 |
-
pendingAhead: sc ? Math.round(sc.pendingAhead) : null,
|
| 68 |
-
dbg: sc ? sc.debug : null,
|
| 69 |
-
};
|
| 70 |
-
}).catch(() => ({}));
|
| 71 |
-
if ((st.count || 0) > lastCount) {
|
| 72 |
-
lastCount = st.count;
|
| 73 |
-
await page.screenshot({ path: shot("mic-live-" + Math.min(lastCount, 9) + ".png") });
|
| 74 |
-
}
|
| 75 |
-
if (i % 4 === 0) console.log("t=" + (i * 2 + 1) + "s", JSON.stringify({ count: st.count, sections: (st.sections||[]).length, pendingAhead: st.pendingAhead }));
|
| 76 |
-
if (lastCount >= (parseInt(process.env.TARGET || "15", 10))) break;
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
// stop narration
|
| 80 |
-
await page.click("#mic-btn").catch(() => {});
|
| 81 |
-
await page.waitForTimeout(1500);
|
| 82 |
-
await page.screenshot({ path: shot("mic-live-final.png") });
|
| 83 |
-
|
| 84 |
-
// final canvas paint check at the window centre (fill ~[11,13,18] => void; colourful => painted)
|
| 85 |
-
const probe = await page.evaluate(() => {
|
| 86 |
-
const sc = window.LL.scroll, d = sc.debug;
|
| 87 |
-
const xs = [d.scrollX + 40, d.scrollX + d.viewPx / 2, d.scrollX + d.viewPx - 40];
|
| 88 |
-
return { dbg: d, px: xs.map((x) => [Math.round(x), sc.pixelAt(x)]) };
|
| 89 |
-
}).catch((e) => ({ err: String(e).slice(0, 160) }));
|
| 90 |
-
|
| 91 |
-
const evs = await page.evaluate(() => window.__ev || []);
|
| 92 |
-
const transcripts = evs.filter((e) => e.s === "transcript").map((e) => e.t);
|
| 93 |
-
const sections = evs.filter((e) => e.s === "section").map((e) => e.i);
|
| 94 |
-
const session = (evs.find((e) => e.session) || {}).session || null;
|
| 95 |
-
const images = evs.filter((e) => e.s === "section" && e.img).map((e) => e.img);
|
| 96 |
-
console.log("TRANSCRIPTS", JSON.stringify(transcripts));
|
| 97 |
-
console.log("SECTIONS", JSON.stringify(sections));
|
| 98 |
-
console.log("SESSION", JSON.stringify(session));
|
| 99 |
-
console.log("IMAGES", JSON.stringify(images));
|
| 100 |
-
// timing: warm (tap -> first section) and the cadence between sections + transcripts
|
| 101 |
-
const timing = await page.evaluate(() => {
|
| 102 |
-
const t0 = window.__t0 || 0, evs = window.__ev || [];
|
| 103 |
-
const secs = evs.filter((e) => e.s === "section");
|
| 104 |
-
const trs = evs.filter((e) => e.s === "transcript");
|
| 105 |
-
const firstSec = secs.length ? Math.round(secs[0].at - t0) : null;
|
| 106 |
-
const firstTr = trs.length ? Math.round(trs[0].at - t0) : null;
|
| 107 |
-
const deltas = secs.slice(1).map((e, i) => Math.round(e.at - secs[i].at));
|
| 108 |
-
const avg = deltas.length ? Math.round(deltas.reduce((a, b) => a + b, 0) / deltas.length) : null;
|
| 109 |
-
return { firstTranscript_ms: firstTr, firstSection_ms: firstSec, sectionCount: secs.length, avgSectionGap_ms: avg, gaps: deltas };
|
| 110 |
-
}).catch(() => ({}));
|
| 111 |
-
console.log("TIMING", JSON.stringify(timing));
|
| 112 |
-
console.log("PAINT_PROBE", JSON.stringify(probe));
|
| 113 |
-
console.log("JS_ERRORS", JSON.stringify(errs));
|
| 114 |
-
await browser.close();
|
| 115 |
-
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-motion.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
// Prove the cinematic motion: load ONE scene and capture it at two moments ~4s
|
| 2 |
-
// apart so the lateral ken-burns glide + depth parallax + forward zoom are visible
|
| 3 |
-
// as a real difference. Usage: node scripts/shoot-motion.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const ROOT = process.cwd();
|
| 9 |
-
const PORT = 8807;
|
| 10 |
-
const CT = { ".html": "text/html", ".js": "application/javascript", ".webp": "image/webp", ".png": "image/png" };
|
| 11 |
-
const HTML = `<!doctype html><html><head>
|
| 12 |
-
<script type="importmap">{"imports":{"three":"/frontend/vendor/three.module.js"}}</script>
|
| 13 |
-
<style>html,body{margin:0;background:#07080c;overflow:hidden}#c{width:100vw;height:100vh;display:block}</style>
|
| 14 |
-
</head><body><canvas id="c"></canvas><script type="module">
|
| 15 |
-
import "/frontend/js/stage-corridor.js";
|
| 16 |
-
const SC=window.LL.corridor; SC.init(document.getElementById('c'));
|
| 17 |
-
SC.addScene({imageUrl:'/shots/world/w-1.webp', depthUrl:'/shots/world/w-1-depth.png'});
|
| 18 |
-
</script></body></html>`;
|
| 19 |
-
const server = http.createServer((req, res) => {
|
| 20 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 21 |
-
if (p === "/_m.html") { res.writeHead(200, { "content-type": "text/html" }); res.end(HTML); return; }
|
| 22 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7);
|
| 23 |
-
fs.readFile(path.join(ROOT, p), (e, d) => { if (e) { res.writeHead(404); res.end("x"); } else { res.writeHead(200, { "content-type": CT[path.extname(p)] || "application/octet-stream" }); res.end(d); } });
|
| 24 |
-
});
|
| 25 |
-
(async () => {
|
| 26 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 27 |
-
const b = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist"] });
|
| 28 |
-
const pg = await b.newPage({ viewport: { width: 1280, height: 720 } });
|
| 29 |
-
await pg.goto(`http://localhost:${PORT}/_m.html`, { waitUntil: "networkidle" }).catch(() => {});
|
| 30 |
-
await pg.waitForTimeout(900);
|
| 31 |
-
await pg.screenshot({ path: path.join(ROOT, ".shots", "motion-a.png") });
|
| 32 |
-
await pg.waitForTimeout(4200);
|
| 33 |
-
await pg.screenshot({ path: path.join(ROOT, ".shots", "motion-b.png") });
|
| 34 |
-
console.log("motion frames captured");
|
| 35 |
-
await b.close(); server.close();
|
| 36 |
-
})().catch((e) => { console.error(e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-pano.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
// Visual test for the immersive panorama renderer (stage-pano.js): drive LL.pano
|
| 2 |
-
// with a synthetic equirectangular panorama + depth and screenshot the sphere view.
|
| 3 |
-
const { chromium } = require("playwright");
|
| 4 |
-
const http = require("http");
|
| 5 |
-
const fs = require("fs");
|
| 6 |
-
const path = require("path");
|
| 7 |
-
const ROOT = process.cwd();
|
| 8 |
-
const PORT = 8801;
|
| 9 |
-
const CT = { ".html": "text/html", ".js": "application/javascript", ".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png" };
|
| 10 |
-
|
| 11 |
-
const TEST_HTML = `<!doctype html><html><head>
|
| 12 |
-
<script type="importmap">{"imports":{"three":"/frontend/vendor/three.module.js"}}</script>
|
| 13 |
-
<style>html,body{margin:0;background:#0a0a0c}#c{width:1280px;height:536px;display:block;margin:24px auto}</style>
|
| 14 |
-
</head><body><canvas id="c"></canvas>
|
| 15 |
-
<script type="module">
|
| 16 |
-
import "/frontend/js/stage-pano.js";
|
| 17 |
-
function eq(){const c=document.createElement('canvas');c.width=1024;c.height=512;const g=c.getContext('2d');
|
| 18 |
-
const sky=g.createLinearGradient(0,0,0,256);sky.addColorStop(0,'#13233a');sky.addColorStop(1,'#f0a83d');g.fillStyle=sky;g.fillRect(0,0,1024,256);
|
| 19 |
-
g.fillStyle='#23301f';g.fillRect(0,256,1024,256);
|
| 20 |
-
g.fillStyle='#fff6e6';g.beginPath();g.arc(512,200,46,0,7);g.fill();
|
| 21 |
-
g.fillStyle='#0c0c10';for(let i=0;i<7;i++){g.beginPath();g.moveTo(i*170,256);g.lineTo(i*170+90,150);g.lineTo(i*170+180,256);g.closePath();g.fill();}
|
| 22 |
-
g.fillStyle='#0a0a0c';g.fillRect(760,150,46,150);
|
| 23 |
-
return c.toDataURL('image/png');}
|
| 24 |
-
function dep(){const c=document.createElement('canvas');c.width=1024;c.height=512;const g=c.getContext('2d');
|
| 25 |
-
const d=g.createLinearGradient(0,0,0,512);d.addColorStop(0,'#0d0d0d');d.addColorStop(0.5,'#777');d.addColorStop(1,'#e8e8e8');g.fillStyle=d;g.fillRect(0,0,1024,512);
|
| 26 |
-
g.fillStyle='#ffffff';g.fillRect(760,150,46,150);
|
| 27 |
-
return c.toDataURL('image/png');}
|
| 28 |
-
(async()=>{ try{ const cv=document.getElementById('c'); window.LL.pano.init(cv);
|
| 29 |
-
await window.LL.pano.show({panoramaUrl: window.__panoUrl||eq(), depthUrl: window.__depthUrl||dep()}); window.__ok=true; }
|
| 30 |
-
catch(e){ window.__err=String(e&&e.message||e); } })();
|
| 31 |
-
</script></body></html>`;
|
| 32 |
-
|
| 33 |
-
const server = http.createServer((req, res) => {
|
| 34 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 35 |
-
if (p === "/_panotest.html") { res.writeHead(200, { "content-type": "text/html" }); res.end(TEST_HTML); return; }
|
| 36 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7); // serve the downloaded real panorama
|
| 37 |
-
const file = path.join(ROOT, p);
|
| 38 |
-
fs.readFile(file, (e, d) => { if (e) { res.writeHead(404); res.end("nf"); } else { res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" }); res.end(d); } });
|
| 39 |
-
});
|
| 40 |
-
|
| 41 |
-
(async () => {
|
| 42 |
-
const SHOTS = path.join(ROOT, ".shots"); fs.mkdirSync(SHOTS, { recursive: true });
|
| 43 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 44 |
-
const browser = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist"] });
|
| 45 |
-
const page = await browser.newPage({ viewport: { width: 1340, height: 620 } });
|
| 46 |
-
if (process.env.REAL) await page.addInitScript(() => { window.__panoUrl = "/shots/real-pano.webp"; window.__depthUrl = "/shots/real-depth.png"; });
|
| 47 |
-
const errs = []; page.on("pageerror", (e) => errs.push(e.message.slice(0, 200)));
|
| 48 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 49 |
-
await page.goto(`http://localhost:${PORT}/_panotest.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto:" + e.message));
|
| 50 |
-
await page.waitForFunction(() => window.__ok || window.__err, { timeout: 12000 }).catch(() => {});
|
| 51 |
-
await page.waitForTimeout(1500);
|
| 52 |
-
await page.screenshot({ path: path.join(SHOTS, "pano-1.png") });
|
| 53 |
-
await page.waitForTimeout(2500); // let the camera drift to a new angle
|
| 54 |
-
await page.screenshot({ path: path.join(SHOTS, "pano-2.png") });
|
| 55 |
-
const st = await page.evaluate(() => ({ ok: window.__ok, err: window.__err, ready: window.LL && window.LL.pano && window.LL.pano.ready }));
|
| 56 |
-
console.log("PANO:", JSON.stringify(st), "ERRS:", JSON.stringify(errs.slice(0, 8)));
|
| 57 |
-
await browser.close(); server.close();
|
| 58 |
-
})().catch((e) => { console.error("ERR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-scroll.cjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
// Validate the scrolling depth-parallax renderer (stage-scroll.js): feed the test
|
| 2 |
-
// strip + its depth and capture frames as the window scrolls left, to confirm the
|
| 3 |
-
// continuous flow + 2.5D parallax. Usage: node scripts/shoot-scroll.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const ROOT = process.cwd();
|
| 9 |
-
const PORT = 8808;
|
| 10 |
-
const CT = { ".html": "text/html", ".js": "application/javascript", ".webp": "image/webp", ".png": "image/png" };
|
| 11 |
-
const HTML = `<!doctype html><html><head>
|
| 12 |
-
<script type="importmap">{"imports":{"three":"/frontend/vendor/three.module.js"}}</script>
|
| 13 |
-
<style>html,body{margin:0;background:#07080c;overflow:hidden}#c{width:100vw;height:100vh;display:block}</style>
|
| 14 |
-
</head><body><canvas id="c"></canvas><script type="module">
|
| 15 |
-
import "/frontend/js/stage-scroll.js";
|
| 16 |
-
const S=window.LL.scroll; S.init(document.getElementById('c'));
|
| 17 |
-
// feed the strip as a few sections so we also exercise multi-section compositing
|
| 18 |
-
(async()=>{
|
| 19 |
-
// split the wide strip into 3 overlapping sections by using the same urls (the
|
| 20 |
-
// renderer scales each to strip height); for a true test we just add the whole strip.
|
| 21 |
-
await S.addSection({imageUrl:'/shots/scroll-strip.webp', depthUrl:'/shots/scroll-strip-depth.png'});
|
| 22 |
-
})();
|
| 23 |
-
</script></body></html>`;
|
| 24 |
-
const server = http.createServer((req, res) => {
|
| 25 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 26 |
-
if (p === "/_s.html") { res.writeHead(200, { "content-type": "text/html" }); res.end(HTML); return; }
|
| 27 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7);
|
| 28 |
-
fs.readFile(path.join(ROOT, p), (e, d) => { if (e) { res.writeHead(404); res.end("x"); } else { res.writeHead(200, { "content-type": CT[path.extname(p)] || "application/octet-stream" }); res.end(d); } });
|
| 29 |
-
});
|
| 30 |
-
(async () => {
|
| 31 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 32 |
-
const b = await chromium.launch({ args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist"] });
|
| 33 |
-
const pg = await b.newPage({ viewport: { width: 1280, height: 540 } });
|
| 34 |
-
const errs = []; pg.on("pageerror", (e) => errs.push(e.message.slice(0, 200)));
|
| 35 |
-
pg.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 160)); });
|
| 36 |
-
await pg.goto(`http://localhost:${PORT}/_s.html`, { waitUntil: "networkidle" }).catch((e) => errs.push("goto:" + e.message));
|
| 37 |
-
await pg.waitForTimeout(800);
|
| 38 |
-
for (const [i, ms] of [[0, 600], [1, 3000], [2, 3000], [3, 3000]]) {
|
| 39 |
-
await pg.waitForTimeout(ms);
|
| 40 |
-
await pg.screenshot({ path: path.join(ROOT, ".shots", "scroll-" + i + ".png") });
|
| 41 |
-
}
|
| 42 |
-
const st = await pg.evaluate(() => ({ ready: window.LL.scroll.ready }));
|
| 43 |
-
console.log("SCROLL:", JSON.stringify(st), "ERRS:", JSON.stringify(errs.slice(0, 6)));
|
| 44 |
-
await b.close(); server.close();
|
| 45 |
-
})().catch((e) => { console.error(e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-showcase.cjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 1 |
-
// Validate the Showcase reel: load the real app, trigger the pre-rendered
|
| 2 |
-
// journey (btn-showcase -> controller.startShowcase), and screenshot several
|
| 3 |
-
// worlds as the reel cross-fades through them. Usage: node scripts/shoot-showcase.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
|
| 9 |
-
const ROOT = process.cwd();
|
| 10 |
-
const PORT = 8803;
|
| 11 |
-
const CT = {
|
| 12 |
-
".html": "text/html", ".js": "application/javascript", ".mjs": "application/javascript",
|
| 13 |
-
".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png",
|
| 14 |
-
".json": "application/json", ".svg": "image/svg+xml",
|
| 15 |
-
};
|
| 16 |
-
|
| 17 |
-
const server = http.createServer((req, res) => {
|
| 18 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 19 |
-
if (p === "/") p = "/frontend/index.html";
|
| 20 |
-
const file = path.join(ROOT, p);
|
| 21 |
-
fs.readFile(file, (err, data) => {
|
| 22 |
-
if (err) { res.writeHead(404); res.end("not found"); return; }
|
| 23 |
-
res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" });
|
| 24 |
-
res.end(data);
|
| 25 |
-
});
|
| 26 |
-
});
|
| 27 |
-
|
| 28 |
-
(async () => {
|
| 29 |
-
const SHOTS = path.join(ROOT, ".shots");
|
| 30 |
-
fs.mkdirSync(SHOTS, { recursive: true });
|
| 31 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 32 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 33 |
-
const browser = await chromium.launch({
|
| 34 |
-
args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"],
|
| 35 |
-
});
|
| 36 |
-
const page = await browser.newPage({ viewport: { width: 1680, height: 820 } });
|
| 37 |
-
const errs = [];
|
| 38 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 39 |
-
page.on("pageerror", (e) => errs.push("PAGEERROR: " + e.message.slice(0, 200)));
|
| 40 |
-
|
| 41 |
-
await page.goto(`http://localhost:${PORT}/frontend/index.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto:" + e.message));
|
| 42 |
-
await page.waitForTimeout(1200);
|
| 43 |
-
|
| 44 |
-
const started = await page.evaluate(() => {
|
| 45 |
-
const b = document.getElementById("btn-showcase");
|
| 46 |
-
if (b) { b.click(); return { ok: true, clicked: true }; }
|
| 47 |
-
if (window.LL && window.LL.controller) { window.LL.controller.startShowcase(); return { ok: true, called: true }; }
|
| 48 |
-
return { ok: false };
|
| 49 |
-
}).catch((e) => ({ ok: false, why: String(e).slice(0, 160) }));
|
| 50 |
-
|
| 51 |
-
// Capture worlds across the reel (dwell ~7s/world). Resize once it's in #set.
|
| 52 |
-
await page.waitForTimeout(900);
|
| 53 |
-
await page.evaluate(() => window.dispatchEvent(new Event("resize")));
|
| 54 |
-
const caps = [2500, 9000, 17000, 25000];
|
| 55 |
-
let prev = 0;
|
| 56 |
-
for (let i = 0; i < caps.length; i++) {
|
| 57 |
-
await page.waitForTimeout(caps[i] - prev); prev = caps[i];
|
| 58 |
-
await page.screenshot({ path: shot(`sc-reel-${i}.png`) });
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
const st = await page.evaluate(() => ({
|
| 62 |
-
running: window.LL.controller.running,
|
| 63 |
-
playing: window.LL.controller._showcasePlaying,
|
| 64 |
-
activeScreen: [...document.querySelectorAll(".screen.is-active")].map((s) => s.id),
|
| 65 |
-
badge: !!document.getElementById("ll-showcase-badge"),
|
| 66 |
-
}));
|
| 67 |
-
console.log("STARTED:", JSON.stringify(started));
|
| 68 |
-
console.log("STATE:", JSON.stringify(st));
|
| 69 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 12)));
|
| 70 |
-
await browser.close();
|
| 71 |
-
server.close();
|
| 72 |
-
})().catch((e) => { console.error("HARNESS ERROR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-voice-live.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
// Live VOICE end-to-end on the deployed Space: a fake mic plays a real speech WAV
|
| 2 |
-
// into the browser recorder, which encodes a 16 kHz WAV and sends it to the real
|
| 3 |
-
// /transcribe (Cohere); the transcript starts a real /world; scenes stream into
|
| 4 |
-
// the corridor. Proves mic -> ASR -> world on the live Space.
|
| 5 |
-
// Usage: PANO_TOKEN=hf_xxx node scripts/shoot-voice-live.cjs
|
| 6 |
-
const { chromium } = require("playwright");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
const fs = require("fs");
|
| 9 |
-
|
| 10 |
-
const SPACE = process.env.SPACE_URL || "https://efradeca-lightloom-dev.hf.space";
|
| 11 |
-
const TOKEN = process.env.PANO_TOKEN || "";
|
| 12 |
-
const WAV = path.join(process.cwd(), ".shots", "test-voice.wav");
|
| 13 |
-
|
| 14 |
-
(async () => {
|
| 15 |
-
if (!TOKEN) { console.error("PANO_TOKEN required"); process.exit(2); }
|
| 16 |
-
if (!fs.existsSync(WAV)) { console.error("missing " + WAV); process.exit(2); }
|
| 17 |
-
const SHOTS = path.join(process.cwd(), ".shots");
|
| 18 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 19 |
-
const browser = await chromium.launch({
|
| 20 |
-
args: [
|
| 21 |
-
"--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl",
|
| 22 |
-
"--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream",
|
| 23 |
-
"--use-file-for-fake-audio-capture=" + WAV,
|
| 24 |
-
],
|
| 25 |
-
});
|
| 26 |
-
const ctx = await browser.newContext({ viewport: { width: 1680, height: 900 }, permissions: ["microphone"] });
|
| 27 |
-
await ctx.route("**/*", (route) => {
|
| 28 |
-
const url = route.request().url();
|
| 29 |
-
if (url.startsWith(SPACE)) return route.continue({ headers: { ...route.request().headers(), authorization: "Bearer " + TOKEN } });
|
| 30 |
-
return route.continue();
|
| 31 |
-
});
|
| 32 |
-
const page = await ctx.newPage();
|
| 33 |
-
const errs = [];
|
| 34 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 35 |
-
page.on("pageerror", (e) => errs.push("PE:" + e.message.slice(0, 200)));
|
| 36 |
-
|
| 37 |
-
await page.goto(SPACE + "/", { waitUntil: "networkidle", timeout: 30000 }).catch((e) => errs.push("goto:" + e.message));
|
| 38 |
-
await page.waitForTimeout(1500);
|
| 39 |
-
|
| 40 |
-
// Capture the transcript the recorder produces.
|
| 41 |
-
await page.evaluate(() => {
|
| 42 |
-
const c = window.LL.controller; const orig = c.startWorld.bind(c);
|
| 43 |
-
window.__story = null;
|
| 44 |
-
c.startWorld = (t) => { window.__story = t; return orig(t); };
|
| 45 |
-
});
|
| 46 |
-
|
| 47 |
-
await page.click("#mic-btn").catch((e) => errs.push("mic1:" + e.message));
|
| 48 |
-
await page.waitForTimeout(8000); // record the fake speech
|
| 49 |
-
await page.click("#mic-btn").catch((e) => errs.push("mic2:" + e.message));
|
| 50 |
-
|
| 51 |
-
// Wait for transcript -> world.
|
| 52 |
-
let scenes = 0, story = null;
|
| 53 |
-
for (let i = 0; i < 70; i++) {
|
| 54 |
-
const r = await page.evaluate(() => ({ story: window.__story, count: (window.LL.corridor && window.LL.corridor.count) || 0 })).catch(() => ({}));
|
| 55 |
-
if (r.story && !story) { story = r.story; console.log("TRANSCRIPT:", JSON.stringify(story).slice(0, 200)); }
|
| 56 |
-
if ((r.count || 0) > scenes) scenes = r.count;
|
| 57 |
-
if (scenes >= 2) break;
|
| 58 |
-
await page.waitForTimeout(2500);
|
| 59 |
-
}
|
| 60 |
-
await page.waitForTimeout(2500);
|
| 61 |
-
await page.screenshot({ path: shot("voice-live.png") });
|
| 62 |
-
console.log("STORY_SET:", !!story, "SCENES:", scenes);
|
| 63 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 10)));
|
| 64 |
-
await browser.close();
|
| 65 |
-
})().catch((e) => { console.error("ERR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot-voice.cjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
| 1 |
-
// Validate the voice wiring locally: fake mic -> LL.recorder captures + encodes a
|
| 2 |
-
// WAV -> (stubbed) LL.api.transcribe -> transcript fills the recital -> (stubbed)
|
| 3 |
-
// streamPanorama reveals the world. Proves the recorder graph + flow without the
|
| 4 |
-
// real ASR endpoint. Usage: node scripts/shoot-voice.cjs
|
| 5 |
-
const { chromium } = require("playwright");
|
| 6 |
-
const http = require("http");
|
| 7 |
-
const fs = require("fs");
|
| 8 |
-
const path = require("path");
|
| 9 |
-
|
| 10 |
-
const ROOT = process.cwd();
|
| 11 |
-
const PORT = 8804;
|
| 12 |
-
const CT = {
|
| 13 |
-
".html": "text/html", ".js": "application/javascript", ".mjs": "application/javascript",
|
| 14 |
-
".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png",
|
| 15 |
-
".json": "application/json", ".svg": "image/svg+xml",
|
| 16 |
-
};
|
| 17 |
-
|
| 18 |
-
const server = http.createServer((req, res) => {
|
| 19 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 20 |
-
if (p === "/") p = "/frontend/index.html";
|
| 21 |
-
if (p.startsWith("/shots/")) p = "/.shots/" + p.slice(7);
|
| 22 |
-
const file = path.join(ROOT, p);
|
| 23 |
-
fs.readFile(file, (err, data) => {
|
| 24 |
-
if (err) { res.writeHead(404); res.end("nf"); return; }
|
| 25 |
-
res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" });
|
| 26 |
-
res.end(data);
|
| 27 |
-
});
|
| 28 |
-
});
|
| 29 |
-
|
| 30 |
-
(async () => {
|
| 31 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 32 |
-
const browser = await chromium.launch({
|
| 33 |
-
args: [
|
| 34 |
-
"--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl",
|
| 35 |
-
"--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream",
|
| 36 |
-
],
|
| 37 |
-
});
|
| 38 |
-
const ctx = await browser.newContext({ viewport: { width: 1680, height: 820 }, permissions: ["microphone"] });
|
| 39 |
-
const page = await ctx.newPage();
|
| 40 |
-
const errs = [];
|
| 41 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 42 |
-
page.on("pageerror", (e) => errs.push("PAGEERROR: " + e.message.slice(0, 200)));
|
| 43 |
-
|
| 44 |
-
await page.goto(`http://localhost:${PORT}/frontend/index.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto:" + e.message));
|
| 45 |
-
await page.waitForTimeout(1000);
|
| 46 |
-
|
| 47 |
-
// Stub the network bits: transcribe returns a known line; panorama reveals a real world.
|
| 48 |
-
await page.evaluate(() => {
|
| 49 |
-
const LL = window.LL;
|
| 50 |
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
| 51 |
-
window.__transcribeCalled = false;
|
| 52 |
-
window.__wavBytes = 0;
|
| 53 |
-
LL.api.transcribe = async (b64) => {
|
| 54 |
-
window.__transcribeCalled = true;
|
| 55 |
-
window.__wavBytes = (b64 || "").length;
|
| 56 |
-
return { text: "An old lighthouse keeper counted the waves at the edge of the world.", error: null };
|
| 57 |
-
};
|
| 58 |
-
LL.api.streamPanorama = async (text, lang, onEvent) => {
|
| 59 |
-
window.__panoText = text;
|
| 60 |
-
onEvent({ stage: "warming" });
|
| 61 |
-
await sleep(40);
|
| 62 |
-
onEvent({ stage: "painted", panorama: "/shots/real-pano.webp" });
|
| 63 |
-
await sleep(60);
|
| 64 |
-
onEvent({ stage: "depth", depth: "/shots/real-depth.png" });
|
| 65 |
-
onEvent({ stage: "done", session: "voice" });
|
| 66 |
-
return { session: "voice", done: true, cancelled: false };
|
| 67 |
-
};
|
| 68 |
-
return { supported: LL.recorder && LL.recorder.supported };
|
| 69 |
-
});
|
| 70 |
-
|
| 71 |
-
// Click Narrate (start recording) -> wait (capture fake audio) -> click again (stop).
|
| 72 |
-
const sup = await page.evaluate(() => window.LL.recorder && window.LL.recorder.supported);
|
| 73 |
-
await page.click("#btn-narrate").catch(() => {});
|
| 74 |
-
await page.waitForTimeout(1500);
|
| 75 |
-
const recState = await page.evaluate(() => window.LL.recorder.state);
|
| 76 |
-
await page.click("#btn-narrate").catch(() => {});
|
| 77 |
-
// Wait for transcribe -> recital -> world reveal.
|
| 78 |
-
await page.waitForFunction(() => window.LL.controller && window.LL.controller._worldShown, { timeout: 8000 }).catch(() => {});
|
| 79 |
-
await page.evaluate(() => window.dispatchEvent(new Event("resize")));
|
| 80 |
-
await page.waitForTimeout(1500);
|
| 81 |
-
await page.screenshot({ path: path.join(ROOT, ".shots", "voice-world.png") });
|
| 82 |
-
|
| 83 |
-
const st = await page.evaluate(() => ({
|
| 84 |
-
supported: window.LL.recorder.supported,
|
| 85 |
-
transcribeCalled: window.__transcribeCalled,
|
| 86 |
-
wavLen: window.__wavBytes,
|
| 87 |
-
panoText: window.__panoText,
|
| 88 |
-
worldShown: window.LL.controller._worldShown,
|
| 89 |
-
activeScreen: [...document.querySelectorAll(".screen.is-active")].map((s) => s.id),
|
| 90 |
-
}));
|
| 91 |
-
console.log("SUPPORTED:", sup, "REC_STATE_WHILE_RECORDING:", recState);
|
| 92 |
-
console.log("RESULT:", JSON.stringify(st));
|
| 93 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 10)));
|
| 94 |
-
await browser.close();
|
| 95 |
-
server.close();
|
| 96 |
-
})().catch((e) => { console.error("HARNESS ERROR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/shoot.cjs
DELETED
|
@@ -1,88 +0,0 @@
|
|
| 1 |
-
// Visual-validation harness: serve the frontend locally + headless Chromium (WebGL
|
| 2 |
-
// via swiftshader) + screenshot the lobby and the 3D stage driven with a test
|
| 3 |
-
// image+depth. Lets Claude actually SEE the rendered UI. Usage: node scripts/shoot.cjs
|
| 4 |
-
const { chromium } = require("playwright");
|
| 5 |
-
const http = require("http");
|
| 6 |
-
const fs = require("fs");
|
| 7 |
-
const path = require("path");
|
| 8 |
-
|
| 9 |
-
const ROOT = process.cwd();
|
| 10 |
-
const PORT = 8799;
|
| 11 |
-
const CT = {
|
| 12 |
-
".html": "text/html", ".js": "application/javascript", ".mjs": "application/javascript",
|
| 13 |
-
".css": "text/css", ".woff2": "font/woff2", ".webp": "image/webp", ".png": "image/png",
|
| 14 |
-
".json": "application/json", ".svg": "image/svg+xml",
|
| 15 |
-
};
|
| 16 |
-
|
| 17 |
-
const server = http.createServer((req, res) => {
|
| 18 |
-
let p = decodeURIComponent(req.url.split("?")[0]);
|
| 19 |
-
if (p === "/") p = "/frontend/index.html";
|
| 20 |
-
const file = path.join(ROOT, p);
|
| 21 |
-
fs.readFile(file, (err, data) => {
|
| 22 |
-
if (err) { res.writeHead(404); res.end("not found"); return; }
|
| 23 |
-
res.writeHead(200, { "content-type": CT[path.extname(file)] || "application/octet-stream" });
|
| 24 |
-
res.end(data);
|
| 25 |
-
});
|
| 26 |
-
});
|
| 27 |
-
|
| 28 |
-
(async () => {
|
| 29 |
-
const SHOTS = path.join(ROOT, ".shots");
|
| 30 |
-
fs.mkdirSync(SHOTS, { recursive: true });
|
| 31 |
-
const shot = (n) => path.join(SHOTS, n);
|
| 32 |
-
await new Promise((r) => server.listen(PORT, r));
|
| 33 |
-
const browser = await chromium.launch({
|
| 34 |
-
args: ["--use-gl=angle", "--use-angle=swiftshader", "--ignore-gpu-blocklist", "--enable-webgl"],
|
| 35 |
-
});
|
| 36 |
-
const page = await browser.newPage({ viewport: { width: 1680, height: 800 }, deviceScaleFactor: 1 });
|
| 37 |
-
const errs = [];
|
| 38 |
-
page.on("console", (m) => { if (m.type() === "error") errs.push(m.text().slice(0, 200)); });
|
| 39 |
-
page.on("pageerror", (e) => errs.push("PAGEERROR: " + e.message.slice(0, 200)));
|
| 40 |
-
|
| 41 |
-
await page.goto(`http://localhost:${PORT}/frontend/index.html`, { waitUntil: "networkidle", timeout: 25000 }).catch((e) => errs.push("goto: " + e.message));
|
| 42 |
-
await page.waitForTimeout(2000);
|
| 43 |
-
await page.screenshot({ path: shot("lobby.png") });
|
| 44 |
-
|
| 45 |
-
// Reveal the recital composer (so the lobby looks like a judge would see it).
|
| 46 |
-
await page.evaluate(() => { const b = document.getElementById("btn-recital"); if (b) b.click(); }).catch(() => {});
|
| 47 |
-
await page.waitForTimeout(600);
|
| 48 |
-
await page.screenshot({ path: shot("lobby-recital.png") });
|
| 49 |
-
|
| 50 |
-
// Drive the 3D stage directly with a test color image + radial depth (data URLs),
|
| 51 |
-
// so we can SEE the renderer without the GPU backend.
|
| 52 |
-
const driven = await page.evaluate(async () => {
|
| 53 |
-
function makeImg(draw) {
|
| 54 |
-
const c = document.createElement("canvas"); c.width = 1024; c.height = 576;
|
| 55 |
-
const g = c.getContext("2d"); draw(g, c.width, c.height); return c.toDataURL("image/png");
|
| 56 |
-
}
|
| 57 |
-
const img = makeImg((g, w, h) => {
|
| 58 |
-
const grad = g.createLinearGradient(0, 0, 0, h);
|
| 59 |
-
grad.addColorStop(0, "#e8a33d"); grad.addColorStop(0.5, "#c25a2a"); grad.addColorStop(1, "#1b2a3a");
|
| 60 |
-
g.fillStyle = grad; g.fillRect(0, 0, w, h);
|
| 61 |
-
g.fillStyle = "#f5efe6"; g.beginPath(); g.arc(w * 0.5, h * 0.55, 90, 0, 7); g.fill(); // a "sun"
|
| 62 |
-
g.fillStyle = "#0a0a0c"; g.fillRect(w * 0.7, h * 0.4, 70, h * 0.6); // a "tower"
|
| 63 |
-
});
|
| 64 |
-
const depth = makeImg((g, w, h) => {
|
| 65 |
-
const rad = g.createRadialGradient(w * 0.72, h * 0.5, 10, w * 0.72, h * 0.5, 400);
|
| 66 |
-
rad.addColorStop(0, "#ffffff"); rad.addColorStop(1, "#202020"); // tower=near(white), rest far
|
| 67 |
-
g.fillStyle = rad; g.fillRect(0, 0, w, h);
|
| 68 |
-
});
|
| 69 |
-
document.querySelectorAll(".screen").forEach((s) => s.classList.remove("is-active"));
|
| 70 |
-
const set = document.getElementById("set"); if (set) set.classList.add("is-active");
|
| 71 |
-
const canvas = document.getElementById("stage-canvas");
|
| 72 |
-
if (!window.LL || !window.LL.stage) return { ok: false, why: "LL.stage missing", stageType: typeof (window.LL && window.LL.stage) };
|
| 73 |
-
try { window.LL.stage.init(canvas); } catch (e) { return { ok: false, why: "init: " + e.message }; }
|
| 74 |
-
try {
|
| 75 |
-
await window.LL.stage.revealBeat({ imageUrl: img, depthUrl: depth, cameraMove: "dolly_in", transition: "crossfade", reducedMotion: false });
|
| 76 |
-
} catch (e) { return { ok: false, why: "revealBeat: " + e.message }; }
|
| 77 |
-
const hasLL = Object.keys(window.LL || {});
|
| 78 |
-
return { ok: true, hasLL };
|
| 79 |
-
}).catch((e) => ({ ok: false, why: "evaluate: " + e.message }));
|
| 80 |
-
|
| 81 |
-
await page.waitForTimeout(1200);
|
| 82 |
-
await page.screenshot({ path: shot("stage.png") });
|
| 83 |
-
|
| 84 |
-
console.log("DRIVEN:", JSON.stringify(driven));
|
| 85 |
-
console.log("JS_ERRORS:", JSON.stringify(errs.slice(0, 12)));
|
| 86 |
-
await browser.close();
|
| 87 |
-
server.close();
|
| 88 |
-
})().catch((e) => { console.error("HARNESS ERROR:", e.message); process.exit(1); });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/lightloom/depth/depth.py
CHANGED
|
@@ -14,10 +14,12 @@ import numpy as np
|
|
| 14 |
from lightloom.core.config import MODEL_REFS
|
| 15 |
|
| 16 |
|
| 17 |
-
def normalize_depth(raw: np.ndarray, invert: bool =
|
| 18 |
-
"""Min-max normalize a raw depth map to [0,1].
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
raw = raw.astype("float32")
|
| 22 |
lo = float(raw.min())
|
| 23 |
hi = float(raw.max())
|
|
@@ -44,11 +46,13 @@ def load_depth_pipeline(device: str = "cuda") -> Any:
|
|
| 44 |
)
|
| 45 |
|
| 46 |
|
| 47 |
-
def estimate_depth(depth_pipeline: Any, image: Any, invert: bool =
|
| 48 |
-
"""Run depth estimation on a PIL image.
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
| 52 |
out = depth_pipeline(image)
|
| 53 |
predicted = out["predicted_depth"]
|
| 54 |
array = predicted.detach().cpu().numpy() if hasattr(predicted, "detach") else np.asarray(predicted)
|
|
|
|
| 14 |
from lightloom.core.config import MODEL_REFS
|
| 15 |
|
| 16 |
|
| 17 |
+
def normalize_depth(raw: np.ndarray, invert: bool = False) -> np.ndarray:
|
| 18 |
+
"""Min-max normalize a raw depth map to [0,1]. The parallax shader wants 1 = near, 0 = far.
|
| 19 |
+
Depth-Anything-V2 emits DISPARITY (near = HIGH value), so plain min-max ALREADY yields 1=near/0=far
|
| 20 |
+
-> the default is ``invert=False``. Pass ``invert=True`` ONLY for a TRUE-depth source (near = LOW).
|
| 21 |
+
Applying invert to a disparity map flips it inside-out (near reads as far) -> inverted parallax +
|
| 22 |
+
aerial on the wrong regions + disocclusion streaks. A flat map returns zeros (no divide-by-zero)."""
|
| 23 |
raw = raw.astype("float32")
|
| 24 |
lo = float(raw.min())
|
| 25 |
hi = float(raw.max())
|
|
|
|
| 46 |
)
|
| 47 |
|
| 48 |
|
| 49 |
+
def estimate_depth(depth_pipeline: Any, image: Any, invert: bool = False, normalize: bool = True) -> np.ndarray:
|
| 50 |
+
"""Run depth estimation on a PIL image. DA-V2 emits DISPARITY (near=HIGH); with ``normalize``
|
| 51 |
+
(default) plain min-max yields 1=near/0=far (the shader convention) — so ``invert`` defaults to
|
| 52 |
+
False (do NOT flip a disparity map). With ``normalize=False`` returns the RAW model disparity
|
| 53 |
+
(un-scaled) so the caller can apply ONE session-global scale across all strips — the only way
|
| 54 |
+
adjacent strips share a depth scale (per-strip min-max makes 'near' mean a different thing every
|
| 55 |
+
section -> seams + flatness)."""
|
| 56 |
out = depth_pipeline(image)
|
| 57 |
predicted = out["predicted_depth"]
|
| 58 |
array = predicted.detach().cpu().numpy() if hasattr(predicted, "detach") else np.asarray(predicted)
|
src/lightloom/paint/scroll.py
CHANGED
|
@@ -4,8 +4,10 @@ Instead of discrete images, the world is ONE horizontal panorama that keeps
|
|
| 4 |
extending to the right as the narration flows: each step OUTPAINTS the right edge,
|
| 5 |
conditioned on an overlap strip carried over from the previous section, so the new
|
| 6 |
content continues the old SEAMLESSLY. The browser scrolls left through the strip
|
| 7 |
-
with a depth parallax.
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
|
| 11 |
from __future__ import annotations
|
|
|
|
| 4 |
extending to the right as the narration flows: each step OUTPAINTS the right edge,
|
| 5 |
conditioned on an overlap strip carried over from the previous section, so the new
|
| 6 |
content continues the old SEAMLESSLY. The browser scrolls left through the strip
|
| 7 |
+
with a depth parallax. Uses the live painter — the DISTILLED FLUX.2-klein-4B inpaint
|
| 8 |
+
pipeline (4-step, CFG-free) — for a fast masked right-edge outpaint; no 360 LoRA is
|
| 9 |
+
loaded (see ``load_fast_pipeline``). The only adapter fused is the painterly STYLE
|
| 10 |
+
LoRA at warm-up, which is in the runtime ledger.
|
| 11 |
"""
|
| 12 |
|
| 13 |
from __future__ import annotations
|
tests/test_audio.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
"""Tests for the ambient ducking law (docs/02 §2.7)."""
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
from lightloom.sound.ambient import BED_DB, duck_gain_db
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def test_bed_sits_at_minus_16_when_silent() -> None:
|
| 9 |
-
assert duck_gain_db(False) == BED_DB == -16.0
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def test_bed_ducks_6db_when_voice_active() -> None:
|
| 13 |
-
assert duck_gain_db(True) == -22.0
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def test_custom_levels() -> None:
|
| 17 |
-
assert duck_gain_db(True, bed_db=-12.0, duck_db=8.0) == -20.0
|
| 18 |
-
assert duck_gain_db(False, bed_db=-12.0, duck_db=8.0) == -12.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_beats.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
| 1 |
-
"""Contract tests for VAD beat segmentation (docs/02 §2.1, docs/06 §2).
|
| 2 |
-
|
| 3 |
-
Hysteresis: enter speech at p>0.6, leave at p<0.35 sustained >=0.6 s. A beat is
|
| 4 |
-
emitted only if its duration is in [1.2 s, 12 s]; longer speech is split at T_max.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
from lightloom.core.beats import WINDOW_S, segment_beats
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def seg(prob: float, seconds: float, window_s: float = WINDOW_S) -> list[float]:
|
| 13 |
-
return [prob] * round(seconds / window_s)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def test_silence_gap_over_tau_splits_into_two_beats() -> None:
|
| 17 |
-
probs = seg(0.9, 2.0) + seg(0.0, 1.5) + seg(0.9, 2.0)
|
| 18 |
-
beats = segment_beats(probs)
|
| 19 |
-
assert len(beats) == 2
|
| 20 |
-
for start, end in beats:
|
| 21 |
-
assert 1.8 <= (end - start) <= 2.2
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def test_short_silence_under_tau_keeps_single_beat() -> None:
|
| 25 |
-
# 0.3 s gap is below the 0.6 s silence threshold -> one continuous beat.
|
| 26 |
-
probs = seg(0.9, 2.0) + seg(0.0, 0.3) + seg(0.9, 2.0)
|
| 27 |
-
beats = segment_beats(probs)
|
| 28 |
-
assert len(beats) == 1
|
| 29 |
-
start, end = beats[0]
|
| 30 |
-
assert (end - start) >= 4.0
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
def test_sub_t_min_utterance_is_dropped() -> None:
|
| 34 |
-
probs = seg(0.9, 0.5) + seg(0.0, 1.0)
|
| 35 |
-
assert segment_beats(probs) == []
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
def test_hysteresis_dip_above_theta_off_does_not_close() -> None:
|
| 39 |
-
# Dips to 0.4 (between theta_off=0.35 and theta_on=0.6) must not end the beat.
|
| 40 |
-
probs = seg(0.9, 1.0) + seg(0.4, 1.0) + seg(0.9, 1.0) + seg(0.0, 1.0)
|
| 41 |
-
beats = segment_beats(probs)
|
| 42 |
-
assert len(beats) == 1
|
| 43 |
-
start, end = beats[0]
|
| 44 |
-
assert (end - start) >= 2.9 # ~3 s minus window quantization (0.03 s)
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
def test_long_speech_is_split_at_t_max() -> None:
|
| 48 |
-
probs = seg(0.9, 15.0) + seg(0.0, 1.0)
|
| 49 |
-
beats = segment_beats(probs)
|
| 50 |
-
assert len(beats) == 2
|
| 51 |
-
assert beats[0][1] - beats[0][0] <= 12.0 + 1e-6
|
| 52 |
-
assert beats[0][1] - beats[0][0] >= 11.5
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def test_low_prob_below_theta_on_never_starts() -> None:
|
| 56 |
-
probs = seg(0.5, 5.0)
|
| 57 |
-
assert segment_beats(probs) == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_budget.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
"""Contract tests for the per-session GPU-second budget and quota guard.
|
| 2 |
-
|
| 3 |
-
docs/01 §4, docs/04 §2: warn at 70 %, offer Replay/Export at exhaustion, and never
|
| 4 |
-
start a beat that cannot finish within the remaining budget.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
from lightloom.core.budget import GpuBudget
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def test_fresh_budget_is_ok_and_full() -> None:
|
| 13 |
-
b = GpuBudget(total_s=90.0)
|
| 14 |
-
assert b.spent_s == 0.0
|
| 15 |
-
assert b.remaining_s == 90.0
|
| 16 |
-
assert b.status() == "ok"
|
| 17 |
-
assert b.can_start_beat(2.5) is True
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def test_warn_threshold_at_70_percent() -> None:
|
| 21 |
-
b = GpuBudget(total_s=10.0)
|
| 22 |
-
b.add(6.9)
|
| 23 |
-
assert b.status() == "ok"
|
| 24 |
-
b.add(0.2) # 7.1 / 10 -> over 70 %
|
| 25 |
-
assert b.status() == "warn"
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
def test_exhaustion_blocks_new_beats() -> None:
|
| 29 |
-
b = GpuBudget(total_s=10.0)
|
| 30 |
-
b.add(10.0)
|
| 31 |
-
assert b.status() == "exhausted"
|
| 32 |
-
assert b.remaining_s == 0.0
|
| 33 |
-
assert b.can_start_beat(0.1) is False
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
def test_remaining_never_negative_and_negatives_ignored() -> None:
|
| 37 |
-
b = GpuBudget(total_s=5.0)
|
| 38 |
-
b.add(8.0)
|
| 39 |
-
assert b.remaining_s == 0.0
|
| 40 |
-
b.add(-3.0) # ignored, cannot refund
|
| 41 |
-
assert b.spent_s == 8.0
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
def test_cannot_start_beat_that_would_overrun() -> None:
|
| 45 |
-
b = GpuBudget(total_s=10.0)
|
| 46 |
-
b.add(8.0) # 2 s left
|
| 47 |
-
assert b.can_start_beat(2.5) is False
|
| 48 |
-
assert b.can_start_beat(1.5) is True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_compliance.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
from pathlib import Path
|
| 4 |
-
import re
|
| 5 |
-
|
| 6 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 7 |
-
RUNTIME_DIRS = [ROOT / "src", ROOT / "frontend", ROOT / "app.py"]
|
| 8 |
-
|
| 9 |
-
FORBIDDEN = [
|
| 10 |
-
"api.openai.com",
|
| 11 |
-
"api.cohere",
|
| 12 |
-
"bfl.ai/api",
|
| 13 |
-
"InferenceClient",
|
| 14 |
-
"huggingface_hub.InferenceApi",
|
| 15 |
-
]
|
| 16 |
-
|
| 17 |
-
TOKEN_RE = re.compile(r"hf_[A-Za-z0-9]{20,}")
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def _runtime_files() -> list[Path]:
|
| 21 |
-
files: list[Path] = []
|
| 22 |
-
for root in RUNTIME_DIRS:
|
| 23 |
-
if root.is_file():
|
| 24 |
-
files.append(root)
|
| 25 |
-
elif root.exists():
|
| 26 |
-
files.extend(path for path in root.rglob("*") if path.is_file())
|
| 27 |
-
return files
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
def test_no_cloud_api_literals_in_runtime() -> None:
|
| 31 |
-
offenders: list[str] = []
|
| 32 |
-
for path in _runtime_files():
|
| 33 |
-
text = path.read_text(encoding="utf-8", errors="ignore")
|
| 34 |
-
for pattern in FORBIDDEN:
|
| 35 |
-
if pattern in text:
|
| 36 |
-
offenders.append(f"{path.relative_to(ROOT)}:{pattern}")
|
| 37 |
-
assert offenders == []
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
def test_no_hf_tokens_in_repo_text_files() -> None:
|
| 41 |
-
offenders: list[str] = []
|
| 42 |
-
for path in ROOT.rglob("*"):
|
| 43 |
-
if ".git" in path.parts or ".venv" in path.parts:
|
| 44 |
-
continue
|
| 45 |
-
if not path.is_file():
|
| 46 |
-
continue
|
| 47 |
-
try:
|
| 48 |
-
text = path.read_text(encoding="utf-8")
|
| 49 |
-
except UnicodeDecodeError:
|
| 50 |
-
continue
|
| 51 |
-
if TOKEN_RE.search(text):
|
| 52 |
-
offenders.append(str(path.relative_to(ROOT)))
|
| 53 |
-
assert offenders == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_depth.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
"""Tests for depth normalization (docs/02 §2.5). The map fed to the parallax
|
| 2 |
-
shader is in [0,1] with 1 = near; model loading/inference is GPU-only and untested
|
| 3 |
-
here."""
|
| 4 |
-
|
| 5 |
-
from __future__ import annotations
|
| 6 |
-
|
| 7 |
-
import numpy as np
|
| 8 |
-
|
| 9 |
-
from lightloom.depth.depth import normalize_depth
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def test_normalizes_to_unit_range() -> None:
|
| 13 |
-
raw = np.array([[10.0, 20.0], [30.0, 40.0]], dtype="float32")
|
| 14 |
-
out = normalize_depth(raw, invert=False)
|
| 15 |
-
assert out.min() == 0.0
|
| 16 |
-
assert out.max() == 1.0
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
def test_invert_makes_one_equal_near() -> None:
|
| 20 |
-
raw = np.array([[0.0, 1.0]], dtype="float32")
|
| 21 |
-
out = normalize_depth(raw, invert=True)
|
| 22 |
-
# raw min -> 1.0 (near), raw max -> 0.0 (far)
|
| 23 |
-
assert out[0, 0] == 1.0
|
| 24 |
-
assert out[0, 1] == 0.0
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def test_constant_map_does_not_divide_by_zero() -> None:
|
| 28 |
-
raw = np.full((3, 3), 0.5, dtype="float32")
|
| 29 |
-
out = normalize_depth(raw, invert=False)
|
| 30 |
-
assert np.all(out == 0.0)
|
| 31 |
-
assert out.shape == (3, 3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_director_parse.py
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
"""Tests for the tolerant Director parser (_coerce_shot) — CPU only, no model.
|
| 2 |
-
|
| 3 |
-
These pin the salvage behavior that keeps the GPU Director's JSON-validity high
|
| 4 |
-
without a grammar (transformers 5.x is incompatible with lm-format-enforcer).
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
from __future__ import annotations
|
| 8 |
-
|
| 9 |
-
import json
|
| 10 |
-
|
| 11 |
-
from lightloom.director.director import _coerce_shot
|
| 12 |
-
|
| 13 |
-
GOLD = {
|
| 14 |
-
"decision": "continuity",
|
| 15 |
-
"shot_scale": "MS",
|
| 16 |
-
"camera_move": "tilt_up",
|
| 17 |
-
"lighting": "stormy dusk",
|
| 18 |
-
"palette": ["#1B2A3A", "#C9A227", "#6E7B8B"],
|
| 19 |
-
"setting": "inside the lighthouse",
|
| 20 |
-
"characters": ["an old lighthouse keeper"],
|
| 21 |
-
"image_prompt_en": "a keeper climbs the stairs",
|
| 22 |
-
"ambient_prompt_en": "rain on glass, wind",
|
| 23 |
-
"transition": "crossfade",
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def test_valid_passes_uncoerced() -> None:
|
| 28 |
-
shot, coerced = _coerce_shot(json.dumps(GOLD))
|
| 29 |
-
assert not coerced
|
| 30 |
-
assert shot.transition == "crossfade"
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
def test_missing_transition_is_repaired_by_decision() -> None:
|
| 34 |
-
cut = {**GOLD, "decision": "cut"}
|
| 35 |
-
del cut["transition"]
|
| 36 |
-
shot, coerced = _coerce_shot(json.dumps(cut))
|
| 37 |
-
assert coerced and shot.transition == "hard_cut"
|
| 38 |
-
|
| 39 |
-
cont = dict(GOLD)
|
| 40 |
-
del cont["transition"]
|
| 41 |
-
shot2, _ = _coerce_shot(json.dumps(cont))
|
| 42 |
-
assert shot2.transition == "crossfade"
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
def test_transition_as_list_takes_first_valid() -> None:
|
| 46 |
-
payload = {**GOLD, "transition": ["wipe_left", "hard_cut"]}
|
| 47 |
-
shot, coerced = _coerce_shot(json.dumps(payload))
|
| 48 |
-
assert coerced and shot.transition == "wipe_left"
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
def test_overlong_ambient_is_clamped() -> None:
|
| 52 |
-
payload = {**GOLD, "ambient_prompt_en": "rain " * 60}
|
| 53 |
-
shot, coerced = _coerce_shot(json.dumps(payload))
|
| 54 |
-
assert coerced and len(shot.ambient_prompt_en) <= 160
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
def test_camera_synonym_is_mapped() -> None:
|
| 58 |
-
shot, coerced = _coerce_shot(json.dumps({**GOLD, "camera_move": "zoom_in"}))
|
| 59 |
-
assert coerced and shot.camera_move == "dolly_in"
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
def test_unknown_enums_fall_back_to_defaults() -> None:
|
| 63 |
-
payload = {**GOLD, "camera_move": "orbit", "shot_scale": "HUGE", "decision": "maybe"}
|
| 64 |
-
shot, coerced = _coerce_shot(json.dumps(payload))
|
| 65 |
-
assert coerced
|
| 66 |
-
assert shot.camera_move == "static"
|
| 67 |
-
assert shot.shot_scale == "MS"
|
| 68 |
-
assert shot.decision == "continuity"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_gate_g1.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
|
| 6 |
-
import benchmarks.gate_g1 as gate_g1
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def test_g1_dry_run_writes_non_authoritative_results(tmp_path, monkeypatch) -> None:
|
| 10 |
-
json_path = tmp_path / "g1.json"
|
| 11 |
-
md_path = tmp_path / "g1.md"
|
| 12 |
-
monkeypatch.setattr(gate_g1, "DEFAULT_JSON", json_path)
|
| 13 |
-
monkeypatch.setattr(gate_g1, "DEFAULT_MD", md_path)
|
| 14 |
-
data = gate_g1.run(dry_run=True, reps=2, allow_local=False)
|
| 15 |
-
assert data["authoritative"] is False
|
| 16 |
-
assert data["decision"]["status"] == "blocked"
|
| 17 |
-
assert json_path.exists()
|
| 18 |
-
assert md_path.exists()
|
| 19 |
-
saved = json.loads(Path(json_path).read_text(encoding="utf-8"))
|
| 20 |
-
assert saved["results"]
|
| 21 |
-
assert all(item["status"] == "dry_run" for item in saved["results"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_gate_g2_g3.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
import benchmarks.gate_g2_g3 as gate_g2_g3
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def test_g2_g3_dry_run_writes_temp_results(tmp_path, monkeypatch) -> None:
|
| 9 |
-
g2_path = tmp_path / "g2.json"
|
| 10 |
-
g3_path = tmp_path / "g3.json"
|
| 11 |
-
monkeypatch.setattr(gate_g2_g3, "G2_JSON", g2_path)
|
| 12 |
-
monkeypatch.setattr(gate_g2_g3, "G3_JSON", g3_path)
|
| 13 |
-
g2, g3 = gate_g2_g3.run(dry_run=True)
|
| 14 |
-
assert g2["authoritative"] is False
|
| 15 |
-
assert g3["authoritative"] is False
|
| 16 |
-
assert g2_path.exists()
|
| 17 |
-
assert g3_path.exists()
|
| 18 |
-
assert json.loads(g2_path.read_text(encoding="utf-8"))["decision"] == "dry_run"
|
| 19 |
-
assert json.loads(g3_path.read_text(encoding="utf-8"))["decision"] == "dry_run"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|