HuggingFaceM4/ChartQA
Viewer • Updated • 32.7k • 13.8k • 65
This is a fine-tuned ResNet-18 model trained for binary image classification, distinguishing between diagrams and non-diagrams. The model is designed for use in applications that need automatic filtering or processing of diagram-based content.
microsoft/resnet-18This model is intended for classifying images as diagrams or non-diagrams. It can be used in:
Users should evaluate the model on their specific dataset before deployment to ensure it performs well in their context.
You can download the model and load it using torch.
import torch
from huggingface_hub import hf_hub_download
# Download model from Hugging Face Hub
model_path = hf_hub_download(repo_id="Ayamohamed/DiaClassification", filename="model.pth")
# Load model
model_hg = torch.load(model_path)
model_hg.eval() # Set to evaluation mode
from PIL import Image
from torchvision import transforms
# Define Image Transformations
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
def predict(image_path):
image = Image.open(image_path).convert("RGB")
image = transform(image).unsqueeze(0)
with torch.no_grad():
output = model_hg(image)
class_idx = torch.argmax(output, dim=1).item()
return "Diagram" if class_idx == 0 else "Not Diagram"
# Example usage
print(predict("my-diagram-classifier/31188_1536932698.jpg"))
The model was trained using:
microsoft/resnet-18If you use this model, please cite:
@misc{aya2025diaclass,
author = {Aya Mohamed},
title = {Diagram Classification Model},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/Ayamohamed/diaclass-model}
}
Base model
microsoft/resnet-18