[fix] fix image save path bug in Windows (#1423)

* [fix] fix image save path bug in Windows

* fix lint error
This commit is contained in:
Pan Zhang 2022-04-09 21:17:51 +08:00 committed by GitHub
parent 28488851fd
commit da8b79b4da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)))