Quickstart & Execution Recipes
Standard usage patterns and rapid prototyping code
Basic Execution Recipe
import termux_vision as tv
# 1. 100% Vulkan GPU Canny Edge Detection (0.23ms) or NEON CPU (3.02ms)
img = tv.io.load_image("photo.jpg")
edges = tv.cv.canny(tv.transforms.to_grayscale(img), low_threshold=40, high_threshold=120, backend="auto")
tv.io.save_image(edges, "edges.png")
# 2. UltraFace SSD Neural Face Detection (11.94ms, 100% False-Positive Elimination)
detections = tv.detect.detect_faces(img, score_threshold=0.70, backend="auto")
for d in detections:
print(f"Face Box: {d.bbox.to_xywh()}, Confidence: {d.score * 100:.1f}%")
# 3. On-Device VLM Multimodal Inference with 5-Backend Hardware Acceleration
with tv.vlm.load("smolvlm-500m", device="gpu") as engine:
res = engine.describe("photo.jpg", prompt="Describe this scene in detail.", quality="optimal")
print(f"Generated ({res.metrics.tokens_per_second:.1f} t/s via {res.metrics.backend}): {res.text}")