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

about the pretrained vqgan #18

Open
Devil-Ideal opened this issue Oct 26, 2024 · 0 comments
Open

about the pretrained vqgan #18

Devil-Ideal opened this issue Oct 26, 2024 · 0 comments

Comments

@Devil-Ideal
Copy link

Hi ! I just load the pretrained vqgan, and reconstruct the input as below, but the backgound is noisy and the forground is blur. Is thre any thing wrong in my code?
`
images, labels = batch["image"], batch["label"]
batch_size = images.shape[0]
times = [4, 9, 14, 19]
outputs = []
# 移除批量和通道维度,得到 (96, 96, 96)
ct_image_np = images.squeeze().cpu().numpy().astype(np.float32)

    # 创建一个 NIfTI 图像对象
    nii_image = nib.Nifti1Image(ct_image_np, affine=np.eye(4))
    nib.save(nii_image, path)


    img_ = self.vqgan.encode(images, quantize=False, include_embeddings=True)
    _sample = self.vqgan.decode(img_, quantize=True)
    ct_pre = _sample.squeeze().cpu().numpy().astype(np.float32)

    # 创建一个 NIfTI 图像对象
    nii_image = nib.Nifti1Image(ct_pre, affine=np.eye(4))

    # 保存为 .nii.gz 文件
    nib.save(nii_image, path2)

`
B0R LJJK%RRT(IPQ18RP_L

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

1 participant