platedet


Nameplatedet JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/pstwh/platedet
SummaryDetect license plates
upload_time2024-07-26 21:12:33
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.5
licenseNone
keywords plate detection brazilian
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# platedet

`platedet` is a lightweight package for detecting license plates in images using an ONNX model. It is designed to be part of a pipeline for detecting, cropping, and reading license plates. The underlying model is just YOLO, converted to ONNX format. The training data comprises primarily Brazilian license plates, sourced from internet images.

## Installation

To install the required dependencies, use the following command:

For cpu

```bash
pip install "platedet[cpu]"
```

For cuda 11.X
```bash
pip install "platedet[gpu]"
```

For cuda 12.X
```bash
pip install "platedet[gpu]" --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/
```

## Usage

### Command Line Interface

You can use the command line interface to detect license plates in an image:

```bash
platedet image_path [--model_path MODEL_PATH] [--return_types RETURN_TYPES] [--providers PROVIDERS] [--save_images] [--show_result]
```

#### Arguments

- `image_path`: Path to the input image.
- `--model_path`: Path to the ONNX model (default: `artifacts/platedet.onnx`).
- `--return_types`: Output formats (choices: `raw`, `pil`, `np_array`, `boxes`).
- `--providers`: ONNX Runtime providers (default: `CPUExecutionProvider`).
- `--save_images`: Save cropped images of detected plates.
- `--show_result`: Display results with bounding boxes and confidence scores.

### Example

To detect license plates and save the cropped images:

```bash
platedet path/to/image.png --save_images
```

To display the results with bounding boxes:

```bash
platedet detect.py path/to/image.png --show_result
```

### Using in Code

```python
from PIL import Image
from platedet import Platedet

platedet = Platedet()
image = Image.open('examples/1.jpg')
crops = platedet.inference(image, return_types=['pil'])
for idx, crop in enumerate(crops['pil']['images']):
    crop.save(f'{idx}.jpg')
```

If you want to use CUDA:
```python
from PIL import Image
from platedet import Platedet

platedet = Platedet(providers=["CUDAExecutionProvider"])
image = Image.open('examples/1.jpg')
crops = platedet.inference(image, return_types=['pil'])
for idx, crop in enumerate(crops['pil']['images']):
    crop.save(f'{idx}.jpg')
```

Check all execution providers [here](https://onnxruntime.ai/docs/execution-providers/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pstwh/platedet",
    "name": "platedet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.5",
    "maintainer_email": null,
    "keywords": "plate, detection, brazilian",
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "\n# platedet\n\n`platedet` is a lightweight package for detecting license plates in images using an ONNX model. It is designed to be part of a pipeline for detecting, cropping, and reading license plates. The underlying model is just YOLO, converted to ONNX format. The training data comprises primarily Brazilian license plates, sourced from internet images.\n\n## Installation\n\nTo install the required dependencies, use the following command:\n\nFor cpu\n\n```bash\npip install \"platedet[cpu]\"\n```\n\nFor cuda 11.X\n```bash\npip install \"platedet[gpu]\"\n```\n\nFor cuda 12.X\n```bash\npip install \"platedet[gpu]\" --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/\n```\n\n## Usage\n\n### Command Line Interface\n\nYou can use the command line interface to detect license plates in an image:\n\n```bash\nplatedet image_path [--model_path MODEL_PATH] [--return_types RETURN_TYPES] [--providers PROVIDERS] [--save_images] [--show_result]\n```\n\n#### Arguments\n\n- `image_path`: Path to the input image.\n- `--model_path`: Path to the ONNX model (default: `artifacts/platedet.onnx`).\n- `--return_types`: Output formats (choices: `raw`, `pil`, `np_array`, `boxes`).\n- `--providers`: ONNX Runtime providers (default: `CPUExecutionProvider`).\n- `--save_images`: Save cropped images of detected plates.\n- `--show_result`: Display results with bounding boxes and confidence scores.\n\n### Example\n\nTo detect license plates and save the cropped images:\n\n```bash\nplatedet path/to/image.png --save_images\n```\n\nTo display the results with bounding boxes:\n\n```bash\nplatedet detect.py path/to/image.png --show_result\n```\n\n### Using in Code\n\n```python\nfrom PIL import Image\nfrom platedet import Platedet\n\nplatedet = Platedet()\nimage = Image.open('examples/1.jpg')\ncrops = platedet.inference(image, return_types=['pil'])\nfor idx, crop in enumerate(crops['pil']['images']):\n    crop.save(f'{idx}.jpg')\n```\n\nIf you want to use CUDA:\n```python\nfrom PIL import Image\nfrom platedet import Platedet\n\nplatedet = Platedet(providers=[\"CUDAExecutionProvider\"])\nimage = Image.open('examples/1.jpg')\ncrops = platedet.inference(image, return_types=['pil'])\nfor idx, crop in enumerate(crops['pil']['images']):\n    crop.save(f'{idx}.jpg')\n```\n\nCheck all execution providers [here](https://onnxruntime.ai/docs/execution-providers/).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Detect license plates",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/pstwh/platedet"
    },
    "split_keywords": [
        "plate",
        " detection",
        " brazilian"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50370ecc8ab264aff7c5e6478edbd35fc4cbd15374f7272f22669aea8a188f2d",
                "md5": "2d78951b386d45ba77b6ba827b943636",
                "sha256": "c39c602c4824809fa2e2f6c213f1fb1211b966bc99776c16c41d80caadf80d4f"
            },
            "downloads": -1,
            "filename": "platedet-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d78951b386d45ba77b6ba827b943636",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.5",
            "size": 21922638,
            "upload_time": "2024-07-26T21:12:33",
            "upload_time_iso_8601": "2024-07-26T21:12:33.726625Z",
            "url": "https://files.pythonhosted.org/packages/50/37/0ecc8ab264aff7c5e6478edbd35fc4cbd15374f7272f22669aea8a188f2d/platedet-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-26 21:12:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pstwh",
    "github_project": "platedet",
    "github_not_found": true,
    "lcname": "platedet"
}
        
Elapsed time: 0.37079s