Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from PIL import Image | |
| # Load the YOLOv8 model | |
| from ultralytics import YOLO | |
| model = YOLO("best.pt") | |
| # Define a function for inference | |
| def detect_objects(input_image): | |
| # Convert Gradio input to a PIL image | |
| # Perform object detection | |
| results = model(input_image) | |
| for r in results: | |
| im_array = r.plot() # plot a BGR numpy array of predictions | |
| im = Image.fromarray(im_array[..., ::-1]) | |
| return im | |
| # Define the Gradio interface | |
| outputs = gr.outputs.Image(type="pil", label="Output Image") | |
| demo = gr.Interface( | |
| detect_objects, | |
| gr.Image(type="pil"), | |
| outputs, | |
| title="Burn Detection" | |
| ) | |
| demo.launch() | |