xufangchn / GLF-CR

GLF-CR: SAR-Enhanced Cloud Removal with Global-Local Fusion
44 stars 5 forks source link

关于保存rpg图片 #9

Open nbhuangzhixuan opened 1 year ago

nbhuangzhixuan commented 1 year ago

作者您好,我再复现的时候,想把网络中的预测乌云图像保存成rgb图像,但是颜色不对,一会偏红,一会偏紫。 这是我的代码,万分感谢

def get_image(img_cld,img_fake,img_truth): output_img = np.zeros((img_size, 3 img_size, 3), dtype=np.uint8) img_cld = uint16to8((torch.squeeze(img_cld).cpu().numpy() scale).astype("uint16")).transpose(1, 2, 0) img_fake = uint16to8((torch.squeeze(img_fake).cpu().numpy() scale).astype("uint16")).transpose(1, 2, 0) img_truth = uint16to8((torch.squeeze(img_truth).cpu().numpy() scale).astype("uint16")).transpose(1, 2, 0) img_cld_RGB = getRGBImg(img_cld[:, :, 3], img_cld[:, :, 2], img_cld[:, :, 1], img_size) img_fake_RGB = getRGBImg(img_fake[:, :, 3], img_fake[:, :, 2], img_fake[:, :, 1], img_size) img_truth_RGB = getRGBImg(img_truth[:, :, 3], img_truth[:, :, 2], img_truth[:, :, 1], img_size) output_img[:, 0 img_size:1 img_size, :] = img_cld_RGB output_img[:, 1 img_size:2 img_size, :] = img_fake_RGB output_img[:, 2 img_size:3 img_size, :] = img_truth_RGB return output_img

def uint16to8(bands, lower_percent=0.001, higher_percent=99.999): out = np.zeros_like(bands, dtype=np.uint8) n = bands.shape[0] for i in range(n): a = 0 # np.min(band) b = 255 # np.max(band) c = np.percentile(bands[i, :, :], lower_percent) d = np.percentile(bands[i, :, :], higher_percent) t = a + (bands[i, :, :] - c) * (b - a) / (d - c) t[t < a] = a t[t > b] = b out[i, :, :] = t return out

def SaveImg(img,path): cv2.imwrite(path, img)

def getRGBImg(r,g,b,img_size=256): img=np.zeros((img_size,img_size,3),dtype=np.uint8) img[:,:,0]=r img[:,:,1]=g img[:,:,2]=b return img

zasr99 commented 10 months ago

你好,请问你用作者训练好的模型进行预测输出的无云图像效果好吗,我输出的图像视觉效果不好,但是SSIM和PSNR的数值又还不错

nbhuangzhixuan commented 10 months ago

@zasr99 我试了下只有小部分的颜色是正确的,应该是psnr和ssim对颜色不敏感。基本上psnr能在26-28,但颜色基本都是不对的

123eye commented 6 months ago

你好,请问你的data.csv文件是怎么弄的,是自己随便划分的吗?

123eye commented 5 months ago

你好,请问你用训练好的模型进行预测输出的无云图像效果好吗,我输出的视觉图像效果不好,但是SSIM和PSNR作者的数值又还好

你好,请问你复现出代码来了吗,我这边用虚拟环境配置的时候cudnn会报错,降低版本后感觉是在cpu跑的

nbhuangzhixuan commented 5 months ago

没有,我也是cuda报错 cuda call failed啥的,还有一堆错误,都是跟cuda和pytorch版本相关

Miraitowa515 commented 2 months ago

@nbhuangzhixuan 请问cuda报错您是怎么解决的呢

nbhuangzhixuan commented 2 months ago

@Miraitowa515 没有解决,我有一台比较老的机器gtx960可以跑没有cuda报错,但学校服务器的环境跑不了,cuda报错。我觉得可能是环境太新的话跑不了