kbardool / Keras-frcnn

Keras Implementation of Faster R-CNN
Apache License 2.0
394 stars 313 forks source link

No object detected in test_image #67

Open rachiitgupta opened 4 years ago

rachiitgupta commented 4 years ago

No object is getting detected in the test_image

i tried to pass two images for testing, but there is an empty array in the console git

manohar8642 commented 4 years ago

Please comment if you are able to solve this. Facing the same issue.

Arthur023 commented 4 years ago

This is because your network is not working good enough. On line 146 you can find the

bbox_threshold = 0.8

Which is set to 0.8. This means that your netwerk will only show the bounding boxes of which it is at least 80% sure that it is in a class. Big chance that if you set this really low that you will see a lot of boxes

Qcatbot commented 4 years ago

I can confirm that I got the results like @ rachiitgupta . However, after fine tune bbox_threshold I was able to obtain some values!! Since I use medical images for tumor detection... its very hard to detect with good accuracy it seems..

Arthur023 commented 4 years ago

I'm using biological data as well and it is very hard indeed. I found out that the RPN_model is doing a great job finding the regions of intrest. But after that the classifier doesn't work at all.

I think this is because the pretrained network that I'm loading in is not trained on biological data. And I think that this is not a big problem for the RPN model since that one is just looking for general regions. Since the pretrained network did the same it is already good in it. But the classifier is not pretrained on my network at all so it has a difficult time adjusting.

Anyway what I did and it seems to work is: I first just trained the full network on 2000 images for 30 epoches. After I took a look at the RPN and it was doing a great job. So then I stopped training the RPN and just trained the classifier for another 10 epoches. This seems to work but I'll have to look deeper into how good it works.

Arthur023 commented 4 years ago

If you want to check if your RPN_model is working you can add following code in the frcnn_test_vgg code just behind this line:

R = rpn_to_roi(Y1, Y2, C, K.common.image_dim_ordering(), overlap_thresh=0.7,max_boxes = max_boxes)

So just behind that line you can add the following code and it will show you the 20 best boxes of the rpn model:

    tel=0
    for co in R:
        if tel<20:
            (real_x1, real_y1, real_x2, real_y2) = get_real_coordinates(0.0625*ratio, co[0], co[1], co[2], co[3])
            kleur_1=0
            kleur_2=0
            kleur_3=60
            kleur_1 = 254-tel
            kleur_2 = tel
            if kleur_1<0:
                kleur_1 = 0
                kleur_2 = 254
                kleur_3 = tel-200

            cv2.rectangle(img,(real_x1, real_y1), (real_x2, real_y2), (kleur_3, kleur_1, kleur_2),6)
        tel+=1

Extra: The 0.0625 is there for some reason but I'm not 100% sure. I think it's because the model divide the image by 16 but anyway it should be there. If your boxes are super small or huge then you can change that number

Qcatbot commented 4 years ago

thanks @Arthur023!! I will try to include it in my code and share the results.

Qcatbot commented 4 years ago

@Arthur023 do you have any idea what should be the length of one epoch? I have 1500 mammography images approximately. I use Tesla K80-12GB memory, 64GB ram. I am worried about the time it takes to train.. I have to submit my thesis next week. Can give me a clue how much time it might take approximately? My background is physics. Sometimes my ignorance about the gpu put me in trouble. Thank you.

Arthur023 commented 4 years ago

To be honest I have no idea. Here this guy talks about how the epoch length works but I don't fully understand what he means. Maybe you can take a fresh look at it and let me know what you think.

I'm struggling with the following question on epoch length: Do you decide the batch size first and calculate the epoch lenght based on the batch size or is it the other way around and does the batch size changes when you change the epoch length

https://github.com/kbardool/keras-frcnn/issues/25#issuecomment-572170152

I took 500 and I have 1400 pictures. It takes me 12 minutes per epoch. I did turn all the data augmentation off (turning, mirroring images) because I already did that in my preprocessing step. This made the training significantly faster.

Qcatbot commented 4 years ago

@Arthur023 in the psper of faster rcnn.. They take the batch size of 1. They feed one image at a time. So if you have 1400 images, the epoch length should be 1400 I guess. I came to the conclusion based on the link you shared. Epoch length= #of images/batch size Please tell me if I am wrong

Arthur023 commented 4 years ago

This could be the case indeed. In that link they do say that in one epoch you go through the full data set no matter the epoch length. But this seems weird to me because when I set the epoch length to 1000 it takes double the time to train the model.

So I think you are right. Also because of this line of code. Here it is clear that the model will stop after epoch_length pictures. image

What I don't understand is how we can see the batch size. I assume it is one since you only take one image at a time. But would there be a possibility to change that. Since this could limit the training time which would be nice because my full data set has 16.000 images.

I also found somewhere else that the batch size could be the number of regions of intrest that we send to the classifier at once. Which is 4 normally (in this code). But to me it looks like this is the batch size of the classifier but not of the rpn which will take in the images.

Sorry it got kinda long I just putted my thoughts on here. I do think your right with the epoch length but then the question is how can we change the batch size to make the training go faster.

YUSRA100 commented 3 years ago

No object is getting detected in the test_image

i tried to pass two images for testing, but there is an empty array in the console git

Hi. I am facing the same issue. Please help me out if you have solved it. I have total 98 images of sugar sacks and ran on 50 epochs. Would be grateful.

Dharmal commented 3 years ago

I'm using biological data as well and it is very hard indeed. I found out that the RPN_model is doing a great job finding the regions of intrest. But after that the classifier doesn't work at all.

I think this is because the pretrained network that I'm loading in is not trained on biological data. And I think that this is not a big problem for the RPN model since that one is just looking for general regions. Since the pretrained network did the same it is already good in it. But the classifier is not pretrained on my network at all so it has a difficult time adjusting.

Anyway what I did and it seems to work is: I first just trained the full network on 2000 images for 30 epoches. After I took a look at the RPN and it was doing a great job. So then I stopped training the RPN and just trained the classifier for another 10 epoches. This seems to work but I'll have to look deeper into how good it works.

@Arthur023 Can you please help… on how to train only classifier model

ghost commented 3 years ago

@Arthur023 where to find detection result?.. i dont find any detection results after testing.