Jwalit/document-moire-detector
1278
Document Moiré Detection Model (V2)
A fine-tuned DeiT-small Vision Transformer for detecting moiré patterns in document images.
Model Description
Binary classifier: detects whether a document image contains moiré artifacts (common from screen photography, scanning, or screen captures).
Labels:
clean(0): No moiré patternsmoire(1): Moiré patterns detected
V1 → V2 Comparison
Note: V2 was evaluated on harder examples including subtle single-frequency moiré and localized moiré patterns that V1 never trained on. V2 achieves near-perfect recall (99.75%) — it catches virtually all moiré patterns including very subtle ones, at the cost of slightly lower precision.
Training Details
Moiré Generation Methods
- Resize aliasing — downscale+upscale with NEAREST interpolation + pattern overlay
- Pattern overlay — sinusoidal interference with per-channel color variation
- Multi-frequency — 2-4 patterns at different frequencies + color displacement
- Screen simulation — pixel grid + rotation + moiré overlay
- Subtle moiré — very low strength single-frequency (hard examples)
- Localized moiré — moiré in elliptical region with gaussian mask
Performance (Best Checkpoint)
Training Progression
Usage
from transformers import pipeline
classifier = pipeline("image-classification", model="Jwalit/document-moire-detector")
result = classifier("path/to/document.jpg")
print(result)
# [{'label': 'clean', 'score': 0.99}, {'label': 'moire', 'score': 0.01}]Or manually:
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
processor = AutoImageProcessor.from_pretrained("Jwalit/document-moire-detector")
model = AutoModelForImageClassification.from_pretrained("Jwalit/document-moire-detector")
image = Image.open("document.jpg")
inputs = processor(image, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
predicted = logits.argmax(-1).item()
print(model.config.id2label[predicted]) # 'clean' or 'moire'Limitations
- Trained on synthetic moiré patterns — may not capture all real-world moiré variations
- Optimized for document images; performance on natural scene images may vary
- Input images resized to 224×224; very subtle moiré in high-resolution images may be lost
- Higher recall than precision — may occasionally flag clean images as moiré (false positive rate ~1.5%)
