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

WARNING: FAILED to save image out/Gundam/validate/mask/val_000000_mask.png #43

Open
WakyWakyWayne opened this issue Sep 13, 2023 · 2 comments

Comments

@WakyWakyWayne
Copy link

print(result_dict)
{'shaded': tensor([[[1.0000, 1.0000, 1.0000],
[1.0000, 1.0000, 1.0000],
[1.0000, 1.0000, 1.0000],
...,
[1.0000, 1.0000, 1.0000],
[1.0000, 1.0000, 1.0000],
[1.0000, 1.0000, 1.0000]],

    [[1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     ...,
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000]],

    [[1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     ...,
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000]],

    ...,

    [[1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     ...,
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000]],

    [[1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     ...,
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000]],

    [[1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     ...,
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000],
     [1.0000, 1.0000, 1.0000]]], device='cuda:0'), 

mask': tensor([[[0.],
[0.],
[0.],
...,
[0.],
[0.],
[0.]],

    [[0.],
     [0.],
     [0.],
     ...,
     [0.],
     [0.],
     [0.]],

    [[0.],
     [0.],
     [0.],
     ...,
     [0.],
     [0.],
     [0.]],

    ...,

    [[0.],
     [0.],
     [0.],
     ...,
     [0.],
     [0.],
     [0.]],

    [[0.],
     [0.],
     [0.],
     ...,
     [0.],
     [0.],
     [0.]],

    [[0.],
     [0.],
     [0.],
     ...,
     [0.],
     [0.],
     [0.]]], device='cuda:0'), 

'normal': tensor([[[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.],
...,
[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]],

    [[1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.],
     ...,
     [1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.]],

    [[1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.],
     ...,
     [1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.]],

    ...,

    [[1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.],
     ...,
     [1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.]],

    [[1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.],
     ...,
     [1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.]],

    [[1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.],
     ...,
     [1., 1., 1.],
     [1., 1., 1.],
     [1., 1., 1.]]], device='cuda:0')}

When
def save_image(fn, x : np.ndarray):
try:
if os.path.splitext(fn)[1] == ".png":
imageio.imwrite(fn, np.clip(np.rint(x * 255.0), 0, 255).astype(np.uint8), compress_level=3) # Low compression for faster saving
else:
imageio.imwrite(fn, np.clip(np.rint(x * 255.0), 0, 255).astype(np.uint8))
except:

    print("WARNING: FAILED to save image %s" % fn)

I cant save mask.png. And the mask shape is (512,512,1), it looks no issue.
normal and shaded PNG are OK,only mask failed.

@WakyWakyWayne
Copy link
Author

OK,I find the problem.
imageio cant save single channel mask.png, here need cv2 instead

@ruiqixu37
Copy link

OK,I find the problem. imageio cant save single channel mask.png, here need cv2 instead

This solved my problem too. Thanks!

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

2 participants