SPG icon indicating copy to clipboard operation
SPG copied to clipboard

How to put the pre-training model in the right place?

Open xiaopingzeng opened this issue 7 years ago • 7 comments

Which folder should I put the pre-training model “cub_epoch_100_glo_step_20200.pth.zip” and “imagenet_epoch_2_glo_step_128118.pth.zip” in?

xiaopingzeng avatar Nov 29 '18 01:11 xiaopingzeng

Hi @xiaopingzeng ,

Did you figure this out ?

Rahul-Venugopal avatar Dec 05 '18 18:12 Rahul-Venugopal

You have two choices

  1. mkdir -p snapshots/inception_imagenet_full_spg cp ***.pth.zip snapshots/inception_imagenet_full_spg/ The script of utils/Restore.py will automatically load the least saved model according to the save date. You can also read through this script to make some modifications for your convinience.

  2. add the variable restore_from to your testing script. The value of this variable should be the path of your saved trained model.

xiaomengyc avatar Dec 05 '18 23:12 xiaomengyc

Thanks @xiaomengyc
...I have done that and now the pretrained model "cub_epoch_100_glo_step_20200.pth.zip" is loaded . As mentioned in your page , I am using sh val_cub_full.sh to generate attention maps . Is there any test script which I have to use for generating heatmap on a new image ? or can I use val_cub_full.sh for the same purpose ?

I have edited val_cub_full.sh as following

#!/bin/sh

cd ../exper/

#v5_v3

ROOT_DIR=/home/rr/Desktop/The/Reference/WSOL/ACoL/SPG

CUDA_VISIBLE_DEVICES=0 python val_frame.py --arch=inception3_spg
--batch_size=1
--img_dir=${ROOT_DIR}/test_images/
--train_list=${ROOT_DIR}/datalist/CUB/train_list.txt
--test_list=${ROOT_DIR}/datalist/CUB/test_list.txt
--num_gpu=1
--dataset=cub
--num_classes=200
--snapshot_dir=../snapshots/inception_imagenet_full_spg/ --onehot=False

I am trying to use model trained on CUB . If I want to generate attention map on a new image , where should I put the image and what modifications should I make on the script ?

Rahul-Venugopal avatar Dec 06 '18 11:12 Rahul-Venugopal

@Rahul-Venugopal If you want to test on a new dataset without largely changing this code, a feasible solution I suggest is to generate a testing list file like datalist/test_list.txt. But no worries! I am preparing a demo script for testing arbitrary single image. Hope I can finish this in a few days. By the way, if you'd like testing a random image, it would be better to use the model trained on ImageNet, because the CUB dataset only contains many kinds of birds.

xiaomengyc avatar Dec 06 '18 23:12 xiaomengyc

Hi , Thanks for replying. And I hope a demo script will be very helpful and thanks for your effort.

By the way , I have already tried creating a testing file like datalist/test_list.txt . When i run sh val_cub_full.sh , a masked image as similair to the output of proposed network is created under ../save_bins . Is it possible to create attention map as shown in figure or my be bounding boxes ? When i check ../util/save_attn.py , some portions to generate heatmaps are commented out. Do I have to modify anything there to generate attention maps ?

Thanks Rahul

Rahul-Venugopal avatar Dec 07 '18 15:12 Rahul-Venugopal

Hi @xiaomengyc ,

Is there any update on demo script on testing as you mentioned before ?

Rahul-Venugopal avatar Jan 25 '19 09:01 Rahul-Venugopal

Hi @Rahul-Venugopal ,

Sorry for the late reply. The demo scripts have been uploaded. Please refer to the setup_demo.txt for more guidance.

xiaomengyc avatar Feb 13 '19 00:02 xiaomengyc