From c8311a4f2e27fbde8c8f2c31a61bd1f2661c1142 Mon Sep 17 00:00:00 2001 From: Malinda Date: Sat, 6 Aug 2022 23:46:15 -0700 Subject: [PATCH] Using with stmt --- body/human_pose/ambiguity_aware/lib/utils/misc.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/body/human_pose/ambiguity_aware/lib/utils/misc.py b/body/human_pose/ambiguity_aware/lib/utils/misc.py index cc152168d..a42ef786d 100644 --- a/body/human_pose/ambiguity_aware/lib/utils/misc.py +++ b/body/human_pose/ambiguity_aware/lib/utils/misc.py @@ -48,9 +48,8 @@ def init_weights(model): m.bias.data.zero_() def save_pickle(data, save_path): - f = open(save_path, "wb") - pkl.dump(data, f) - f.close() + with open(save_path, "wb") as f: + pkl.dump(data, f) print(f"=> saved to {save_path}") def load_pickle(load_path):