Spaces:
Running
Running
File size: 1,291 Bytes
23680f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#!/usr/bin/env python
"""Hugging Face Spaces entrypoint for HyperView.
This script serves a pre-computed demo dataset stored in LanceDB.
The dataset is computed at Docker build time by scripts/precompute_hf_demo.py.
For HuggingFace Spaces deployment under Hyper3Labs/HyperView.
"""
import os
# Configuration from environment
HOST = os.environ.get("HOST", "0.0.0.0")
PORT = int(os.environ.get("PORT", 7860))
DATASET_NAME = os.environ.get("DEMO_DATASET", "cifar10_hf_demo")
def main() -> None:
"""Load pre-computed dataset and launch server."""
import hyperview as hv
dataset = hv.Dataset(DATASET_NAME)
spaces = dataset.list_spaces()
layouts = dataset.list_layouts()
if not spaces or not layouts:
print("Pre-computed embeddings not found in storage.")
print("Falling back to computing on startup (this will be slow)...")
from scripts.precompute_hf_demo import create_demo_dataset
dataset = create_demo_dataset()
else:
print(f"Loaded dataset '{DATASET_NAME}' with pre-computed embeddings")
print(f"\nStarting HyperView server on {HOST}:{PORT}")
print("=" * 50)
hv.launch(
dataset,
host=HOST,
port=PORT,
open_browser=False,
)
if __name__ == "__main__":
main()
|