Here is the code:
app = Flask('test_api')
@app.route('/recognition', methods=['post','get'])
def recognition():
    imgid =request.values.get("ImgId")
    addtime = request.values.get("DateTime")
    img = request.values.get("Image")
    img = img.replace(' ', '+')
    torch.cuda.empty_cache()
    gc.collect()

    img_b64decode = base64.b64decode(img) # base64解码
    #num_img = np.fromstring(img_b64decode, np.uint8) # 转换np序列
    num_img = np.array(Image.open(BytesIO(img_b64decode)))
    predict = test_net()

if __name__ == '__main__':
    ...
    app.run(port=6321, debug='true', host="0.0.0.0", threaded=True)

After running a few times, the GPU memory will be full.
I don’t know if it is related to Flask, I would like to ask you for advice.
Python: 3.6.8
Flask: 2.0.0
PyTorch: 1.5.1+cu101
GPU: RTX 2070