MedARC-AI / fMRI-reconstruction-NSD

fMRI-to-image reconstruction on the NSD dataset.
MIT License
280 stars 39 forks source link

Incorrect precision when applying low level reconstruction decoder #28

Closed reesekneeland closed 8 months ago

reesekneeland commented 9 months ago

Hello,

When launching the reconstruction script, I received the following error message from the vd_pipe decoder regarding incorrect precision.

Traceback (most recent call last): File "/export/raid1/home/kneel027/fMRI-reconstruction-NSD/src/Reconstructions.py", line 370, in <module> blurry_recons = vd_pipe.vae.decode(ae_preds.to(device).half()/0.18215).sample / 2 + 0.5 File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/diffusers/utils/accelerate_utils.py", line 46, in wrapper return method(self, *args, **kwargs) File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/diffusers/models/autoencoder_kl.py", line 154, in decode decoded = self._decode(z).sample File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/diffusers/models/autoencoder_kl.py", line 124, in _decode z = self.post_quant_conv(z) File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 463, in forward return self._conv_forward(input, self.weight, self.bias) File "/export/raid1/home/kneel027/miniconda3/envs/mindeye/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Input type (c10::Half) and bias type (float) should be the same

I fixed it in my local version by removing the .half() call on line 370, but a deeper look may be warranted if there was a reason for it's placement.

PaulScotti commented 8 months ago

This is now fixed, thanks for pointing this out!