# fo.data, # final_weight, # features[-1], # thresholds[-1], # preds, # logits, # prev_layername=layernames[-1], # prev_tally=tallies[-1], # contributors=contrs_spread[-1], # skip=False, # ) # # ==== STEP 6: generate index html ==== # # Add final contrs/tallies/layernames/htmls: # all_card_htmls["final"] = final_card_htmls # if len(all_card_htmls) <= 1: # # Don't overwrite the existing one # print("Warning - no card htmls collected") # else: # with open(all_card_htmls_fname, "wb") as f: # pickle.dump(all_card_htmls, f) # # Add final tallies and layernames (one indexed) # tallies.append({k: {"label": v} for k, v in ade20k.I2S.items()}) # layernames.append("final") # vindex.generate_index(layernames, contrs_spread, tallies, all_card_htmls) if settings.CLEAN: clean()
# setup a hook to extract unit info for name in args.FEATURE_NAMES: model._modules.get(name).register_forward_hook(hook_feature) if args.GPU: model.cuda() model.eval() ############ STEP 1: feature extraction ############### features, maxfeature = fo.feature_extraction(model=model) for layer_id, layer in enumerate(args.FEATURE_NAMES): ############ STEP 2: calculating threshold ############ thresholds = fo.quantile_threshold(features[layer_id], savepath="quantile.npy") ############ STEP 3: calculating IoU scores ########### tally_result = fo.tally(features[layer_id], thresholds, savepath="tally.csv") ############ STEP 4: generating results ############### generate_html_summary(fo.data, layer, args, tally_result=tally_result, maxfeature=maxfeature[layer_id], features=features[layer_id], thresholds=thresholds) if args.CLEAN: clean(args)