keras-yolo2 icon indicating copy to clipboard operation
keras-yolo2 copied to clipboard

0 box detect

Open dr-askar opened this issue 5 years ago • 19 comments

thanx for this project i have tried raccoon train on tiny yolo and useed this config `{ "model" : { "backend": "Tiny Yolo", "input_size": 416, "anchors": [3.97,5.13, 5.55,9.46, 7.56,11.61, 9.65,8.51, 11.26,11.97], "max_box_per_image": 10,
"labels": ["raccoon"] },

"train": {
    "train_image_folder":   "/content/raccoon_dataset/train_image_folder/",
    "train_annot_folder":   "/content/raccoon_dataset/train_annot_folder/",     
      
    "train_times":          100,
    "pretrained_weights":   "tiny_yolo_r.h5",
    "batch_size":           32,
    "learning_rate":        1e-4,
    "nb_epochs":            1,
    "warmup_epochs":        3,

    "object_scale":         5.0 ,
    "no_object_scale":      1.0,
    "coord_scale":          1.0,
    "class_scale":          1.0,

    "saved_weights_name":   "tiny_yolo_r.h5",
    "debug":                true
},

"valid": {
    "valid_image_folder":   "/content/raccoon_dataset/valid_image_folder/",
    "valid_annot_folder":   "/content/raccoon_dataset/valid_annot_folder/",

    "valid_times":          5
}

} ` but always when predict got 0 boxes what is the problem??

dr-askar avatar Mar 28 '19 06:03 dr-askar

i run frontend.py do warm up then do training with warm up 0 and used the wieght from warm up and still 0 box

dr-askar avatar Mar 28 '19 07:03 dr-askar

I am facing the same issue but using the blood cell detection. After 7-8 iterations I get an early stop and when I run the detection I get the same image with boxes=[]. Its weird because I am using the same notebook, the same dataset and just downloaded the yolo.weights. The explore check is working correctly but I am getting no prediction.

zenetio avatar Mar 30 '19 04:03 zenetio

I'm facing the same problem. map decreases zero and no boxes detected, recall also becomes zero.

werfxz avatar Mar 30 '19 20:03 werfxz

I saw in a thread that we need normalize both train and valid datasets. So I saw that train was not normalized and when I fixed it the model learned quick and is predicting correctly. So, it was fixed!

zenetio avatar Mar 31 '19 02:03 zenetio

Thanx .. How can i normalize the datasets ?

dr-askar avatar Mar 31 '19 05:03 dr-askar

@zenetio Both valid_generator and train_generator takes norm=self.feature_extractor.normalize as a parameter. Why train data is not normalized but validation is? How can we fix this problem?

train_generator = BatchGenerator(train_imgs, generator_config, norm=self.feature_extractor.normalize) valid_generator = BatchGenerator(valid_imgs, generator_config, norm=self.feature_extractor.normalize, jitter=False)

werfxz avatar Mar 31 '19 11:03 werfxz

@werfxz I am guessing I am using a different implementation where, in the code, only validation was normalized. So, I just changed the code to accept normalize in train and the model learned and is predicting well.

zenetio avatar Mar 31 '19 15:03 zenetio

Can you share your code? I am running code in python 3.6 could it be the problem?

werfxz avatar Apr 01 '19 10:04 werfxz

I am using the Blood Cell Detection notebook as code base and you can find it in this current repo. Note the difference between train and valid calculation.

zenetio avatar Apr 01 '19 18:04 zenetio

@zenetio I think all images are already normalized according to its respective feature extractor as can be seen in the frontend.py here.

@dr-askar have you tried raising the values of the scales?

MBoaretto25 avatar Apr 02 '19 16:04 MBoaretto25

@MBoaretto25 I am not using frontend.py. I am using the notebook code and so I had to normalize my dataset.

zenetio avatar Apr 02 '19 19:04 zenetio

I have the same problem. Did you find the solution?

lenhatdong avatar May 03 '19 12:05 lenhatdong

As I said, I just normalized both train and valid datasets and the issue was fixed. My project is based on the Blood Cell project on this repo.

zenetio avatar May 03 '19 17:05 zenetio

Thanks for your answer, but I mean on frontend.py

lenhatdong avatar May 06 '19 06:05 lenhatdong

Sorry @mikado3119 but I am not using frontend.py. I am using the notebook code.

zenetio avatar May 30 '19 15:05 zenetio

@zenetio how did you normalize the datasets? The notebook uses this function:

def normalize(image): return image / 255.

which is then used when creating the Batch Generators:

train_imgs, seen_train_labels = parse_annotation(train_annot_folder, train_image_folder, labels=LABELS) train_batch = BatchGenerator(train_imgs, generator_config, norm=normalize) valid_imgs, seen_valid_labels = parse_annotation(valid_annot_folder, valid_image_folder, labels=LABELS) valid_batch = BatchGenerator(valid_imgs, generator_config, norm=normalize, jitter=False)

Is this not enough for normalization?

eirini5th avatar Jul 19 '21 15:07 eirini5th

@eirini5th As you stated, I just passed the normalize function to both train and valid BatchGenerator and it was enough to make the model generalize properly. Before doing that, the model was not learning.

zenetio avatar Jul 20 '21 02:07 zenetio

@zenetio thanks for your answer! Unfortunately in my case it still predicts 0 boxes even after using the normalize function. Only difference is I don't use a valid_batch, I wanted to first test it on a single image, which I am also normalizing before the prediction. Maybe I should try with an actual batch of validation images?

eirini5th avatar Jul 20 '21 12:07 eirini5th

eirini5th Note that the example works with the current dataset. So, I would suggest you run the notebook example and then start to replace parts of the example with your needs. Then when you see that it stops working, you will have a good idea of where the problem is located. For example, use train and validation. Is it working? Then remove validation and see what happens.


De: eirini5th @.> Enviado: terça-feira, 20 de julho de 2021 12:36 Para: experiencor/keras-yolo2 @.> Cc: carlos @.>; Mention @.> Assunto: Re: [experiencor/keras-yolo2] 0 box detect (#409)

@zenetiohttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fzenetio&data=04%7C01%7C%7C2b4964556de2404ae0bb08d94b7b07e1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637623814054931235%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nGgKWH7YsdsEmXS2j22D2ZhNzifUFDhOYWg7%2BTfKbtw%3D&reserved=0 thanks for your answer! Unfortunately in my case it still predicts 0 boxes even after using the normalize function. Only difference is I don't use a valid_batch, I wanted to first test it on a single image, which I am also normalizing before the prediction. Maybe I should try with an actual batch of validation images?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fexperiencor%2Fkeras-yolo2%2Fissues%2F409%23issuecomment-883357891&data=04%7C01%7C%7C2b4964556de2404ae0bb08d94b7b07e1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637623814054941230%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=G47Q8NwEXPZZx5rAs2VfWg%2BN2TnE81r4nWU05UKZwO0%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAENGIKFFHAMNC3QSL7TZ6TTYVUVVANCNFSM4HB5TU2A&data=04%7C01%7C%7C2b4964556de2404ae0bb08d94b7b07e1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637623814054941230%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uKgSYUe50FLLywLjfXGybPoHfDStOf1slOZoc0jM1hA%3D&reserved=0.

zenetio avatar Jul 20 '21 15:07 zenetio