diff --git a/History.md b/History.md index 0d06a43c..140c3cd1 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ **updates** * Refactored code with Sonarqube * Added Pipelines + * Restructured code 2.5.0 / 2021-11-24 ================== diff --git a/README.md b/README.md index 55bb402f..736557e1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ -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 +

+
+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) +
+ ## Introduction Nomeroff Net is an opensource python license plate @@ -72,6 +79,7 @@ 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") @@ -79,8 +87,8 @@ number_plate_detection_and_reading = pipeline("number_plate_detection_and_readin (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) ``` @@ -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) ``` diff --git a/docker/tensorrt/Dockerfile b/docker/tensorrt/Dockerfile index 460bb1f1..2cfafb71 100644 --- a/docker/tensorrt/Dockerfile +++ b/docker/tensorrt/Dockerfile @@ -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 @@ -10,7 +12,7 @@ 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 &&\ @@ -18,7 +20,7 @@ RUN apt-get update &&\ 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 @@ -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 diff --git a/examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py b/examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py index 55c5cc14..528c1318 100644 --- a/examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py +++ b/examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py @@ -1,3 +1,6 @@ +""" +python3 examples/py/model_convertors/ocr2tensorrt/convert_ocr_to_onnx.py +""" import sys import os import time diff --git a/nomeroff_net/pipelines/number_plate_detection_and_reading_v2.py b/nomeroff_net/pipelines/number_plate_detection_and_reading_v2.py index 183edab2..f1091955 100644 --- a/nomeroff_net/pipelines/number_plate_detection_and_reading_v2.py +++ b/nomeroff_net/pipelines/number_plate_detection_and_reading_v2.py @@ -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 @@ -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) diff --git a/nomeroff_net/pipes/number_plate_keypoints_detectors/bbox_np_points.py b/nomeroff_net/pipes/number_plate_keypoints_detectors/bbox_np_points.py index 0dfd9907..0c37440f 100644 --- a/nomeroff_net/pipes/number_plate_keypoints_detectors/bbox_np_points.py +++ b/nomeroff_net/pipes/number_plate_keypoints_detectors/bbox_np_points.py @@ -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) diff --git a/public/images/nomeroff_net.svg b/public/images/nomeroff_net.svg new file mode 100644 index 00000000..09f0ff82 --- /dev/null +++ b/public/images/nomeroff_net.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/russian_troops_bombed_a_maternity_hospital_in_Mariupol_2022-03-09_19-26-39.jpg b/public/images/russian_troops_bombed_a_maternity_hospital_in_Mariupol_2022-03-09_19-26-39.jpg new file mode 100644 index 00000000..a381cb40 Binary files /dev/null and b/public/images/russian_troops_bombed_a_maternity_hospital_in_Mariupol_2022-03-09_19-26-39.jpg differ