Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from ultralytics import YOLO | |
| # Load model dari Hugging Face | |
| model = YOLO("https://huggingface.co/astrolabesp/car-brands_deepl/resolve/main/best_car-brands.pt") | |
| # Daftar kelas sesuai model | |
| class_names = [ | |
| 'HONDA', | |
| 'HYUNDAI', | |
| 'MAZDA', | |
| 'MITSUBISHI', | |
| 'SUZUKI', | |
| 'TOYOTA' | |
| ] | |
| def classify_image(image): | |
| results = model(image) # Jalankan model pada gambar | |
| probs = results[0].probs # Ambil hasil probabilitas | |
| # Prediksi kelas dengan probabilitas tertinggi | |
| 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="Car-Brands Detection Demo" | |
| ) | |
| demo.launch(share=True) |