Update infer.py

pull/3872/head
张春乔 11 months ago committed by GitHub
parent 7d825c42b1
commit cc4904b67a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -119,6 +119,7 @@ class SSLExecutor(BaseExecutor):
'--verbose',
action='store_true',
help='Increase logger verbosity of current task.')
self.last_call_params = None
def _init_from_path(self,
model_type: str=None,
@ -287,8 +288,8 @@ class SSLExecutor(BaseExecutor):
f"we will use the {model_type} like model to extract audio feature."
)
try:
out_feature = self.model.extract_features(audio[:, :, 0])
self._outputs["result"] = out_feature
out_feature = self.model(audio[:, :, 0])
self._outputs["result"] = out_feature[0]
except Exception as e:
logger.exception(e)
@ -453,6 +454,22 @@ class SSLExecutor(BaseExecutor):
Python API to call an executor.
"""
current_call_params = {
"model": model,
"task": task,
"lang": lang,
"sample_rate": sample_rate,
"config": config,
"ckpt_path": ckpt_path,
"decode_method": decode_method,
"force_yes": force_yes,
"rtf": rtf,
"device": device
}
if self.last_call_params is not None and self.last_call_params != current_call_params and hasattr(self, 'model'):
del self.model
self.last_call_params = current_call_params
audio_file = os.path.abspath(audio_file)
paddle.set_device(device)
self._init_from_path(model, task, lang, sample_rate, config,

Loading…
Cancel
Save