Yuval728 commited on
Commit
3905691
·
verified ·
1 Parent(s): 21836f5

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +38 -0
  2. best.pt +3 -0
  3. last.pt +3 -0
  4. readme.md +31 -0
  5. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ from ultralytics import YOLO
4
+ import easyocr
5
+ import gradio as gr
6
+ import json
7
+
8
+
9
+ number_plate_model = YOLO("best.pt", task='detection')
10
+ reader = easyocr.Reader(['en'])
11
+
12
+ def detect_number_plate(image):
13
+ results = number_plate_model(image)
14
+ for result in results:
15
+ result = json.loads(result.tojson())
16
+
17
+ x1, y1, x2, y2 = map(int, result[0]['box'].values())
18
+ # print(x1, y1, x2, y2)
19
+
20
+ number_plate = image[y1:y2, x1:x2]
21
+ number_plate = cv2.cvtColor(number_plate, cv2.COLOR_BGR2RGB)
22
+
23
+ number_plate_text = reader.readtext(number_plate)
24
+ if len(number_plate_text) > 0:
25
+ number_plate_text = number_plate_text[0][-2]
26
+ else:
27
+ number_plate_text = "No text detected"
28
+
29
+ cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
30
+ cv2.putText(image, number_plate_text, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 3)
31
+
32
+ return image
33
+
34
+ # Define Gradio interface
35
+ image = gr.Image(height=640, width=640, type="numpy")
36
+ label = gr.Image(height=640, width=640, type="numpy")
37
+
38
+ gr.Interface(fn=detect_number_plate, inputs=image, outputs=label).launch(debug=True, share=False)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac7f9183c233032df6b41cf786b14c69915f3d2f46620f06d0d6c7cc80559672
3
+ size 6226339
last.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73c870c92dc41ce25b5dc06f0b53f7d8adcf85032e76de6de13ac4cdc6faa8ec
3
+ size 6226467
readme.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Number Plate Detection using YOLO and Gradio
2
+
3
+ This repository contains code and resources for number plate detection using YOLO (You Only Look Once) object detection algorithm and Gradio for building a user-friendly interface.
4
+
5
+ ## Table of Contents
6
+ - [Introduction](#introduction)
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [Contributing](#contributing)
10
+ - [License](#license)
11
+
12
+ ## Introduction
13
+ Number plate detection is an important task in various applications such as traffic surveillance, parking management, and law enforcement. This project utilizes the YOLO algorithm, a state-of-the-art object detection model, to detect number plates in images or videos. Gradio, a Python library, is used to create a simple and interactive user interface for easy testing and deployment.
14
+
15
+ ## Installation
16
+ To use this project, follow these steps:
17
+
18
+ 1. Clone the repository: `git clone https://github.com/yuval728/number-plate-detection.git`
19
+ 2. Install the required dependencies: `pip install -r requirements.txt`
20
+
21
+ ## Usage
22
+ 1. Run the `app/app.py` script.
23
+ 2. Open your web browser and navigate to `http://localhost:7860`.
24
+ 3. Upload an image or video file to detect number plates.
25
+ 4. View the detected number plates and their bounding boxes.
26
+
27
+ ## Contributing
28
+ Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request.
29
+
30
+ ## License
31
+ This project is licensed under the [MIT License](LICENSE).
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ opencv-python
3
+ ultralytics
4
+ gradio
5
+ easyocr