diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index f89e5b925d2265cc5b766f068fe14d9533a39e81..0000000000000000000000000000000000000000 --- a/.dockerignore +++ /dev/null @@ -1,18 +0,0 @@ -# Git -.git - -# Python -__pycache__ -*.py[cod] -.venv -venv - -# Caches -.mypy_cache -.pytest_cache - -# Local runtime artifacts -demo_data - -# Misc -.DS_Store diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..ef97a47556e2730f72dce85b60f08a19a4a554cc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +bundle/api/samples/inat24_1005710/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1057675/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1103438/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1108956/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1122590/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1200798/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1212752/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1237216/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1283238/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1348688/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1431996/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1440675/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1598137/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1612128/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_164388/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1909712/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1963975/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_197364/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_1998170/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_2097011/content filter=lfs diff=lfs merge=lfs -text +bundle/api/samples/inat24_243827/content filter=lfs diff=lfs merge=lfs -text diff --git a/.hyperview/extensions/hello-world-intro/extension.toml b/.hyperview/extensions/hello-world-intro/extension.toml deleted file mode 100644 index 1b1abcea5912ceb32669c427f52183786d5bfa94..0000000000000000000000000000000000000000 --- a/.hyperview/extensions/hello-world-intro/extension.toml +++ /dev/null @@ -1,8 +0,0 @@ -name = "hello-world-intro" -description = "Short orientation panel for the HyperView Hello World workspace" - -[[panels]] -id = "hello-world-intro" -title = "Start here" -position = "right" -file = "panel.jsx" diff --git a/Dockerfile b/Dockerfile index 2ba29728036f0030e22f87f16ff5de85d85b6575..6db735ee80aa585dce1a860322bb9570caabc550 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,7 @@ FROM python:3.11-slim RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ curl \ - git \ - libssl-dev \ - pkg-config \ && rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user @@ -17,35 +13,37 @@ ENV HOME=/home/user \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 -WORKDIR $HOME/app +WORKDIR /home/user/app RUN pip install --upgrade pip - -ARG HYPERVIEW_VERSION=1.1.1 -ARG HYPER_MODELS_VERSION=0.3.2 - -# Install CPU-only PyTorch first so the Space does not pull the default CUDA bundle, -# then pin released HyperView packages so Docker cache cannot hold an older release. -RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -RUN pip install "hyperview==${HYPERVIEW_VERSION}" && python -c "import hyperview; print('hyperview', hyperview.__version__)" -RUN pip install "hyper-models[ml]==${HYPER_MODELS_VERSION}" && python -c "import hyper_models; print('hyper_models', hyper_models.__version__)" - -COPY --chown=user demo.py ./demo.py -COPY --chown=user .hyperview ./.hyperview - -# Only POST/PATCH/DELETE under /api/ are token-gated -- media GETs stay open -# either way. This marks the server public so viewer commands run without the -# token, while provider.register, extension.install, tools and compute get 403. +RUN pip install \ + "hyperview==1.2.0" \ + "hyper-models==0.4.0" + +# The bundle is the unit of delivery: `hyperview serve --from` restores the +# exported workspace, dataset, and layouts from it at startup. +COPY --chown=user bundle /home/user/app/bundle +RUN mkdir -p /home/user/app/data/datasets /home/user/app/data/media + +# HyperView mints a session token and rejects unauthenticated runtime +# commands. A public Space has no way to hand visitors that token, so panel +# creation and case switching 401 without this. It marks the server public: +# visitors get the viewer commands and nothing else, so provider registration, +# extension install, tool execution and compute stay closed. ENV HYPERVIEW_NO_AUTH=1 -ENV HYPERVIEW_DATASETS_DIR=/home/user/app/demo_data/datasets \ - HYPERVIEW_MEDIA_DIR=/home/user/app/demo_data/media +ENV HYPERVIEW_DATASETS_DIR=/home/user/app/data/datasets \ + HYPERVIEW_MEDIA_DIR=/home/user/app/data/media EXPOSE 7860 -HEALTHCHECK --interval=30s --timeout=10s --start-period=600s --retries=3 \ - CMD curl -f http://localhost:7860/__hyperview__/health || exit 1 - -# Dataset is built at first startup (model download + embedding computation). -# Precomputing at Docker build time causes LanceDB to be stored in overlay -# filesystem layers, which are extremely slow to reopen on free-tier CPUs. -CMD ["python", "demo.py"] +HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \ + CMD curl -f http://localhost:7860/api/runtime || exit 1 + +# The image carries the bundle and never moves it, so the restored dataset +# points at the bundle's own media instead of copying it a second time. +CMD ["hyperview", "serve", \ + "--from", "/home/user/app/bundle", \ + "--link-media", \ + "--host", "0.0.0.0", \ + "--port", "7860", \ + "--public"] diff --git a/README.md b/README.md index 0cbee5cf6c92c2109b7236bd0089570174dc3a6c..3a21b56f199c1605ab5fed76d7012f05c5e8bd48 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,25 @@ --- -title: HyperView -emoji: 🔮 -colorFrom: purple -colorTo: blue +title: HyperView Hello World +emoji: 🔭 +colorFrom: blue +colorTo: green sdk: docker app_port: 7860 pinned: false +short_description: HyperView Live Space for hello_world_inat24_multigeometry --- # HyperView Hello World -This is the main HyperView starter Space. It shows the same higher-resolution, -taxonomy-backed image sample through three geometric views and includes a small -custom introduction panel built with the public HyperView panel SDK: +A HyperView **Live Space**: the container runs the HyperView server over an +exported workspace bundle, so visitors can browse the prepared view and also +run new text queries, layouts, and model jobs. -- CLIP (`openai/clip-vit-base-patch32`) in Euclidean 3D -- CLIP (`openai/clip-vit-base-patch32`) in spherical 3D -- Hyper3-CLIP (`hyper3-clip-v1`) in hyperbolic Poincare 2D +## Contents -The sample is drawn from `evendrow/inat24_tiny`, a compact iNaturalist 2024 -subset with 1,000 images, 100 species, and taxonomy metadata. The visible label -is the broad `supercategory`, while sample metadata keeps common name, species, -kingdom, phylum, class, order, family, genus, location fields, license, and -rights holder. +- Workspace: `hello-world` +- Dataset: `hello_world_inat24_multigeometry` +- Exported with HyperView `1.2.0` +- Capabilities: browse_samples, lasso_2d, layouts, sample_similarity, selection -The Docker image installs released packages from PyPI: - -- `hyperview==1.1.1` -- `hyper-models[ml]==0.3.2` - -## Dataset - -The default stratified sample contains 300 images: - -| Label | Samples | -| --- | ---: | -| plants | 50 | -| insects | 50 | -| birds | 42 | -| arachnids | 36 | -| amphibians | 30 | -| reptiles | 26 | -| fungi | 26 | -| mammals | 20 | -| fish | 10 | -| mollusks | 10 | - -This keeps the demo small enough for Hugging Face CPU Spaces while preserving a -real biological hierarchy for geometry comparison. Images are resized only -when they exceed 1024 × 1024, avoiding the tiny 32 × 32 appearance of CIFAR. - -## Reuse This Template - -When copying this folder for another dataset: - -1. Edit the constants block at the top of [demo.py](demo.py). -2. Update the stratification labels and target counts. -3. Rename the copied Space from `HyperView` to your project name. -4. Point a deploy workflow at the new folder. - -## Deploy Source - -This folder is synchronized to `hyper3labs/HyperView` by GitHub Actions from -the `hyperview-spaces` deployment repository. - -Because `hyper3-clip-v1` is gated on Hugging Face, the running Space needs an -`HF_TOKEN` Space secret with read access to the model. The GitHub deployment -credential does not become a runtime secret automatically. +Built with [HyperView](https://github.com/Hyper3Labs/HyperView). diff --git a/bundle/.assetsignore b/bundle/.assetsignore new file mode 100644 index 0000000000000000000000000000000000000000..fddccbcbd4518b8bde5c714de93ac1c83c263b59 --- /dev/null +++ b/bundle/.assetsignore @@ -0,0 +1,2 @@ +wrangler.jsonc +.assetsignore diff --git a/bundle/404.html b/bundle/404.html new file mode 100644 index 0000000000000000000000000000000000000000..fc1739addb061c070c983bbf0ab21b441ae3f6ef --- /dev/null +++ b/bundle/404.html @@ -0,0 +1 @@ +