Lambda function

In lesson-3 Segmentation, what does the Lambda function:
“Lambda x:” does and why is it not in the regular syntax i.e. “def Lambda:” ?

Thanks

Same thing, but more compact and anonymous

1 Like

Hi @ste
How does this function find the mask of the corresponding image?

" get_y_fn = lambda x: path_lbl/f’{x.stem}_P{x.suffix}’ "

X is a path lib Parh.

From patib doc: https://docs.python.org/3/library/pathlib.html)
PurePath.stem
The final path component, without its suffix…

So the mask seems to be:
[imageFileName]_P.[imageExtension]

2 Likes

Ohhh, i get it. Thanks