Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
{
"nbformat": 4,
"nbformat_minor": 5,
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "ppy7so3HYiOK"
},
"source": [
"# Multimodal Mountain Peak Search — Colab Notebook\n",
"\n",
"In this notebook we do the following:\n",
"- Install dependencies\n",
"- Connect to **Elasticsearch**\n",
"- Create indices\n",
"- Index a small **peaks catalog** (text+image blended vectors)\n",
"- Index a few **photos**\n",
"- Run **text → image** search and **identify-from-photo** search\n"
],
"id": "ppy7so3HYiOK"
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "o0tHMSj6YiOM",
"outputId": "f58fb49f-1d7f-49a3-cb26-07f63534497d",
"cellView": "form"
},
"execution_count": 23,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Elasticsearch url(https://localhost:9200): \n",
"Elasticsearch base64 api keyw\n",
"ES_URL : https://localhost:9200\n",
"API_KEY_B64: set\n"
]
}
],
"source": [
"#@title Configure Elasticsearch (API key recommended)\n",
"import os, base64\n",
"\n",
"# Prompt for Elasticsearch URL:\n",
"ES_URL = input(\"Elasticsearch url(https://localhost:9200): \") or \"https://localhost:9200\"\n",
"\n",
"\n",
"#Prompt Elasticsearch base64 api key:\n",
"ES_API_KEY_B64 = input(\"Elasticsearch base64 api key\")\n",
"\n",
"\n",
"print(\"ES_URL :\", ES_URL)\n",
"print(\"API_KEY_B64:\", \"set\" if ES_API_KEY_B64 else \"MISSING\")\n",
"\n",
"# Propagate for scripts\n",
"os.environ[\"ES_URL\"] = ES_URL\n",
"os.environ[\"ES_API_KEY_B64\"] = ES_API_KEY_B64\n",
"\n",
"# Optional model override\n",
"# os.environ[\"SIGLIP_MODEL_ID\"] = \"google/siglip-so400m-patch14-384\"\n"
],
"id": "o0tHMSj6YiOM"
},
{
"cell_type": "code",
"metadata": {
"id": "za6W0opPYiOM",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "bdbdac01-1579-4b60-b2b1-f753deaf9548"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning: https://github.com/navneet83/multimodal-mountain-peak-search\n",
"Cloned and cwd set to /content/multimodal-mountain-peak-search\n"
]
}
],
"source": [
"#@title Clone Github repo\n",
"REPO_URL = \"https://github.com/navneet83/multimodal-mountain-peak-search\"\n",
"TARGET_DIR = \"/content/multimodal-mountain-peak-search\"\n",
"import os, shutil, subprocess, sys\n",
"\n",
"if os.path.exists(TARGET_DIR):\n",
" shutil.rmtree(TARGET_DIR)\n",
"\n",
"print(\"Cloning:\", REPO_URL)\n",
"rc = subprocess.call([\"git\",\"clone\",\"--depth\",\"1\", REPO_URL, TARGET_DIR])\n",
"if rc != 0:\n",
" raise SystemExit(\"❌ Clone failed. Check the repo URL or network.\")\n",
"\n",
"os.chdir(TARGET_DIR)\n",
"sys.path.insert(0, os.path.join(TARGET_DIR, \"src\")) # import ai_mpi.embeddings\n",
"print(\"Cloned and cwd set to\", TARGET_DIR)"
],
"id": "za6W0opPYiOM"
},
{
"cell_type": "code",
"source": [
"#@title Install dependencies\n",
"!pip -q install --upgrade pip\n",
"!pip install -r requirements.txt\n",
"print(\"Installed\")"
],
"metadata": {
"id": "JEMGE9kgrR5v"
},
"id": "JEMGE9kgrR5v",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "6T5tDn7ZYiOO"
},
"execution_count": null,
"outputs": [],
"source": [
"#@title Create indices in Elasticsearch\n",
"!python scripts/create_indices.py --recreate || python scripts/create_indices.py\n",
"print(\"Indices ready\")"
],
"id": "6T5tDn7ZYiOO"
},
{
"cell_type": "code",
"metadata": {
"id": "tk6MFsDyYiOP"
},
"execution_count": null,
"outputs": [],
"source": [
"#@title Index peaks (blended text + reference images)\n",
"!python scripts/embed_and_index_photos.py --index-peaks --peaks-yaml data/peaks.yaml --peaks-images-root data/peaks --blend-alpha-text 0.55 --blend-max-images 3\n",
"print(\"Peaks indexed\")"
],
"id": "tk6MFsDyYiOP"
},
{
"cell_type": "code",
"metadata": {
"id": "ualslgxsYiOP"
},
"execution_count": null,
"outputs": [],
"source": [
"#@title Index your photos\n",
"!python scripts/embed_and_index_photos.py --index-photos --images data/images --topk-predicted 5\n",
"print(\"✅ Photos indexed\")"
],
"id": "ualslgxsYiOP"
},
{
"cell_type": "code",
"source": [
"#@title Text → image search (type a peak name)\n",
"query = \"Pumori\" #@param [\"Ama Dablam\", \"Pumori\", \"Mount Everest\"] {allow-input: true}\n",
"k = 12 #@param {type:\"slider\", min:6, max:30, step:2}\n",
"num_candidates = 4000 #@param {type:\"slider\", min:1000, max:6000, step:1000}\n",
"\n",
"!python scripts/query_by_peak_name.py --peak query --k {k} --num-candidates {num_candidates}"
],
"metadata": {
"cellView": "form",
"id": "VjpCGK9Csz2F"
},
"id": "VjpCGK9Csz2F",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title Identify from photo → similar photos (upload OR reuse a repo image)\n",
"from google.colab import files\n",
"uploaded = files.upload()\n",
"\n",
"for fn in uploaded.keys():\n",
" !python scripts/identify_from_picture_find_similar_peaks.py --image \"{fn}\" --neighbors 30\n"
],
"metadata": {
"id": "mLirCeRJrkDV"
},
"id": "mLirCeRJrkDV",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"colab": {
"name": "02_quickstart_colab_navneet_v2.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.x"
}
}
}
Loading