Spaces:
Sleeping
Sleeping
| from ultralytics import YOLO | |
| import gradio as gr | |
| from PIL import Image | |
| import numpy as np | |
| # Load the trained YOLOv8 model | |
| model = YOLO("yolov8_license_plate.pt") # Path where you uploaded the model | |
| # Define prediction function | |
| def detect_objects(image): | |
| results = model(image) # Perform inference | |
| result_img = results[0].plot() # Draw bounding boxes | |
| return Image.fromarray(result_img.astype(np.uint8)) # Ensure correct image format | |
| # Build Gradio interface | |
| interface = gr.Interface( | |
| fn=detect_objects, | |
| inputs=gr.Image(type="pil", label="Upload Image"), | |
| outputs=gr.Image(type="pil", label="Detected Image"), | |
| title="License Plate Detection (YOLOv8)", | |
| description="Upload an image. The model will detect license plates using YOLOv8." | |
| ) | |
| # Launch the interface | |
| interface.launch(debug=True) | |