Giter Club home page Giter Club logo

keras-segnet-basic's Introduction

SegNet-Basic:


What is Segnet?

  • Deep Convolutional Encoder-Decoder Architecture for Semantic Pixel-wise Image Segmentation

Segnet = (Encoder + Decoder) + Pixel-Wise Classification layer

What is SegNet-Basic?

  • "In order to analyse SegNet and compare its performance with FCN (decoder variants) we use a smaller version of SegNet, termed SegNet-Basic , which ha 4 encoders and 4 decoders. All the encoders in SegNet-Basic perform max-pooling and subsampling and the corresponding decoders upsample its input using the received max-pooling indices."

Basically it's a mini-segnet to experiment / test the architecure with convnets, such as FCN.


Steps To Run The Model:


  1. Run python model-basic.py to create segNet_basic_model for keras to use.

    • model-basic.py contains the architecure.

Dataset:


  1. In a different directory run this to download the dataset from original Implementation.

    • git clone [email protected]:alexgkendall/SegNet-Tutorial.git
    • copy the /CamVid to here, or change the DataPath in data_loader.py to the above directory
  2. The run python data_loader.py to generate these two files:

    • /data/train_data.npz/ and /data/train_label.npz
    • This will make it easy to process the model over and over, rather than waiting the data to be loaded into memory.

To Do:


[x] SegNet-Basic
[ ] SegNet
[x] Test Accuracy
[ ] Requirements

Segnet-Basic Road Scene Results:


  • Train / Test:
	Train on 367 samples, validate on 233 samples
	Epoch 101/102
	366/367 [============================>.] 
	- ETA: 0s - loss: 0.3835 - acc: 0.8737Epoch 00000: val_acc improved from -inf to 0.76367, saving model to weights.best.hdf5
	367/367 [==============================] 
	- 231s - loss: 0.3832 - acc: 0.8738 - val_loss: 0.7655 - val_acc: 0.7637
	Epoch 102/102
	366/367 [============================>.] 
	- ETA: 0s - loss: 0.3589 - acc: 0.8809Epoch 00001: val_acc did not improve
	367/367 [==============================] 
	- 231s - loss: 0.3586 - acc: 0.8810 - val_loss: 2.4447 - val_acc: 0.4478
  • Evaluation:

    acc: 85.47%

    img1

    img2

keras-segnet-basic's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar

keras-segnet-basic's Issues

Predict results are wrong

When I try to test the model on my own dataset, I got the results like the picture.
Do you have any ideas why?
Thanks.
20180720_127
youtube001519

Training my own dataset

How do I train it on my own dataset? Is there any tool to prepare groundtruth for training in my own dataset?

ValueError: GpuDnnConv images and kernel must have the same stack size

Hello,

I'm facing this error, I also followed your steps, any ideas ?

ValueError: GpuDnnConv images and kernel must have the same stack size

Apply node that caused the error: GpuDnnConv{algo='small', inplace=True}(GpuContiguous.0, GpuContiguous.0, GpuAllocEmpty.0, GpuDnnConvDesc{border_mode='valid', subsample=(1, 1), conv_mode='conv', precision='float32'}.0, Constant{1.0}, Constant{0.0})
Toposort index: 688
Inputs types: [CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, 4D), <theano.gof.type.CDataType object at 0x7f0094d97c50>, Scalar(float32), Scalar(float32)]
Inputs shapes: [(6, 480, 182, 34), (128, 64, 3, 3), (6, 128, 180, 32), 'No shapes', (), ()]
Inputs strides: [(2970240, 6188, 34, 1), (576, 9, 3, 1), (737280, 5760, 32, 1), 'No strides', (), ()]
Inputs values: ['not shown', 'not shown', 'not shown', <PyCObject object at 0x7f0081578c88>, 1.0, 0.0]
Inputs name: ('image', 'kernel', 'output', 'descriptor', 'alpha', 'beta')

Outputs clients: [[GpuElemwise{add,no_inplace}(GpuDnnConv{algo='small', inplace=True}.0, GpuReshape{4}.0)]]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

model-full.py has array reshaping errors .

Hello .the Normal Model compiles well but the model_full.py has error on the lower part : because of the reshaping problem . Line 140
segnet_basic.add(Reshape((n_labels, img_h * img_w), input_shape=(12,img_h, img_w)))

They seem to be fine mathematically too . The simplemodel definition(model-basic.py ) is similar like this yet it works .But teh Model-full.py has error in this part .

Any help diagnosing this would be great .

Version of Keras???

I have my Keras version as 2.1.2...

When i tried to run this program i got the below error:

Using TensorFlow backend.
model-basic.py:31: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(64, (3, 3), padding="valid")
Convolution2D(filter_size, kernel, kernel, border_mode='valid'),
model-basic.py:37: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(128, (3, 3), padding="valid")
Convolution2D(128, kernel, kernel, border_mode='valid'),
model-basic.py:43: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(256, (3, 3), padding="valid")
Convolution2D(256, kernel, kernel, border_mode='valid'),
model-basic.py:49: UserWarning: Update your Conv2D call to the Keras 2 API: Conv2D(512, (3, 3), padding="valid")
Convolution2D(512, kernel, kernel, border_mode='valid'),
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1628, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,1,180,128].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "model-basic.py", line 91, in
segnet_basic.add(l)
File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 489, in add
output_tensor = layer(self.outputs[0])
File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 603, in call
output = self.call(inputs, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/keras/layers/pooling.py", line 154, in call
data_format=self.data_format)
File "/usr/local/lib/python3.5/dist-packages/keras/layers/pooling.py", line 217, in _pooling_function
pool_mode='max')
File "/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py", line 3466, in pool2d
data_format=tf_data_format)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/nn_ops.py", line 2140, in max_pool
name=name)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 4641, in max_pool
data_format=data_format, name=name)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1792, in init
control_input_ops)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
raise ValueError(str(e))
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,1,180,128].
*** Error in `python3': free(): invalid pointer: 0x00000000012b2760 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fa4d1bde7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fa4d1be737a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fa4d1beb53c]
/usr/lib/x86_64-linux-gnu/libprotobuf.so.9(_ZN6google8protobuf8internal28DestroyDefaultRepeatedFieldsEv+0x1f)[0x7fa47b2388af]
/usr/lib/x86_64-linux-gnu/libprotobuf.so.9(_ZN6google8protobuf23ShutdownProtobufLibraryEv+0x8b)[0x7fa47b237b3b]
/usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3(+0x233b9)[0x7fa42fdce3b9]
/lib64/ld-linux-x86-64.so.2(+0x10de7)[0x7fa4d215ede7]
/lib/x86_64-linux-gnu/libc.so.6(+0x39ff8)[0x7fa4d1ba0ff8]
/lib/x86_64-linux-gnu/libc.so.6(+0x3a045)[0x7fa4d1ba1045]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf7)[0x7fa4d1b87837]
python3(_start+0x29)[0x5d6049]

Please can you specify which version of the Keras this program requires to run???

Also please help me to resolve the issue?

Thanks,
Arun

Class weight does not work. Accuracy and loss remain same

i use the code and train on dataset from https://github.com/yhlleo/DeepCrack. The images changed to binary images. For the code I just changed the path and the label from 12 to 2 which are crack and background for all the py file. But it seems the class weight is not working.The changes i made are all the value 12 to 2 and the path to my dataset. Full code and dataset can be found at https://drive.google.com/open?id=1wK-non5bMkpApMshtCHXIqLXZOJ9jUxU.
I have been working on this problem for a long time and didn't found any workable solution online. I am desperate for help. So can you help me find the problem or at least give some possible causes that cause the problem of the class weighting not working on the fit generator. I changed the value for the class weight but still the accuracy the same. Changing the optimizer or learning rate also gives the same accuracy. The accuracy is the same for the first epoch which is 95.67%, changing the class weight did not affect it

Segnet basic model

Hello, thank you for your work.
I have issues on segnet-basic model.
It is confirmed that the paper says that the 7x7 kernel size was used, but I want to know if I am mistaken.

SegNet_Basic.py

Hi,

I have few clarifications in SegNet_Basic.py at line 28.

class_weighting= [0.2595, 0.1826, 4.5640, 0.1417, 0.5051, 0.3826, 9.6446, 1.8418, 6.6823, 6.2478, 3.0, 7.3614]

I would like to know how this values are assigned to class weighting.

Regards
Mohan

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.