valeoai / obsnet

32 stars 2 forks source link

Dataset object has no attribute "args.colors" and appropriate pre-trained file for "segnet_file" #2

Closed quanghuy0497 closed 1 year ago

quanghuy0497 commented 1 year ago

Hi, I have just cloned your code on the current version to conduct experiments on my own. I have download the pre-trained file from the provide google drive, and setup the dataset as instructed. However, when running the code with the following command (with some minor customization for the folder), I am facing several issues:

python main.py --dset_folder "data/CamVid" --segnet_file "pre_train/ObsNet_BddAnomaly.pth" --obsnet_file "./ckpt/camvid/" --data "CamVid" --tboard "./logs/camvid" --num_workers 4 --bsize 8 --adv "min_random_patch" --epsilon 0.025 --lr 0.2 --no_pretrained
  1. Dataset.colors is not defined with the following error:

    File "main.py", Line 32, In main
    args.colors = np.array(train_loader.dataset.colors)
    AttributeError: 'StreetHazard' object has no attribute 'colors'

    I can easily tackle the problem by remove this line, but I wonder if there is something missing here.

  2. Error in loading segnet_file: After temporally tackling the first issue, when running the executed code again, I find the error

    File "~/miniconda3/envs/obsnet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1672, in load_state_dict
    self.__class__.__name__, "Init". join (error-msgs)))
    RuntimeError: Error (s) in loading state_dict for SegNet:
    Missing key(s) in state_dict: "down1.conv1.cbr_unit.O.weight", "down1.conv1.cbr_unit.O.bias",....
    Unexpected key(s) in state _dict: "backbone.conv1.weight", "backbone.bn1.weight",....

    Whatever the pre-trained model is (from the provide google drive), I still received the similar error. This erros is only happens when the pre-trained model is incompatible with the designed segnet network, leading to the load_state_dict error.

Therefore, I do not know if I am doing anything wrong here, and how to setup the right setting for running the code to train ObsNet either in CamVid or StreetHarzards dataset.

Thank you very much for your support

quanghuy0497 commented 1 year ago

Update Feb 27, 2023: After trying various combination of configurations, I found all the combinations between architecture model (segnet|deeplabv3plus|road_anomaly) and pre-trained seg-net model (ObsNet_CityScapes.pth, ObsNet_BddAnomaly.pth, WideResnet_DeepLabv3plus_CityScapes.pth, or DeepLabv3plus_BddAnomaly.pth) always results with the same errors in the above comment.

I believe these errors come with incompatible pre-trained model. I can perform experiments from scratch without pre-trained segnet, but I wish to validste ObsNet performance with and without pre-trained models. Therefore, could you look at it and support me with the alternative pre-trained segnet file?

Thank you very much for your support.