From 9ea36dae0b0e5294257a3ca1928338a4a8c938a7 Mon Sep 17 00:00:00 2001 From: Artem Dorofeev <130536391+artem-dorofeev@users.noreply.github.com> Date: Sat, 13 Apr 2024 13:07:29 +0300 Subject: [PATCH 1/2] edit pyproject.toml --- FRONTEND/pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FRONTEND/pyproject.toml b/FRONTEND/pyproject.toml index 6758110e..9de63f04 100644 --- a/FRONTEND/pyproject.toml +++ b/FRONTEND/pyproject.toml @@ -15,6 +15,8 @@ pytz = "^2024.1" qrcode = "^7.4.2" pillow = "^10.3.0" psycopg2-binary = "^2.9.9" +matplotlib = "^3.8.4" +opencv-python = "^4.9.0.80" [build-system] From fd9e6d97abc5fd4da40c8b03de739c17148424a7 Mon Sep 17 00:00:00 2001 From: Artem Dorofeev <130536391+artem-dorofeev@users.noreply.github.com> Date: Sat, 13 Apr 2024 14:24:10 +0300 Subject: [PATCH 2/2] output result get_num_avto --- FRONTEND/fastparking/ds/predict_num.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/FRONTEND/fastparking/ds/predict_num.py b/FRONTEND/fastparking/ds/predict_num.py index 882862db..f688ff57 100644 --- a/FRONTEND/fastparking/ds/predict_num.py +++ b/FRONTEND/fastparking/ds/predict_num.py @@ -242,6 +242,8 @@ def predict_result(ch_contours, model): for i, c in enumerate(characters): dic[i] = c + total_accuracy = 1 + output = [] for i, ch in enumerate(ch_contours): @@ -250,14 +252,24 @@ def predict_result(ch_contours, model): img = fix_dimension(img_) img = img.reshape(1, 28, 28, 3) # preparing image for the model - y_ = np.argmax(model.predict(img, verbose=0), axis=-1)[ + prediction = model.predict(img, verbose=0) + + + y_ = np.argmax(prediction, axis=-1)[ 0 ] # predicting the class - character = dic[y_] + + # print(y_, prediction.shape, prediction) + character = dic[y_] + # accuracy = prediction[0][y_] + # print(f'{accuracy=}') + # total_accuracy *= accuracy + # print(f'{total_accuracy=}') + output.append(character) plate_number = "".join(output) - return plate_number + return plate_number, total_accuracy def get_num_avto(img_avto): @@ -266,10 +278,12 @@ def get_num_avto(img_avto): chars = segment_to_contours(num_img) - predicted_str = predict_result(chars, model) + predicted_str, total_accuracy = predict_result(chars, model) num_avto_str = str.replace(predicted_str, "#", "") - return num_avto_str, num_img + return {'num_avto_str': num_avto_str, + 'accuracy': total_accuracy, + 'num_img': num_img} ################################################################################ @@ -291,4 +305,4 @@ def get_num_avto(img_avto): exit(1) result = get_num_avto(original) - print(f"ok - {result}") + print(result)