KidsWithTokens / MedSegDiff

Medical Image Segmentation with Diffusion Model
MIT License
976 stars 145 forks source link

assertion error assert x_t.shape == eps.shape #145

Open worthlessFella opened 6 months ago

worthlessFella commented 6 months ago

Hi I have trained the segmentation code on dataset ISIC. But when I am running sample I am getting the following error. I have used all the default parameters suggested and have not made any changes to the code except few print statement for debugging:

[W socket.cpp:663] [c10d] The client socket has failed to connect to [::ffff:127.0.1.1]:56131 (system error: 10049 - The requested address is not valid in its context.). Logging to ......\datasets\MedSegDiff\sample creating model and diffusion... sampling... sample_fn False <bound method GaussianDiffusion.p_sample_loop_known of <guided_diffusion.respace.SpacedDiffusion object at 0x000002C1AD337E50>> p_sample_loop_known no dpm-solver p_sample torch.Size([1, 4, 64, 64]) x torch.Size([1, 4, 64, 64]) in _predict_xstart_from_eps: x.shape, eps.shape torch.Size([1, 1, 64, 64]) torch.Size([1, 2, 64, 64]) Traceback (most recent call last): File "C:\Users\bdebnath\data\myprojects\MedSegDiff\scripts\segmentation_sample.py", line 207, in main() File "C:\Users\bdebnath\data\myprojects\MedSegDiff\scripts\segmentation_sample.py", line 117, in main sample, x_noisy, org, cal, cal_out = sample_fn( File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\gaussian_diffusion.py", line 569, in p_sample_loop_known for sample in self.p_sample_loop_progressive( File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\gaussian_diffusion.py", line 654, in p_sample_loop_progressive out = self.p_sample( File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\gaussian_diffusion.py", line 447, in p_sample out = self.p_mean_variance( File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\respace.py", line 90, in p_mean_variance return super().p_mean_variance(self._wrap_model(model), *args, **kwargs) File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\gaussian_diffusion.py", line 329, in p_mean_variance self._predict_xstart_from_eps(x_t=x, t=t, eps=model_output) File "C:\Users\bdebnath\data\myprojects\MedSegDiff\guided_diffusion\gaussian_diffusion.py", line 350, in _predict_xstart_from_eps assert x_t.shape == eps.shape AssertionError

FionaYeager commented 2 months ago

I also encountered the same problem. Have you resolved this bug now?

luisfernandes9 commented 3 weeks ago

I am having the same problem as well

linyuanwang commented 1 week ago

I have encountered the same problem. Has anyone solved it ?