Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting several inputs is not intuitive #26

Open
ambroiseb opened this issue Jan 25, 2024 · 0 comments
Open

Setting several inputs is not intuitive #26

ambroiseb opened this issue Jan 25, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ambroiseb
Copy link
Collaborator

ambroiseb commented Jan 25, 2024

I made a custom plugin with 2 inputs of type ikomia.dataprocess.CImageIO().
I tried to set both inputs this way:

from ikomia.dataprocess.workflow import Workflow
import numpy as np

# Init your workflow
wf = Workflow()

img = np.random.randint(0, 256, (400, 400, 3), dtype=np.uint8)
mask = np.random.randint(0, 256, (400, 400, 1), dtype=np.uint8)

plugin = wf.add_task(name="test_plugin", auto_connect=True)

wf.set_image_input(array=img, index=0)
wf.set_image_input(array=mask, index=1) #this line does nothing

wf.run()

Only the input of index 0 has been passed to the workflow.
A correct way of filling the input 1 of my plugin would have been :

from ikomia.dataprocess.workflow import Workflow
import numpy as np

# Init your workflow
wf = Workflow()

img = np.random.randint(0, 256, (400, 400, 3), dtype=np.uint8)
mask = np.random.randint(0, 256, (400, 400, 1), dtype=np.uint8)

plugin = wf.add_task(name="test_plugin", auto_connect=False)

wf.connect_tasks(wf.root(), plugin, [(0,0), (1,1)])

wf.set_image_input(array=img, index=0)
wf.set_image_input(array=mask, index=1) #this time it will set the input correctly

wf.run()

The first code did not work as expected because auto_connect=True linked root with the plugin test_plugin. But root has by default only 1 input, so when wf.set_image_input is called, it can only set input for index 0.
The good way is to disable auto_connect and make connections between tasks with wf.connect_tasks.

To put it in a nutshell, the behavior of auto_connect=True is not explained and can lead to unexpected mistakes.

@LudoBar LudoBar added the enhancement New feature or request label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants