Project-AgML/fresh_rotten_fruit_classification
Viewer โข Updated โข 15.5k โข 603 โข 1
How to use hafeezaismail/fruit-freshness-convnext with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="hafeezaismail/fruit-freshness-convnext")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("hafeezaismail/fruit-freshness-convnext")
model = AutoModelForImageClassification.from_pretrained("hafeezaismail/fruit-freshness-convnext", device_map="auto")Fine-tuned from facebook/convnext-tiny-224 on the Project-AgML/fresh_rotten_fruit_classification dataset (raw config, 3,200 images).
It predicts both the fruit type and whether it is fresh or rotten (16 classes).
fresh_apple, fresh_banana, fresh_grape, fresh_guava, fresh_jujube, fresh_orange, fresh_pomegranate, fresh_strawberry, rotten_apple, rotten_banana, rotten_grape, rotten_guava, rotten_jujube, rotten_orange, rotten_pomegranate, rotten_strawberry
from transformers import pipeline
clf = pipeline('image-classification', model='hafeezaismail/fruit-freshness-convnext')
print(clf('my_fruit.jpg'))
Trained on a small dataset with clean backgrounds. It only knows the fruits listed above and may be unreliable on other fruits, cluttered scenes or unusual lighting. Not a food-safety tool.
Base model
facebook/convnext-tiny-224