| import gradio as gr |
| from ultralytics import YOLO |
| |
| model = YOLO("https://huggingface.co/ozzadinataX/mineral/resolve/main/best.pt") |
| |
| class_names = [ |
| 'Honda Accord', |
| 'Honda BR-V', |
| 'Honda Brio', |
| 'Honda City Hatchback', |
| 'Honda Civic Hatchback', |
| 'Honda CR-V', |
| 'Honda HR-V', |
| 'Honda Mobilio', |
| 'Honda Odyssey', |
| 'Honda WR-V'] |
| def classify_image(image): |
| results = model(image) |
| probs = results[0].probs |
| |
| top1_index = probs.top1 |
| top1_label = class_names[top1_index] |
| return f"Predicted Class: {top1_label}" |
| demo = gr.Interface( |
| fn=classify_image, |
| inputs=gr.Image(type="pil"), |
| outputs="text", |
| title="Honda-Car Classification" |
| ) |
| demo.launch(share=True) |