Mangaba Carros BR
Brazilian car market classifier
2 min readupdated
The model recognizes 106 popular car models in the Brazilian market (including Onix, HB20, T-Cross, BYD Dolphin, and others) from a photograph. The solution is a lightweight classification head built on top of a frozen CLIP ViT-L/14-336 multimodal backbone (base model by OpenAI, weight file size only 324 KB). The development outperforms the standard CLIP zero-shot approach and is well-suited for car analytics tasks, working with video streams using object detectors, or sorting photo archives.
Key features
- High accuracy: the top-1 metric on validation reaches 87.6% compared to 52.2% for pure CLIP.
- Wide coverage: support for 106 different car models based on a dataset from Wikimedia Commons.
- Regularization during training: preserves zero-shot behavior for classes with a small number of examples.
- Minimal size: the weights consist only of the final layer (head.safetensors) with a size of 324 KB.
What you can do
- Video analysis: use in combination with a vehicle detector (for example, Faster R-CNN) to recognize car brands in traffic flow.
- Photo sorting: automatically classify car photographs in exterior shots.
- Pipeline integration: integrate the ready-made Python script using transformers and safetensors into your own application.
Example
import torch, json
from PIL import Image
from safetensors.torch import load_file
from huggingface_hub import hf_hub_download
from transformers import CLIPModel, CLIPProcessor
repo = "mangaba-ai/Mangaba-Carros-BR"
cfg = json.load(open(hf_hub_download(repo, "config.json")))
head = load_file(hf_hub_download(repo, "head.safetensors"))
clip = CLIPModel.from_pretrained(cfg["base_model"]).eval()
proc = CLIPProcessor.from_pretrained(cfg["base_model"])
with torch.no_grad():
e = clip.get_image_features(**proc(images=Image.open("carro.jpg").convert("RGB"), return_tensors="pt"))
e = e if torch.is_tensor(e) else e.pooler_output
e = torch.nn.functional.normalize(e, dim=-1)
p = torch.softmax(cfg["logit_scale"] * e @ head["weight"].T + head["bias"], -1)[0]
for s, i in zip(*p.topk(3)):
print(cfg["labels"][i], f"{s:.0%}")Read more
DetailsBenchmarks: top-1 87.6%, top-5 98.6% on a validation set of 1,038 photos.
Training: 300 AdamW optimizer steps on precomputed embeddings.
Limitations: identifies only the car model (without year and trim); requires clear exterior images.
Hardware requirements: minimal thanks to the frozen CLIP backbone.










Comments