{ "cells": [ { "cell_type": "markdown", "id": "47ee06e6", "metadata": {}, "source": [ "# HyperView — Colab Smoke Test\n", "\n", "This notebook verifies that HyperView can launch inside Google Colab and open the UI in a new browser tab.\n", "\n", "The smoke test uses a synthetic dataset (random images + precomputed 2D coordinates), so it does not download models or run embedding computation." ] }, { "cell_type": "code", "execution_count": null, "id": "945a1017", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "zsh:1: command not found: pip\n", "Cloning into 'HyperView'...\n", "remote: Enumerating objects: 577, done.\u001b[K\n", "remote: Counting objects: 100% (577/577), done.\u001b[K\n", "remote: Compressing objects: 100% (328/328), done.\u001b[K\n", "remote: Total 577 (delta 240), reused 518 (delta 193), pack-reused 0 (from 0)\u001b[K\n", "Receiving objects: 100% (577/577), 4.29 MiB | 8.76 MiB/s, done.\n", "Resolving deltas: 100% (240/240), done.\n", "/Users/matin/hyperview_org/HyperView/notebooks/HyperView\n", "\u001b[2mUsing Python 3.12.8 environment at: /Users/matin/hyperview_org/HyperView/.venv\u001b[0m\n", "\u001b[2K\u001b[1m\u001b[31merror\u001b[39m\u001b[0m: /Users/matin/hyperview_org/HyperView/notebooks/HyperView does not appear to be a Python project, as neither `pyproject.toml` nor `setup.py` are present in the directory\n" ] } ], "source": [ "%pip install -q git+https://github.com/HackerRoomAI/HyperView.git@hyperview-base" ] }, { "cell_type": "code", "execution_count": null, "id": "58b82256", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "import hyperview as hv\n", "from hyperview.core.sample import SampleFromArray\n", "\n", "dataset = hv.Dataset(\"colab_smoke\", persist=False)\n", "\n", "rng = np.random.default_rng(0)\n", "num_samples = 200\n", "\n", "for i in range(num_samples):\n", " img = (rng.random((64, 64, 3)) * 255).astype(np.uint8)\n", "\n", " sample = SampleFromArray.from_array(\n", " id=f\"s{i}\",\n", " image_array=img,\n", " label=f\"class_{i % 10}\",\n", " metadata={\"i\": i},\n", " )\n", "\n", " # Precomputed 2D Euclidean projection\n", " sample.embedding_2d = [float(rng.normal()), float(rng.normal())]\n", "\n", " # Precomputed 2D hyperbolic projection (inside unit disk)\n", " r = float(rng.random() * 0.95)\n", " theta = float(rng.random() * 2 * np.pi)\n", " sample.embedding_2d_hyperbolic = [float(r * np.cos(theta)), float(r * np.sin(theta))]\n", "\n", " dataset.add_sample(sample)\n", "\n", "hv.launch(dataset, port=6262)" ] }, { "cell_type": "markdown", "id": "b1cb3148", "metadata": {}, "source": [ "Click the link printed above to open HyperView in a new tab. If needed, copy/paste the URL." ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.8" } }, "nbformat": 4, "nbformat_minor": 5 }