mueller-franzes / medfusion

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

About the first stage and second stage #23

Open clearlyzerolxd opened 10 months ago

clearlyzerolxd commented 10 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 10 months ago

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

clearlyzerolxd commented 10 months ago

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

clearlyzerolxd commented 10 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 10 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()