Skip to content

Using segmentation mask to generate classifier label #1628

Answered by rijobro
Vivekrpg asked this question in Q&A
Discussion options

You must be logged in to vote

How about:

def set_class(data):
   data["label"] = np.any(data["segmentation"] != 0)
   return data

transformations = Compose([
    ...,
    RandCropByPosNegLabeld(...),
    Lambda(set_class),
    ...
])

The output of RandSpatialCropSamplesd and RandCropByPosNegLabeld might be lists, in which case, you'd have to put a for loop inside the set_class function.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Vivekrpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants