def initialize():
    wpod_net_path = "model/wpod-net.json"
    wpod_net = CarModel.load_model(wpod_net_path)

    # Load model architecture, weight and labels
    json_file = open('model/MobileNets_character_recognition.json', 'r')
    loaded_model_json = json_file.read()
    json_file.close()
    model = model_from_json(loaded_model_json)
    model.load_weights("model/License_character_recognition_weight.h5")
    print("[INFO] Model loaded successfully...")

    labels = LabelEncoder()
    labels.classes_ = np.load('model/license_character_classes.npy')
    print("[INFO] Labels loaded successfully...")

    return wpod_net, model, labels
Пример #2
0
import cv2
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from local_utils import detect_lp
from os.path import splitext,basename
from keras.models import model_from_json
from keras.preprocessing.image import load_img, img_to_array
from keras.applications.mobilenet_v2 import preprocess_input
from sklearn.preprocessing import LabelEncoder
import glob
from model import CarModel
from helpers import CarHelpers

wpod_net_path = "model/wpod-net.json"
wpod_net = CarModel.load_model(wpod_net_path)

test_image_path = "Plate_examples/2.jpg"
vehicle, LpImg,cor = CarHelpers.get_plate(test_image_path, wpod_net)

fig = plt.figure(figsize=(12,6))
grid = gridspec.GridSpec(ncols=2,nrows=1,figure=fig)
fig.add_subplot(grid[0])
plt.axis(False)
plt.imshow(vehicle)
grid = gridspec.GridSpec(ncols=2,nrows=1,figure=fig)
fig.add_subplot(grid[1])
plt.axis(False)
plt.imshow(LpImg[0])

if (len(LpImg)): #check if there is at least one license image