DEV Community

Jesus Manuel Garcia Torres
Jesus Manuel Garcia Torres

Posted on

Guardabosque: an offline nature guide for Tabasco's jungles, powered by Gemma running on my laptop

Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass Submission 🌿

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass

What I Built

I live in Villahermosa, Tabasco, in southeastern Mexico. We're surrounded by wetlands, rivers, jungle reserves and city parks full of toucans, iguanas, herons and plants most of us can't name. But the moment you walk into Pantanos de Centla or the trails of Agua Blanca, your phone signal disappears, and so does every "identify this plant" app that depends on the cloud.

Guardabosque ("forest ranger" in Spanish) is a nature guide that works with no internet at all:

  1. Your laptop runs Gemma 4 locally through Ollama and serves a small web app.
  2. Your phone connects to the laptop over a local hotspot (no data plan needed) and opens the app.
  3. You snap a photo of a bird, plant or insect. Gemma identifies it, tells you what else to look for nearby, warns you if it's dangerous (snakes, stinging plants, crocodiles: this is Tabasco), and gives you a 5–10 minute field quest so you keep walking instead of scrolling.
  4. A Mission tab generates a short walk for real Tabasco places (Parque Tomás Garrido, La Venta, Yumká, Pantanos de Centla, Agua Blanca, Kolem Jaa', Grutas de Coconá, or just your neighborhood park), with steps you check off as you go.
  5. A field journal saves what you found, with a thumbnail, on your own machine.

The design goal was simple: the screen should be the shortest part of the experience. Take a photo, read for ten seconds, put the phone away.

It's for families, students and anyone in the southeast who wants to know what they're looking at, especially the kids in our STEAM-HER community who are starting to explore science and tech.

Demo

Guardabosque identifying palm fruit from a ranch in Cárdenas, Tabasco

Last week I was at a ranch in Cárdenas, Tabasco and photographed a pile of green fruit that had fallen under the trees. Nobody around was sure what it was. Back home, I ran that photo through Guardabosque. Gemma recognized it as tropical palm fruit, described the oblong, rough-skinned fruit and the jungle setting, and added the one safety note that actually matters: don't eat it without an expert identification, because some tropical plants are toxic. Then it gave me a field quest: walk slowly along the trail and look at the mosses and ferns growing at the base of the trees.

That last part is the whole point. Instead of "here's a Wikipedia summary, keep scrolling", it sends you back out to look at something else.

Here's a real response from Gemma 4 running on my M1 Pro, for a photo of a keel-billed toucan:

{
  "kind": "bird",
  "commonName": "Tucán",
  "scientificName": "Ramphastos",
  "confidence": "high",
  "description": "Es un ave grande con un cuerpo predominantemente negro. Su característica más notable es su pico grande y colorido, que presenta tonos verdes, rojos y amarillos.",
  "lookFor": [
    "Busca aves con picos grandes y coloridos.",
    "Observar el comportamiento de alimentaciĂłn en el dosel del bosque.",
    "Escuchar sus llamadas distintivas."
  ],
  "safety": "",
  "fieldQuest": "Camina lentamente por los senderos permitidos, observando la diversidad de aves en el dosel del bosque durante diez minutos."
}
Enter fullscreen mode Exit fullscreen mode

Each photo takes about 30 seconds on a 16 GB M1 Pro once the model is warm. On a trail, that's fine: you take the photo and keep looking around while it thinks.

Code

GitHub logo gartox / guardabosque

Offline nature guide for Tabasco, Mexico: identify plants and wildlife from a photo with Gemma running locally via Ollama. No internet needed.

Guardabosque

Guardabosque is an offline nature guide for people exploring Tabasco, Mexico. It uses an open-weight Gemma model running locally through Ollama to identify a plant, bird, insect, or other organism from a phone photo, suggest what to observe, and create a short field mission that gets people walking again.

It is designed for parks, wetlands, forests, and neighborhoods where mobile coverage is unreliable. Photos stay on the local device and laptop, there is no service cost, and the model can be changed with GUARDABOSQUE_MODEL.

Requirements

  • Node.js 24 or newer
  • Ollama running on the laptop
  • A Gemma model available locally

Run it

ollama pull gemma4:e4b-it-qat
npm start
Enter fullscreen mode Exit fullscreen mode

Open the printed network URL from a phone connected to the same Wi-Fi network or to a hotspot hosted by the phone or laptop. The laptop runs the server and Ollama; the phone is the field interface.

Useful configuration defaults are:

PORT=3000
…

How I Built It

  • Model: Gemma 4 E4B (gemma4:e4b-it-qat), Google's open-weight multimodal model, in its quantization-aware 6.1 GB build. It reads the photo and answers in Spanish.
  • Local inference: Ollama on the laptop. Nothing leaves the device.
  • App: Node.js with zero dependencies. Just node:http, node:fs and node:test. If the whole point is that it works without internet, I didn't want a npm install step that needs it. The frontend is plain HTML, CSS and JavaScript, installable as a PWA, mobile first, with high contrast so you can read it in full sun.
  • Safety by design: the model's output is treated as untrusted data. The server validates and normalizes every field (unknown values fall back to safe defaults, long text is trimmed), the UI never renders model text as HTML, and the prompt tells Gemma to ignore any instructions written inside a photo.
  • Tests: 12 tests with a fake Ollama server, covering broken JSON from the model, adversarial output with HTML and extra fields, oversized uploads, path traversal and Ollama being offline.

Two things I learned the hard way

1. Structured output isn't guaranteed. My first version asked Ollama to enforce a JSON schema with the format parameter. On my Homebrew build, the MLX engine returned 501 Not Implemented for structured output, and a different build silently ignored the schema and answered in prose. The fix: always describe the schema in the prompt too, extract the JSON even if it's wrapped in markdown, retry once, and remember when a server doesn't support format so you don't pay for the 501 on every request.

2. Pick the model size for the machine you have. The default gemma4:e4b tag pulled a 9.5 GB build, and with Docker running my 16 GB Mac hit 30 GB of swap; a single photo took more than three minutes. Switching to the 6.1 GB QAT build brought it down to about 30 seconds with similar answers. With open weights you choose the trade-off yourself instead of taking whatever a vendor serves.

Why Does Open Innovation Matter?

  • It works where we actually go outside. Pantanos de Centla, Kolem Jaa' and the Sierra de Tabasco have little or no signal. A cloud API is useless there; a model on my laptop works.
  • Photos stay with you. Pictures of your kids at the park, your backyard or a protected area never go to someone else's server.
  • It costs nothing to run. No API key and no per-photo bill, so a school, a community group or a park ranger can use it all day.
  • I can change the model. One environment variable (GUARDABOSQUE_MODEL) swaps Gemma for any other model in Ollama. When I needed a lighter build for my laptop, I switched in minutes. With a closed API I'd have been stuck with whatever was offered.
  • Anyone can adapt it. It's MIT licensed with no dependencies. Someone in Chiapas or the Yucatán can fork it, swap in their own places and run it tomorrow.

Prize Categories

  • Best Use of Gemma: Gemma 4 E4B, running fully locally and multimodal, is the core of the project.

Built by @gartox.

Top comments (0)