Skip to content

Commit da8b79b

Browse files
authored
[fix] fix image save path bug in Windows (open-mmlab#1423)
* [fix] fix image save path bug in Windows * fix lint error
1 parent 2848885 commit da8b79b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/convert_datasets/isaid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ def slide_crop_image(src_path, out_dir, mode, patch_H, patch_W, overlap):
8585

8686
img_patch = img[y_str:y_end, x_str:x_end, :]
8787
img_patch = Image.fromarray(img_patch.astype(np.uint8))
88-
image = osp.splitext(
89-
src_path.split('/')[-1])[0] + '_' + str(y_str) + '_' + str(
90-
y_end) + '_' + str(x_str) + '_' + str(x_end) + '.png'
88+
image = osp.basename(src_path).split('.')[0] + '_' + str(
89+
y_str) + '_' + str(y_end) + '_' + str(x_str) + '_' + str(
90+
x_end) + '.png'
9191
# print(image)
9292
save_path_image = osp.join(out_dir, 'img_dir', mode, str(image))
9393
img_patch.save(save_path_image)
@@ -135,7 +135,7 @@ def slide_crop_label(src_path, out_dir, mode, patch_H, patch_W, overlap):
135135
lab_patch = label[y_str:y_end, x_str:x_end]
136136
lab_patch = Image.fromarray(lab_patch.astype(np.uint8), mode='P')
137137

138-
image = osp.splitext(src_path.split('/')[-1])[0].split(
138+
image = osp.basename(src_path).split('.')[0].split(
139139
'_')[0] + '_' + str(y_str) + '_' + str(y_end) + '_' + str(
140140
x_str) + '_' + str(x_end) + '_instance_color_RGB' + '.png'
141141
lab_patch.save(osp.join(out_dir, 'ann_dir', mode, str(image)))

0 commit comments

Comments
 (0)