File size: 823 Bytes
2649531
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()