| import gradio as gr |
| from ultralytics import YOLO |
| from PIL import Image |
|
|
| |
| model = YOLO('traffic_sign_detection.pt') |
|
|
| |
| def predict(image): |
| results = model.predict(image, conf=0.5) |
| output_img = results[0].plot() |
| return Image.fromarray(output_img) |
|
|
| |
| iface = gr.Interface( |
| fn=predict, |
| inputs=gr.Image(type="pil", label="Upload an Image"), |
| outputs=gr.Image(type="pil", label="Detected Traffic Signs"), |
| title="Traffic Sign Detection", |
| description="Upload an image to detect traffic signs using YOLOv8." |
| ) |
|
|
| |
| iface.launch() |