diff --git a/tools/convert_datasets/isaid.py b/tools/convert_datasets/isaid.py index ff2ce2fcf57..314fb894f82 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)))