if task is None:
if hasattr(checkpoints_data[0]["args"], "mode"):
checkpoints_data[0]["args"].mode = "eval"
task = tasks.setup_task(checkpoints_data[0]["args"])
for checkpoint_data in checkpoints_data:
model = task.build_model(checkpoint_data["args"])
model.load_state_dict(checkpoint_data["model"])
After Change
cfg = get_cfg(checkpoints_data[0], "task")
if hasattr(cfg, "mode"):
cfg.mode = "eval"
task = tasks.setup_task(cfg)
for checkpoint_data in checkpoints_data:
cfg = get_cfg(checkpoint_data, "model")
model = task.build_model(cfg)
model.load_state_dict(checkpoint_data["model"])