Closed HarryHsing closed 3 months ago
请问亲找到mask50的数据了?
This is my code of implementation, hope it helps
` import os import glob from skimage import io from skimage.morphology import dilation, disk
def apply_dilation_to_masks(input_dir, output_dir, struct_elem_size=50): if not os.path.exists(output_dir): os.makedirs(output_dir)
mask_files = glob.glob(os.path.join(input_dir, '*.*')) # Adjust to read all image files
structuring_element = disk(struct_elem_size)
for mask_file in mask_files:
# Load mask in grayscale
mask = io.imread(mask_file, as_gray=True)
mask = (mask > 0).astype('uint8') # Ensure binary mask (0 or 1)
mask_dilated = dilation(mask, structuring_element) # Apply dilation
mask_dilated = (mask_dilated * 255).astype('uint8') # Convert to 0-255 range
# Save dilated mask as a .png file
output_path = os.path.join(output_dir, os.path.basename(mask_file))
output_path = os.path.splitext(output_path)[0] + '.png'
io.imsave(output_path, mask_dilated) # Save dilated mask
input_directory = './SRD/train/train_B' # Replace with the path to your original masks output_directory = './SRD/train/train_B_dilated' # Replace with the path to save the dilated masks
apply_dilation_to_masks(input_directory, output_directory) `
谢谢回复,后来仔细看了原作者的论文,也可以使用引用的论文“From Shadow Generation to Shadow Removal”中的matlab代码获得mask50数据集
谢谢回复,后来仔细看了原作者的论文,也可以使用引用的论文“From Shadow Generation to Shadow Removal”中的matlab代码获得mask50数据集
This is the python version of that matlab code implemented by meself.
请问亲试过将batch_size设置为2 甚至更大吗?为什么设置为更大训练的时候会报错呢?图片显示多了一个维度
请问亲找到mask50的数据了?