Home

Awesome

Pytorch 1.9.0 code for:

F-CAM: Full Resolution Class Activation Maps via Guided Parametric Upscaling (https://arxiv. org/abs/2109.07069)

WACV 2022: [Slides] [Video presentation] [Poster]

Citation:

@InProceedings{belharbi2022fcam,
  title={F-CAM: Full Resolution Class Activation Maps via Guided Parametric Upscaling},
  author={Belharbi, S. and Sarraf, A. and Pedersoli, M. and Ben Ayed, I. and McCaffrey, L. and Granger, E.},
  booktitle = {WACV},
  year={2022}
}

Issues:

Please create a github issue.

Content:

<a name='reqs'> Requirements</a>:

cd dlib/crf/crfwrapper/bilateralfilter
swig -python -c++ bilateralfilter.i
python setup.py install

<a name="datasets"> Download datasets </a>:

See folds/wsol-done-right-splits/dataset-scripts. For more details, see wsol-done-right repo.

Once you download the datasets, you need to explicitly set 'baseurl' in get_root_wsol_dataset() to point to the folder parent containing your data. Inside the 'baseurl' folder there should be your dataset in folder named with the same name as your dataset. The function configure_data_paths() will setup the exact path to the dataset using 'baseurl' and the dataset name.

<a name="datasets"> Run code </a>:

time python main_wsol.py --task STD_CL \
                         --encoder_name resnet50 \
                         --arch STDClassifier \
                         --opt__name_optimizer sgd \
                         --batch_size 32 \
                         --opt__step_size 15 \
                         --opt__gamma 0.1 \
                         --max_epochs 50 \
                         --freeze_cl False \
                         --support_background True \
                         --method CAM \
                         --spatial_pooling WGAP \
                         --dataset CUB \
                         --box_v2_metric False \
                         --cudaid $cudaid \
                         --debug_subfolder None \
                         --opt__lr 0.0017 \
                         --exp_id 08_19_2021_14_05_20_620912__6229687
time python main_wsol.py --task F_CL \
                        --encoder_name resnet50 \
                        --arch UnetFCAM \
                        --opt__name_optimizer sgd \
                        --batch_size 32 \
                        --eval_checkpoint_type best \
                        --opt__step_size 1000 \
                        --opt__gamma 0.1 \
                        --max_epochs 50 \
                        --freeze_cl True \
                        --support_background True \
                        --method CAM \
                        --spatial_pooling WGAP \
                        --dataset CUB \
                        --box_v2_metric False \
                        --cudaid $cudaid \
                        --debug_subfolder None \
                        --opt__lr 0.01 \
                        --elb_init_t 1.0 \
                        --elb_max_t 10.0 \
                        --elb_mulcoef 1.01 \
                        --sl_fc True \
                        --sl_fc_lambda 1.0 \
                        --sl_start_ep 0 \
                        --sl_end_ep -1 \
                        --sl_min 1 \
                        --sl_max 1 \
                        --sl_ksz 3 \
                        --sl_min_p 0.1 \
                        --sl_fg_erode_k 11 \
                        --sl_fg_erode_iter 1 \
                        --crf_fc True \
                        --crf_lambda 2e-09 \
                        --crf_sigma_rgb 15.0 \
                        --crf_sigma_xy 100.0 \
                        --crf_scale 1.0 \
                        --crf_start_ep 0 \
                        --crf_end_ep -1 \
                        --max_sizepos_fc True \
                        --max_sizepos_fc_lambda 0.1 \
                        --max_sizepos_fc_start_ep 0 \
                        --max_sizepos_fc_end_ep -1 \
                        --entropy_fc False \
                        --exp_id 08_19_2021_14_09_48_915565__1492324

<a name='method'> Method</a>:

<img src="doc/fcam-intuition.png" alt="fcam-intuition" width="600"> <img src="doc/fcam-method.png" alt="fcam-method" width="600">

<a name='results'> Results</a>:

<img src="doc/fcam-cub-results.png" alt="fcam-cub-results" width="600"> <img src="doc/fcam-openimages-results.png" alt="fcam-openimages-results" width="600"> <img src="doc/fcam-taux-sensitivity.png" alt="fcam-taux-sensitivity" width="600"> <img src="doc/fcam-cam-distribution.png" alt="fcam-cam-distribution" width="600">