Giter Club home page Giter Club logo

Comments (6)

Baixuzx7 avatar Baixuzx7 commented on August 17, 2024

Hello, I think the problem is that the function (self.transform) can only process the image with 2 or 3 dimention (2 for gray scale image with size of H x W, 3 for color image with size of H x W x C), So please check the size of image data (variable image_ms image_ms_label image_pan_label), maybe the file in the path is not a single image format.

from p2sharpen.

mk12306 avatar mk12306 commented on August 17, 2024

Hello, I think the problem is that the function (self.transform) can only process the image with 2 or 3 dimention (2 for gray scale image with size of H x W, 3 for color image with size of H x W x C), So please check the size of image data (variable image_ms image_ms_label image_pan_label), maybe the file in the path is not a single image format.

"image_ms" is a multispectral image, which is indeed R, G, B, and NIR 4 channels, so there should be a problem here. I haven't modified the code. I'm curious, have you done any other processing here before?

from p2sharpen.

Baixuzx7 avatar Baixuzx7 commented on August 17, 2024

We provide a standard image format that can be processed in the Dataset folder, you can unzip the compressed file and try it out. By the way, can you add the following code in this section, let me confirm the image data format you read in?

def __getitem__(self, item):
    image_pan_path = os.path.join(self.root, 'pan', self.images_pan[item])
    image_ms_path = os.path.join(self.root, 'ms', self.images_ms[item])
    image_ms_label_path = os.path.join(self.root, 'ms_label', self.images_ms_label[item])
    image_pan_label_path = os.path.join(self.root, 'pan_label', self.images_pan_label[item])

    image_pan = imageio.imread(image_pan_path) 
    image_ms = imageio.imread(image_ms_path)  # B G R NIR
    image_ms_label = imageio.imread(image_ms_label_path)
    image_pan_label = imageio.imread(image_pan_label_path)

    print(image_pan.shape,image_ms.shape,image_ms_label.shape,image_pan_label.shape)

    if self.transform is not None:
        image_pan = self.transform(image_pan)
        image_ms = self.transform(image_ms)
        image_pan_label = self.transform(image_pan_label)
        image_ms_label = self.transform(image_ms_label)
        pass

    return image_pan, image_ms, image_pan_label, image_ms_label


For example, running the following code, I get these information.
`

if __name__ == '__main__':
    data_transform = {
    'test': torchvision.transforms.Compose(
        [
            torchvision.transforms.ToTensor(),
            torchvision.transforms.Normalize((0.5), (0.5))
        ]
    )}
    test_dataset = PanSharpeningDataset('./Dataset/TestFolder', transform=data_transform['test'])
    print(len(test_dataset))
    image_pan, image_ms, image_pan_label, image_ms_label = test_dataset[0]
    print(image_pan.size(),image_ms.size(),image_pan_label.size(),image_ms_label.size())
    exit(0)

`
image

from p2sharpen.

L-gzy avatar L-gzy commented on August 17, 2024

Hello, I think the problem is that the function (self.transform) can only process the image with 2 or 3 dimention (2 for gray scale image with size of H x W, 3 for color image with size of H x W x C), So please check the size of image data (variable image_ms image_ms_label image_pan_label), maybe the file in the path is not a single image format.

"image_ms" is a multispectral image, which is indeed R, G, B, and NIR 4 channels, so there should be a problem here. I haven't modified the code. I'm curious, have you done any other processing here before?

Hello, I also have this situation, have you solved it? Can you share it? Thank you very much

from p2sharpen.

L-gzy avatar L-gzy commented on August 17, 2024

您好,我认为问题是函数(self.transform)只能处理2或3尺寸的图像(2用于大小为H x W的灰度图像,3用于大小为H x W x C的彩色图像),因此请检查图像数据的大小(变量image_ms image_ms_label image_pan_label), 也许路径中的文件不是单一的图像格式。

I found that we should in “dataset.py” below
image_pan_label = imageio.imread(image_pan_label_path)
supplement :
image_ms = image_ms[0]
image_pan = image_pan[0]

from p2sharpen.

bingkun99 avatar bingkun99 commented on August 17, 2024

您好,我认为问题是函数(self.transform)只能处理2或3尺寸的图像(2用于大小为H x W的灰度图像,3用于大小为H x W x C的彩色图像),因此请检查图像数据的大小(变量image_ms image_ms_label image_pan_label), 也许路径中的文件不是单一的图像格式。

我发现我们应该在下面的“dataset.py”中image_pan_label = imageio.imread(image_pan_label_path) 补充:image_ms = image_ms[0] image_pan = image_pan[0]

您好,我目前刚定的研究方向是遥感图像融合,我想请教一下您的咱们这个遥感数据的数据集该如何去制作的?我这有几幅原始数据,但是不知道该如何处理。

from p2sharpen.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.