|
|
---
|
|
|
license: apache-2.0
|
|
|
base_model: google/vit-base-patch16-224
|
|
|
tags:
|
|
|
- image-classification
|
|
|
- vision-transformer
|
|
|
- trash-classification
|
|
|
- waste-management
|
|
|
- pytorch
|
|
|
datasets:
|
|
|
- custom
|
|
|
language:
|
|
|
- en
|
|
|
pipeline_tag: image-classification
|
|
|
---
|
|
|
|
|
|
# Modèle de Classification de Propreté des Poubelles
|
|
|
|
|
|
Ce modèle utilise Vision Transformer (ViT) pour classifier les images de poubelles en deux catégories:
|
|
|
- **Clean** (Propre)
|
|
|
- **Dirty** (Sale)
|
|
|
|
|
|
## Modèle de base
|
|
|
- **Architecture**: Vision Transformer (ViT)
|
|
|
- **Modèle de base**: google/vit-base-patch16-224
|
|
|
- **Type**: Classification binaire d'images
|
|
|
- **Taille d'entrée**: 224x224 pixels
|
|
|
|
|
|
## Classes
|
|
|
- `0`: Clean (Poubelle propre)
|
|
|
- `1`: Dirty (Poubelle sale)
|
|
|
|
|
|
## Utilisation
|
|
|
|
|
|
```python
|
|
|
from transformers import ViTImageProcessor, ViTForImageClassification
|
|
|
from PIL import Image
|
|
|
import torch
|
|
|
|
|
|
# Charger le modèle et le processeur
|
|
|
processor = ViTImageProcessor.from_pretrained('JeanPaulLePape/MasterCAMPDataetIAModelGoogleTrained')
|
|
|
model = ViTForImageClassification.from_pretrained('JeanPaulLePape/MasterCAMPDataetIAModelGoogleTrained')
|
|
|
|
|
|
# Fonction de prédiction
|
|
|
def predict_trash_cleanliness(image_path):
|
|
|
image = Image.open(image_path).convert('RGB')
|
|
|
inputs = processor(image, return_tensors="pt")
|
|
|
|
|
|
with torch.no_grad():
|
|
|
outputs = model(**inputs)
|
|
|
predicted_class = torch.argmax(outputs.logits, dim=1).item()
|
|
|
confidence = torch.softmax(outputs.logits, dim=1).max().item()
|
|
|
|
|
|
label = "Clean" if predicted_class == 0 else "Dirty"
|
|
|
return label, confidence
|
|
|
|
|
|
# Exemple d'utilisation
|
|
|
label, confidence = predict_trash_cleanliness("path/to/your/image.jpg")
|
|
|
print(f"Prédiction: {label} (Confiance: {confidence:.2f})")
|
|
|
```
|
|
|
|
|
|
## Entraînement
|
|
|
- **Framework**: Transformers + PyTorch
|
|
|
- **Optimiseur**: AdamW
|
|
|
- **Précision**: Mixed precision (FP16)
|
|
|
- **Métriques**: Accuracy
|
|
|
|