File size: 4,229 Bytes
e3558cd e57b57b e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d 8265be3 5460e8d e3558cd f69b8ef 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d e3558cd 5460e8d |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
---
license: apache-2.0
language:
- en
datasets:
- AiresPucrs/CelebA-Smiles
metrics:
- accuracy
tags:
- image-classification
---
# LeNNon-Smile-Detector
## Model Overview
The LeNNon-Smile-Detector is a convolutional neural network trained to detect the presence of a human smile in a facial image.
### Details
- **Size:** 2,566,506 parameters
- **Model type:** Convolutional neural network
- **Optimizer**: `torch.optim.Adam` with a learning rate of 0.001
- **Number of Epochs:** 20
- **Batch Size:** 256
- **Hardware:** Tesla V4
- **Emissions:** Not measured
- **Total Energy Consumption:** Not measured
### How to Use
To run inference on this model, you can use the following code snippet:
```python
import torch
from PIL import Image
from lennon import LeNNon
from torchvision import transforms
from huggingface_hub import hf_hub_download
# Download the pytorch model
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
filename="LeNNon-Smile-Detector.pt",
local_dir="./",
repo_type="model"
)
# Download the source implementation of the model's architecture
hf_hub_download(repo_id="AiresPucrs/LeNNon-Smile-Detector",
filename="lennon.py",
local_dir="./",
repo_type="model"
)
# Check if GPU is available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load the model an pass it to the proper device
model = torch.load('./LeNNon-Smile-Detector.pt')
model = model.to(device)
model.eval()
# This `transform` object will transform our test images into proper tensors
transform = transforms.Compose([
transforms.Resize((100, 100)), # Resize the image to 100x100
transforms.ToTensor(),
])
image_path = "your_image_path_here"
# Open and preprocess he image
image = Image.open(image_path)
tensor = transform(image)
tensor = tensor.to(device)
# forward pass trough the model
with torch.no_grad():
outputs = model(tensor)
# Get the class prediction
_, predicted = torch.max(outputs.data, 1)
print("Smiling" if predicted.item() > 0 else "Not Smiling")
```
## Intended Use
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.
## Performance Metrics
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).
## Training Data
The model was trained on a subset of the [CelebA dataset](https://www.kaggle.com/datasets/jessicali9530/celeba-dataset), i.e., CelebA-Smiles.
CelebA-Smiles contains 50K images. 25K of smiling faces, and 25K of non smiling faces.
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).
## Limitations
We performed a simple fairness analysis of our model regarding the sensitive attribute **age**.
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).
Other possible biases were not investigated, but further investigations are likely given that other sensitive attributes present in the training dataset are available.
In conclusion, we do not recommend using this model in real-world applications. It was solely developed for academic and educational purposes.
## Cite as
```latex
@misc{teenytinycastle,
doi = {10.5281/zenodo.7112065},
url = {https://github.com/Nkluge-correa/teeny-tiny_castle},
author = {Nicholas Kluge Corr{\^e}a},
title = {Teeny-Tiny Castle},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
}
```
## License
This model is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.
|