Closed sunlanchang closed 4 years ago
hey @sunlanchang My first thought is to put outside a pipeline initialization outside of the POST call. What do you think?
Actually I have tried 3 ways.
ctc_pipeline.py
.deepspeech2.py
None of these works for me, where do you think i can put ? Or maybe i should try put clear_session()
into every .py
file....
hey @rolczynski
Finally I solved the problem, instead of put clear_session() to some position I just move pipeline = asr.load('deepspeech2', lang='en')
outside of the POST call. In this way computing graph will be created only one time. Thanks a lot.
pipeline = asr.load('deepspeech2', lang='en')
@app.route('/test', methods=['POST'])
def hello_world():
....
audio_file = request.files['audio']
audio_file.save(audio_path)
sample = asr.utils.read_audio(audio_path)
sentences = pipeline.predict([sample])
....
return sentences
Recently I put your model behind my flask web server. Every time a POST/GET comes to Flask server, the server will execute
pipeline.predict([sample])
. After couples of POST/GET requests, the server will be out of memory, so I would like to addtf.keras.backend.clear_session()
to your code. I am trying to puttf.keras.backend.clear_session()
to some position, but it seems like not work. I would be greatly appreciated if you help solve the problem.Some Flask server code: