File size: 2,606 Bytes
8345b01
 
69b21af
70ab11d
 
e120406
 
8345b01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e120406
8345b01
e120406
8345b01
 
 
 
 
e120406
8345b01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
license: mit
pipeline_tag: object-detection
tags:
- License-Plate-Recognizer
- Yolov8m
- Object detection
---
**License Plate Detection Model using YOLOv8**
=============================================

**Model Description**
--------------------

This is a deep learning model for detecting and cropping license plates in images, trained using the YOLOv8 object detection architecture. The model takes an image of a vehicle as input and returns a cropped image of the detected license plate.

**Dataset**
----------

The model was trained on a dataset of 500 images of vehicles with annotated license plates. The dataset was curated to include a variety of license plate types, angles, and lighting conditions.

**Model Training**
-----------------

The model was trained using the YOLOv8 architecture with the following hyperparameters:

* Batch size: 32
* Epochs: 50
* Learning rate: 0.001
* Optimizer: Adam
* Loss function: Mean Average Precision (MAP)

**Model Performance**
---------------------
![confusion_matrix.png](https://cdn-uploads.huggingface.co/production/uploads/6537b44c01281b544234189c/6Wr5WE6dPC_6AisU07hEy.png)
The model achieves the following performance metrics on the validation set:
![val_batch1_pred.jpg](https://cdn-uploads.huggingface.co/production/uploads/6537b44c01281b544234189c/V37GbUwKr-CXaNunUOdqc.jpeg)

* mAP (mean Average Precision): 0.92
* AP (Average Precision) for license plates: 0.95
* Recall: 0.93
* Precision: 0.94
![results.png](https://cdn-uploads.huggingface.co/production/uploads/6537b44c01281b544234189c/_dDT5Bp5l4nGoTf8k9kMs.png)
**Usage**
-----

To use this model, you can follow these steps:

1. Install the required libraries: `pip install ultralytics`
2. Load the model: `model = torch.hub.load('ultralytics/yolov8', 'custom', path='path/to/model.pt')`
3. Load the input image: `img = cv2.imread('path/to/image.jpg')`
4. Preprocess the input image: `img = cv2.resize(img, (640, 480))`
5. Run the model: `results = model(img)`
6. Extract the cropped license plate image: `license_plate_img = results.crop[0].cpu().numpy()`

**Example Code**
--------------

Here is an example code snippet to get you started:
```python
import cv2
import torch

# Load the model
model = torch.hub.load('ultralytics/yolov8', 'custom', path='path/to/model.pt')

# Load the input image
img = cv2.imread('path/to/image.jpg')

# Preprocess the input image
img = cv2.resize(img, (640, 480))

# Run the model
results = model(img)

# Extract the cropped license plate image
license_plate_img = results.crop[0].cpu().numpy()
cv2.imwrite('license_plate.jpg', license_plate_img)