Coder Social home page Coder Social logo

xlearn's People

Contributors

decarlof avatar dependabot[bot] avatar hgaertner22 avatar mrakitin avatar salahsabri avatar xyangxray avatar zeliangsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xlearn's Issues

Problems with using multiple training images

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

Multiple training images?

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!

Segmentation Error

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.

offset in img_rec

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?

remove prj_enhancement/

@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,

segmentation.py fails to run on test data

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.

minor issue, training input and testing input are the same

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.