fix: 修复加载h5格式模型文件的问题
This commit is contained in:
parent
b3170d7d5c
commit
faa8d5ccda
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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=''):
|
||||
'''
|
||||
|
|
|
@ -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()
|
||||
|
|
4
test.py
4
test.py
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue