【问题标题】:how to handle with different size of images in CNN network如何在 CNN 网络中处理不同大小的图像
【发布时间】:2019-08-26 13:29:09
【问题描述】:

我正在制作适合拼图并识别完美配对的图像。 这是我的数据

solution.head()
id  pair
0   1   686
1   2   540
2   3   971
3   4   910
4   5   616

我有这样的图像形状:

    png = []
    for image_path in glob.glob("training/training/*.png"):
        png.append(misc.imread(image_path))    

    im = np.asarray(png)

    print ('Importing done...', im.shape)

Importing done... (1000,)

array([array([[[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       ...,

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]],

       [[247, 255, 102],
        [247, 255, 102],
        [247, 255, 102],
        ...,
        [247, 255, 102],
        [247, 255, 102],
        [247, 255, 102]]], dtype=uint8),
       array([[[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,
        [165, 255, 102],
        [165, 255, 102],
        [165, 255, 102]],

       ...,

       [[165, 255, 102],
        [165, 255, 102],
        [165, 255, 102],
        ...,

我不明白如何找到完美的配对图像。我正在尝试调整它们的大小并转换为 gray ,但它会出错。请帮我找到成对组合在一起的图像。 这是我的 colab 链接: https://colab.research.google.com/drive/1bCQUHrXNjdWX8-WKSq6LK01XpR4D52J_

【问题讨论】:

    标签: image-processing deep-learning computer-vision image-segmentation


    【解决方案1】:

    你可以试试这个代码:

       import numpy as np
        import cv2
        import os
        df=pd.read_csv(os.path.join(file_path,'solution.csv'))
        training_data = []
        IMG_SIZE = 100
        for img in  os.listdir('training/training') :  
          path = 'training/training/'+img
          id = img.split('.')[0]
          img = cv2.imread(path,1)
          img = cv2.resize(img, (IMG_SIZE,IMG_SIZE),3)     
          img = np.array(img)
          target = df['pair][int(id)]
          training_data.append([img ,target  ])
    

    【讨论】:

    • 谢谢阿马拉,这里在目标变量上出现一些错误,你在对变量上给定的引号。如何解决这个问题,当我得到唯一的对变量引用时
    • 目标 = df['pair'][int(id)]
    • 我对这些有一个疑问,对有 500,但图像有 1000,我怎么能建立一个 Cnn 网络。请给我一些关于这些的演示。
    • 在csv文件中,'id'列是指图片的名称吗?
    • 嗨,Amara,我的图片是 png 类型,你提供的代码是我执行的,但它得到了一些错误 .keyerror: 867,
    猜你喜欢
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 2023-02-17
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 2014-09-27
    • 2017-06-14
    相关资源
    最近更新 更多