Views
No views yet
import torch
from PIL import Image
from transformers import AutoImageProcessor
from transformers import AutoModelForImageClassification
image_processor = AutoImageProcessor.from_pretrained("aslakey/text_overlay_detection")
model = AutoModelForImageClassification.from_pretrained('aslakey/text_overlay_detection')
model.eval()
# Model labels: [clean_single, double, group, over_the_shoulder, insert, establishing]
image = Image.open('overlay.png')
inputs = image_processor(image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predicted_label = outputs.logits.argmax(-1).item()
print(model.config.id2label[predicted_label])| Class | Precision | Recall | F1-score |
|---|---|---|---|
| no_text_overlay | 0.97 | 0.99 | 0.98 |
| text_overlay | 0.99 | 0.97 | 0.98 |