Ejemplo n.º 1
0
 def __init__(self, tf_model_path, conf_file, ks_model_path):
     cfg_from_file(conf_file)
     self.tf_model_path = tf_model_path
     self.net_name = 'VGGnet_test'
     self.sess, self.net = self.load_tf_model()
     from keras.layers import Input
     from keras.models import Model
     from densenet import keys
     from densenet import densenet
     self.characters = keys.alphabet[:]
     self.characters = self.characters[1:] + u'卍'
     self.nclass = len(self.characters)
     input = Input(shape=(32, None, 1), name='the_input')
     y_pred = densenet.dense_cnn(input, self.nclass)
     self.basemodel = Model(inputs=input, outputs=y_pred)
     modelPath = os.path.join(os.getcwd(), ks_model_path)
     if os.path.exists(modelPath):
         self.basemodel.load_weights(modelPath)
     global graph
     graph = tf.get_default_graph()
Ejemplo n.º 2
0
'''
import tensorflow as tf
import os
from imp import reload
from keras.layers import Input
from keras.models import Model
# import keras.backend as K

from densenet import keys
from densenet import densenet

global basemodel,graph,nclass


graph = graph = tf.get_default_graph()

reload(densenet)

characters = keys.alphabet[:]
characters = characters[1:] + u'卍'
nclass = len(characters)

input = Input(shape=(32, None, 1), name='the_input')
y_pred= densenet.dense_cnn(input, nclass)
basemodel = Model(inputs=input, outputs=y_pred)

modelPath = os.path.join(os.getcwd(), './densenet/models/weights_densenet.h5')
if os.path.exists(modelPath):
    basemodel.load_weights(modelPath)

Ejemplo n.º 3
0
def densenet_cnn_model(height=32,nClass=len(characters)):
    input_tensor = Input(shape=(height,None,1),name='the_input')
    y_pred = densenet.dense_cnn(input_tensor, nClass)
    basemodel = Model(inputs=input_tensor,outputs=y_pred)
    return basemodel
Ejemplo n.º 4
0
 def __init__(self, text_process=False):
     self._text_detector = TextDetector()
     self._ocr_model = dense_cnn(len(char))
     self._ocr_model.load_weights('./weights/weights-densenet.h5')
     self.rec_results = None
     self._text_process = text_process