Image-Text-to-Text
Transformers
ONNX
Transformers.js
lfm2_vl
lfm2
vision
multimodal
food
calories
nutrition
conversational
Instructions to use opencal/opencal-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use opencal/opencal-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="opencal/opencal-base") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("opencal/opencal-base") model = AutoModelForMultimodalLM.from_pretrained("opencal/opencal-base", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Transformers.js
How to use opencal/opencal-base with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-text-to-text', 'opencal/opencal-base'); - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use opencal/opencal-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "opencal/opencal-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "opencal/opencal-base", "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/opencal/opencal-base
- SGLang
How to use opencal/opencal-base with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "opencal/opencal-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "opencal/opencal-base", "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 images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "opencal/opencal-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "opencal/opencal-base", "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" } } ] } ] }' - Docker Model Runner
How to use opencal/opencal-base with Docker Model Runner:
docker model run hf.co/opencal/opencal-base
File size: 3,232 Bytes
4ecaaf8 | 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 | ---
library_name: transformers
pipeline_tag: image-text-to-text
tags:
- lfm2
- vision
- multimodal
- food
- calories
- nutrition
- onnx
- transformers.js
license: apache-2.0
base_model: LiquidAI/LFM2.5-VL-450M
model-type: lfm2_vl
---
# OpenCal Base
**OpenCal Base** is a LFM2.5-VL-450M fine-tune that reads food photos (and text) and
outputs structured ingredient + gram-weight extractions aligned to the USDA food
database. It is exported to ONNX for the `@huggingface/transformers.js` browser
runtime (WebGPU / WASM / CPU).
## Model details
| Field | Value |
| --- | --- |
| Base model | [`LiquidAI/LFM2.5-VL-450M`](https://huggingface.co/LiquidAI/LFM2.5-VL-450M) |
| Fine-tune | LoRA, OpenCal v6 (gram-weight + kcal/macro target) |
| Architecture | `Lfm2VlForConditionalGeneration` (`model_type: lfm2_vl`) |
| Runtime | ONNX / transformers.js (WebGPU, WASM, CPU) |
| License | Apache-2.0 |
## Fine-tune summary
LoRA on top of the frozen base, merged weights. Target format is a JSON list of
`{name, grams, kcal, protein_g, carbs_g, fat_g}` extracted per item, with grams
normalized per 100 g and macros sourced from USDA data. The model is used by the
OpenCal app to turn a photo or a text description of a meal into per-item
nutrition.
### Benchmark results (OpenCal internal evals)
- **F101** (full meals, median gold kcal ≈ 293): kcal MAE **243**, WAPE **41.5%**,
within-50% of gold **70.4%**.
- **N5k** (lab samples, median gold kcal ≈ 43): ingredient-identity recall
baseline **76.4%**, this model **84.4%** (reference LLM **73.6%**).
## Usage (transformers.js)
```js
import { AutoModelForImageTextToText, AutoProcessor, RawImage } from '@huggingface/transformers';
const processor = await AutoProcessor.from_pretrained('OpenCal/opencal-base');
const model = await AutoModelForImageTextToText.from_pretrained('OpenCal/opencal-base', { dtype: 'auto', device: 'webgpu' });
const image = await RawImage.fromURL('https://example.com/meal.jpg');
const texts = ['List the ingredients and their amounts in grams'];
const { inputs } = await processor(image, texts, { return_tensor: false });
const { logits } = await model(inputs);
const decoded = processor.batch_decode(logits[1].id); // [1] for single sample
console.log(decoded[0]);
```
## File layout (ONNX)
The model is split into the standard LFM2.5-VL ONNX components. The suffix of each
weight file selects the runtime/precision:
| File | Precision | Use |
| --- | --- | --- |
| `embed_tokens{,_fp16,_q4,_quantized}.onnx` | fp32 / fp16 / q4 / q8 | input embeddings (`input_ids → inputs_embeds`) |
| `decoder_model_merged{,_fp16,_q4,_q4f16}.onnx` | fp32 / fp16 / q4 / q4f16 | text decoder (main body) |
| `vision_encoder{,_fp16,_q4,_quantized}.onnx` | fp32 / fp16 / q4 / q8 | vision encoder |
- `q4f16` — MatMulNBits q4 weights with fp16 scales / KV cache (WebGPU production path).
- `quantized` (= q8, `MatMulNBits`) — WASM path.
- `fp16` — 16-bit WebGPU path.
`tokenizer.json`, `preprocessor_config.json`, `config.json`, and
`generation_config.json` are at the repository root.
## Citation / base model
This model derives from `LiquidAI/LFM2.5-VL-450M`. Please see the base repository
for the original weights and paper.
|