Download app.py from Dirake/Pokemon2: direct link, hf CLI and curl.
- Browser
- Download file 823 Bytes
-
https://huggingface.co/spaces/Dirake/Pokemon2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Dirake/Pokemon2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Dirake/Pokemon2/resolve/main/app.py
823 Bytes
| 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() | |