git.graph-it.com
/
graphit
/
controlpi-imageproc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a8ef5f1
)
Bugfixes.
master
author
RSortPi
<info@graph-it.com>
Wed, 11 Aug 2021 10:02:26 +0000
(12:02 +0200)
committer
RSortPi
<info@graph-it.com>
Wed, 11 Aug 2021 10:02:26 +0000
(12:02 +0200)
controlpi_plugins/imageproc.py
patch
|
blob
|
history
diff --git
a/controlpi_plugins/imageproc.py
b/controlpi_plugins/imageproc.py
index 273f4b5b5f3311e740d590bd44617d129b43d3b8..b59f552ffc2fcf14b7944a6c248da7669a92b934 100644
(file)
--- a/
controlpi_plugins/imageproc.py
+++ b/
controlpi_plugins/imageproc.py
@@
-1,7
+1,9
@@
import asyncio
import concurrent.futures
import asyncio
import concurrent.futures
-import
urllib.request
+import
functools
import PIL
import PIL
+import time
+import urllib.request
from controlpi import BasePlugin, Message, MessageTemplate
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:
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:
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:
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',
# Send the result on the message bus:
await self.bus.send(Message(self.name,
{'event': 'image analysed',