Created
July 18, 2017 15:24
-
-
Save femioladeji/970581ab2022a938dca00f71809f4eff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import segmentation | |
from sklearn.externals import joblib | |
# load the model | |
current_dir = os.path.dirname(os.path.realpath(__file__)) | |
model_dir = os.path.join(current_dir, 'models/svc/svc.pkl') | |
model = joblib.load(model_dir) | |
classification_result = [] | |
for each_character in segmentation.characters: | |
# converts it to a 1D array | |
each_character = each_character.reshape(1, -1); | |
result = model.predict(each_character) | |
classification_result.append(result) | |
print(classification_result) | |
plate_string = '' | |
for eachPredict in classification_result: | |
plate_string += eachPredict[0] | |
print(plate_string) | |
# it's possible the characters are wrongly arranged | |
# since that's a possibility, the column_list will be | |
# used to sort the letters in the right order | |
column_list_copy = segmentation.column_list[:] | |
segmentation.column_list.sort() | |
rightplate_string = '' | |
for each in segmentation.column_list: | |
rightplate_string += plate_string[column_list_copy.index(each)] | |
print(rightplate_string) |
it gets value error what about that
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Pasandil, been a while I worked on this but I trained a machine learning model using scikit learn's SVM