简体   繁体   English

零大小数组到最大归约操作,对于多输出 U-net 没有标识

[英]zero-size array to reduction operation maximum which has no identity for multi output U-net

Im trying to use U-net to do multi task label segmentation following this stackoverflow im note sure what Im doing wrong , this is a part of the code我正在尝试使用 U-net 在此stackoverflow之后进行多任务标签分割,请注意确定我做错了什么,这是代码的一部分

def trainGenerator(batch_size,train_path,image_path, sub_path1, sub_path2, aug_dict,image_color_mode = "rgb",image_folder='image', mask_folder="label", 
               mask_color_mode = "grayscale",image_save_prefix  = "image",mask_save_prefix  = "mask",flag_multi_class = False,num_class = 2,save_to_dir = None,target_size = (224,224),seed = 1):
'''
can generate image and mask at the same time
use the same seed for image_datagen and mask_datagen to ensure the transformation for image and mask is the sameTO  visualize the results of generator, set save_to_dir = "your path"
'''

image_datagen = ImageDataGenerator(**aug_dict)
mask_datagen = ImageDataGenerator(**aug_dict)


image_generator = image_datagen.flow_from_directory(

    image_path ,
    classes = [image_folder],
    class_mode = None,
    color_mode = image_color_mode,
    target_size = target_size,
    batch_size = 2,
    save_to_dir = save_to_dir,
    save_prefix  = image_save_prefix,
    seed = seed)
mask_generator1= mask_datagen.flow_from_directory(

    sub_path1,
    classes = [mask_folder],
    class_mode = None,
    color_mode = mask_color_mode,
    target_size = target_size,
    batch_size = 2,
    save_to_dir = save_to_dir,
    save_prefix  = mask_save_prefix,
    seed = seed)
mask_generator2 = mask_datagen.flow_from_directory(

    sub_path2,
    classes = [mask_folder],
    class_mode = None,
    color_mode = mask_color_mode,
    target_size = target_size,
    batch_size = 2,
    save_to_dir = save_to_dir,
    save_prefix  = mask_save_prefix,
    seed = seed)



train_generator = zip(image_generator, mask_generator1, mask_generator2 )
for (img,mask1, mask2) in train_generator:
    img,mask1 = adjustData(img,mask1,flag_multi_class,num_class)
    img,mask2 = adjustData(img,mask2,flag_multi_class,num_class)
    yield (img,mask1, mask2)

and not sure if my sub directories are in the right order or not并且不确定我的子目录的顺序是否正确

myGene = trainGenerator(2,train_path,image_path,sub_path_1, sub_path_2, aug_dict=data_gen_args,save_to_dir = None)

history= model.fit_generator(myGene,steps_per_epoch=3240,epochs=150,callbacks=[model_checkpoint])

where the directories are as following其中目录如下

image_folder= "data\\membrane\\train\\image_path\\image"
mask_folder1="data\\membrane\\train\\sub_path1\\label"
mask_folder2="data\\membrane\\train\\sub_path2\\label"

this is the error Ive got error I dont know why all the labels has been detected in the both mask folders meanwhile the images in the image folder are 0这是错误我有错误我不知道为什么在两个掩码文件夹中都检测到所有标签同时图像文件夹中的图像为 0

please any help will be appreciated请任何帮助将不胜感激

I found the solution i just changed the line我找到了解决方案,我只是改变了线路

myGene = trainGenerator(2,train_path,image_path,sub_path_1, sub_path_2, aug_dict=data_gen_args,save_to_dir = None)

to

myGene = trainGenerator(2,'image_path',sub_path1, sub_path2, aug_dict=data_gen_args,save_to_dir = None)

and the fit_generator worked perfectly并且 fit_generator 完美运行

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 零大小数组到没有标识的最大归约操作 - zero-size array to reduction operation maximum which has no identity 零大小数组到没有标识的缩减操作 fmin - zero-size array to reduction operation fmin which has no identity 具有Statsmodel ValueError的多个OLS回归:零大小数组到减少操作最大值,没有标识 - Multiple OLS Regression with Statsmodel ValueError: zero-size array to reduction operation maximum which has no identity 如何修复 keras pad_sequences 中的“零大小数组到没有标识的最大缩减操作” - How to fix "zero-size array to reduction operation maximum which has no identity" in keras pad_sequences SciPy optimize.fmin ValueError:零大小数组到减少操作最大值,没有标识 - SciPy optimize.fmin ValueError: zero-size array to reduction operation maximum which has no identity OLS回归存储问题:零大小数组到归约操作最大值,没有身份 - OLS regression storing problem: zero-size array to reduction operation maximum which has no identity 如何将 np.max 用于没有 ValueError 的空 numpy 数组:零大小数组到没有标识的缩减操作最大值 - how to use np.max for empty numpy array without ValueError: zero-size array to reduction operation maximum which has no identity 为什么我会得到以及如何解决 ValueError: zero-size array to reduction operation maximum which has no identity - Why am I getting and how to solve ValueError: zero-size array to reduction operation maximum which has no identity 如何修复'ValueError:零尺寸数组到没有身份的归约运算fmin' - How to fix 'ValueError: zero-size array to reduction operation fmin which has no identity' ValueError:零大小数组到没有标识的最小化操作 - ValueError: zero-size array to reduction operation minimum which has no identity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM