There is a folklore which says talks about a king who placed a challenge — asking the people to count the number of grains. And if they could do it it will lead to great riches.
Many tried, and failed. And finally they gave up.
If only they had EfficientSAM in those days! 🙂
A pipeline to read a large file, slice it into smaller pieces, run it through Efficient Segment Anything Model and then stich the images together. Basically this is a fine grained segmentation and counting strategy that helps you count all the hundreds of small sized grains.
The code and sample image is provided below
Github Code for implementing the fine-grained implementation