From e645d70ac454fc6c358863990ac311774ab7a319 Mon Sep 17 00:00:00 2001 From: Jorge Ortiz Date: Mon, 7 Aug 2023 15:18:36 +0200 Subject: [PATCH] MET-5350 remove garbage colleciton --- metis-image-enhancer-python-rest/src/main/api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/metis-image-enhancer-python-rest/src/main/api.py b/metis-image-enhancer-python-rest/src/main/api.py index e6e1128..658aa6e 100644 --- a/metis-image-enhancer-python-rest/src/main/api.py +++ b/metis-image-enhancer-python-rest/src/main/api.py @@ -4,7 +4,6 @@ import socket import io import filetype -import gc from flask import Flask, request, jsonify, send_file, make_response from waitress import serve @@ -64,8 +63,9 @@ def enhance_image(): img = Image.open(io.BytesIO(image_data)).convert("RGBA") rgb_img = Image.new("RGBA", img.size, "WHITE") rgb_img.paste(img, mask=img) - sr_img = model.predict(np.array(rgb_img.convert("RGB")), by_patch_of_size=16) - sr_img = Image.fromarray(sr_img) + + sr_mod = model.predict(np.array(rgb_img.convert("RGB")), by_patch_of_size=24) + sr_img = Image.fromarray(sr_mod) # save it to memory in the original format raw_bytes = io.BytesIO() @@ -82,17 +82,19 @@ def enhance_image(): #response file with bytes and mime type response = make_response(send_file(raw_bytes, mimetype=kind.mime)) + # processing elapsed time end_process = time.time() response.headers['Elapsed-Time'] = end_process - start_process del raw_bytes + del sr_mod del sr_img del rgb_img del img del image_data - gc.collect() - return response + + return response, 200 if request.method == 'GET': app.logger.info('GET request running on host: ' + socket.gethostname())