It is also possible to write custom steps in Python to implement the steps that are missing to build you specific workflow. To do so, you need to write the code of those custom steps in a separate Python file
For each custom step, you need to create a new class that inherits from the CutomNode class, and implement the
processmethods. You will then be able to add steps with this type in your
workflow.yamlfile (the name of your class is the type of the step).
from deepomatic.workflows.nodes import CustomNode
def __init__(self, *args, **kwargs):
def process(self, context, *custom_step_inputs):
### Implements the logic of your custom step
Let's look at the following custom step and see how you can add arguments and inputs in the logic you implement.
You might indeed need to add arguments to your custom step, so that you can use the same custom step and adapt it to a specific usage (the
model_idis for instance an argument of the Inference step). To do so, you need to specify those arguments in the signature of the
__init__method. You will also probably want to save those values as attributes to use them in the
def __init__(self, *args, my_first_arg, my_second_arg, **kwargs):
self._context_technician = my_first_arg
self._category = my_second_arg
In the same way, your step will use input that might be entries of your workflow or outputs from other steps. You are able to use those inputs in the process method to implement the logic that you need.
def process(self, context, image_input, category):
processmethod should return either:
- the list of modified or created regions
- an empty list is nothing has been created or modified
Noneif you want to stop the execution of the following steps in the corresponding workflow branch