From 24d52c273e4fa0219260ce2a671e48297ea86f81 Mon Sep 17 00:00:00 2001 From: RSortPi Date: Wed, 11 Aug 2021 12:02:26 +0200 Subject: [PATCH] Bugfixes. --- controlpi_plugins/imageproc.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/controlpi_plugins/imageproc.py b/controlpi_plugins/imageproc.py index 273f4b5..b59f552 100644 --- a/controlpi_plugins/imageproc.py +++ b/controlpi_plugins/imageproc.py @@ -1,7 +1,9 @@ import asyncio import concurrent.futures -import urllib.request +import functools import PIL +import time +import urllib.request from controlpi import BasePlugin, Message, MessageTemplate @@ -45,7 +47,9 @@ class ImageProc(BasePlugin): loop = asyncio.get_running_loop() executor = concurrent.futures.ProcessPoolExecutor() # Initialise the model: - model = await loop.run_in_executor(executor, Model()) + model = await loop.run_in_executor( + executor, + functools.partial(Model)) print("Model initialised.") while True: # Wait until an image is there: @@ -54,8 +58,9 @@ class ImageProc(BasePlugin): image = self._current_image url = self.conf['url'] + image # Give it to the model: - category = await loop.run_in_executor(executor, - model.analyse(url)) + category = await loop.run_in_executor( + executor, + functools.partial(model.analyse, url)) # Send the result on the message bus: await self.bus.send(Message(self.name, {'event': 'image analysed', -- 2.34.1