Quickstart & Recipes
Practical minimal code recipes for Python, Node.js, and CLI workflows
Recipe 1: Multimodal VLM Image Chat (Python)
import termux_vision as tv
# Load VLM Engine (Auto Vulkan GPU with CPU fallback)
with tv.vlm.load(model_id="smolvlm-500m-q4", device="auto") as engine:
result = engine.describe(
"photo.jpg",
prompt="이 사진 속 인물과 배경을 요약 설명해줘.",
max_tokens=150
)
print(f"[Result]: {result.text}")
print(f"[Speed]: {result.metrics.tokens_per_second:.1f} t/s")
Recipe 2: Multimodal VLM Image Chat (Node.js)
const tv = require('termux-vision');
async function main() {
const engine = await tv.vlm.load({
modelId: 'smolvlm-500m-q4',
device: 'auto'
});
const res = await engine.describe('photo.jpg', {
prompt: 'Explain what is happening in this image.'
});
console.log(`[Result]: ${res.text}`);
console.log(`[Decode]: ${res.metrics.decodeMs} ms`);
}
main();
Recipe 3: Classical Canny Edge Detection (Python)
import termux_vision as tv
# Load, resize, and convert to grayscale
img = tv.io.load_image("input.jpg")
gray = tv.transforms.to_grayscale(tv.transforms.resize(img, (512, 512)))
# Execute 5-stage Canny Edge Detection
edges = tv.cv.canny(gray, low_threshold=40.0, high_threshold=120.0)
tv.io.save_image(edges, "edges.png")
print("Edges saved to edges.png")
Recipe 4: Haar Cascade Face Detection
import termux_vision as tv
img = tv.io.load_image("selfie.jpg")
detections = tv.detect.detect_faces(img)
print(f"Found {len(detections)} candidate face regions:")
for d in detections:
print(f" - BBox: {d.bbox.to_xywh()} (Score: {d.score})")