astrolabesp commited on
Commit
fee7ae4
·
verified ·
1 Parent(s): 2b0b466

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralytics import YOLO
3
+ # Load model dari Hugging Face
4
+ model = YOLO("https://huggingface.co/ozzadinataX/mineral/resolve/main/best.pt")
5
+ # Daftar kelas sesuai model
6
+ class_names = [
7
+ 'Honda Accord',
8
+ 'Honda BR-V',
9
+ 'Honda Brio',
10
+ 'Honda City Hatchback',
11
+ 'Honda Civic Hatchback',
12
+ 'Honda CR-V',
13
+ 'Honda HR-V',
14
+ 'Honda Mobilio',
15
+ 'Honda Odyssey',
16
+ 'Honda WR-V']
17
+ def classify_image(image):
18
+ results = model(image) # Jalankan model pada gambar
19
+ probs = results[0].probs # Ambil hasil probabilitas
20
+ # Prediksi kelas dengan probabilitas tertinggi
21
+ top1_index = probs.top1
22
+ top1_label = class_names[top1_index]
23
+ return f"Predicted Class: {top1_label}"
24
+ demo = gr.Interface(
25
+ fn=classify_image,
26
+ inputs=gr.Image(type="pil"),
27
+ outputs="text",
28
+ title="Honda-Car Classification"
29
+ )
30
+ demo.launch(share=True)