| import gradio as gr |
| from ultralytics import YOLO |
| import cv2 |
| import numpy as np |
| from PIL import Image |
|
|
| |
| model_path = 'best_hat_detection_model_100.pt' |
| model = YOLO(model_path) |
|
|
| |
| def predict_safety_hat(image): |
| |
| image = np.array(image) |
| |
| |
| results = model(image) |
| |
| |
| result_image = results[0].plot() |
| |
| |
| return Image.fromarray(result_image) |
|
|
| |
| inputs = gr.Image(label="Input kép", type="numpy") |
| outputs = gr.Image(label="Output kép") |
|
|
| title = "Safety Hat Detection | Biztonsági sisak detektálás" |
| description = "Tölts fel egy képet és a rendszer bekeretezi a sisakot" |
|
|
| gr.Interface(fn=predict_safety_hat, inputs=inputs, outputs=outputs, title=title, description=description).launch() |
|
|