Skip to content
Snippets Groups Projects
Commit cb8e73f2 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Make test runnable without pyconrad

parent 34e86539
No related branches found
No related tags found
No related merge requests found
Pipeline #22246 passed
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
[metadata] [metadata]
name = pyronn-torch name = pyronn-torch
description = Add a short description here! description = PyTorch bindings for PYRO-NN (https://github.com/csyben/PYRO-NN)
author = Stephan Seitz author = Stephan Seitz, Christopher Symben
author-email = stephan.seitz@fau.de author-email = stephan.seitz@fau.de, christopher.syben@fau.de
license = mit license = GPLv3
long-description = file: README.rst long-description = file: README.rst
long-description-content-type = text/x-rst; charset=UTF-8 long-description-content-type = text/x-rst; charset=UTF-8
url = https://github.com/pyscaffold/pyscaffold/ url = https://github.com/pyscaffold/pyscaffold/
......
...@@ -41,8 +41,6 @@ if __name__ == "__main__": ...@@ -41,8 +41,6 @@ if __name__ == "__main__":
[generated_file] + cuda_sources, [generated_file] + cuda_sources,
extra_compile_args={'cxx': ['--std=c++14'], extra_compile_args={'cxx': ['--std=c++14'],
'nvcc': ['-arch=sm_35']}) 'nvcc': ['-arch=sm_35']})
], ],
cmdclass={ cmdclass={
'build_ext': BuildExtension 'build_ext': BuildExtension
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
""" """
""" """
import os
import numpy as np
import pytest import pytest
import pyronn_torch import pyronn_torch
...@@ -18,6 +21,41 @@ def test_init(): ...@@ -18,6 +21,41 @@ def test_init():
@pytest.mark.parametrize('with_texture', ('with_texture', False)) @pytest.mark.parametrize('with_texture', ('with_texture', False))
@pytest.mark.parametrize('with_backward', ('with_backward', False)) @pytest.mark.parametrize('with_backward', ('with_backward', False))
def test_projection(with_texture, with_backward): def test_projection(with_texture, with_backward):
projector = pyronn_torch.ConeBeamProjector(
(128, 128, 128),
(2.0, 2.0, 2.0),
(-127.5, -127.5, -127.5),
(2, 480, 620),
[1.0, 1.0],
(0, 0),
np.array([[[-3.10e+2, -1.20e+03, 0.00e+00, 1.86e+5],
[-2.40e+2, 0.00e+00, 1.20e+03, 1.44e+5],
[-1.00e+00, 0.00e+00, 0.00e+00, 6.00e+2]],
[[-2.89009888e+2, -1.20522754e+3, -1.02473585e-13,
1.86000000e+5],
[-2.39963440e+2, -4.18857765e+0, 1.20000000e+3,
1.44000000e+5],
[-9.99847710e-01, -1.74524058e-2, 0.00000000e+0,
6.00000000e+2]]])
)
volume = projector.new_volume_tensor(requires_grad=True if with_backward else False)
volume += 1.
result = projector.project_forward(volume, use_texture=with_texture)
assert result is not None
if with_backward:
assert volume.requires_grad
assert result.requires_grad
loss = result.mean()
loss.backward()
@pytest.mark.skipif('CI' in os.environ, reason="No conrad config on CI")
@pytest.mark.parametrize('with_backward', ('with_backward', False))
def test_conrad_config(with_backward, with_texture=True):
projector = pyronn_torch.ConeBeamProjector.from_conrad_config() projector = pyronn_torch.ConeBeamProjector.from_conrad_config()
volume = projector.new_volume_tensor(requires_grad=True if with_backward else False) volume = projector.new_volume_tensor(requires_grad=True if with_backward else False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment