Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model for food classification | |
| food_classifier = pipeline(task="image-classification", model="mhdiqbalpradipta/minang_food_classification") | |
| def predict_food(image): | |
| # Perform prediction using the model | |
| result = food_classifier(images=image)[0] | |
| # Save label and score | |
| food_label = result['label'] | |
| score = result['score'] | |
| return f"Food: {food_label}, Score: {score:.2f}" | |
| # Gradio Interface | |
| image_in = gr.Image(type='pil') | |
| label_out = "text" | |
| example_images = ['ayam_goreng.jpg', 'ayam_pop.jpg', 'daging_rendang.jpg', 'dendeng_batokok.jpg', 'gulai_ikan.jpg', 'gulai_tambusu.jpg', 'gulai_tunjang.jpg', 'telur_balado.jpg', 'telur_dadar.jpg'] | |
| intf = gr.Interface(fn=predict_food, inputs=image_in, outputs=label_out, examples=example_images, title="Minang Food Classifier", description="Upload an image of food to classify it into Minang dishes.") | |
| intf.launch(share=False); |