0-ma's picture
Update README.md
f249d1f verified
|
raw
history blame
1.8 kB
---
base_model: microsoft/beit-base-patch16-224-pt22k-ft22k
datasets:
- 0-ma/geometric-shapes
license: apache-2.0
metrics:
- accuracy
pipeline_tag: image-classification
---
# Model Card for VIT Geometric Shapes Dataset Tiny
## Training Dataset
- **Repository:** https://huggingface.co/datasets/0-ma/geometric-shapes
## Base Model
- **Repository:** https://huggingface.co/models/microsoft/beit-base-patch16-224-pt22k-ft22k
## Accuracy
- Accuracy on dataset 0-ma/geometric-shapes [test] : ????
# Loading and using the model
import numpy as np
from PIL import Image
from transformers import AutoImageProcessor, AutoModelForImageClassification
import requests
labels = [
"None",
"Circle",
"Triangle",
"Square",
"Pentagon",
"Hexagon"
]
images = [Image.open(requests.get("https://raw.githubusercontent.com/0-ma/geometric-shape-detector/main/input/exemple_circle.jpg", stream=True).raw),
Image.open(requests.get("https://raw.githubusercontent.com/0-ma/geometric-shape-detector/main/input/exemple_pentagone.jpg", stream=True).raw)]
feature_extractor = AutoImageProcessor.from_pretrained('0-ma/beit-geometric-shapes-base')
model = AutoModelForImageClassification.from_pretrained('0-ma/beit-geometric-shapes-base')
inputs = feature_extractor(images=images, return_tensors="pt")
logits = model(**inputs)['logits'].cpu().detach().numpy()
predictions = np.argmax(logits, axis=1)
predicted_labels = [labels[prediction] for prediction in predictions]
print(predicted_labels)
## Modfel generation
The model has been created using the 'train_shape_detector.py.py' of the project from the project https://github.com/0-ma/geometric-shape-detector. No external code sources were used.