metadata
license: apache-2.0
tags:
- image-classification
- pytorch
- computer-vision
- ocr
- crossed-out-text
library_name: pytorch
pipeline_tag: image-classification
crossed-out-text-classifier
Model Description
This is a ResNet18-based binary classifier trained to detect crossed out text in OCR images. The model classifies images into two categories:
no
: Text is not crossed outyes
: Text is crossed out
Model Details
- Architecture: ResNet18 with modified classification head
- Parameters: 11,187,158
- Input Size: 224x224 RGB images
- Classes: ['no', 'yes']
- Validation Accuracy: 0.9688
- Training Framework: PyTorch
Usage
Using the model directly
import torch
from PIL import Image
import torchvision.transforms as transforms
# Load model
model = torch.load('pytorch_model.bin', 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])
])
image = Image.open('your_image.png').convert('RGB')
input_tensor = transform(image).unsqueeze(0)
# Make prediction
with torch.no_grad():
outputs = model(input_tensor)
probabilities = torch.nn.functional.softmax(outputs, dim=1)
predicted_class = torch.argmax(probabilities, dim=1).item()
confidence = torch.max(probabilities, dim=1)[0].item()
class_names = ['no', 'yes']
print(f"Prediction: {class_names[predicted_class]} (confidence: {confidence:.4f})")
Using the inference module
from src.inference import CrossedOutPredictor
# Initialize predictor
predictor = CrossedOutPredictor()
predictor.load_model('pytorch_model.bin')
# Make prediction
prediction, confidence = predictor.predict_image('your_image.png')
print(f"Prediction: {prediction} (confidence: {confidence:.4f})")
Training Data
The model was trained on a dataset of OCR images with crossed out and non-crossed out text. The training used:
- Data augmentation including rotation, scaling, shearing, and color jittering
- Transfer learning from ImageNet pretrained ResNet18
- Two-phase training: frozen backbone followed by full fine-tuning
Limitations
- The model is specifically designed for OCR images and may not generalize well to other image types
- Performance may vary with different text fonts, sizes, or crossing-out patterns
- Trained on specific image resolution (224x224) and normalization
Intended Use
This model is intended for:
- OCR post-processing pipelines
- Document analysis systems
- Text validation workflows
License
This model is released under the Apache 2.0 license.
Citation
If you use this model, please cite:
@misc{Sleeeepy_crossed_out_text_classifier,
title={Crossed Out Text Classifier},
author={Your Name},
year={2025},
howpublished={\url{https://huggingface.co/Sleeeepy/crossed-out-text-classifier}}
}