fizyr / keras-retinanet

Keras implementation of RetinaNet object detection.
Apache License 2.0
4.38k stars 1.96k forks source link

RetinaNet on 1 class Regression loss == 0 #555

Closed Xqua closed 6 years ago

Xqua commented 6 years ago

Hi,

I am trying to fit a RetinaNet on microscopy data where there is background and nuclei. Basically my dataset has just 1 class, nuclei, and the default class background. I am trying to find the anchor box around my nuclei, I have a training set of 65k images with a variable number of nuclei in them.

I successfully trained a Unet on this dataset, but ran into the problem of overlapping nuclei. So I am trying to use RetinaNet to fit an object detection instead of a segmentation. I hope that it will learn the shape of 1 nuclei and therefore resolve the overlapping ones.

Maybe it's just that the ResNet backbone fails when there is only one class, but in my understanding of its theory it should still work. No ?

In anycase, when I run retinaNet on it, the Classification loss drops to 10-6 very quickly (after 100 images) which ... well I am expecting given that the dataset only has one class. But where I am confused is that the regression Loss is at 0. it starts at 0 and stays at 0.

Am I doing something impossible, or is there a detail in the code that I missed ?

yhenon commented 6 years ago

Are your objects small or your images large? Having 0 regression loss is a good indicator that there are no positive anchors.

Have a look at the debugging section in the README, and try running debug.py.

Xqua commented 6 years ago

I guess both

Images are 512x512 And objects are on average 16px wide

I'm sorry for.my lack of knowledge but what do you mean by no positive anchors ? No anchors with a p>0 ?

I'll take a look at debug.py :)

Xqua commented 6 years ago

@yhenon Ok I finally got around to debug (sorry I was out of internet for days)

image image

Here are my anchor boxes... They look like they are working ...

image

A small number looks like this but it's maybe one out of ... 20: image

Xqua commented 6 years ago

Ok it was my fault I included the parameters --min-size and --max-size and it messed it up !

bw4sz commented 6 years ago

@Xqua what did you mean by the --max-size and --min-size arguments. Can you point in the code? Did you mean

    parser.add_argument('--image-min-side', help='Rescale the image so the smallest side is min_side.', type=int, default=800)

I'm debugging some smaller boxes that aren't being fit. Large boxes are fine.

Xqua commented 6 years ago

indeed @bw4sz I added the --image-min-side and --image-max-side

parameters and they were giving erroneous bounding boxes

xiaoxifei1223 commented 5 years ago

@Xqua hi,could you help me train RetinaNet on biological graphs, for example, how to set the num_class parameter on your microscopy graphs to detect nuclei?