PaddleOCR
English
legal
A newer version of this model is available: Ultralytics/YOLOv8

License Plate Detection

This project combines a FastAPI backend and a Streamlit frontend to detect and display license plates in a video stream. The backend processes frames with a YOLO model, tracks detected plates, and runs OCR on the recognized regions. The frontend presents the result in a simple web dashboard.

Features

  • License plate detection using YOLO
  • Object tracking with ByteTrack
  • Bounding boxes and labels overlayed on video frames
  • OCR text extraction for detected plates
  • Video streaming through FastAPI
  • Simple UI with Streamlit for starting the detection feed

Project Structure

  • main.py โ€” FastAPI backend that reads the video stream, runs detection, and serves the processed output
  • UI.py โ€” Streamlit interface that loads the detection stream from the backend
  • best (11).pt โ€” trained YOLO model weights
  • Readme.md โ€” project documentation
  • 15562388_2160_3840_50fps.mp4 โ€” input video used by the detector

Requirements

Install the required packages:

pip install fastapi uvicorn opencv-python ultralytics supervision easyocr streamlit

If you are using a GPU, install the matching PyTorch build for your environment first for better performance.

Setup

  1. Make sure the model file exists in the project folder.
  2. Confirm that the input video file is available.
  3. If the video name changes, update the path in main.py:
cap = cv2.VideoCapture('15562388_2160_3840_50fps.mp4')

Run the Backend

From the project folder, start the API server:

python main.py

The backend will run on:

http://localhost:5000

Run the Frontend

Open a second terminal and run:

streamlit run UI.py

Then open the local Streamlit URL shown in the terminal, usually:

http://localhost:8501

API Endpoints

GET /

Returns a simple health message.

{ "message": "Welcome to the License Plate Detection API" }

GET /detect

Streams annotated video frames as a multipart MJPEG stream.

http://localhost:5000/detect

The Streamlit UI sends a request to this route and displays the video feed.

How It Works

  1. The backend opens the input video.
  2. Every 5th frame is processed by the YOLO model.
  3. Detected objects are tracked across frames with ByteTrack.
  4. Boxes and labels are added to the frame.
  5. EasyOCR reads text from the frame and prints results to the console.
  6. The processed frame is returned to the frontend as a stream.

Usage

  • Start the backend.
  • Start the Streamlit app.
  • Click the Run Detection button in the UI.
  • View the processed license plate detection feed in the browser.

Notes

  • The app currently uses a fixed video source and model path.
  • Detection is limited to every few frames to reduce processing cost.
  • OCR results are printed in the terminal, not displayed directly in the UI.
  • This project is suitable for testing, demos, and prototype systems.

Troubleshooting

Streamlit error about list context manager

This usually happens when code uses an object like this:

col1 = st.columns(1)[0]
with col1:
    ...

st.columns() returns a list, not a Streamlit container that supports the with statement. Use the returned container directly or avoid the with block.

Example:

col1 = st.columns(1)[0]
run_button = col1.button("Run Detection")

Video not loading

  • Check that the video file exists in the project folder.
  • Make sure the file name matches the path in main.py.

Model not found

  • Confirm that best (11).pt exists in the project directory.
  • Update the model path if needed.

Backend not reachable

  • Make sure main.py is running before starting the UI.
  • Verify that the backend is listening on port 5000.

License

This project is intended for learning, experimentation, and demonstration. Please check all model, data, and third-party asset licenses before using it in production or public deployment.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Gideon-0-1/_license_plate

Finetuned
(200)
this model

Dataset used to train Gideon-0-1/_license_plate