MedSegDiff icon indicating copy to clipboard operation
MedSegDiff copied to clipboard

Problems during sample

Open ValeriaLiu opened this issue 1 year ago • 7 comments

I run the segmentation_sample.py, and meet the problem:

Logging to /root/autodl-tmp/MedSegDif/med_results/img_out/ creating model and diffusion... sampling... no dpm-solver /root/miniconda3/lib/python3.8/site-packages/torch/nn/functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") Traceback (most recent call last): File "MedSegDif/med_scripts/segmentation_sample.py", line 163, in main() File "MedSegDif/med_scripts/segmentation_sample.py", line 109, in main sample, x_noisy, org, cal, cal_out = sample_fn( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 553, in p_sample_loop_known for sample in self.p_sample_loop_progressive( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 624, in p_sample_loop_progressive out = self.p_sample( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 435, in p_sample out = self.p_mean_variance( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/respace.py", line 90, in p_mean_variance return super().p_mean_variance(self._wrap_model(model), *args, **kwargs) File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 319, in p_mean_variance model_mean, _, _ = self.q_posterior_mean_variance( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 219, in q_posterior_mean_variance assert x_start.shape == x_t.shape AssertionError

I know that it is because x_start.shape is not equal to x_t.shape. However, My dataset is similar to ISICDataset, so I feel very strange. Thanks a lot if you can reply.

ValeriaLiu avatar Mar 10 '23 16:03 ValeriaLiu

I run the segmentation_sample.py, and meet the problem:

Logging to /root/autodl-tmp/MedSegDif/med_results/img_out/ creating model and diffusion... sampling... no dpm-solver /root/miniconda3/lib/python3.8/site-packages/torch/nn/functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") Traceback (most recent call last): File "MedSegDif/med_scripts/segmentation_sample.py", line 163, in main() File "MedSegDif/med_scripts/segmentation_sample.py", line 109, in main sample, x_noisy, org, cal, cal_out = sample_fn( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 553, in p_sample_loop_known for sample in self.p_sample_loop_progressive( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 624, in p_sample_loop_progressive out = self.p_sample( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 435, in p_sample out = self.p_mean_variance( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/respace.py", line 90, in p_mean_variance return super().p_mean_variance(self._wrap_model(model), *args, **kwargs) File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 319, in p_mean_variance model_mean, _, _ = self.q_posterior_mean_variance( File "/root/autodl-tmp/./MedSegDif/med_guided_diffusion/gaussian_diffusion.py", line 219, in q_posterior_mean_variance assert x_start.shape == x_t.shape AssertionError

I know that it is because x_start.shape is not equal to x_t.shape. However, My dataset is similar to ISICDataset, so I feel very strange. Thanks a lot if you can reply.

Have you solved it? I have the same doubt, thanks!

iYeekk avatar Apr 12 '23 08:04 iYeekk

Have you figure it out? I have the same question...

jojo803 avatar May 26 '23 09:05 jojo803

could you print x_start.shape and x_t.shape?

WuJunde avatar May 26 '23 09:05 WuJunde

I try to print x_start.shape and x_t.shape however there is an error occurred before I can get x_start.

Traceback (most recent call last): File "F:\dpm\MedSegDiff-master-v2\v2\scripts\segmentation_sample.py", line 194, in main() File "F:\dpm\MedSegDiff-master-v2\v2\scripts\segmentation_sample.py", line 116, in main sample, x_noisy, org, cal, cal_out = sample_fn( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 566, in p_sample_loop_known for sample in self.p_sample_loop_progressive( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 651, in p_sample_loop_progressive out = self.p_sample( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 446, in p_sample out = self.p_mean_variance( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\respace.py", line 90, in p_mean_variance return super().p_mean_variance(self._wrap_model(model), *args, **kwargs) File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 325, in p_mean_variance self._predict_xstart_from_eps(x_t=x, t=t, eps=model_output) File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 350, in _predict_xstart_from_eps assert x_t.shape == eps.shape AssertionError

I print x_t.shape and eps.shape, and result is like this: x_t.shape= torch.Size([1, 1, 64, 64]) eps.shape= torch.Size([1, 2, 64, 64])

I suppose to use the right dataset step by step in Readme.md. The eps[:, 0, :, :] is totally the same as eps[:, 1; :, :]. After clipping eps to [1,1,64,64] by deleting either of them, program can work. I can't understand why their shapes are not consistant. Therefore, I can't figure out whether I can get the right answer by simple clipping conducted by myself without theory support.

jojo803 avatar May 26 '23 10:05 jojo803

I try to print x_start.shape and x_t.shape however there is an error occurred before I can get x_start.

Traceback (most recent call last): File "F:\dpm\MedSegDiff-master-v2\v2\scripts\segmentation_sample.py", line 194, in main() File "F:\dpm\MedSegDiff-master-v2\v2\scripts\segmentation_sample.py", line 116, in main sample, x_noisy, org, cal, cal_out = sample_fn( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 566, in p_sample_loop_known for sample in self.p_sample_loop_progressive( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 651, in p_sample_loop_progressive out = self.p_sample( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 446, in p_sample out = self.p_mean_variance( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\respace.py", line 90, in p_mean_variance return super().p_mean_variance(self._wrap_model(model), *args, **kwargs) File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 325, in p_mean_variance self._predict_xstart_from_eps(x_t=x, t=t, eps=model_output) File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 350, in _predict_xstart_from_eps assert x_t.shape == eps.shape AssertionError

I print x_t.shape and eps.shape, and result is like this: x_t.shape= torch.Size([1, 1, 64, 64]) eps.shape= torch.Size([1, 2, 64, 64])

I suppose to use the right dataset step by step in Readme.md. The is totally the same as . After clipping eps to by deleting either of them, program can work. I can't understand why their shapes are not consistant. Therefore, I can't figure out whether I can get the right answer by simple clipping conducted by myself without theory support.eps[:, 0, :, :]``eps[:, 1; :, :]``[1,1,64,64]

Hello! I have encountered a type-related issue with the ISIC dataset. Specifically, I'm getting the following error:

"assert x_t.shape == eps.shape AssertionError"

Could you please help me identify which line of code needs to be modified to make the project run successfully?

rrrrrrrrrice avatar Sep 04 '23 17:09 rrrrrrrrrice

Has it been resolved? I encountered the same problem

zzh1230 avatar Oct 10 '23 11:10 zzh1230

Why is it that the result of my last training in BraTS is a MRI diagram?

chenyu1330 avatar Apr 01 '24 01:04 chenyu1330