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
process methods. You will then be able to add steps with this type in your
workflow.yaml file (the name of your class is the type of the step).
Custom stepfrom deepomatic.workflows.nodes import CustomNodeclass MyCustomStep(CustomNode):def __init__(self, *args, **kwargs):super().__init__(*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.
steps:- name:type: MyCustomStepinputs:- image_input- categoryargs:my_first_arg: context_technicianmy_second_arg: intervention_type
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_id is 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):super().__init__(*args, **kwargs)self._context_technician = my_first_argself._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):
process method should return either:
the list of modified or created regions
an empty list is nothing has been created or modified
None if you want to stop the execution of the following steps in the corresponding workflow branch