Dirake commited on
Commit
2649531
·
verified ·
1 Parent(s): f76413c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralytics import YOLO
2
+ import gradio as gr
3
+ from PIL import Image
4
+
5
+ # โหลดโมเดลที่เทรนไว้
6
+ model = YOLO("pokemon_best.pt")
7
+
8
+ def detect(image):
9
+ results = model(image)
10
+ return results[0].plot() # คืนภาพพร้อมกล่องตรวจจับ
11
+
12
+ # สร้าง Gradio UI
13
+ demo = gr.Interface(
14
+ fn=detect,
15
+ inputs=gr.Image(type="pil", label="อัปโหลดภาพโปเกมอน"),
16
+ outputs=gr.Image(label="ผลลัพธ์การตรวจจับ"),
17
+ title="Pokémon Object Detection (YOLOv8)",
18
+ description="อัปโหลดภาพโปเกมอน แล้วระบบจะตรวจจับว่ามีโปเกมอนตัวไหนบ้างในภาพ"
19
+ )
20
+
21
+ demo.launch()