From cba10b3f15ef7f6b9d78a64a80488e3d1217af4b Mon Sep 17 00:00:00 2001 From: Pan Zhang <pzhang.omega@gmail.com> Date: Sat, 9 Apr 2022 21:17:51 +0800 Subject: [PATCH] [fix] fix image save path bug in Windows (#1423) * [fix] fix image save path bug in Windows * fix lint error --- tools/convert_datasets/isaid.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/convert_datasets/isaid.py b/tools/convert_datasets/isaid.py index ff2ce2fc..314fb894 100644 --- a/tools/convert_datasets/isaid.py +++ b/tools/convert_datasets/isaid.py @@ -85,9 +85,9 @@ def slide_crop_image(src_path, out_dir, mode, patch_H, patch_W, overlap): img_patch = img[y_str:y_end, x_str:x_end, :] img_patch = Image.fromarray(img_patch.astype(np.uint8)) - image = osp.splitext( - src_path.split('/')[-1])[0] + '_' + str(y_str) + '_' + str( - y_end) + '_' + str(x_str) + '_' + str(x_end) + '.png' + image = osp.basename(src_path).split('.')[0] + '_' + str( + y_str) + '_' + str(y_end) + '_' + str(x_str) + '_' + str( + x_end) + '.png' # print(image) save_path_image = osp.join(out_dir, 'img_dir', mode, str(image)) img_patch.save(save_path_image) @@ -135,7 +135,7 @@ def slide_crop_label(src_path, out_dir, mode, patch_H, patch_W, overlap): lab_patch = label[y_str:y_end, x_str:x_end] lab_patch = Image.fromarray(lab_patch.astype(np.uint8), mode='P') - image = osp.splitext(src_path.split('/')[-1])[0].split( + image = osp.basename(src_path).split('.')[0].split( '_')[0] + '_' + str(y_str) + '_' + str(y_end) + '_' + str( x_str) + '_' + str(x_end) + '_instance_color_RGB' + '.png' lab_patch.save(osp.join(out_dir, 'ann_dir', mode, str(image))) -- GitLab