mueller-franzes / medfusion

Implementation of Medfusion - A latent diffusion model for medical image synthesis.
MIT License
165 stars 32 forks source link

About the first stage and second stage #23

Open clearlyzerolxd opened 11 months ago

clearlyzerolxd commented 11 months ago

Hello, I have some questions about the way to normalize data. Should normalization be done this way to get good results or is it like this?

T.ToTensor(),

T.Normalize(mean=0.5, std=0.5)

or

T.ToTensor()
data = (data -1)/2
clearlyzerolxd commented 11 months ago

截图 2023-12-10 13-44-52

clearlyzerolxd commented 11 months ago

截图 2023-12-10 13-46-42 The reconstruction effect is still a bit blurry. Is this trend correct?

clearlyzerolxd commented 11 months ago

I rewrote the second stage code using pytorch according to the author's ideas. I found that it didn't seem to converge well.

clearlyzerolxd commented 11 months ago

The idea is roughly like this

            with torch.no_grad():
                out = vae.module.encode(data.to(device))
            loss = diffusion(out,None)
            net_optim.zero_grad()
            loss.backward()
            net_optim.step()