is_oxford_paris_dataset, is_revisited_dataset, is_whiten_dataset, l2n, ) from vissl.utils.instance_retrieval_utils.rmac import get_rmac_descriptors from vissl.utils.io import load_file, makedir, save_file from vissl.utils.logger import setup_logging, shutdown_logging from vissl.utils.pca import load_pca, train_and_save_pca from vissl.utils.perf_stats import PerfStats, PerfTimer # frequency at which we log the image number being processed. LOG_FREQUENCY = 100 # Setup perf timer. PERF_STATS = PerfStats() def build_retrieval_model(cfg): """ Builds the model on 1-gpu and initializes from the weight. """ logging.info("Building model....") model = build_model(cfg.MODEL, cfg.OPTIMIZER) if g_pathmgr.exists(cfg.MODEL.WEIGHTS_INIT.PARAMS_FILE): init_weights_path = cfg.MODEL.WEIGHTS_INIT.PARAMS_FILE logging.info(f"Initializing model from: {init_weights_path}") weights = load_checkpoint(init_weights_path, device=torch.device("cuda")) skip_layers = cfg.MODEL.WEIGHTS_INIT.get("SKIP_LAYERS", []) replace_prefix = cfg.MODEL.WEIGHTS_INIT.get("REMOVE_PREFIX", None)
def on_phase_start(self, task: "tasks.ClassyTask") -> None: """ Initialize start time and reset perf stats """ self.start_time = time.time() task.perf_stats = PerfStats()