Image-Text-to-Text
MLX
Safetensors
qwen3_5
clairic
cloudflare
systemone
structured-output
information-extraction
multimodal
custom-code
conversational
4-bit precision
Instructions to use mlx-community/clairic-flash-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/clairic-flash-4bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("mlx-community/clairic-flash-4bit") config = load_config("mlx-community/clairic-flash-4bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/clairic-flash-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-flash-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/clairic-flash-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use mlx-community/clairic-flash-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-flash-4bit"
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 mlx-community/clairic-flash-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/clairic-flash-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-flash-4bit"
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 "mlx-community/clairic-flash-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download clairic_runtime/orientation.py from mlx-community/clairic-flash-4bit: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/orientation.py
- Command line
-
hf download hf://mlx-community/clairic-flash-4bit/clairic_runtime/orientation.py
-
curl -L -o orientation.py https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/orientation.py
3.18 kB
| """Conservative page orientation from detached dots beside Latin letter stems. | |
| This examines glyph geometry only; it performs no text readout. Pages without | |
| enough consistent evidence retain their supplied orientation. | |
| """ | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from PIL import Image | |
| def document_rotation(image: Image.Image) -> tuple[int, list[int]]: | |
| import cv2 | |
| import numpy as np | |
| page = image.convert("L") | |
| page.thumbnail((1600, 1600)) | |
| pixels = np.asarray(page) | |
| _, ink = cv2.threshold(pixels, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU) | |
| _, _, stats, _ = cv2.connectedComponentsWithStats(ink, connectivity=8) | |
| stats = stats[1:] | |
| votes = [0, 0, 0, 0] | |
| if not len(stats) or len(stats) > 12_000: | |
| return 0, votes | |
| width, height, area = stats[:, 2:].T | |
| short, long = np.minimum(width, height), np.maximum(width, height) | |
| stems = stats[(long >= 9) & (long <= 60) & (long >= 2.5 * short) & (area >= 8)] | |
| dots = stats[(width <= 12) & (height <= 12) & (area >= 2) & (area <= 100)] | |
| if not len(stems) or not len(dots) or len(stems) > 1200 or len(dots) > 2400: | |
| return 0, votes | |
| dx, dy, dw, dh, da = dots.T | |
| for sx, sy, sw, sh, sa in stems: | |
| vertical = sh > sw | |
| across = dx + dw / 2 if vertical else dy + dh / 2 | |
| center = sx + sw / 2 if vertical else sy + sh / 2 | |
| start, length = (sy, sh) if vertical else (sx, sw) | |
| left, size = (dy, dh) if vertical else (dx, dw) | |
| thin = sw if vertical else sh | |
| aligned = (abs(across - center) <= max(1.5, thin * 0.6)) & ( | |
| size <= length * 0.4 | |
| ) | |
| aligned &= (dw <= max(3, thin * 2)) if vertical else (dh <= max(3, thin * 2)) | |
| aligned &= da < sa * 0.7 | |
| before = ( | |
| aligned & (left + size <= start) & (start - left - size <= length * 0.45) | |
| ) | |
| after = ( | |
| aligned | |
| & (left >= start + length) | |
| & (left - start - length <= length * 0.45) | |
| ) | |
| if vertical: | |
| votes[0] += int(np.any(before)) | |
| votes[2] += int(np.any(after)) | |
| else: | |
| votes[1] += int(np.any(before)) | |
| votes[3] += int(np.any(after)) | |
| letters = (area >= 10) & (short >= 3) & (long <= 60) & (long <= 4 * short) | |
| if int(letters.sum()) < 80: | |
| return 0, votes | |
| aspect = float(np.median(width[letters] / height[letters])) | |
| if aspect < 0.8: | |
| directions = (0, 2) | |
| elif aspect > 1.25: | |
| directions = (1, 3) | |
| else: | |
| return 0, votes | |
| # Text-line direction excludes accidental dot/stem pairs in the other axis. | |
| winner = max(directions, key=votes.__getitem__) | |
| runner = votes[directions[0] if winner == directions[1] else directions[1]] | |
| if ( | |
| votes[winner] < 12 | |
| or votes[winner] < 3 * max(1, runner) | |
| or votes[winner] < 0.7 * (votes[winner] + runner) | |
| ): | |
| return 0, votes | |
| return winner * 90, votes | |
| def orient_document(image: Image.Image) -> Image.Image: | |
| rotation, _ = document_rotation(image) | |
| return image.rotate(-rotation, expand=True) if rotation else image | |