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

通过预训练权重推理图片进行超分 #5

Open
youngbaldy opened this issue Oct 5, 2023 · 7 comments
Open

通过预训练权重推理图片进行超分 #5

youngbaldy opened this issue Oct 5, 2023 · 7 comments

Comments

@youngbaldy
Copy link

我已参考 https://huggingface.co/spaces/KyanChen/FunSR/blob/main/App_main.py 中的sr_func函数,打算对其他遥感数据集进行超分,但是得到的结果似乎是字典形式:{'encoder_spec': {'name': 'rdn', 'args': {'no_upsampling': True}}, 'has_multiscale': True, 'neck': {'name': 'transformer_neck', 'args': {'d_dim': 256, 'downsample': True, 'has_pe': True, 'has_norm': True, 'class_token': True, 'num_encoder_layers': 3}}, 'decoder': {'name': 'sirens', 'args': {'num_inner_layers': 5, 'is_residual': True}}, 'global_decoder': {'name': 'sirens', 'is_proj': True, 'args': {'num_inner_layers': 5, 'is_residual': True}}, 'encoder_rgb': True, 'n_forward_times': 1, 'encode_hr_coord': True, 'has_bn': True, 'encode_scale_ratio': True, 'local_unfold': False, 'weight_gen_func': 'bicubic'},而我期望得到超分后的图像,我该怎么做?应该通过tools文件夹下的某个可视化脚本吗?

@youngbaldy
Copy link
Author

上述问题已解决,模型输入似乎只能是4848,4倍超分输出是192192。这输入似乎是固定的?

@xiaying-bot
Copy link

你好,请问有提供模型的权重参数吗?我打开huggingface链接解压出来里面只有一个data.pkl,似乎没有UC_FunSR_RDN.pth文件?

@KyanChen
Copy link
Owner

@xiaying-bot
Copy link

https://huggingface.co/spaces/KyanChen/FunSR/tree/main/pretrain

非常感谢您的回复,我在前面README里的【5. [optional] Model Download】看到了这个链接,下载之后解压出来里面的文件结构是这样的,没有UC_FunSR_RDN.pth权重文件

截屏2024-04-21 下午3 24 29

@KyanChen
Copy link
Owner

image

@Bulinken
Copy link

Bulinken commented May 12, 2024

你好,ulits模块中没有找到对rgb2ycbcr_pt函数的定义
def calculate_ssim_pt(img, img2, crop_border, test_y_channel=False, **kwargs):
"""Calculate SSIM (structural similarity) (PyTorch version).
Paper: Image quality assessment: From error visibility to structural similarity
The results are the same as that of the official released MATLAB code in
https://ece.uwaterloo.ca/~z70wang/research/ssim/.
For three-channel images, SSIM is calculated for each channel and then
averaged.
Args:
img (Tensor): Images with range [0, 1], shape (n, 3/1, h, w).
img2 (Tensor): Images with range [0, 1], shape (n, 3/1, h, w).
crop_border (int): Cropped pixels in each edge of an image. These pixels are not involved in the calculation.
test_y_channel (bool): Test on Y channel of YCbCr. Default: False.
Returns:
float: SSIM result.
"""

assert img.shape == img2.shape, f'Image shapes are different: {img.shape}, {img2.shape}.'

if crop_border != 0:
    img = img[:, :, crop_border:-crop_border, crop_border:-crop_border]
    img2 = img2[:, :, crop_border:-crop_border, crop_border:-crop_border]

if test_y_channel:
    img = rgb2ycbcr_pt(img, y_only=True)
    img2 = rgb2ycbcr_pt(img2, y_only=True)

img = img.to(torch.float64)
img2 = img2.to(torch.float64)

ssim = _ssim_pth(img * 255., img2 * 255.)
return ssim

@YHY0202
Copy link

YHY0202 commented Jun 19, 2024

我已参考 https://huggingface.co/spaces/KyanChen/FunSR/blob/main/App_main.py 中的sr_func函数,打算对其他遥感数据集进行超分,但是得到的结果似乎是字典形式:{'encoder_spec': {'name': 'rdn', 'args': {'no_upsampling': True}}, 'has_multiscale': True, 'neck': {'name': 'transformer_neck', 'args': {'d_dim': 256, 'downsample': True, 'has_pe': True, 'has_norm': True, 'class_token': True, 'num_encoder_layers': 3}}, 'decoder': {'name': 'sirens', 'args': {'num_inner_layers': 5, 'is_residual': True}}, 'global_decoder': {'name': 'sirens', 'is_proj': True, 'args': {'num_inner_layers': 5, 'is_residual': True}}, 'encoder_rgb': True, 'n_forward_times': 1, 'encode_hr_coord': True, 'has_bn': True, 'encode_scale_ratio': True, 'local_unfold': False, 'weight_gen_func': 'bicubic'},而我期望得到超分后的图像,我该怎么做?应该通过tools文件夹下的某个可视化脚
请问你这个怎么解决的

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

5 participants