Using instance segmentation on human cells for biology project

Hello,

I am completely new to deep learning and fastai and this is probably a really easy problem but I am stuck doing some instance segmentation for my project that is related to biology.

About the problem: I have some pictures of human cells (there is around 5 cells per image) and what I want to achieve is to create a model that will take such picture and recognise the cells. The problem I face is: I can get the model to recognise the cells, but is does not discern among different ones. (that means that as an output I get an .png picture of either 0 for background and 1 for cells; so i do not get the information about their seperation). This is a problem if I for an example: want to count how many cells there are on the picture.

To clarify: at my disposal I have: the picture of cells (RGB, .jpg) and I have 2 types of masks: first one is greyscale (background is 0, cells are all 1, .png) and I also have an RGB picture where all the cells have different RGB value (if there are 4 cells on the picture, there are 4 different RGB values present; the background is always 0). Also .png.

Using fastai, my DataBlock looks like this:

            dblock = DataBlock(blocks    = (ImageBlock, MaskBlock(codes)),
                               get_items = get_image_files,
                               splitter  = RandomSplitter(),
                               get_y     = get_label,
                               item_tfms = Resize(224))
            
            dls = dblock.dataloaders(path, bs=5)

Question: I know that this code can’t work because the model is fed greyscale images that are only 0 and 1. But I do not know how to incorporate the other type of mask that actually contains the informations about the separation of different cells. (all of the cells are of the same type).

Thank you very much for any help,
Andrej