Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,46 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: microsoft/resnet-50
|
3 |
+
datasets:
|
4 |
+
- 0-ma/geometric-shapes
|
5 |
+
license: apache-2.0
|
6 |
+
metrics:
|
7 |
+
- accuracy
|
8 |
+
pipeline_tag: image-classification
|
9 |
+
---
|
10 |
+
|
11 |
+
# Model Card for Resnet Geometric Shapes Dataset
|
12 |
+
|
13 |
+
## Training Dataset
|
14 |
+
|
15 |
+
- **Repository:** https://huggingface.co/datasets/0-ma/geometric-shapes
|
16 |
+
|
17 |
+
## Base Model
|
18 |
+
|
19 |
+
- **Repository:** https://huggingface.co/models/microsoft/resnet-50
|
20 |
+
|
21 |
+
## Accuracy
|
22 |
+
|
23 |
+
- Accuracy on dataset 0-ma/geometric-shapes [test] : 0.7828571428571428
|
24 |
+
|
25 |
+
# Loading and using the model
|
26 |
+
import numpy as np
|
27 |
+
from PIL import Image
|
28 |
+
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
29 |
+
import requests
|
30 |
+
labels = [
|
31 |
+
"Only text",
|
32 |
+
"Circle",
|
33 |
+
"Triangle",
|
34 |
+
"Square",
|
35 |
+
"Pentagon",
|
36 |
+
"Hexagon"
|
37 |
+
]
|
38 |
+
images = [Image.open(requests.get("https://raw.githubusercontent.com/0-ma/geometric-shape-detector/main/input/exemple_circle.jpg", stream=True).raw),
|
39 |
+
Image.open(requests.get("https://raw.githubusercontent.com/0-ma/geometric-shape-detector/main/input/exemple_pentagone.jpg", stream=True).raw)]
|
40 |
+
feature_extractor = AutoImageProcessor.from_pretrained('0-ma/resnet-geometric-shapes')
|
41 |
+
model = AutoModelForImageClassification.from_pretrained('0-ma/resnet-geometric-shapes')
|
42 |
+
inputs = feature_extractor(images=images, return_tensors="pt")
|
43 |
+
logits = model(**inputs)['logits'].cpu().detach().numpy()
|
44 |
+
predictions = np.argmax(logits, axis=1)
|
45 |
+
predicted_labels = [labels[prediction] for prediction in predictions]
|
46 |
+
print(predicted_labels)
|