from ultralytics import YOLO import gradio as gr from PIL import Image # โหลดโมเดลที่เทรนไว้ model = YOLO("pokemon_best.pt") def detect(image): results = model(image) return results[0].plot() # คืนภาพพร้อมกล่องตรวจจับ # สร้าง Gradio UI demo = gr.Interface( fn=detect, inputs=gr.Image(type="pil", label="อัปโหลดภาพโปเกมอน"), outputs=gr.Image(label="ผลลัพธ์การตรวจจับ"), title="Pokémon Object Detection (YOLOv8)", description="อัปโหลดภาพโปเกมอน แล้วระบบจะตรวจจับว่ามีโปเกมอนตัวไหนบ้างในภาพ" ) demo.launch()