From 99318fda14c907c62fd66d896f3a7ebecc14b1c6 Mon Sep 17 00:00:00 2001 From: dhodcz2 Date: Mon, 29 Jul 2024 20:33:26 -0500 Subject: [PATCH] validate_topn save should makedir if not exists --- src/tile2net/tileseg/utils/trnval_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tile2net/tileseg/utils/trnval_utils.py b/src/tile2net/tileseg/utils/trnval_utils.py index 55b2c66..8fa1bbe 100644 --- a/src/tile2net/tileseg/utils/trnval_utils.py +++ b/src/tile2net/tileseg/utils/trnval_utils.py @@ -296,7 +296,12 @@ def validate_topn(val_loader, net, criterion, optim, epoch, args, dump_assets=Tr output_data = torch.nn.functional.softmax(output, dim=1).cpu().data op = output_data.cpu().detach().numpy() - np.save(f'{cfg.RESULT_DIR}/output_{epoch}_{val_idx}.npy', op) + path = os.path.join( + cfg.RESULT_DIR, + f'output_{epoch}_{val_idx}.npy' + ) + os.makedirs(cfg.RESULT_DIR, exist_ok=True) + np.save(path, op) prob_mask, predictions = output_data.max(1) #define assests based on the eval_minibatch function assets = {}