matejgrcic / DenseHybrid

Official implementation of paper "DenseHybrid: Hybrid Anomaly Detection for Dense Open-set Recognition"
GNU General Public License v2.0
34 stars 2 forks source link

Requirements for the code #3

Closed mbisan closed 1 year ago

mbisan commented 1 year ago

Hi, I'm trying to execute the code as explained in the readme. I'm getting some errors probably related to version changes. I give some examples of the errors I am getting below and how I tried to solve them. I would like a list of requirements/dependencies for this repo.

I installed the following packages for python 3.10.6:

pytorch 1.13.1 numpy 1.24.1

I also installed tqdm, tensorboard, matplotlib, sklearn and other packages, but I am getting two errors that I think are related to the above packages:

UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.

Which is related to pytorch, and:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (14, 2) + inhomogeneous part.

Which occurs in the file DenseHybrid/data/datasets/street_hazards/streethazards_labels.py

The first error I just changed the function as the warning recommends where it was needed, but for the other error I'm not sure what to do.

I tried changing self.color_info = np.array(color_info) to self.color_info = np.array(color_info, dtype=object). The warning disappears.

I also changed some lines in DenseHybrid/evaluations/base.py as I was getting the following error:

conf = conf_probs.cpu()[label != 2] RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

I changed the line from conf = conf_probs.cpu()[label != 2] to conf = conf_probs[label != 2].cpu()

All in all, I would like the list of requirements, preferably with the proper versions, before trying to make everything work with the newer packages.

P.S. I managed to run successfully the following scripts after the above mentioned changes:

python3 ./DenseHybrid/evaluate_ood.py --dataroot ./datasets/lost_found --dataset lf --folder ./output-folder --params ./dlv3+_cityscapes_ade_negative_finetune.pth

python3 ./DenseHybrid/evaluate_ood.py --dataroot ./datasets/fs_static --dataset static --folder ./output-folder-fstatic --params ./dlv3+_cityscapes_ade_negative_finetune.pth

And:

python3 ./DenseHybrid/evaluate_ood.py --dataroot ./datasets/streethazards_test --dataset street-hazards --folder ./output-folder-sh-2 --params ./ldn121_street_hazards_ade_negatives_finetune.pth

mbisan commented 1 year ago

torch 1.12.1 numpy 1.23.3

With these versions the errors related to the numpy array are solved, and also the error about tensors not being in the same device.