Skip to content

Commit 7957c27

Browse files
Merge pull request #211 from agimus-project/fix/deprecation_warnings
Fix/deprecation warnings
2 parents 1a480db + 42c044f commit 7957c27

File tree

10 files changed

+20
-10
lines changed

10 files changed

+20
-10
lines changed

happypose/pose_estimators/cosypose/cosypose/evaluation/evaluation.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def load_detector(run_id, ds_name):
6060
cfg = check_update_config_detector(cfg)
6161
label_to_category_id = cfg.label_to_category_id
6262
model = create_model_detector(cfg, len(label_to_category_id))
63-
ckpt = torch.load(run_dir / "checkpoint.pth.tar", map_location=device)
63+
ckpt = torch.load(
64+
run_dir / "checkpoint.pth.tar", map_location=device, weights_only=True
65+
)
6466
ckpt = ckpt["state_dict"]
6567
model.load_state_dict(ckpt)
6668
model = model.to(device).eval()

happypose/pose_estimators/cosypose/cosypose/evaluation/meters/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def gather_distributed(self, tmp_dir):
3838
all_datas = self.datas
3939
for n in range(1, world_size):
4040
tmp_file = tmp_file_template.format(rank=n)
41-
datas = torch.load(tmp_file)
41+
datas = torch.load(tmp_file, weights_only=True)
4242
for k in all_datas.keys():
4343
all_datas[k].extend(datas.get(k, []))
4444
Path(tmp_file).unlink()

happypose/pose_estimators/cosypose/cosypose/multiview/ransac.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def make_obj_infos(matched_candidates):
133133
scene_infos = matched_candidates.infos.loc[:, ["obj_id", "score", "label"]].copy()
134134
gb = scene_infos.groupby("obj_id")
135135
scene_infos["n_cand"] = gb["score"].transform(len).astype(int)
136-
scene_infos["score"] = gb["score"].transform(np.sum)
136+
scene_infos["score"] = gb["score"].transform("sum")
137137
scene_infos = gb.first().reset_index(drop=False)
138138
return scene_infos
139139

happypose/pose_estimators/cosypose/cosypose/scripts/run_bop_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def load_detector(run_id):
8383
cfg = check_update_config_detector(cfg)
8484
label_to_category_id = cfg.label_to_category_id
8585
model = create_model_detector(cfg, len(label_to_category_id))
86-
ckpt = torch.load(run_dir / "checkpoint.pth.tar")
86+
ckpt = torch.load(run_dir / "checkpoint.pth.tar", weights_only=True)
8787
ckpt = ckpt["state_dict"]
8888
model.load_state_dict(ckpt)
8989
model = model.cuda().eval()

happypose/pose_estimators/cosypose/cosypose/scripts/run_detection_eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def load_detector(run_id):
5555
cfg = check_update_config(cfg)
5656
label_to_category_id = cfg.label_to_category_id
5757
model = create_model_detector(cfg, len(label_to_category_id))
58-
ckpt = torch.load(run_dir / "checkpoint.pth.tar")
58+
ckpt = torch.load(run_dir / "checkpoint.pth.tar", weights_only=True)
5959
ckpt = ckpt["state_dict"]
6060
model.load_state_dict(ckpt)
6161
model = model.cuda().eval()

happypose/pose_estimators/cosypose/cosypose/training/evaluation.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def load_detector(run_id, ds_name):
6969
cfg = check_update_config_detector(cfg)
7070
label_to_category_id = cfg.label_to_category_id
7171
model = create_model_detector(cfg, len(label_to_category_id))
72-
ckpt = torch.load(run_dir / "checkpoint.pth.tar", map_location=device)
72+
ckpt = torch.load(
73+
run_dir / "checkpoint.pth.tar", map_location=device, weights_only=True
74+
)
7375
ckpt = ckpt["state_dict"]
7476
model.load_state_dict(ckpt)
7577
model = model.to(device).eval()

happypose/pose_estimators/cosypose/cosypose/training/pose_models_cfg.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ def load_model_cosypose(
6565
cfg = yaml.load((run_dir / "config.yaml").read_text(), Loader=yaml.UnsafeLoader)
6666
cfg = check_update_config(cfg)
6767
model = create_pose_model_cosypose(cfg, renderer=renderer, mesh_db=mesh_db_batched)
68-
ckpt = torch.load(run_dir / "checkpoint.pth.tar", map_location=device)
68+
ckpt = torch.load(
69+
run_dir / "checkpoint.pth.tar", map_location=device, weights_only=True
70+
)
6971
ckpt = ckpt["state_dict"]
7072
model.load_state_dict(ckpt)
7173
model = model.to(device).eval()

happypose/pose_estimators/cosypose/cosypose/training/train_detector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def make_datasets(dataset_names):
218218
resume_dir = EXP_DIR / args.resume_run_id
219219
path = resume_dir / "checkpoint.pth.tar"
220220
logger.info(f"Loading checkpoing from {path}")
221-
save = torch.load(path)
221+
save = torch.load(path, weights_only=True)
222222
state_dict = save["state_dict"]
223223
model.load_state_dict(state_dict)
224224
start_epoch = save["epoch"] + 1

happypose/pose_estimators/cosypose/cosypose/training/train_pose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def make_datasets(dataset_names):
349349
resume_dir = EXP_DIR / args.resume_run_id
350350
path = resume_dir / "checkpoint.pth.tar"
351351
logger.info(f"Loading checkpoing from {path}")
352-
save = torch.load(path)
352+
save = torch.load(path, weights_only=True)
353353
state_dict = save["state_dict"]
354354
model.load_state_dict(state_dict)
355355
start_epoch = save["epoch"] + 1

happypose/toolbox/inference/utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ def load_detector(run_id: str, device="cpu") -> torch.nn.Module:
6464
cfg = check_update_config_detector(cfg)
6565
label_to_category_id = cfg.label_to_category_id
6666
model = create_model_detector(cfg, len(label_to_category_id))
67-
ckpt = torch.load(run_dir / "checkpoint.pth.tar", map_location=torch.device(device))
67+
ckpt = torch.load(
68+
run_dir / "checkpoint.pth.tar",
69+
map_location=torch.device(device),
70+
weights_only=True,
71+
)
6872
ckpt = ckpt["state_dict"]
6973
model.load_state_dict(ckpt)
7074
model = model.to(device).eval()

0 commit comments

Comments
 (0)