(args)
| 129 | return data, best |
| 130 | |
| 131 | def main(args): |
| 132 | |
| 133 | #must pass in dataset arg for proper results |
| 134 | |
| 135 | os.makedirs(args.out_dir, exist_ok=True) |
| 136 | # setup plots |
| 137 | sns.set_style('darkgrid') |
| 138 | sns.set() |
| 139 | |
| 140 | frames = [] #array that collects dataframes from each file |
| 141 | if(args.dataset == "all"): |
| 142 | dataset_type = "*" |
| 143 | else: |
| 144 | dataset_type = args.dataset |
| 145 | |
| 146 | #gets all files that start with "resisc_" (still need a file with the baseline results) |
| 147 | # result_files = glob.glob(os.path.join(args.results_dir, dataset_type + "*.json"), recursive=True) |
| 148 | result_files1 = glob.glob(os.path.join(args.results_dir, dataset_type + "*crop*.json"), recursive=True) |
| 149 | result_files2 = glob.glob(os.path.join(args.results_dir, dataset_type + "*color*.json"), recursive=True) |
| 150 | result_files3 = glob.glob(os.path.join(args.results_dir, dataset_type + "*gray*.json"), recursive=True) |
| 151 | result_files = result_files1 + result_files2 + result_files3 |
| 152 | result_files.append(os.path.join(args.results_dir, dataset_type + "_results.json")) |
| 153 | |
| 154 | moco_baseline = imagenet_baseline = nobt_baseline = 0 |
| 155 | |
| 156 | for resfile in result_files: |
| 157 | with open(resfile, 'r') as infile: |
| 158 | raw_data = json.load(infile) |
| 159 | |
| 160 | print(resfile) |
| 161 | |
| 162 | types = [] #used for concatenating the resultzs from each basetrained model |
| 163 | data = pd.DataFrame(raw_data.values()) |
| 164 | |
| 165 | |
| 166 | #finds the relevant values for moco bt, imagenet supervised bt, and no bt |
| 167 | #mainly done to work around the baseline json file (has extra info that we don't want) |
| 168 | if (dataset_type + "_results.json") in resfile: |
| 169 | linear_data = data[data.result_type=='linear-eval'] |
| 170 | linear_data = linear_data[linear_data.variant=="linear-eval-lr"] |
| 171 | |
| 172 | data_moco = linear_data[data.basetrain=="moco_v2_800ep"] |
| 173 | data_moco = data_moco[data_moco.pretrain_iters=="5000"] |
| 174 | data_moco = data_moco[data_moco.pretrain_data==dataset_type] |
| 175 | data_moco, moco_baseline = reduce(data_moco) |
| 176 | |
| 177 | if args.basetrain == 'supervised': |
| 178 | data_imagenet = linear_data[data.basetrain=="imagenet_r50_supervised"] |
| 179 | data_imagenet = data_imagenet[data_imagenet.pretrain_iters=="50000"] |
| 180 | data_imagenet = data_imagenet[data_imagenet.pretrain_data==dataset_type] |
| 181 | data_imagenet, imagenet_baseline= reduce(data_imagenet) |
| 182 | types.append(data_imagenet) |
| 183 | |
| 184 | data_nobt = linear_data[data.basetrain=="no"] |
| 185 | data_nobt= data_nobt[data_nobt.pretrain_iters=="100000"] |
| 186 | data_nobt= data_nobt[data_nobt.pretrain_data==dataset_type] |
| 187 | data_nobt, nobt_baseline = reduce(data_nobt) |
| 188 |
no test coverage detected