Skip to content

Bad PSNR Evaluation Code #16

@yonagin

Description

@yonagin

Hi, thank you for sharing the code!

I found a logical error in the metric evaluation loop in evaluation.py.

In the loop used to calculate SSIM and PSNR for the batch, the SSIM calculation correctly uses the sliced individual images (rgb_restored_s, rgb_gt_s). However, the PSNR calculation mistakenly passes the entire batch arrays (rgb_gt, rgb_restored) instead of the individual samples.

Location:
https://github.com/youngsheen/SimVQ/blob/main/evaluation.py#L176

Current Code:

for i in range(B):
    rgb_restored_s, rgb_gt_s = rgb_restored[i], rgb_gt[i]
    ssim_temp += ssim_loss(rgb_restored_s, rgb_gt_s, data_range=1.0, channel_axis=-1)
    # Bug: Using the whole batch (rgb_gt) inside the loop
    psnr_temp += psnr_loss(rgb_gt, rgb_restored) 

Expected Behavior:
It should calculate the PSNR between the current ground truth image and the restored image, similar to the SSIM calculation above it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions