Spaces:
Sleeping
Sleeping
File size: 742 Bytes
ff5ce98 4554c4f ff5ce98 9d48970 ff5ce98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from ultralytics import YOLO
# Load model dari Hugging Face
model = YOLO("https://huggingface.co/septyandy/Rock_Type_Classification/resolve/main/best.pt")
# Daftar kelas sesuai model
class_names = ['Igneous_Rock', 'Sedimentary_Rock', 'Metamorphic_Rock']
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="Rock Type Identification App"
)
demo.launch(share=True) |