Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

预测效果不好 #6

Open
chunbai1 opened this issue Feb 1, 2024 · 6 comments
Open

预测效果不好 #6

chunbai1 opened this issue Feb 1, 2024 · 6 comments

Comments

@chunbai1
Copy link

chunbai1 commented Feb 1, 2024

您好,我推理的效果感觉很差。
我使用的是北京数据,将 tif 图像剪切为 512x512 大小,使用 predict.py 文件,模型是直接从仓库提供的 onedrive 网址下载的,然后可视化的结果大概如下:
res
切割图像代码如下

import os
import re
import numpy as np
import tqdm
from PIL import Image
import tifffile as tf

def img_split(img_path, target_path, img_size):
    files = os.listdir(img_path)
    tqdm_file = tqdm.tqdm(files, total=len(files))
    for file in tqdm_file:
        img = tf.imread(os.path.join(img_path, file))
        range_x = img.shape[0] // img_size
        range_y = img.shape[1] // img_size
        num = 0
        for x in range(range_x):
            for y in range(range_y):
                split_img = img[x * img_size:(x + 1) * img_size, y * img_size:(y + 1) * img_size]
                tf.imwrite(os.path.join(target_path, file.split('.')[0] + '_' + str(num) + '.tif'), split_img)
                num += 1
    tqdm_file.close()

if __name__ == '__main__':
    img_path = './city/wuhan'
    target_path = './target/wuhan'
    if not os.path.exists(target_path):
        os.makedirs(target_path)
    img_split(img_path=img_path, target_path=target_path, img_size=512)

请问是我在处理数据的时候存在问题吗

@x-ytong
Copy link
Owner

x-ytong commented Feb 6, 2024

请问你使用的北京数据具体是什么数据?在预处理后波段的排序和我的数据一致吗?

@chunbai1
Copy link
Author

请问你使用的北京数据具体是什么数据?在预处理后波段的排序和我的数据一致吗?

使用的数据是T50TMK_20210929T030539.tif,从readme中提供的网址中下载,然后使用上述代码切分成512x512大小,我没有对波段排序进行处理,所以应该是和原数据一致的,tifffile库似乎也不会对波段排序产生影响。请问可能会是哪里存在问题呢?

@x-ytong
Copy link
Owner

x-ytong commented Feb 18, 2024

你好,可能是这句
img = tf.imread(os.path.join(img_path, file))
请使用我代码里面的图像读取语句试试
image = Image.open(args.inputpath + name).convert('CMYK')
我的预处理是用PIL库做的,所以后面训练测试都用这个,之前虽然没有试过tifffile库,但试过别的库,会发生波段数据丢失

@chunbai1
Copy link
Author

你好,可能是这句 img = tf.imread(os.path.join(img_path, file)) 请使用我代码里面的图像读取语句试试 image = Image.open(args.inputpath + name).convert('CMYK') 我的预处理是用PIL库做的,所以后面训练测试都用这个,之前虽然没有试过tifffile库,但试过别的库,会发生波段数据丢失

好的,我会尝试一下,谢谢你

@rongtongxueya
Copy link

请问有结果吗?是否是因为使用的库的问题造成的这个问题呢

@chunbai1
Copy link
Author

请问有结果吗?是否是因为使用的库的问题造成的这个问题呢

我后面直接将一整幅图输入模型进行测试,没有自己split成512x512,结果与论文是一致的,就没有继续探究,你可以试试看。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants