inspire-group / DetectorGuard

Code for "DetectorGuard: Provably Securing Object Detectors against Localized Patch Hiding Attacks"
MIT License
14 stars 0 forks source link

BagNet Training #3

Closed quangnguyen-uoa closed 1 year ago

quangnguyen-uoa commented 1 year ago

Hi im using train_bagnet script code to train for my own traffic sign dataset but the loss didn't seem to decrease much and bagnet33 keeps predicting objects as background after few epochs. I already find New feature map size of my input using bagnet33. What did i do wrong

xiangchong1 commented 1 year ago

I don't have enough information to debug the issue. Here are some guesses

  1. the input image size to the model could cause a problem. Note that we are using BagNet with small receptive fields. If the image size is too larger and the object is too large, BagNet might not be able to make any reasonable prediction. In our paper, we use 416×416 for COCO and VOC and 224×740 for KITTI
  2. If you are using a customized dataset, make sure that you didn't mess up with the box coordinates: for example, accidentally treat x coordinates as y.
  3. The training loss is a combination of loss_pos and loss_negative. You might want to add a coefficient to balance these two losses. In your case, you might want to have a larger weight on loss_negative https://github.com/inspire-group/DetectorGuard/blob/main/checkpoints/train_bagnet_coco.py#L92
  4. Try other classic hyper-parameters tuning: e.g., try a different learning rate, use BagNet pre-trained on ImageNet, try a different BagNet (BagNet-17) etc.
quangnguyen-uoa commented 1 year ago

my image size is 600x800 and the objects height range from 24 to 120. Do u think the size is too big ? i would appreciate if u could have a look at my dataset (sent via email). I will definitely cite your work when i finish this paper

xiangchong1 commented 1 year ago

could you use the letterbox() to resize and pad it to 416x416? https://github.com/inspire-group/DetectorGuard/blob/main/utils/dataset.py#L18

you can send me the dataset, but I can't promise when I will have time to take a look at it. Unfortunately, training models for customized datasets is always a tricky process.

by the way, there is another repository that does not involve bagnet training, which might be easier for you to use https://github.com/inspire-group/ObjectSeeker

quangnguyen-uoa commented 1 year ago

Thanks alot !! i haven't read this repo but is this still a defense for backdoor attack

xiangchong1 commented 1 year ago

ObjectSeeker and DetectorGuard consider the same threat model: test-time adversarial patch attacks. they are not primarily designed for the backdoor attack, though they might work for localized backdoor triggers at the test time