cuda 10.1
python 3.7
-python libraries:
--pytorch 1.0
--torchvision
--math
--scipy
--numpy
--numbers



For ZSL results
Put images of AWA1 to datasets/Images/AWA1
run:
python train_Norm_Triplet_3Scale.py --dataset AWA1 --split PP --gpu 0 --BATCH_SIZE 40
or prefered 2-gpus
python train_Norm_Triplet_3Scale.py --dataset AWA1 --split PP --gpu 0,1 --BATCH_SIZE 64

To go over the whole precedure:
================================================================================
Step1-pretrain: finetune VGG19 backbone, and produce channel grouping by k-means

In the python train_finetune_STEP1.py, 
uncomment: train() 
comment:
  resume = 'models_MA/MA_CNN_STEP1_PP/ZSL_Finetune_STEP1_Epoch10.tar'
  channel_clustering_Conv5_4(ngroup=2, resume=resume)
==> python train_finetune_STEP1.py --dataset AWA1 --split PP --gpu 0 --nepoch 10
you will have the file: models_MA/AWA1/MA_CNN_STEP1_PP/ZSL_Finetune_STEP1_Epoch10.tar

In the python train_finetune_STEP1.py, 
comment: train() 
uncomment:
  resume = 'models_MA/MA_CNN_STEP1_PP/ZSL_Finetune_STEP1_Epoch10.tar'
  channel_clustering_Conv5_4(ngroup=2, resume=resume)
==> python train_finetune_STEP1.py --dataset AWA1 --split PP --gpu 0 
you will have the file: models_MA/AWA1/MA_CNN_STEP1_PP/train_channel_cluster_STEP1_2Group.pkl
================================================================================

================================================================================
Step2-pretrain: train channel grouping layers (2 stacked FC layers) (Note: use single gpu. There may be a bug in multi-gpu)
Uncomment train() comment others
==> python train_finetune_STEP2_2Group.py --dataset AWA1 --split PP --gpu 0
	--channel_cluster = models_AWA1/MA_CNN_STEP1_PP/train_channel_cluster_STEP1_2Group.pkl
    --resume_STEP1    = models_AWA1/MA_CNN_STEP1_PP/ZSL_Finetune_STEP1_Epoch10.tar
You will get the file: models_MA/AWA1/MA_CNN_STEP2_PP/ZSL_Finetune_STEP2_Phase2_CHG_2Group_Epoch3.tar

Uncomment visualize_test() comment others
==> python train_finetune_STEP2_2Group.py --dataset AWA1 --split PP --gpu 0
	--resume_Phase2 models_MA/AWA1/MA_CNN_STEP2_PP/ZSL_Finetune_STEP2_Phase2_CHG_2Group_Epoch3.tar
You can see some results visualization: attention maps, channel-weights

Uncomment test_generate_rec_Img() comment others
==> python train_finetune_STEP2_2Group.py --dataset AWA1 --split PP --gpu 0
	--resume_Phase2 models_MA/AWA1/MA_CNN_STEP2_PP/ZSL_Finetune_STEP2_Phase2_CHG_2Group_Epoch3.tar
You can get the file: models_MA/AWA1/MA_CNN_STEP2_PP/Pred_Boxes_half_PP.json (All Boundingbox)
If you use:
test_generate_rec_Img(save_image_folder='AWA1_data_box_half_PP', size='half')
you can get the images with boundingbox marked in the folder 'AWA1_data_box_half_PP'.
(Note, it would be very slow.)
================================================================================

================================================================================
Step3: ZSL model training, The Joint Feature Learning Subnet in the paper. 
copy models_MA/AWA1/MA_CNN_STEP2_PP/Pred_Boxes_half_PP.json 
to datasets/BBoxes/AWA1/Pred_Boxes_half_PP.json 
run:
python train_Norm_Triplet_3Scale.py --dataset AWA1 --split PP --gpu 0 --BATCH_SIZE 40
or prefered 2-gpus
python train_Norm_Triplet_3Scale.py --dataset AWA1 --split PP --gpu 0,1 --BATCH_SIZE 64


