Open jazberna1 opened 3 months ago
Hi,
I took a look to the code and this is what I think is happening:
In function predict_as_tiles
the input image is read as one channel image
Image_raw = io.imread(Image_path, as_gray = True)
Then the placeholder for the whole prediction is set as as having one channel too:
prediction = np.zeros(Image.shape)
However the predicted_patch has three channels:
predicted_patch = model.predict(patch, batch_size = 1)
Hence the error here when trying to fill the prediction array with the corresponding predicted patch
prediction[xi:xi+patch_size[0], yi:yi+patch_size[1]] = np.squeeze(predicted_patch)
I did make this change so the prediction array has three channels:
prediction = np.zeros((Image.shape[0],Image.shape[1],3))
By doing so I was able to get the predictions:
This is the version I am using:
6. Version log
v2.1.1:
Replaced all absolute pathing with relative pathing
v2.1:
TensorFlow version updated from 1.15 to the one locally installed in Google Colab's virtual machine (currently TensorFlow 2.11).
Export BioImage Model Zoo model has been updated. Currently using version 0.5.8
Generate predictions from unseen data has been corrected to be compatible with other data format (e.g. png)
Installs a new version of fpdf and fixes bugs in the function to write pdf files.
Hi @jazberna1 ,
Thank you very much for reporting this bug! ❤️ Seems that you are right, the seems that the code is only prepared for 1 channel. Your proposed solution seems a really good approach, I will test it and check that it works in other possible scenarios and if works I will upload the newest version and let you know 🤗
Thanks again!
Hello,
I get the following error in section
5.1 Generate prediction(s) from unseen dataset
when running the notebookU-Net_2D_ZeroCostDL4Mic.ipynb
with this datasethttps://zenodo.org/records/5639253
which I believe is given as example.To Reproduce I have run the following sections of the notebook:
Use_Data_augmentation
2.3. Using weights from a pre-trained model as initial weights Here I selectedUse_pretrained_model
and the code picks up the appropiate weightsDescribe the bug ValueError: could not broadcast input array from shape (256,256,3) into shape (256,256)
Expected behavior Get model predictions
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information): Does not apply