Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Files as *.npy output from Jupyter Notebook not generated #894

Closed
JT-24 opened this issue Mar 18, 2024 · 4 comments
Closed

Save Files as *.npy output from Jupyter Notebook not generated #894

JT-24 opened this issue Mar 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@JT-24
Copy link

JT-24 commented Mar 18, 2024

I am trying to run Cellpose 2.0 through a Jupyter notebook (have used the same one previously without issue and have not changed any code). The block dedicated to generating the .npy files runs without error, but the .npy files are not being saved to the google drive folder with the source images (nor anywhere else for that matter). I require the .npy files as some manual annotation is still necessary.

The issue is observed after executing the following code block in a Jupyter notebook after running the Custom model:

from cellpose import io

io.masks_flows_to_seg(images, masks, flows, diameter*np.ones(len(masks)), files, [chan,chan2])

The subsequent code block works just fine and generates the png/tif files etc. as required without issue:

io.save_masks(images, masks, flows, files, channels=[chan, chan2], png=True, # save masks as PNGs and save example image tif=True, # save masks as TIFFs save_txt=True, # save txt outlines for ImageJ save_flows=False, # save flows as TIFFs save_outlines=False, # save outlines as TIFFs )

Has anyone else experienced this issue? Or is there a workaround? I am running the segmentation on local cpu in the interim, however this is much more time consuming. Any feedback or input is much appreciated, thanks!

@JT-24 JT-24 added the bug Something isn't working label Mar 18, 2024
@awight-watershed
Copy link

I've noticed the exact same thing - io.masks_flows_to_seg() runs cleanly but doesn't actually save anything anywhere, while io.save_masks() works as expected (as does plt.savefig() from downstream plots in the example code).

Salient package versions:

cellpose version: 	3.0.6 
platform:       	         linux 
python version: 	3.8.5 
torch version:  	1.8.2+cu102

Thanks!

@JT-24
Copy link
Author

JT-24 commented Mar 18, 2024

Good to know it's not just a local issue in that case, thanks for your comment! Indeed, io.save_masks() works perfectly fine. For me, I don't run plt.savefig() but the subsequent code block after io.save_masks() runs plt.figure and plt.imshow which is currently returning an error: CRITICAL:cellpose.io:ERROR: could not read file, 'NoneType' object has no attribute 'ndim'.

However, I think this is to do with my images as they are stitched images taken with a confocal microscope. It isn't an issue for me though, as I am only concerned with obtaining the masks and .npy files. I've run similar images using the Jupyter notebook code to implement Cellpose 2.0 and have not had this issue with the .npy files happen before.

@mrariden
Copy link
Collaborator

mrariden commented Mar 19, 2024

The io.save_masks() function will save the masks, while the io.masks_flows_to_seg() function only returns the mask data. Closing for now, reopen if needed.

Ill look into this

@mrariden
Copy link
Collaborator

mrariden commented May 7, 2024

Should be fixed with #932

@mrariden mrariden closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants