WongKinYiu / PyTorch_YOLOv4

PyTorch implementation of YOLOv4
1.88k stars 585 forks source link

Step size in plots is not uniform (wandb) #371

Open antimo22 opened 2 years ago

antimo22 commented 2 years ago

Hi, training a YOLOv4 model on my custom dataset, I see that the step size in the wandb plots is not uniform between the various metrics: for instance, after 2 epochs, I have the precision value only for step=7 and step=20, while the recall for step=5 and step=18. Can you tell me why I'm having this problem? I've followed the darknet guide to change the batch size / nclasses ecc.

WongKinYiu commented 2 years ago

https://github.com/WongKinYiu/PyTorch_YOLOv4/issues/364#issuecomment-923929174

antimo22 commented 2 years ago

Hi @WongKinYiu, thanks for your reply, I've already seen that issue but I'm not able to understand that language, even with google translate.

WongKinYiu commented 2 years ago

it due to when call wandb.log, the step in wandb will increase by 1. so you need change line 357 to 361 of train.py to

            if wandb:
                wandb_log_dict = {}
            for x, tag in zip(list(mloss[:-1]) + list(results) + lr, tags):
                if tb_writer:
                    tb_writer.add_scalar(tag, x, epoch)  # tensorboard
                if wandb:
                    wandb_log_dict[tag] = x
            if wandb:
                wandb.log(wandb_log_dict)  # W&B

and maybe also need to comment line 239 to 241 of test.py