WendongZh / SPL

[IJCAI'21] Code for Context-Aware Image Inpainting with Learned Semantic Priors,
53 stars 4 forks source link

There was a problem with the eval: NameError: name 'device' is not defined #10

Closed vivibyl closed 2 years ago

vivibyl commented 2 years ago

image Looking forward to your reply!Thanks!

WendongZh commented 2 years ago

Thanks for your interest!

It seems that you try to evaluate our model with CPU only. The reason for this error lies in that the current code only supports evaluation with GPUs. Sorry for that.

So the solution is, if you have no GPU for test, you can simply remove all the "device" and ".cuda()" in eval_final.py file, and remove line 186 to line 193 in eval_final.py file. I think it may works. In this case, you should use command as follows:

python eval_final.py --bs 50 --cpu --dataset paris \
        --img_flist your/test/image/flist/ --mask_flist your/flist/of/masks --mask_index your/npy/file/to/form/img-mask/pairs \
        --model checkpoints/x_launcherRN_bs_4_epoch_best.pt --save --save_path ./test_results

If you have at least on GPU, you can directly use our provided command:

CUDA_VISIBLE_DEVICES=0 python eval_final.py --bs 50 --gpus 1 --dataset paris \
        --img_flist your/test/image/flist/ --mask_flist your/flist/of/masks --mask_index your/npy/file/to/form/img-mask/pairs \
        --model checkpoints/x_launcherRN_bs_4_epoch_best.pt --save --save_path ./test_results

This command will use the GPU for evaluation.

Good luck for you.