Image-Text-to-Text
PEFT
Safetensors
GGUF
microscopy
vision-language
diatoms
fungal-spores
biology
bioindicator
gemma-4
unsloth
qlora
multimodal
on-device
offline
conversational
Instructions to use Laborator/microlens-final with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Laborator/microlens-final with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-4-e2b-it-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "Laborator/microlens-final") - llama-cpp-python
How to use Laborator/microlens-final with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Laborator/microlens-final", filename="mmproj.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Laborator/microlens-final with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Laborator/microlens-final # Run inference directly in the terminal: llama cli -hf Laborator/microlens-final
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Laborator/microlens-final # Run inference directly in the terminal: llama cli -hf Laborator/microlens-final
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Laborator/microlens-final # Run inference directly in the terminal: ./llama-cli -hf Laborator/microlens-final
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Laborator/microlens-final # Run inference directly in the terminal: ./build/bin/llama-cli -hf Laborator/microlens-final
Use Docker
docker model run hf.co/Laborator/microlens-final
- LM Studio
- Jan
- vLLM
How to use Laborator/microlens-final with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Laborator/microlens-final" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Laborator/microlens-final", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Laborator/microlens-final
- Ollama
How to use Laborator/microlens-final with Ollama:
ollama run hf.co/Laborator/microlens-final
- Unsloth Studio
How to use Laborator/microlens-final with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Laborator/microlens-final to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Laborator/microlens-final to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Laborator/microlens-final to start chatting
- Pi
How to use Laborator/microlens-final with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Laborator/microlens-final
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Laborator/microlens-final" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Laborator/microlens-final with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Laborator/microlens-final
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Laborator/microlens-final
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use Laborator/microlens-final with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf Laborator/microlens-final
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "Laborator/microlens-final" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use Laborator/microlens-final with Docker Model Runner:
docker model run hf.co/Laborator/microlens-final
- Lemonade
How to use Laborator/microlens-final with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Laborator/microlens-final
Run and chat with the model
lemonade run user.microlens-final-{{QUANT_TAG}}List all available models
lemonade list
File size: 6,887 Bytes
5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed 8fc5d75 a4770bc 8fc5d75 a4770bc 8fc5d75 b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed 8e7ec19 5ca94ed b125e41 5ca94ed b125e41 8e7ec19 b125e41 5ca94ed b125e41 5ca94ed b125e41 5ca94ed b125e41 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | ---
license: apache-2.0
base_model: unsloth/gemma-4-E2B-it
library_name: peft
pipeline_tag: image-text-to-text
tags:
- microscopy
- vision-language
- diatoms
- fungal-spores
- biology
- bioindicator
- gemma-4
- unsloth
- qlora
- multimodal
- on-device
- offline
datasets:
- sergheibrinza/microlens-vqa-hackathon
- sergheibrinza/microlens-images-hackathon
language:
- en
- de
- fr
- es
- it
- pt
- ru
- zh
- ja
- ko
---
# MicroLens — Final
**A pocket-microscope expert.** Vision-language model that identifies microscopy specimens — diatoms and fungal spores across 95 genera — names the genus, and explains morphology, habitat, and identification cues. Built on Gemma 4 E2B, runs offline on a 4 GB Android, speaks 140+ languages out of the box.
Submission to the **Kaggle Gemma 4 Good Hackathon 2026**.
## Demo video
### 🎬 [Watch the 90-second demo on YouTube](https://youtu.be/r1GIi4EukVg)
[](https://youtu.be/r1GIi4EukVg)
<a href="https://youtu.be/r1GIi4EukVg"><img src="https://img.youtube.com/vi/r1GIi4EukVg/hqdefault.jpg" alt="MicroLens demo — click to play on YouTube" width="640"/></a>
*Base Gemma 4 vs MicroLens on real diatom and fungal-spore specimens.*
## Links
| Resource | URL |
|---|---|
| Live web demo | https://huggingface.co/spaces/Laborator/microlens |
| Live Kaggle notebook (T4, 9 min) | https://www.kaggle.com/code/sergheibrinza/microlens-final |
| GitHub (source, APK, Modelfile) | https://github.com/SergheiBrinza/microlens |
| Training VQA dataset (75,491 pairs) | https://www.kaggle.com/datasets/sergheibrinza/microlens-vqa-hackathon |
| Training images (75,491 PNGs) | https://www.kaggle.com/datasets/sergheibrinza/microlens-images-hackathon |
| Ollama (3 GB GGUF) | `ollama run brinzaengineeringai/microlens-final` |
| Android APK | https://github.com/SergheiBrinza/microlens/releases |
## What this model is
A 4-bit QLoRA fine-tune of `unsloth/gemma-4-E2B-it` that turns a generic vision-language model into a structured microscopy assistant. For any specimen image, MicroLens returns four sections:
- **Genus** (and species when it is sure)
- **Morphology** — shape, size, raphe, frustule
- **Habitat** — where this organism typically lives
- **Identification cues** — what to look for in the image
Covers **95 genera** across two categories: diatoms (the standard bioindicator behind the EU Water Framework Directive) and fungal spores.
## Quick start (Python + Unsloth)
```python
from unsloth import FastVisionModel
from peft import PeftModel
from PIL import Image
import torch
base, tokenizer = FastVisionModel.from_pretrained(
'unsloth/gemma-4-E2B-it',
load_in_4bit=True,
use_gradient_checkpointing='unsloth',
max_seq_length=2048,
)
model = PeftModel.from_pretrained(base, 'Laborator/microlens-final')
FastVisionModel.for_inference(model)
img = Image.open('your_specimen.png').convert('RGB')
prompt = 'Identify the organism in this microscopy image and describe its morphology.'
msgs = [{'role':'user','content':[{'type':'image'},{'type':'text','text':prompt}]}]
text = tokenizer.apply_chat_template(msgs, add_generation_prompt=True)
inp = tokenizer(img, text, add_special_tokens=False, return_tensors='pt').to('cuda')
out = model.generate(**inp, max_new_tokens=200, do_sample=False)
print(tokenizer.decode(out[0][inp.input_ids.shape[-1]:], skip_special_tokens=True))
```
## Quick start (Ollama, on-device)
```bash
ollama run brinzaengineeringai/microlens-final
```
Pulls the 3 GB Q4_K_M GGUF and runs entirely on CPU or any consumer GPU.
## Training summary
- **Base model:** `unsloth/gemma-4-E2B-it` (4.44 B parameters, ~2 B effective via Per-Layer Embeddings)
- **Method:** 4-bit QLoRA via Unsloth FastVisionModel, both vision tower and language tower trainable
- **Data:** 75,491 VQA pairs (67,121 train + 8,370 val), 95 genera, 2 categories
- **Schedule:** 2 epochs, 8,392 steps, lr 2e-4 cosine, batch 2×8=16, AdamW-8bit, bf16, seq 2048
- **Hardware:** 1× RTX 3090 Ti (24 GB), 14.7 hours wall-clock
- **Trainable params:** 29.9 M (0.58% of base), LoRA r=16, α=32
- **Final eval loss:** 0.0189 (smooth monotone decrease)
## Evaluation results
Stratified 200-pair validation, 150 diatom + 50 fungal spore.
| Metric | Diatom (n=150) | Fungal spore (n=50) | Overall (n=200) |
|---|---|---|---|
| **Genus accuracy** (substring match) | 85.3% | **100%** | **89.0%** |
| **Category accuracy** | 100% | 100% | **100%** |
| **Format adherence** (morphology + habitat + cues) | 95.3% | 72.0% | **89.5%** |
Reproducible end to end on a free Kaggle T4 in 9 minutes — see the linked Kaggle notebook.
## Training data — license-clean for commercial use
| Source | License | Pairs (train) |
|---|---|---|
| UDE Diatoms in the Wild 2024 (Zenodo 10410655) | CC0 | 39,389 |
| DIATLAS (Zenodo 16260887) | CC-BY 4.0 | 23,544 |
| TgFC — Tectona grandis fungal community (figshare 28855910) | CC-BY 4.0 | 4,188 |
Top-30 genera have hand-curated knowledge-base answers from AlgaeBase, WoRMS, ITIS. Only upstream sources whose licences unambiguously permit commercial reuse (CC0 or CC-BY 4.0) are included, so this release is clean for commercial use end to end.
## Honest limits
- Trained on stained light-microscopy at 384×384. SEM and fluorescence are out of distribution.
- Only 95 genera across two categories (diatoms + fungal spores). Anything else is out of distribution and the model output should be treated as ungrounded.
- Long-tail genera produce shorter answers. The curated knowledge base only covers the top 30.
- Confidence is expressed in words ("looks like X but the asymmetry suggests Y"), not calibrated probabilities. Good for an explainable assistant, bad for automated decisions.
- No held-out test split. The 8,370 val pairs do double duty for per-step and final eval. A future release will fix that.
- **Research artefact — not a medical device. Not for clinical, diagnostic, or regulatory use.**
## License & attribution
Apache 2.0 — matches base Gemma 4 license. Please credit *Serghei Brinza — MicroLens, Vienna 2026*.
## Citation
If you use MicroLens in research, please cite:
```bibtex
@misc{brinza2026microlens,
author = {Serghei Brinza},
title = {MicroLens: A Pocket-Microscope Expert via Gemma 4 E2B},
year = 2026,
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Laborator/microlens-final}},
note = {Kaggle Gemma 4 Good Hackathon 2026 submission}
}
```
Also cite the upstream:
- Gemma 4 (Google DeepMind)
- Unsloth (Daniel & Michael Han) — https://github.com/unslothai/unsloth
- AlgaeBase, WoRMS, ITIS — taxonomic knowledge bases
- UDE Diatoms in the Wild 2024 (Zenodo 10410655)
- DIATLAS (Zenodo 16260887)
- TgFC (figshare 28855910)
|