File size: 1,782 Bytes
0bce965
 
 
 
 
 
 
 
 
 
34a6f83
0bce965
 
 
 
 
 
 
 
 
 
 
8547cd4
0bce965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
base_model: google/mobilenet_v2_1.0_224
datasets:
- 0-ma/geometric-shapes
license: other
metrics:
- accuracy
pipeline_tag: image-classification
---

# Model Card for Mobilenet Geometric Shapes Dataset

## Training Dataset

- **Repository:** https://huggingface.co/datasets/0-ma/geometric-shapes

## Base Model

- **Repository:** https://huggingface.co/models/google/mobilenet_v2_1.0_224

## Accuracy

 - Accuracy on dataset 0-ma/geometric-shapes [test] : 0.7683333333333333

# 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/mobilenet-v2-geometric-shapes')
    model = AutoModelForImageClassification.from_pretrained('0-ma/mobilenet-v2-geometric-shapes')
    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)

## Model 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.