admin管理员组文章数量:1356753
this what i write but when i open an png image it s just the image i put here, help idk why
for filename in os.listdir(input_dir):
if filename.endswith(".h5"):
file_path = os.path.join(input_dir, filename)
with h5py.File(file_path, "r") as f:
if "image" in f:
image_data = np.array(f["image"])
print(f"Image size: {image_data.shape}")
image_data = np.clip(image_data, 0, 255)
image_data = image_data.astype(np.uint8)
img = Image.fromarray(image_data)
output_path = os.path.join(output_dir, filename.replace(".h5", ".png"))
img.save(output_path)
print(f"Save: {output_path}")
本文标签: numpyIssues to convert h5 file to png with PythonStack Overflow
版权声明:本文标题:numpy - Issues to convert .h5 file to .png with Python - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743949085a2566950.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论