Skip to content

Commit

Permalink
Prettify nomeroff_net v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitroprobachay committed Mar 22, 2022
1 parent d67b18f commit 4f0eba1
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 18 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**updates**
* Refactored code with Sonarqube
* Added Pipelines
* Restructured code

2.5.0 / 2021-11-24
==================
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<img width="400" src="http://linux.ria.ua/img/articles/numberplate_detection/nomeroff_net.svg" alt="Nomeroff Net. Automatic numberplate recognition system"/>

![Nomeroff Net. Automatic numberplate recognition system](./public/images/nomeroff_net.svg)

Nomeroff Net. Automatic numberplate recognition system. Version 3.0
<br /><br />
<blockquote style="border-left-color: #ff0000">
Now there is a war going on in my country, Russian soldiers are shooting at civilians in Ukraine. Enemy aviation launches rockets and drops bombs on residential quarters.
For 2 weeks we have been appealing to USA & Nato: "Please close the sky", but so far these calls remain unanswered...

![Russian troops bombed a maternity hospital in Mariupol](./public/images/russian_troops_bombed_a_maternity_hospital_in_Mariupol_2022-03-09_19-26-39.jpg?raw=true)
</blockquote>


## Introduction
Nomeroff Net is an opensource python license plate
Expand Down Expand Up @@ -72,15 +79,16 @@ pip3 install -r requirements.txt

```python
from nomeroff_net import pipeline
from nomeroff_net.tools import unzip

number_plate_detection_and_reading = pipeline("number_plate_detection_and_reading",
image_loader="opencv")

(images, images_bboxs,
images_points, images_zones, region_ids,
region_names, count_lines,
confidences, texts) = number_plate_detection_and_reading(['./images/example1.jpeg',
'./images/example2.jpeg'])
confidences, texts) = unzip(number_plate_detection_and_reading(['./data/examples/oneline_images/example1.jpeg',
'./data/examples/oneline_images/example2.jpeg']))

print(texts)
```
Expand All @@ -90,15 +98,14 @@ Note: This example disables some important Nomeroff Net features. It will recogn

```python
from nomeroff_net import pipeline
from nomeroff_net.tools import unzip

number_plate_detection_and_reading = pipeline("number_plate_detection_and_reading_tiny",
number_plate_detection_and_reading = pipeline("number_plate_short_detection_and_reading",
image_loader="opencv")

(images, images_bboxs,
images_points, images_zones, region_ids,
region_names, count_lines,
confidences, texts) = number_plate_detection_and_reading(['./images/example1.jpeg',
'./images/example2.jpeg'])
(images, images_bboxs,
zones, texts) = unzip(number_plate_detection_and_reading(['./data/examples/oneline_images/example1.jpeg',
'./data/examples/oneline_images/example2.jpeg']))

print(texts)
```
Expand Down
10 changes: 6 additions & 4 deletions docker/tensorrt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM nvcr.io/nvidia/tensorrt:20.12-py3
# nVidia TensorRT Base Image
ARG TRT_VERSION=21.07
FROM nvcr.io/nvidia/tensorrt:${TRT_VERSION}-py3

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Europe/Kiev
Expand All @@ -10,15 +12,15 @@ WORKDIR /var/www
RUN apt-get update

ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
ARG ONNXRUNTIME_BRANCH=rel-1.8.2
ARG ONNXRUNTIME_BRANCH=v1.10.0
ARG CMAKE_CUDA_ARCHITECTURES=37;50;52;60;61;70;75;80

RUN apt-get update &&\
apt-get install -y sudo git bash unattended-upgrades
RUN unattended-upgrade

WORKDIR /code
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.14.3-linux-x86_64/bin:${PATH}
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.21.0-linux-x86_64/bin:/opt/miniconda/bin:${PATH}

# Prepare onnxruntime repository & build onnxruntime with TensorRT
# for Jetson you may use https://elinux.org/Jetson_Zoo#ONNX_Runtime
Expand All @@ -40,7 +42,7 @@ RUN apt-get install -y libgl1-mesa-glx
# turbojpeg
RUN apt-get install -y libturbojpeg

RUN pip3 install torch==1.10.0+cu111 torchvision==0.11.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip3 install torch==1.10.0+cu113 torchvision==0.11.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html
RUN pip3 install setuptools
RUN pip3 install "PyYAML>=5.3"
RUN pip3 install scikit_image
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
python3 examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py
"""
import sys
import os
import time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from torch import no_grad
from typing import Any, Dict, Optional, List, Union
from nomeroff_net.tools import unzip
from nomeroff_net.image_loaders import BaseImageLoader
from nomeroff_net.pipelines.base import Pipeline, empty_method
from nomeroff_net.tools.image_processing import crop_number_plate_zones_from_images, group_by_image_ids
Expand Down Expand Up @@ -76,9 +77,8 @@ def forward_detection_np(self, images: Any, **forward_parameters: Dict):
orig_img_shapes,
**forward_parameters)

images_points, images_mline_boxes = self.key_points_detector.detect_mline_many(
images,
images_target_boxes,
images_points, images_mline_boxes = self.key_points_detector.detect(
unzip([images, images_target_boxes]),
**forward_parameters)

zones, image_ids = crop_number_plate_zones_from_images(images, images_points)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def preprocessing_craft(image, canvas_size, mag_ratio):

@staticmethod
def craft_postprocessing(score_text: np.ndarray, score_link: np.ndarray, text_threshold: float,
link_threshold: float, low_text: float, ratio_w: float, ratio_h: float):
link_threshold: float, low_text: float, ratio_w: float, ratio_h: float):
# Post-processing
boxes = get_det_boxes(score_text, score_link, text_threshold, link_threshold, low_text)

Expand Down
43 changes: 43 additions & 0 deletions public/images/nomeroff_net.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4f0eba1

Please sign in to comment.