Skip to content

Commit 3370d81

Browse files
committed
fix tmp already exists error when downloading weights
1 parent 7457947 commit 3370d81

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Cifar/models/simplenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def _gen_simplenet(
351351
checkpoint_path = f"tmp/{checkpoint_filename}"
352352
print(f"saving in checkpoint_path:{checkpoint_path}")
353353
if not os.path.exists(checkpoint_path):
354-
os.makedirs("tmp")
354+
os.makedirs("tmp", exist_ok=True)
355355
download_url_to_file(url, checkpoint_path)
356356
checkpoint = torch.load(checkpoint_path, map_location="cpu",)
357357
model.load_state_dict(checkpoint)

ImageNet/simplenet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def _gen_simplenet(
352352
checkpoint_path = f"tmp/{checkpoint_filename}"
353353
print(f"saving in checkpoint_path:{checkpoint_path}")
354354
if not os.path.exists(checkpoint_path):
355-
os.makedirs("tmp")
355+
os.makedirs("tmp", exist_ok=True)
356356
download_url_to_file(url, checkpoint_path)
357357
checkpoint = torch.load(checkpoint_path, map_location="cpu",)
358358
model.load_state_dict(checkpoint)

0 commit comments

Comments
 (0)