[KongchangAI]
· 2 min read· 1,434 words

TerraGemma: An Offline Edge AI Hiking Companion That Lets You Put Down Your Phone and Look Up

TerraGemma: An Offline Edge AI Hiking Companion That Lets You Put Down Your Phone and Look Up

TerraGemma runs Google Gemma 3 entirely on-device to deliver offline AI wilderness navigation where cloud services fail.

TerraGemma is an outdoor adventure app built on Google's open-weight Gemma 3 model that runs 100% locally, designed around the philosophy of "look up, put down the screen." It separates deterministic computation (NOAA solar engine, Naismith turnaround deadlines) from local generative reasoning (sensory navigation cues, WFR emergency triage, toxic plant identification). The primary gemma3:1b model is just 815 MB and infers in ~500ms on a laptop CPU; offline voice briefings play via the browser's native Web Speech API so you can pocket your phone immediately. Built with Python and Streamlit, it uploads zero data and costs $0 to run — a pragmatic edge AI demo showing that small models in offline-critical scenarios outperform large cloud models that simply don't work without signal.

There's a painful irony at the heart of modern outdoor apps: they encourage you to stare at a glowing screen while passing through ancient forests and mountain ranges. Your watch buzzes every 30 seconds with navigation cues, and hikers end up missing the rustle of leaves, the scent of damp hemlock needles, and the mountain wind hinting at a shift in weather. Walk a mile past the trailhead and the cell towers disappear — every cloud-dependent AI assistant (ChatGPT, Claude, the Gemini API) instantly becomes a useless loading spinner.

TerraGemma was built to solve exactly this problem — a 100% locally-run, offline-first wilderness companion powered by Google's open-weight model Gemma 3.

Core Philosophy: Look Up, Put Down the Screen

TerraGemma's design philosophy is almost radical: the screen should be the smallest part of your time outdoors.

TerraGemma Expedition Planner Interface

Rather than chaining users to information feeds or turn-by-turn navigation, it implements several mechanisms to reduce screen dependency:

  • NOAA Solar Engine & Naismith Turnaround Calculator: Precisely computes astronomical sunset and golden hour, then factors in elevation gain penalties (Naismith's Rule) to produce a hard "turnaround deadline" — so you're never caught on the mountain after dark.
  • Sensory Navigation Guides: Gemma 3 synthesizes 3–4 physical sensory cues, such as "Listen for the stream at 0.8 miles; feel the wind shifting from the western valley as you exit the tree line" — letting you navigate by natural perception rather than screen-staring.
  • Offline Audio Briefings: A short voice briefing plays at the trailhead using the browser's native Web Speech API — no cloud voice service or network connection required. Listen once, pocket your phone, start hiking.
  • Offline Wilderness First Responder (WFR) Triage: With zero signal, Gemma 3 provides immediate triage for hypothermia, heat stroke, snakebite, anaphylaxis, and sprains, complete with international three-whistle rescue signal protocols.
  • Plant, Animal & Toxic Lookalike Identification: Side-by-side comparisons of dangerous lookalike species (poison ivy vs. Virginia creeper; wild carrot vs. deadly hemlock; black bear vs. grizzly bear).

Naismith's Rule is an empirical formula for estimating hiking time, proposed by Scottish mountaineer William Naismith in 1892. The core rule: allow 1 hour for every 5 km of distance, plus 1 additional hour for every 600 m of elevation gain. It's widely used in mountaineering planning because in mountain terrain, elevation gain is far more physically demanding than horizontal distance. TerraGemma digitizes this into a "turnaround deadline": given a known route distance and elevation gain, it works backward to calculate the latest moment you must turn around to descend safely before sunset. It's worth noting that Naismith's Rule assumes a healthy adult at a normal pace — TerraGemma applies additional safety buffers to account for personal fitness, pack weight, trail conditions, and weather.

Four Key Feature Scenarios, Broken Down

From the author's demo, TerraGemma's workflow covers the complete lifecycle of an outdoor trip.

Planning phase: The user selects a wilderness route or enters custom coordinates. The offline NOAA solar engine calculates sunrise, sunset, and civil twilight. Naismith's Rule factors in route distance and 2,000+ feet of vertical gain, immediately producing a color-coded daylight status (🟢 Safe, 🟡 Caution, 🔴 Danger) and a hard turnaround timestamp. Waypoints, stream crossings, and high-altitude checkpoints are rendered on an interactive OpenStreetMap layer.

Pre-departure phase: Tap "Synthesize Sensory Field Briefing" and local Gemma 3 generates sensory landmark anchors in milliseconds. Tap "Listen & Pocket Phone" and the speech player reads it aloud. The user then puts their phone in their pack.

Emergency phase: If something goes wrong, switch to the WFR tab. Even in airplane mode, you get calm, step-by-step first aid protocols, critical contraindications (what not to do), evacuation urgency assessment, and rescue signal guidance.

Technical Architecture: 100% Local, Zero Cloud

TerraGemma is built with Python and Streamlit, designed for offline execution on consumer hardware. Several architectural decisions stand out as pragmatic tradeoffs for edge inference:

  • Local open-weight AI: The primary model is gemma3:1b (~815 MB), completing inference in ~500ms on a standard laptop CPU — fast enough for instant briefings without draining the battery. More complex wilderness first aid and plant identification calls use gemma3:4b for deeper reasoning. Models connect via Ollama's local HTTP API, with keep_alive: 60m to keep weights resident in memory.
  • Deterministic NOAA Solar & Naismith Engine: A pure Python implementation of the NOAA solar algorithm (official sunset at 90.833° zenith angle, civil twilight at 96°) with no dependency on any astronomy C libraries. Naismith's Rule adds 1 hour per 2,000 feet of elevation gain on top of base pace, plus a safety buffer.
  • Offline Web Speech API Synthesizer: Calls window.speechSynthesis via a self-contained HTML/JS component, synthesizing speech locally in the user's browser — no external cloud TTS required.
  • Geospatial Mapping: Renders OpenStreetMap tiles using folium and streamlit-folium.

The elegance of this architecture lies in the separation of deterministic computation (solar calculations, turnaround times, maps) from generative reasoning (sensory landmarks, first aid, species identification). The former has zero dependencies and is absolutely reliable; the latter is handled by the local LLM, backed by a heuristic fallback engine for zero downtime.

Ollama is an open-source local LLM runtime that lets developers download and run open-weight models like Llama, Gemma, and Mistral on their own devices — no complex Python environment or GPU driver setup required. It exposes a local HTTP endpoint compatible with the OpenAI API (default http://localhost:11434), allowing developers to switch between cloud APIs and local models with nearly identical code. The keep_alive: 60m parameter keeps model weights resident in memory for 60 minutes after first load, avoiding repeated disk loads for each query (cold starts can take tens of seconds on CPU) — critical for fast-response wilderness emergency scenarios. Quantization is the technique of compressing model weights from 32-bit floats to 4-bit or 8-bit integers, trading a slight accuracy loss for dramatic gains in memory efficiency and inference speed. It's the key reason Gemma 3 1B can achieve sub-second inference on a standard laptop.

Why Open Source and Edge Deployment Are Non-Negotiable Here

The author's argument is highly compelling in an outdoor context. Relying on a closed-source cloud API in a coffee shop is convenient enough — but in the wilderness, a closed-source API equals 100% failure.

Zero-connectivity resilience comes first: once you cross the trailhead into a national park, canyon, or alpine pass, signal drops to zero. Cloud APIs become endless loading spinners, while open-weight models like Gemma 3 run natively on edge devices.

Privacy is another critical consideration. Commercial hiking apps routinely package high-precision GPS tracks, departure times, and personal health metrics to sell to data brokers. TerraGemma runs entirely locally — coordinates, route notes, and first aid symptoms never leave your device.

Cost: closed-source APIs charge per token and impose rate limits. For a multi-day backpacking trip, an open-weight model costs $0.00, never hits a rate limit, and can run indefinitely. Gemma 3 (1B) uses under 1 GB of memory and completes inference in hundreds of milliseconds, without draining the battery you need for survival navigation — this is the real-world value of edge-quantized models.

Edge deployment means running an AI model directly on an end-user device (phone, laptop, embedded hardware) rather than calling a remote server over the network. This contrasts with mainstream cloud AI services, where every inference request makes a round trip to a data center — latency and availability are entirely dependent on network connectivity. The tradeoff is that model capability is constrained by local compute, which has driven the development of small-parameter models (1B–7B) and quantization techniques optimized for the edge. In the extreme scenario of wilderness use, edge deployment shifts from "an optional performance optimization" to "a prerequisite for the system to work at all" — which is exactly why TerraGemma chose a 1B model over a higher-accuracy 70B model. The latter simply cannot run offline on consumer hardware.

A Few Thoughts

TerraGemma is a Week 1 submission to the Hacktoberfest Open Source AI Challenge (theme: "Touch Grass"), with complete source code released under the MIT license on GitHub. It isn't a technical breakthrough, but it demonstrates a consistently underappreciated direction: the real value of edge AI often isn't parameter count — it's still being available where the cloud fails.

Using a small 1B model for offline-critical scenarios like outdoor safety is a far better fit for real-world needs than blindly chasing larger cloud models. Whether or not it wins a prize, projects like this remind developers that offline capability, privacy, and zero cost form a moat that closed-source cloud services simply cannot cross in certain scenarios.

#TerraGemma#offline AI hiking companion#Gemma 3 edge deployment#wilderness navigation app#offline LLM#edge AI#Ollama local model#WFR triage app#NOAA solar calculator#open source hiking AI
Share:

Related articles