prevision / apps /renderer /README.md
github-actions[bot]
Automated Deploy: 6d2e55112e3ada832d411bd3301a883ce9eba3a9
c7a38a3
|
Raw History Blame Contribute Delete
4.86 kB
metadata
title: Floor Visualizer
emoji: 🏆
colorFrom: indigo
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
license: mit
short_description: Visualize custom texture or tiles on your floor

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

Local setup

The Python virtual environment is disposable. To recreate it after deleting .venv, use the platform-specific commands in SETUP.md.

Quick macOS CPU run:

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements-mac.txt
VISUALIZER_CONFIG=visualizer.local.toml uvicorn app:app --host 0.0.0.0 --port 8002

Optional Gemini tile refinement:

export GEMINI_API_KEY="your-google-ai-studio-key"
export GEMINI_IMAGE_MODEL="gemini-3.1-flash-image"

/gemini/refine-tile-render is the older pass used by BAETES clients (unchanged). The Prevision studio uses POST /enhance/room ("Enhance with AI" v2): the browser sends its frozen wallpaper layers, the renderer repairs coverage from the original photo, the AI supplies lighting only, and the result is composited over the original. See docs/ENHANCE_WITH_AI.md.

Tests (no models, AI stubbed; pip install httpx for FastAPI's test client):

python -m unittest test_access_policy test_free_tries test_enhance_room

scripts/enhance_compare_sheet.py <run> builds a before/after sheet from an ENHANCE_DEBUG_DIR dump; scripts/enhance_replay.py <run> --reuse-answer re-runs repair and lighting on a dump without a new AI call.

Optional DigitalOcean Spaces upload archive in apps/renderer/.env:

SPACES_BUCKET="your-space-name"
SPACES_REGION="nyc3"
SPACES_ACCESS_KEY_ID="your-spaces-access-key"
SPACES_SECRET_ACCESS_KEY="your-spaces-secret-key"
SPACES_UPLOAD_PREFIX="room-uploads"

When these are set, /viz2d/convert keeps the current frontend flow unchanged and uploads a copy of each room image to Spaces in the background.

Visual QA runner:

QA_FRONTEND_URL="https://your-vercel-frontend.example"
QA_BACKEND_URL="https://your-backend.example"
QA_FRONTEND_DIR="/mnt/room-editor/frontend/viz2d-demo"

For Hugging Face, QA_FRONTEND_DIR defaults to /app/frontend/viz2d-demo in the Dockerfile.

The debug visualizer QA page calls /qa/images, /qa/runs, /qa/runs/{run_id}/events, and /qa/runs/{run_id}. /qa/images lists DigitalOcean Spaces directly through the S3 API, deduplicates exact object matches by ETag and size, and does not use a database. /qa/runs deduplicates the selected image keys again, downloads the unique Spaces images into data/qa-runs/{run_id}/, starts the Playwright test suite from QA_FRONTEND_DIR, and stores file-backed run status/results in that run folder. The Playwright suite uploads each selected image once, then applies the selected tiles one by one, removing the previous tile before applying the next tile. /qa/runs/{run_id}/events streams run updates as Server-Sent Events so the debug page does not need to poll while a run is active. Playwright writes incremental progress after every completed test, so the completed, passed, and failed counters update before the final report is generated. /qa/runs/{run_id}/report renders a shareable HTML report with screenshot URLs; /qa/runs/{run_id}/report.md returns the compact Markdown summary.

On Hugging Face, the deploy workflow copies a minimal frontend/viz2d-demo QA runner folder into the Space: npm manifests, Playwright config, e2e tests, and the Markdown report script. It intentionally does not copy frontend image assets or test-images; real QA images are downloaded from DigitalOcean during each run. The Dockerfile installs Node, npm, Playwright, and Chromium during the Space rebuild. For non-Hugging Face servers, install the Node runner dependencies manually:

cd /mnt/room-editor/frontend/viz2d-demo
npm install
npx playwright install --with-deps chromium

GPU run:

python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements-gpu-cu126.txt
VISUALIZER_CONFIG=visualizer.gpu.toml uvicorn app:app --host 0.0.0.0 --port 8002

Hugging Face GPU Spaces use the Dockerfile in this directory. It installs the CUDA 12.6 PyTorch stack and starts FastAPI on port 7860 with visualizer.gpu.toml.

The GPU profile uses shi-labs/oneformer_ade20k_swin_large for segmentation, Ruicheng/moge-2-vitl-normal for metric point maps, surface normals, and camera intrinsics, and depth-anything/Depth-Anything-V2-Metric-Indoor-Large-hf for metric depth. If MoGe cannot load or its floor-plane fit is unreliable, the service falls back to Depth Anything V2 metric depth, then to the existing image-space homography.