Python 3.8.11 (default, Aug 3 2021, 15:09:35)

Type "copyright", "credits" or "license" for more information.


IPython 7.22.0 -- An enhanced Interactive Python.


Restarting kernel...




In [1]: runcell(0, '/home/min/a/tibrayev/RESEARCH/active_fable/fable_v2_falcon/FALcon_collect_samples_imagenet2013_det.py')

/home/min/a/tibrayev/miniconda3/envs/torch_1.9_torchvision_10.0/lib/python3.8/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html

from .autonotebook import tqdm as notebook_tqdm


In [2]: config_3 = FALcon_config

   ...: config_3_copy = {k: v for k, v in config_3.__dict__.items() if '__' not in k}


In [3]: config_3_copy

Out[3]:

{'seed': 16,

'dataset': 'imagenet2013-det',

'dataset_dir': '/home/nano01/a/tibrayev/imagenet/imagenet2013-detection',

'loader_type': 'valid',

'num_classes': 1000,

'in_num_channels': 3,

'full_res_img_size': (256, 256),

'cls_model_name': 'resnet50',

'cls_pretrained': True,

'cls_ckpt_dir': None,

'save_dir': './results/imagenet/wsol_method_PSOL/trained_on_train_split/arch_vgg16_pretrained_init_normalization_none_seed_16/',

'model_name': 'vgg16',

'initialize': 'resume',

'ckpt_dir': './results/imagenet/wsol_method_PSOL/trained_on_train_split/arch_vgg16_pretrained_init_normalization_none_seed_16/model.pth',

'batch_size_eval': 50,

'init_factual': 'pretrained',

'downsampling': 'M',

'fc1': 256,

'fc2': 128,

'dropout': 0.5,

'norm': 'none',

'init_weights': True,

'adaptive_avg_pool_out': (1, 1),

'saccade_fc1': 256,

'saccade_dropout': False,

'num_glimpses': 16,

'fovea_control_neurons': 4,

'glimpse_size_grid': (20, 20),

'glimpse_size_init': (20, 20),

'glimpse_size_fixed': (96, 96),

'glimpse_size_step': (20, 20),

'glimpse_change_th': 0.5,

'iou_th': 0.5,

'ratio_wrong_init_glimpses': 0.5,

'switch_location_th': 0.2,

'objectness_based_nms_th': 0.5,

'confidence_based_nms_th': 0.5}


In [4]: from voclike_imagenet_evaluator import do_voc_evaluation

   ...: collected_samples = {}

   ...: path_to_samples = './results/imagenet/wsol_method_PSOL/trained_on_train_split/arch_vgg16_pretrained_init_normalization_none_seed_16/'

   ...: partial_sample_collections = list(filter((lambda x: ('imagenet2013-det_collected_sample_from' in x)), os.listdir(path_to_samples)))

   ...: for partial in partial_sample_collections:

   ...: ckpt = torch.load(os.path.join(path_to_samples, partial))

   ...: collected_samples.update(ckpt)


In [5]: len(collected_samples)

Out[5]: 20120


In [6]: results_ap = do_voc_evaluation(collected_samples)


In [7]: results_ap

Out[7]:

{'ap': array([ nan, 0. , 0.367 , 0. , 0. , 0. , 0.0909, 0. , 0. , 0. , 0. , 0. , 0. , 0.0568, 0. , 0.0045, 0. , 0.0909, 0. ,

0. , 0.0909, 0. , 0.0909, 0. , 0.0455, 0. , 0.026 , 0.1549, 0.0043, 0.1549, 0. , 0.1455, 0.1173, 0. , 0. , 0.0952, 0.0909, 0.1031,

0.0165, 0.0909, 0.0909, 0. , 0.2859, 0.0303, 0.1914, 0.139 , 0.3056, 0.114 , 0. , 0.0909, 0.0455, 0.013 , 0.1356, 0.0909, 0.0906, 0.0909, 0. ,

0.1364, 0. , 0. , 0.0364, 0. , 0.0455, 0. , 0.0909, 0.0909, 0.1136, 0. , 0.234 , 0.2285, 0.2723, 0.2548, 0.0888, 0.1281, 0. , 0.0093,

0.2331, 0.0083, 0.011 , 0.0909, 0.4793, 0.0227, 0. , 0. , 0. , 0. , 0.0909, 0.0909, 0.0909, 0.0182, 0.0909, 0.0909, 0.0949, 0.0105, 0.1136,

0. , 0.1136, 0. , 0.0909, 0.1402, 0.4503, 0.1234, 0. , 0.1552, 0. , 0.0935, 0.0158, 0.0909, 0.2207, 0.0519, 0.0182, 0. , 0.1001, 0.1225,

0.0839, 0.1364, 0.1636, 0.1136, 0.1532, 0. , 0.4641, 0.141 , 0.0227, 0.1488, 0.0227, 0.0135, 0.0455, 0. , 0.1803, 0. , 0.4871, 0.0303, 0.6263,

0.013 , 0.0065, 0.0198, 0.3364, 0. , 0.1382, 0.1185, 0.0909, 0.2109, 0. , 0.3725, 0.0909, 0. , 0.2623, 0.0227, 0.0909, 0. , 0.1085, 0.2631,

0.1119, 0.1399, 0.0455, 0.1589, 0.0069, 0.2704, 0.1189, 0. , 0.0893, 0. , 0.0909, 0.0606, 0.1322, 0.0045, 0. , 0.007 , 0.0065, 0.1488, 0.4847,

0.0545, 0.1212, 0.0909, 0. , 0.1658, 0.1591, 0.1364, 0. , 0.5487, 0.0063, 0.1044, 0.1405, 0. , 0.0606, 0.2445, 0.2034, 0.4183, 0.5584, 0.0354,

0. , 0.0829, 0.1455, 0.4597, 0.3931, 0. , 0.0455, 0.3171, 0.4136, 0.21 , 0.0579]),

'map': 0.10316761396673853}


In [8]: len(results_ap['ap'])

Out[8]: 201


In [9]: np.nanmean(results_ap['ap'][1:])

Out[9]: 0.10316761396673854


In [10]: