KidsWithTokens / MedSegDiff

Medical Image Segmentation with Diffusion Model
MIT License
980 stars 147 forks source link

Sampling problem #113

Open jojo803 opened 1 year ago

jojo803 commented 1 year ago

When I ran sample.py , I got this problem: 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 563, 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 648, in p_sample_loop_progressive out = self.p_sample( File "F:\dpm\MedSegDiff-master-v2\v2\scripts..\guided_diffusion\gaussian_diffusion.py", line 443, 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 324, 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 347, in _predict_xstart_from_eps assert x_t.shape == eps.shape AssertionError

My Brats2020 dataset is the same as yours, but my testing data has ground truth. I can't figure it out, can you please help me with it?

smallboy-code commented 1 year ago

I also meet this problem. I think it's because your "x_t".shape(B, 1, H, W) is not the same as the "eps".shape(B, 2, H, W). You set the output of the model in "script_util" to 2, so the eps".shape will to be(B, 2, H, W).

rrrrrrrrrice commented 10 months ago

我也遇到了这个问题。我认为这是因为您的“x_t”.shape(B, 1, H, W) 与“eps”.shape(B, 2, H, W) 不同。您将“script_util”中模型的输出设置为 2,因此 eps“.shape 将为 (B, 2, H, W)。

Hello, I've also encountered this issue. I'd like to ask you specifically which parameter you modified in the "script_util" file, or which line of code you changed to resolve this problem? Can you help me with that?

HEL7777 commented 8 months ago

我也遇到了这个问题。我认为这是因为您的“x_t”.shape(B, 1, H, W) 与“eps”.shape(B, 2, H, W) 不同。您将“script_util”中模型的输出设置为 2,因此 eps“.shape 将为 (B, 2, H, W)。

Hello, I've also encountered this issue. I'd like to ask you specifically which parameter you modified in the "script_util" file, or which line of code you changed to resolve this problem? Can you help me with that?

你好,请问你解决了吗