Skip to content

ToTensorV2 - How to convert mask format from uint8 to float32? #1273

Answered by Dipet
rfmiotto asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like we need to add control flag to change mask dtype inside ToTensorV2.

So I'm left with the question: is it calling mask_img = mask_img.astype(np.float32) the best way to handle this situation?

It is better to call this mask = mask.to(torch.float32) after calling transform, because processing a uint8 mask is much faster.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rfmiotto
Comment options

Answer selected by rfmiotto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants