nicholasKluge
commited on
Commit
•
e34d949
1
Parent(s):
86a2540
Update README.md
Browse files
README.md
CHANGED
@@ -9,27 +9,11 @@ metrics:
|
|
9 |
tags:
|
10 |
- image-classification
|
11 |
---
|
|
|
12 |
|
13 |
-
|
14 |
|
15 |
-
##
|
16 |
-
|
17 |
-
The LeNNon-Smile-Detector is a convolutional neural network trained to detect the presence of a human smile in a facial image.
|
18 |
-
|
19 |
-
### Details
|
20 |
-
|
21 |
-
- **Size:** 2,566,506 parameters
|
22 |
-
- **Model type:** Convolutional neural network
|
23 |
-
- **Optimizer**: `torch.optim.Adam` with a learning rate of 0.001
|
24 |
-
- **Number of Epochs:** 20
|
25 |
-
- **Batch Size:** 256
|
26 |
-
- **Hardware:** Tesla V4
|
27 |
-
- **Emissions:** Not measured
|
28 |
-
- **Total Energy Consumption:** Not measured
|
29 |
-
|
30 |
-
### How to Use
|
31 |
-
|
32 |
-
To run inference on this model, you can use the following code snippet:
|
33 |
|
34 |
```python
|
35 |
import torch
|
@@ -40,17 +24,17 @@ from huggingface_hub import hf_hub_download
|
|
40 |
|
41 |
# Download the pytorch model
|
42 |
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
# Download the source implementation of the model's architecture
|
49 |
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
# Check if GPU is available
|
56 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -62,8 +46,8 @@ model.eval()
|
|
62 |
|
63 |
# This `transform` object will transform our test images into proper tensors
|
64 |
transform = transforms.Compose([
|
65 |
-
|
66 |
-
|
67 |
])
|
68 |
|
69 |
image_path = "your_image_path_here"
|
@@ -76,56 +60,10 @@ tensor = tensor.to(device)
|
|
76 |
# forward pass trough the model
|
77 |
with torch.no_grad():
|
78 |
|
79 |
-
|
80 |
|
81 |
# Get the class prediction
|
82 |
_, predicted = torch.max(outputs.data, 1)
|
83 |
|
84 |
print("Smiling" if predicted.item() > 0 else "Not Smiling")
|
85 |
```
|
86 |
-
|
87 |
-
## Intended Use
|
88 |
-
|
89 |
-
This model was created for research purposes only. Specifically, it was designed to explore discriminatory biases present in a subset of the CelebA dataset (the [CelebA-Smiles](https://huggingface.co/datasets/AiresPucrs/CelebA-Smiles)). We do not recommend any application of this model outside this scope.
|
90 |
-
|
91 |
-
|
92 |
-
## Performance Metrics
|
93 |
-
|
94 |
-
The model achieved an accuracy of 97% in a test set split containing 5000 images from the [CelebA-Smiles](https://huggingface.co/datasets/AiresPucrs/CelebA-Smiles).
|
95 |
-
|
96 |
-
## Training Data
|
97 |
-
|
98 |
-
The model was trained on a subset of the [CelebA dataset](https://www.kaggle.com/datasets/jessicali9530/celeba-dataset), i.e., CelebA-Smiles.
|
99 |
-
|
100 |
-
CelebA-Smiles contains 50K images. 25K of smiling faces, and 25K of non smiling faces.
|
101 |
-
|
102 |
-
Images on the CelebA-Smiles were resized to 100 x 100 pixels before training the model. For more details on the features contained in the CelebA-Smiles dataset, check its [dataset card](https://huggingface.co/datasets/AiresPucrs/CelebA-Smiles).
|
103 |
-
|
104 |
-
## Limitations
|
105 |
-
|
106 |
-
We performed a simple fairness analysis of our model regarding the sensitive attribute **age**.
|
107 |
-
|
108 |
-
According to our analysis, the model has no discriminatory bias regarding this feature. Results can be found [here](https://github.com/Nkluge-correa/teeny-tiny_castle/blob/master/ML%20Fairness/fair_metrics_celeba.ipynb).
|
109 |
-
|
110 |
-
Other possible biases were not investigated, but further investigations are likely given that other sensitive attributes present in the training dataset are available.
|
111 |
-
|
112 |
-
In conclusion, we do not recommend using this model in real-world applications. It was solely developed for academic and educational purposes.
|
113 |
-
|
114 |
-
## Cite as
|
115 |
-
|
116 |
-
```latex
|
117 |
-
@misc{teenytinycastle,
|
118 |
-
doi = {10.5281/zenodo.7112065},
|
119 |
-
url = {https://github.com/Nkluge-correa/teeny-tiny_castle},
|
120 |
-
author = {Nicholas Kluge Corr{\^e}a},
|
121 |
-
title = {Teeny-Tiny Castle},
|
122 |
-
year = {2024},
|
123 |
-
publisher = {GitHub},
|
124 |
-
journal = {GitHub repository},
|
125 |
-
}
|
126 |
-
```
|
127 |
-
|
128 |
-
## License
|
129 |
-
|
130 |
-
This model is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.
|
131 |
-
|
|
|
9 |
tags:
|
10 |
- image-classification
|
11 |
---
|
12 |
+
# LeNNon Smile Detector (Teeny-Tiny Castle)
|
13 |
|
14 |
+
This model is part of a tutorial tied to the [Teeny-Tiny Castle](https://github.com/Nkluge-correa/TeenyTinyCastle), an open-source repository containing educational tools for AI Ethics and Safety research.
|
15 |
|
16 |
+
## How to Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
```python
|
19 |
import torch
|
|
|
24 |
|
25 |
# Download the pytorch model
|
26 |
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
|
27 |
+
filename="LeNNon-Smile-Detector.pt",
|
28 |
+
local_dir="./",
|
29 |
+
repo_type="model"
|
30 |
+
)
|
31 |
|
32 |
# Download the source implementation of the model's architecture
|
33 |
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
|
34 |
+
filename="lennon.py",
|
35 |
+
local_dir="./",
|
36 |
+
repo_type="model"
|
37 |
+
)
|
38 |
|
39 |
# Check if GPU is available
|
40 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
46 |
|
47 |
# This `transform` object will transform our test images into proper tensors
|
48 |
transform = transforms.Compose([
|
49 |
+
transforms.Resize((100, 100)), # Resize the image to 100x100
|
50 |
+
transforms.ToTensor(),
|
51 |
])
|
52 |
|
53 |
image_path = "your_image_path_here"
|
|
|
60 |
# forward pass trough the model
|
61 |
with torch.no_grad():
|
62 |
|
63 |
+
outputs = model(tensor)
|
64 |
|
65 |
# Get the class prediction
|
66 |
_, predicted = torch.max(outputs.data, 1)
|
67 |
|
68 |
print("Smiling" if predicted.item() > 0 else "Not Smiling")
|
69 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|