Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Tải model phân loại rác từ Hugging Face | |
| # Sử dụng model yangy50/garbage-classification như đã trích dẫn ở phần 1 | |
| classifier = pipeline("image-classification", model="yangy50/garbage-classification") | |
| def predict(image): | |
| # Dự đoán và trả về kết quả dưới dạng dictionary {nhãn: độ tin cậy} | |
| predictions = classifier(image) | |
| return {p["label"]: p["score"] for p in predictions} | |
| # Tạo giao diện Webapp | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(num_top_classes=3), | |
| title="Ứng dụng Phân loại Rác (AI Waste Classification)", | |
| description="Tải ảnh lên để AI nhận diện loại rác: Cardboard, Glass, Metal, Paper, Plastic, Trash." | |
| ) | |
| iface.launch() |