From b6ec4ab1e6b955cc59fa895140b3efb5fab8ba12 Mon Sep 17 00:00:00 2001 From: Kedreamix <1016617094@qq.com> Date: Tue, 30 May 2023 14:44:05 +0800 Subject: [PATCH] Fixes an issue in isaid.py (#3010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation When processing data in the isaid experiment, generated images only have binary pixel values of 0 or 1 instead of the corresponding class values. This causes significant interference and prevents subsequent experiments from proceeding. After investigation, it was found that the issue was caused by using the wrong image format for saving the images. Saving the images as PNG resulted in binary pixel values, while saving the images as BMP resolved the issue and correctly saved the class values. ## Modification `img_patch.save(save_path_image, format='BMP')` This code will save the image data as BMP format. ## BC-breaking Confirm that the modification does not introduce new issues and test that the modified code successfully resolves the original problem. --------- Co-authored-by: 谢昕辰 Co-authored-by: CSH <40987381+csatsurnh@users.noreply.github.com> --- tools/dataset_converters/isaid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dataset_converters/isaid.py b/tools/dataset_converters/isaid.py index 1da264d97..1d5ccd9c7 100644 --- a/tools/dataset_converters/isaid.py +++ b/tools/dataset_converters/isaid.py @@ -91,7 +91,7 @@ def slide_crop_image(src_path, out_dir, mode, patch_H, patch_W, overlap): x_end) + '.png' # print(image) save_path_image = osp.join(out_dir, 'img_dir', mode, str(image)) - img_patch.save(save_path_image) + img_patch.save(save_path_image, format='BMP') def slide_crop_label(src_path, out_dir, mode, patch_H, patch_W, overlap):