HenriquesLab / ZeroCostDL4Mic

ZeroCostDL4Mic: A Google Colab based no-cost toolbox to explore Deep-Learning in Microscopy
MIT License
566 stars 130 forks source link

Re-training StarDist 2D to create model and avoid runtime disconnected error #253

Closed anirbannavalarch closed 1 year ago

anirbannavalarch commented 1 year ago

Hi Team StarDist 2D, I am trying to re-train Stardist 2D in StarDist_2D_ZeroCostDL4Mic.ipynb to process some of my SEM images. So, I am trying to train the model with 10 training SEM images each having width and length of 1024x1536. Also, I have masked the same 10 images. Number of epochs used for training the model is 450 as I am going to use the model for my research to process over 200 images. Further, I am using default advanced parameters. While training the model, each epochs takes about 15 minutes to complete. So total amount of time taken 15*450 = 6750 minutes (almost 4.7 days), which is too long. Almost all the time, I am encountering the runtime disconnected error while training the model. Number of epochs completed before the runtime error pops up is 95th epoch. Moreover, I have purchased the subscription for Colab pro as well. Attached is the image for training parameters. Also find attached 1 training image and a corresponding masked images for your review. image

Desktop (please complete the following information):

Please let me know, the steps that would help me create a model for my own data set which will allow me to process the images effectively. Further, I will use the model generated in Fiji software to process images. Looking forward to hear from you. Regards, Anirban

guijacquemet commented 1 year ago

Hi, Regarding your training dataset, are you using the mask image above as a training target? StarDist requires label images (see here. Your images are pretty big; you could consider cropping them. You can do that easily using the Augmentor notebook. I suggest 1024x1024 maximum. Are you using augmentation? The times you indicate seem slow; could you check that a GPU is allocated to your session?

FYI, the model you are training in the notebook will not be compatible with the StarDist Fiji plugin out of the box (you would need to convert the model or to use DeepImageJ). Unfortunately, Fiji does not yet support Tensorflow 2, which is used in Google Colab.

anirbannavalarch commented 1 year ago

Hi, Thanks for replying it promptly. Regarding your training dataset, are you using the mask image above as a training target? Yes No, I am not using augmentation. My actual SEM images are 1526x 1024, if I crop it to 1024x 1024, then will it create problems when I use this model to process images of 1526x1024. Is there any other way I can process the model without cropping i.e., reducing the number of training and mask images. Moreover, I have downloaded and used StarDist 2D plugin in Fiji and it works well. That motivated me to create my own model in ZeroCostDL4Mic. Most of time I am allocated with Tesla T4 GPU. Please help and guide me as I do not enough knowledge about python. Appreciated. REgards, Anirban

On Thu, 23 Mar 2023 at 11:33, guijacquemet @.***> wrote:

Hi, Regarding your training dataset, are you using the mask image above as a training target? StarDist requires label images (see here https://github.com/HenriquesLab/ZeroCostDL4Mic/wiki/Stardist. Your images are pretty big; you could consider cropping them. You can do that easily using the Augmentor notebook. I suggest 1024x1024 maximum. Are you using augmentation? The times you indicate seem slow; could you check that a GPU is allocated to your session?

FYI, the model you are training in the notebook will not be compatible with the StarDist Fiji plugin out of the box (you would need to convert the model or to use DeepImageJ). Unfortunately, Fiji does not yet support Tensorflow 2, which is used in Google Colab.

— Reply to this email directly, view it on GitHub https://github.com/HenriquesLab/ZeroCostDL4Mic/issues/253#issuecomment-1481512908, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6SPULN4AXX3MCQKCNRBNCTW5R3MJANCNFSM6AAAAAAWFNYBQI . You are receiving this because you authored the thread.Message ID: @.***>

guijacquemet commented 1 year ago

Hi, You can train a model using 1024x1024 and apply the model to images of different sizes (i.e., 1526x1024 or larger). You cannot train StarDist using the mask images you displayed above. You need to create label images where each nucleus as a different label (different pixel intensity). Cheers

anirbannavalarch commented 1 year ago

Hi, Thanks for helping me. Thanks for letting me know that a model train with 1024x1024 could be used for 1526x1024. Second thing is: How do I create mask images with different pixel intensity in Fiji software? Please guide me with some of the videos if possible. Also, please outline the steps to create the mask images for training the model. Looking forward to hear from you. Regards, Anirban.

On Thu, 23 Mar 2023 at 12:01, guijacquemet @.***> wrote:

Hi, You can train a model using 1024x1024 and apply the model to images of different sizes (i.e., 1526x1024 or larger). You cannot train StarDist using the mask images you displayed above. You need to create label images where each nucleus as a different label (different pixel intensity). Cheers

— Reply to this email directly, view it on GitHub https://github.com/HenriquesLab/ZeroCostDL4Mic/issues/253#issuecomment-1481554056, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6SPULKMOI3J4SOXDISRP2DW5R6WDANCNFSM6AAAAAAWFNYBQI . You are receiving this because you authored the thread.Message ID: @.***>

guijacquemet commented 1 year ago

Check the short protocol here: https://github.com/HenriquesLab/ZeroCostDL4Mic/wiki/Stardist#generating-masks-for-stardist-2d

anirbannavalarch commented 1 year ago

Hi, Thanks for helping me. I appreciate your help. Also, I am looking forward to know about the number of training images that I need to train my model for research use. Same number images, I will use to mask using the guideline stated by you. Also, If you could let me know if any training advanced parameter values needs to be keyed in while training the model apart from using Epochs 450. Please, let me know if data augmentation needs to be checked while training the model. Thanks for your help. Appreciate your help and guidance. Regards, Anirban

On Thu, 23 Mar 2023 at 12:25, guijacquemet @.***> wrote:

Check the short protocol here: https://github.com/HenriquesLab/ZeroCostDL4Mic/wiki/Stardist#generating-masks-for-stardist-2d

— Reply to this email directly, view it on GitHub https://github.com/HenriquesLab/ZeroCostDL4Mic/issues/253#issuecomment-1481594103, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6SPULN4HQCB3JQMQ3235ADW5SBSNANCNFSM6AAAAAAWFNYBQI . You are receiving this because you authored the thread.Message ID: @.***>