14
14
from skimage .filters import gaussian
15
15
from skimage .io import imsave
16
16
17
- from monai .deploy .core import Operator , OperatorSpec
17
+ from monai .deploy .core import ConditionType , Operator , OperatorSpec
18
18
19
19
20
20
# If `pip_packages` is specified, the definition will be aggregated with the package dependency list of other
@@ -29,19 +29,22 @@ class GaussianOperator(Operator):
29
29
DEFAULT_OUTPUT_FOLDER = Path .cwd () / "output"
30
30
31
31
def __init__ (self , * args , output_folder : Path , ** kwargs ):
32
+ self .output_folder = output_folder if output_folder else GaussianOperator .DEFAULT_OUTPUT_FOLDER
33
+ self .index = 0
34
+
32
35
# If `self.sigma_default` is set here (e.g., `self.sigma_default = 0.2`), then
33
36
# the default value by `param()` in `setup()` will be ignored.
34
37
# (you can just call `spec.param("sigma_default")` in `setup()` to use the
35
38
# default value)
36
- self .output_folder = output_folder if output_folder else GaussianOperator . DEFAULT_OUTPUT_FOLDER
37
- self .index = 0
39
+ self .sigma_default = 0.2
40
+ self .channel_axis = 2
38
41
39
42
# Need to call the base class constructor last
40
43
super ().__init__ (* args , ** kwargs )
41
44
42
45
def setup (self , spec : OperatorSpec ):
43
46
spec .input ("in1" )
44
- # spec.output("out1") # Cannot have a output without having downstream receiver
47
+ spec .output ("out1" ). condition ( ConditionType . NONE ) # This condition type allows for no or not-ready receiver.
45
48
spec .param ("sigma_default" , 0.2 )
46
49
spec .param ("channel_axis" , 2 )
47
50
@@ -57,4 +60,4 @@ def compute(self, op_input, op_output, context):
57
60
output_path = self .output_folder / "final_output.png"
58
61
imsave (output_path , data_out )
59
62
60
- # op_input .emit(data_out, "out1") # CANNOT emit a dangling output!!!
63
+ op_output .emit (data_out , "out1" )
0 commit comments