Local AI Image Classifier
Contents
Local AI Image Classifier
Classify images by description — no cloud API needed, everything runs locally.
How it works
Uses OpenAI CLIP to compute similarity between an image and a list of text labels. The highest-scoring label wins.
from PIL import Image
import clip, torch
model, preprocess = clip.load("ViT-B/32")
image = preprocess(Image.open("photo.jpg")).unsqueeze(0)
labels = ["a cat", "a dog", "a car", "a tree"]
text = clip.tokenize(labels)
with torch.no_grad():
logits, _ = model(image, text)
probs = logits.softmax(dim=-1)
best = labels[probs.argmax()]
print(f"Predicted: {best}")Interface
Flask-based web UI. Drop an image, enter labels, get a classification.
Status
v0.1.0 — proof of concept. Works on CPU, slow on large batches.

