From bb7047775512324adcfbe3db0daaed495b28a618 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 20 Aug 2022 14:46:04 -0700 Subject: [PATCH] tensorflow: free image before analyzing --- plugins/tensorflow-lite/src/tflite/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/tensorflow-lite/src/tflite/__init__.py b/plugins/tensorflow-lite/src/tflite/__init__.py index af13b0451..7d016af37 100644 --- a/plugins/tensorflow-lite/src/tflite/__init__.py +++ b/plugins/tensorflow-lite/src/tflite/__init__.py @@ -204,17 +204,16 @@ class TensorFlowLitePlugin(DetectPlugin): return try: image = Image.frombuffer('RGB', (width, height), info.data.tobytes()) - - _, scale = common.set_resized_input( - self.interpreter, image.size, lambda size: image.resize(size, Image.ANTIALIAS)) - - with self.mutex: - self.interpreter.invoke() - objs = detect.get_objects( - self.interpreter, score_threshold=score_threshold, image_scale=scale) finally: buf.unmap(info) + _, scale = common.set_resized_input( + self.interpreter, image.size, lambda size: image.resize(size, Image.ANTIALIAS)) + + with self.mutex: + self.interpreter.invoke() + objs = detect.get_objects( + self.interpreter, score_threshold=score_threshold, image_scale=scale) allowList = settings.get('allowList', None)