fix: 修复加载h5格式模型文件的问题

This commit is contained in:
nl 2021-05-16 21:14:52 +08:00
parent b3170d7d5c
commit faa8d5ccda
13 changed files with 15 additions and 15 deletions

View File

@ -191,7 +191,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename='model_speech/speech_model24',comment=''):
'''

View File

@ -200,7 +200,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename='model_speech/speech_model25',comment=''):
'''

View File

@ -211,7 +211,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''
@ -439,7 +439,7 @@ if(__name__=='__main__'):
ms = ModelSpeech(datapath)
#ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_100000.model')
#ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_100000.h5')
ms.TrainModel(datapath, epoch = 50, batch_size = 16, save_step = 500)
#t1=time.time()

View File

@ -209,7 +209,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''

View File

@ -213,7 +213,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''

View File

@ -217,7 +217,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''

View File

@ -218,7 +218,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename='model_speech/m26/speech_model26',comment=''):
'''

View File

@ -226,7 +226,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''

View File

@ -230,7 +230,7 @@ class ModelSpeech(): # 语音模型类
加载模型参数
'''
self._model.load_weights(filename)
self.base_model.load_weights(filename + '.base')
#self.base_model.load_weights(filename + '.base')
def SaveModel(self,filename = abspath + 'model_speech/m'+ModelName+'/speech_model'+ModelName,comment=''):
'''

View File

@ -34,7 +34,7 @@ from LanguageModel import ModelLanguage
datapath = './'
modelpath = 'model_speech/'
ms = ModelSpeech(datapath)
ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_12000.model')
ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_12000.h5')
ml = ModelLanguage('model_language')
ml.LoadModel()

View File

@ -46,8 +46,8 @@ else:
ms = ModelSpeech(datapath)
#ms.LoadModel(modelpath + 'm22_2\\0\\speech_model22_e_0_step_257000.model')
ms.LoadModel(modelpath + 'm251\\speech_model251_e_0_step_625000.model')
#ms.LoadModel(modelpath + 'm22_2\\0\\speech_model22_e_0_step_257000.h5')
ms.LoadModel(modelpath + 'm251\\speech_model251_e_0_step_625000.h5')
#ms.TestModel(datapath, str_dataset='test', data_count = 64, out_report = True)
r = ms.RecognizeSpeech_FromFile('D:\\语音数据集\\ST-CMDS-20170001_1-OS\\20170001P00241I0052.wav')

View File

@ -64,7 +64,7 @@ else:
ms = ModelSpeech(datapath)
ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_42500.model')
ms.LoadModel(modelpath + 'm251/speech_model251_e_0_step_42500.h5')
ms.TestModel(datapath, str_dataset='test', data_count = 128, out_report = True)

View File

@ -63,7 +63,7 @@ else:
ms = ModelSpeech(datapath)
#ms.LoadModel(modelpath + 'speech_model251_e_0_step_327500.model')
#ms.LoadModel(modelpath + 'speech_model251_e_0_step_327500.h5')
ms.TrainModel(datapath, epoch = 50, batch_size = 16, save_step = 500)