Skip to content

Commit 70ee706

Browse files
committed
Update Jupyter notebook
Signed-off-by: M Q <mingmelvinq@nvidia.com>
1 parent 94d093a commit 70ee706

File tree

3 files changed

+530
-279
lines changed

3 files changed

+530
-279
lines changed

examples/apps/simple_imaging_app/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def compose(self):
5252
# and the others as kwargs.
5353
# Also note the CountCondition of 1 on the first operator, indicating to the application executor
5454
# to invoke this operator, hence the pipleline, only once.
55-
sobel_op = SobelOperator(self, CountCondition(self, 1), input_folder=sample_data_path, name="sobel_op")
55+
sobel_op = SobelOperator(self, CountCondition(self, 1), input_path=sample_data_path, name="sobel_op")
5656
median_op = MedianOperator(self, name="median_op")
5757
gaussian_op = GaussianOperator(self, output_folder=output_data_path, name="gaussian_op")
5858
self.add_flow(

examples/apps/simple_imaging_app/sobel_operator.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,18 @@ class SobelOperator(Operator):
2929

3030
DEFAULT_INPUT_FOLDER = Path.cwd() / "input"
3131

32-
def __init__(self, fragment: Fragment, *args, input_folder: Path, **kwargs):
32+
def __init__(self, fragment: Fragment, *args, input_path: Path, **kwargs):
3333
"""Create an instance to be part of the given application (fragment).
3434
3535
Args:
3636
fragment (Fragment): An instance of the Application class which is derived from Fragment
37-
input_folder (Path): The folder to read the image file from
37+
input_path (Path): The path of the input image file or folder containing the image file
3838
"""
3939
self.index = 0
4040

4141
# May want to validate the path, but it should really be validated when the compute function is called, also,
4242
# when file path as input is supported in the operator or execution context, input_folder needs not an attribute.
43-
self.input_folder = (
44-
input_folder if (input_folder and input_folder.is_dir()) else SobelOperator.DEFAULT_INPUT_FOLDER
45-
)
43+
self.input_path = input_path if input_path else SobelOperator.DEFAULT_INPUT_FOLDER
4644

4745
# Need to call the base class constructor last
4846
super().__init__(fragment, *args, **kwargs)
@@ -59,12 +57,12 @@ def compute(self, op_input, op_output, context):
5957
# Ideally the op_input or execution context should provide the file path
6058
# to read data from, for operators that are file input based.
6159
# For now, use a temporary way to get input path. e.g. value set on init
62-
input_folder = self.input_folder
63-
print(f"Input from: {input_folder}, whose absolute path: {input_folder.absolute()}")
64-
if input_folder.is_dir():
65-
input_file = next(input_folder.glob("*.*")) # take the first file
60+
input_path = self.input_path
61+
print(f"Input from: {input_path}, whose absolute path: {input_path.absolute()}")
62+
if input_path.is_dir():
63+
input_path = next(input_path.glob("*.*")) # take the first file
6664

67-
data_in = io.imread(input_file)[:, :, :3] # discard alpha channel if exists
65+
data_in = io.imread(input_path)[:, :, :3] # discard alpha channel if exists
6866
data_out = filters.sobel(data_in)
6967

7068
op_output.emit(data_out, "out1")

notebooks/tutorials/01_simple_app.ipynb

Lines changed: 521 additions & 268 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)