tomography / xlearn Goto Github PK
View Code? Open in Web Editor NEWDeep learning toolbox for x-ray imaging
Home Page: http://xlearn.readthedocs.io
License: Other
Deep learning toolbox for x-ray imaging
Home Page: http://xlearn.readthedocs.io
License: Other
from xlearn.transform import train
fails with:
ValueError: You are tring to use the old GPU back-end. It was removed from Theano. Use device=cuda* now. See https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29 for more information.
Hi,
I'm trying to run the training code with multiple training images and run into an error when executing mdl = train(). The code I'm using is as following:
import dxchange
import matplotlib.pyplot as plt
from xlearn.transform import train
from xlearn.transform import model
import glob, os
batch_size = 400
nb_epoch = 10
#dim_img = 20
nb_filters = 32
nb_conv = 3
patch_step = 2
#patch_size = (dim_img, dim_img)
patch_size = (520, 472)
img_x=dxchange.read_tiff("SLS_raw_stack.tif")
img_y=dxchange.read_tiff("SLS_handSeg_stack.tif")
mdl = train(img_x, img_y, patch_size, patch_step, dim_img, nb_filters, nb_conv, batch_size, nb_epoch)
Running the mdl=train() results in the error message "ValueError: Height of the patch should be less than the height of the image."
I tried changing the patch_size variable to patch_size = (3, 520, 472), but that ended in an error too.
Would anyone have an idea how to solve the problem?
Cheers,
Sina
PS: the two test stacks (raw and segmented images) are attached in the zip
Test_stacks.zip
I was wondering if there is a way to add additional training data to the program, or can it only allow for one training image at a time? Thank you!
Using Python 3.6 on Windows, I tried to use the segmentation example (https://github.com/tomography/xlearn/blob/master/doc/demo/segmentation.py) so that I could use multiple training images to identify features in an image. However, when I try this I get an error "TypeError: Expected int32, got 8.0 of type 'float' instead" (Full error message below). I was wondering if anyone had suggestions as to how to fix this? Thank you
runfile('C:/Users/Hannah/Downloads/python programs/xlearn_seg2.py', wdir='C:/Users/Hannah/Downloads/python programs')
Traceback (most recent call last):
File "", line 1, in
runfile('C:/Users/Hannah/Downloads/python programs/xlearn_seg2.py', wdir='C:/Users/Hannah/Downloads/python programs')
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Hannah/Downloads/python programs/xlearn_seg2.py", line 34, in
mdl=seg_train(imgx, imgy, batch_size=batch_size, nb_epoch=nb_epoch, nb_gpu=nb_gpu)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\xlearn-0.2.0-py3.6.egg\xlearn\segmentation.py", line 138, in seg_train
mdl = model_choose(patch_size, patch_size, nb_conv, size_conv, nb_down, nb_gpu)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\xlearn-0.2.0-py3.6.egg\xlearn\segmentation.py", line 69, in model_choose
mdl = transformer2(ih, iw, nb_conv, size_conv, nb_gpu)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\xlearn-0.2.0-py3.6.egg\xlearn\models.py", line 161, in transformer2
fc1 = Reshape((ih / 4, iw / 4, 1))(fc1)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\keras_impl\keras\engine\topology.py", line 258, in call
output = super(Layer, self).call(inputs, **kwargs)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\layers\base.py", line 652, in call
outputs = self.call(inputs, *args, **kwargs)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\keras_impl\keras\layers\core.py", line 401, in call
return K.reshape(inputs, (K.shape(inputs)[0],) + self.target_shape)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\keras_impl\keras\backend.py", line 1986, in reshape
return array_ops.reshape(x, shape)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 5184, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 513, in _apply_op_helper
raise err
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\ops.py", line 1022, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1001, in _autopacking_conversion_function
return _autopacking_helper(v, inferred_dtype, name or "packed")
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\ops\array_ops.py", line 963, in _autopacking_helper
constant_op.constant(elem, dtype=dtype, name=str(i)))
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\constant_op.py", line 212, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 413, in make_tensor_proto
_AssertCompatible(values, dtype)
File "C:\Users\Hannah\Downloads\WinPython\python-3.6.5.amd64\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 328, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).name))
TypeError: Expected int32, got 8.0 of type 'float' instead.
Hello,
I have fixed these errors and now we can use it. Could you please give me the permission to pull a request?
Thx
Zeliang,
Hi,
I was wondering why you have an offset in your image reconstruction. Since we know the true object from your transform_train where the values ranges in [0,255], your output in transform_predict ranges in ~[0, 0.137]. How can we resolve this?
@XYangXRay we should probably delete the prj_enhancement folder and move its functions to the demo/example folder or to the library modules (inside xlearn/). As is, it looks confusing,
python segmentation.py
Using TensorFlow backend.
Traceback (most recent call last):
File "segmentation.py", line 18, in
mdl = seg_train(imgx, imgy, batch_size = batch_size, nb_epoch = nb_epoch, nb_down = nb_down, nb_gpu = nb_gpu)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/segmentation.py", line 138, in seg_train
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/segmentation.py", line 67, in model_choose
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/models.py", line 235, in transformer3_pooling
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/engine/base_layer.py", line 314, in call
output = super(Layer, self).call(inputs, *args, **kwargs)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 717, in call
outputs = self.call(inputs, *args, **kwargs)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/layers/core.py", line 420, in call
(array_ops.shape(inputs)[0],) + self.target_shape)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 6113, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper
raise err
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1104, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1034, in _autopacking_conversion_function
return _autopacking_helper(v, inferred_dtype, name or "packed")
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 996, in _autopacking_helper
constant_op.constant(elem, dtype=dtype, name=str(i)))
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 432, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 343, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).name))
TypeError: Expected int32, got 4.0 of type 'float' instead.
(test) bash-4.2$ python segmentation.py
Using TensorFlow backend.
Traceback (most recent call last):
File "segmentation.py", line 21, in
mdl = seg_train(imgx, imgy, batch_size = batch_size, nb_epoch = nb_epoch, nb_down = nb_down, nb_gpu = nb_gpu)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/segmentation.py", line 138, in seg_train
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/segmentation.py", line 67, in model_choose
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/xlearn-0.2.0-py3.6.egg/xlearn/models.py", line 235, in transformer3_pooling
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/engine/base_layer.py", line 314, in call
output = super(Layer, self).call(inputs, *args, **kwargs)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 717, in call
outputs = self.call(inputs, *args, **kwargs)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/layers/core.py", line 420, in call
(array_ops.shape(inputs)[0],) + self.target_shape)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 6113, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper
raise err
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1104, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1034, in _autopacking_conversion_function
return _autopacking_helper(v, inferred_dtype, name or "packed")
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 996, in _autopacking_helper
constant_op.constant(elem, dtype=dtype, name=str(i)))
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 432, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/local/decarlo/conda/anaconda/envs/test/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 343, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).name))
TypeError: Expected int32, got 4.0 of type 'float' instead.
test/test_data/ptrdict_test.tiff which you used to test your trained model and test/test_data/training_input.tiff looks exactly the same, which means you test with training input which does not make sense and cannot validate if the mode is overfitted
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.