Identifying Cells | Part 2

kathleen wang
2 min readFeb 17, 2021

So I did a little bit of research and I found out that I actually should have done instance segmentation from the beginning. In my previous post, I did object detection. I ended up implementing Mask R-CNN, which is built on top of Faster R-CNN.

Despite being fairly similar, there was some differences that I had to figure out the hard way. The classes were set up just slightly differently. I ended up being off by one line of code, and it caused the gradient to keep exploding. No matter how low I made my learning rate, after running for a few minutes it would throw an error saying that the loss was nan.

I also found out that each instance in the masks used for training was supposed to be a different color. I had them all white, which made the predictions look really strange. I ended up writing a bit of code to identify the number of instances per mask, and then assigning each of them a different number.

I also figured out how to put all my tiles together. I made a numpy zeros array the same size as the original image, and then wrote a function to put the number 255 in all the places where the pixels of the target cells are located. The names of my sliced images include the coordinates of one corner at which they were sliced so I was able to do some math to figure out where they belonged.

Here is my result!

--

--