Skip to content

ReyaLab/AI_Organoid_Counter

Repository files navigation

AI_Organoid_Counter

Uses a segmentation NN to count organoids in brightfield images.

Test the model on our Huggingface Space!

Fine-tuned on custom data from the following segmentation NN: https://huggingface.co/nvidia/segformer-b3-finetuned-cityscapes-1024-1024

https://github.com/NVlabs/SegFormer?tab=readme-ov-file

Xie, E., Wang, W., Yu, Z., Anandkumar, A., Alvarez, J. M., & Luo, P. (2021). SegFormer: Simple and efficient design for semantic segmentation with transformers. arXiv preprint arXiv:2105.15203. https://arxiv.org/abs/2105.15203

The file ColonyAssaySegformerTern.py was used to download the model and fine-tune it using custom data. FIJI was used to create masks for the training data, and the file Image_Rotator.py was used to rotate, flip, and subdivide the large 1536x2048 images into 512x512 sections. The file Additional_training.py was used to fine-tune the model further.

Currently only works for 1536x2048 images but check for updates to fix this. The images are cut into 12 sections and fed into the segmentation model as tiles. Compatible with .tif, .png, and .jpg images.

For the actual usage of the program, only the model itself and the following three Python files are needed:

Organoid_analyzer_gui.py Organoid_analyzer_AI.py Organoid_analyzer_Zstack.py

example example2

Installation:

Have Python3, and the following libraries: Numpy, Pandas, Tkinter, Opencv, Transformers, PIL, matplotlib. NVIDIA's CUDA is recommended for performance but not strictly necessary for usage. We recommend you use a conda environment to avoid conflicts with other projects. Download the three python files above and the model itself (place the model.safetensors, config.json, and training_args.bin files in one folder with the model name).

https://huggingface.co/ReyaLabColumbia/Segformer_Organoid_Counter_GP

Place the model subfolder and all the files in the same folder and it should be ready to run. To run in Windows, you can just left click Organoid_analyzer_gui.py.

To set up a clickable icon in Linux, add the path to the Organoid_analyzer_gui.py file into the launch_gui.sh file (instructions inside) and then put the path to the launch_gui.sh file into the launcher.desktop file (instructions inside). Then put the launcher.desktop file on your /desktop and you can run it by clicking.

In any OS, you can run the program by left clicking inside the folder, open in terminal, and then "python Organoid_analyzer_gui.py".

The following is an example of the output by the program: Group_analysis_results3

Group_analysis_results3.xlsx

Group_analysis_results Group_analysis_results.xlsx

Group_analysis_results Group_analysis_results.xlsx

This is what the working UI looks like. Screenshot from 2025-07-17 23-25-35

About

Uses a segmentation NN to count organoids in brightfield images.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published