odlgroup / odl

Operator Discretization Library https://odlgroup.github.io/odl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when using odl and import pytorch

drgHannah opened this issue · comments

Hi, I would like to run radon transformation and filtered backprojection on my pytorch data. However, the transformation is only correct if I do not import pytorch (import torch) and the same applies to from odl.contrib.torch import OperatorModule. Can anyone help me with this?

I have attached the code and my results below for reproducibility.

With_Import_Torch

# Imports
import numpy as np
import odl
import torch
#from odl.contrib.torch import OperatorModule

# ODL
reco_space = odl.uniform_discr(min_pt=[-20, -20], max_pt=[20, 20], shape=[300, 300], dtype='float32')
angle_partition = odl.uniform_partition(0, np.pi, 50)
detector_partition = odl.uniform_partition(-30, 30, 300)
geometry = odl.tomo.Parallel2dGeometry(angle_partition, detector_partition)

ray_trafo = odl.tomo.RayTransform(reco_space, geometry,impl='astra_cuda')
fbp = odl.tomo.fbp_op(ray_trafo)


## Run
phantom = odl.phantom.shepp_logan(reco_space, modified=True)
proj_data = ray_trafo(phantom)
fbp_reconstruction = fbp(proj_data)

phantom.show(title='Phantom')
proj_data.show(title='Projection Data (Sinogram)')
fbp_reconstruction.show(title='Filtered Back-projection', force_show=True)