Many thanks for the hint. While this will make the ImageBlock read black and white images but the output of the network that is specified by MaskBlock is still multi-channel. See the attached screenshot below:
When I take out the n_out=1 and keep using PILImageBW, everything works fine but the returned output is two-channel. However, a new issue is that I can’t export the model anymore. See the error below:
If you are using n_out=1 then you can change your loss function to BCEWithLogitsLossFlat. I am not sure why export is not working. You can try just saving the model weights, its just a PyTorch model.
Thanks for the reply. I will try changing the loss function.
For the export issue, I found its know problem with lambda functions and has been answered on the forum. I was able to resolve it. It has nothing to do with n_out or PILImageBW options.
Looking at the code it appears that MaskBlock and TensorMask have no current functionality to convert to black and white. But it’s easy enough to copy the implementation of ImageBlock and PILImageBW to do it yourself like:
I’m having problems with my grayscale B&W RGB images and found this in a search. I added it to my code and am finally seeing train_loss and valid_loss values, they were 0 before and the model failed a prediction of any of the training images. I NEVER would have thought of this as a solution because I don’t see this level of explanation anywhere, in the API or the book. There’s a lot to this.
Just for grins, if you’re still paying any attention, where did you pick up this nugget of wisdom?