kahua-ml/nameplate-classification
Viewer • Updated • 4.28k • 20 • 1
This is a lightweight binary image classifier that determines whether an image contains a readable nameplate or not. The model is based on MobileNetV2 architecture and is optimized for industrial equipment nameplate detection.
no_nameplate (0): Image does not contain a readable nameplatehas_nameplate (1): Image contains a readable nameplateThe model was trained on the kahua-ml/nameplate-classification dataset, which contains:
import torch
import torchvision.transforms as transforms
from PIL import Image
# Load model
model = torch.load("model.pth", map_location='cpu')
model.eval()
# Prepare image
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
# Predict
image = Image.open("your_image.jpg")
input_tensor = transform(image).unsqueeze(0)
with torch.no_grad():
outputs = model(input_tensor)
probabilities = torch.nn.functional.softmax(outputs, dim=1)
predicted = torch.max(outputs, 1)[1].item()
confidence = probabilities[0][predicted].item()
result = "has_nameplate" if predicted == 1 else "no_nameplate"
print(f"Prediction: {result} (Confidence: {confidence:.3f})")
LightweightNameplateClassifier(
(backbone): MobileNetV2(
(classifier): Sequential(
(0): Dropout(p=0.2)
(1): Linear(in_features=1280, out_features=128)
(2): ReLU()
(3): Dropout(p=0.3)
(4): Linear(in_features=128, out_features=2)
)
)
)
If you use this model in your research, please cite:
@misc{kahua-nameplate-classifier,
title={Lightweight Nameplate Classifier},
author={Kahua ML Team},
year={2024},
howpublished={\url{https://huggingface.co/kahua-ml/nameplate-classifier}}
}