Skip to content

Commit 993a98a

Browse files
authored
Fix invalid characters in filename in neural_style.py (line 119 in train function) (#1294)
Replaced colon (:) in the timestamp to ensure the file can be saved correctly on Windows. The change was made at line 119 of the train function in neural_style.py.
1 parent 892eca0 commit 993a98a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fast_neural_style/neural_style/neural_style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def train(args):
116116

117117
# save model
118118
transformer.eval().cpu()
119-
save_model_filename = "epoch_" + str(args.epochs) + "_" + str(time.ctime()).replace(' ', '_') + "_" + str(
120-
args.content_weight) + "_" + str(args.style_weight) + ".model"
119+
timestamp = time.strftime("%Y-%m-%d_%H-%M-%S")
120+
save_model_filename = f"epoch_{args.epochs}_{timestamp}_{args.content_weight}_{args.style_weight}.model"
121121
save_model_path = os.path.join(args.save_model_dir, save_model_filename)
122122
torch.save(transformer.state_dict(), save_model_path)
123123

0 commit comments

Comments
 (0)