The model is based on the Vision Transformer (ViT) architecture and has been trained on a custom dataset of waste images. It uses the google/vit-base-patch16-224 backbone and has been fine-tuned for waste classification.
1from transformers import ViTForImageClassification, ViTImageProcessor
2from PIL import Image
3
4# Load model and processor
5model = ViTForImageClassification.from_pretrained("your-username/waste-classifier")
6processor = ViTImageProcessor.from_pretrained("your-username/waste-classifier")
7
8# Load and preprocess image
9image = Image.open("path_to_image.jpg")
10inputs = processor(images=image, return_tensors="pt")
11
12# Get prediction
13outputs = model(**inputs)
14predicted_class = outputs.logits.argmax(-1).item()
15classes = ['compostable', 'general_waste', 'recyclable']
16prediction = classes[predicted_class]
This model is available for use under the MIT license.