Giter VIP home page Giter VIP logo

hasnainraz / fc-densenet-tensorflow Goto Github PK

View Code? Open in Web Editor NEW
123.0 6.0 41.0 867 KB

Fully Convolutional DenseNet (A.K.A 100 layer tiramisu) for semantic segmentation of images implemented in TensorFlow.

License: MIT License

Python 100.00%
tensorflow densenet fully-convolutional-networks tiramisu semantic-segmentation image-segmentation test-coverage convolution convolutions artificial-intelligence

fc-densenet-tensorflow's People

Contributors

hasnainraz 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  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  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

fc-densenet-tensorflow's Issues

Why not change the training mode to 'False' in the line # 339?

Hi, thanks for your sharing. I learned a lot!
I am little confused for the training mode in the Model.py (line#: 339). To get the dice for the validation set, we should change the training mode from 'True' to 'False', is that right? Because we we have trained the weights by the training set, and we should not train any weights by the validation set.

I am a new learner. I will be very grateful if you reply me.
Thanks a lot!

about testing

Thanks for your work. I have a question that after training how to test the model on my own data sets?

how to solve this error

python main.py --mode=train
Traceback (most recent call last):
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1094, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 931, in _TensorTensorConversionFunction
(dtype.name, t.dtype.name, str(t)))

ValueError: Tensor conversion requested dtype string for Tensor with dtype float32: 'Tensor("arg0:0", shape=(), dtype=float32)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 44, in
main()
File "main.py", line 38, in main
FLAGS.batch_size, FLAGS.epochs, FLAGS.learning_rate)
File "/home/user10/notebook/tiramisu/model.py", line 281, in train
train_image_paths, train_mask_paths, batch_size)
File "/home/user10/notebook/tiramisu/utility.py", line 86, in data_batch
num_parallel_calls=num_threads).prefetch(30)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 988, in map
return ParallelMapDataset(self, map_func, num_parallel_calls)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2230, in init
super(ParallelMapDataset, self).init(input_dataset, map_func)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2198, in init
map_func, "Dataset.map()", input_dataset)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1454, in init
self._function.add_to_graph(ops.get_default_graph())
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 481, in add_to_graph
self._create_definition_if_needed()
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed
self._create_definition_if_needed_impl()
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl
self._capture_by_value, self._caller_device)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func
outputs = func(*func_graph.inputs)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper
ret = func(*nested_args)
File "/home/user10/notebook/tiramisu/utility.py", line 5, in _parse_data_infer
image_content = tf.read_file(image_paths)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_io_ops.py", line 528, in read_file
"ReadFile", filename=filename, name=name)
File "/home/user10/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 533, in _apply_op_helper
(prefix, dtypes.as_dtype(input_arg.type).name))

TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

normalize_data problem why image/255 and mask/255 when training

before training, why should image/255 and mask/255 my mask's each pixel is an index in [0,classnumber] if mask/255 they will all be 0 (class:background) when i use pascal VOC 2012 dataset
one more thing why use 30 in parse resize normaliza and shuffle thanks a lot

HI~Can i ask about this error?

i didnt change any word in model.py

Traceback (most recent call last):
File "main.py", line 44, in
main()
File "main.py", line 38, in main
FLAGS.batch_size, FLAGS.epochs, FLAGS.learning_rate)
File "/home/user/CHI_FCN/FC-DenseNet-TensorFlow-master/model.py", line 347, in train
total_train_cost / train_step, total_val_cost / val_step))
UnboundLocalError: local variable 'train_step' referenced before assignment

Pictures in output are all black

after training,model will save three ckpt files, .index .meta and .data, how can I run infer?I run the
python main.py --ckpt=models/model.ckpt-4
but the pictures in output are all black. And there is no errors and warnings.

Some minor bugs.

  • weight init
    In the original paper, he initialization is used instead of xavier, this would translate to using: tf.contrib.layers.variance_scaling_initializer
  • max pooling
    In the original paper, the transition down should be a 2x2 max pool that is non-overlapping. Checking the original Lasagne code it seems they use a 2x2 max pool with a window of 2x2 and stride of 2x2. Wasn't sure if your current 4x4 window as intentional.

Great work on this btw, very readable!

Cant read Inputfiles

I've set the default Path, in the main.py script, to my Dataset Folder:

parser.add_argument("--train_data", default="./dataset/img", help="Directory for training images")

My folder sctruture inside the project looks like this:

  • dataset
    • img
      • images
      • masks

When i call the main.py script without arguments, i get the error: TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

Infer fail due to model shape not match

I'm trying to run train & infer.
However I encounter error while infer

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1,1,48,2] rhs shape= [1,1,80,2]
	 [[Node: save/Assign_87 = Assign[T=DT_FLOAT, _class=["loc:@prediction/last_conv1x1/kernel"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](prediction/last_conv1x1/kernel, save/RestoreV2_87)]]

Could you provide some advise, Thanks

two bugs?

I found two issues in the process of running the codes.

  1. Model.py (line#: 66), it should be 'def batch_norm(self, x, training, name)'?

  2. Model.py (line#: 229), it should be
    'x = self.dense_block(x, training, block_nb - 1, 'up_dense_block_' + str(block_nb))' ?

about the upsampling

hey
I am building the FC-dense net.
in the paper. The upsampling path is only using the output of the last dense block
but in your code
print("Building upsample path...")

for i, block_nb in enumerate(range(self.nb_blocks - 1, 0, -1)):
    x = self.transition_up(x, x.get_shape()[-1], 'trans_up_' + str(block_nb))
    x = tf.concat([x, concats[len(concats) - i - 1]], axis=3, name='up_concat_' + str(block_nb))
    print(x.get_shape())
    x = self.dense_block(x, training, block_nb, 'up_dense_block_' + str(block_nb))

here x is the last skip list tensor--->concats[4]
maybe you should write this:
x=dense
before the for loop,so that x will be the output of the dense block
thanks.

Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED and Possibly insufficient driver version: 384.81.0 Segmentation fault (core dumped)

when i run the order :
python main.py --mode=train --train_data=/mnt/saners-extend/FC-DenseNet-TensorFlow/data/train --val_data=/mnt/saners-extend/FC-DenseNet-TensorFlow/data/val --layers_per_block=4,5,7,10,12,15 --batch_size=2 --epochs=10 --growth_k=16 --num_classes=2 --learning_rate=0.001

it shows that:
/home/anaconda3/lib/python3.6/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
First Convolution Out: (?, 256, 256, 48)
Downsample Out: (?, 128, 128, 112)
Downsample Out: (?, 64, 64, 192)
Downsample Out: (?, 32, 32, 304)
Downsample Out: (?, 16, 16, 464)
Downsample Out: (?, 8, 8, 656)
Bottleneck Block: (?, 8, 8, 240)
Upsample after concat: (?, 16, 16, 896)
Upsample after concat: (?, 32, 32, 704)
Upsample after concat: (?, 64, 64, 496)
Upsample after concat: (?, 128, 128, 352)
Upsample after concat: (?, 256, 256, 224)
Mask Prediction: (?, 256, 256, 2)
2018-10-25 15:54:14.641467: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-10-25 15:54:14.781306: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-10-25 15:54:14.781714: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties:
name: Tesla P100-PCIE-12GB major: 6 minor: 0 memoryClockRate(GHz): 1.3285
pciBusID: 0000:05:01.0
totalMemory: 11.91GiB freeMemory: 2.58GiB
2018-10-25 15:54:14.781753: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2018-10-25 15:54:15.190540: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-10-25 15:54:15.190615: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0
2018-10-25 15:54:15.190628: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N
2018-10-25 15:54:15.190885: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 2277 MB memory) -> physical GPU (device: 0, name: Tesla P100-PCIE-12GB, pci bus id: 0000:05:01.0, compute capability: 6.0)
2018-10-25 15:55:52.442988: E tensorflow/stream_executor/cuda/cuda_dnn.cc:352] Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2018-10-25 15:55:52.443130: E tensorflow/stream_executor/cuda/cuda_dnn.cc:360] Possibly insufficient driver version: 384.81.0
Segmentation fault (core dumped)

my environment is cuda9.0, cudnn7.0,tensorflow 1.10.1,anyone can give some advice ? thanks very much

out of memory

2*1080ti out of memory ,cityscapesScripts datasets,batch size 4.

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.