【问题标题】:Crop the image using tensoflow Imagegenerator preprocessing fucntion by opencv使用 opencv 的 tensorflow Image Generator 预处理功能裁剪图像
【发布时间】:2022-01-20 20:57:27
【问题描述】:

我创建了一个用于裁剪眼睛图像的功能。因为眼睛图像的外侧是平衡的和不必要的像素。但是如果我使用这个函数在opencv中加载图像,对于大分辨率,分配内存。我想使用 opencv 的 tensorflow imagedatagenerator 预处理功能裁剪图像。 'crop_image' 是我的功能,它可以正常工作。 火车是一条路径。 train> 存储图像的正常和异常文件

def preprocessing_fun(train):

  img=cv2.imread(train,cv2.IMREAD_COLOR)
  img=crop_image(img)
        
  if img is not None:
    image=cv2.resize(img,(512,512))
    img=cv2.addWeighted ( image,4, cv2.GaussianBlur( image , (0,0) ,224/10) ,-4 ,128) 
    return img
  img_datagen = ImageDataGenerator(rescale=1./255,
                           preprocessing_function = 
  preprocessing_fun)
training_gen = img_datagen.flow_from_directory(train, target_size=(224,224),
                          color_mode='rgb',batch_size=32,)

使用它后,它会看到图像的数量但显示错误: SystemError:返回 NULL 而不设置错误 这个问题怎么解决??

【问题讨论】:

    标签: python tensorflow-serving


    【解决方案1】:

    您的 cv2.imread 没有根据您的功能读取一张图像,因为 cv2.imread 一次只能读取一张图像。

    例如:假设你的函数 train 是一个列表,那么你可以通过使用 for 循环(for image in train:) 来读取类似的东西

    【讨论】:

      猜你喜欢
      • 2017-05-21
      • 1970-01-01
      • 2012-12-31
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 2017-08-04
      • 2023-03-05
      相关资源
      最近更新 更多