Code Monkey home page Code Monkey logo

segnet.tf's Introduction

SegNet

SegNet is a TensorFlow implementation of the segmentation network proposed by Kendall et al., with cool features like strided deconvolution, a minified architecture and more.

Configuration

Create a config.py file, containing color maps, working dataset and other options.

autoencoder = 'segnet'
colors = {
  'segnet-32': [
    [64, 128, 64],   # Animal
    [192, 0, 128],   # Archway
    [0, 128, 192],   # Bicyclist
    [0, 128, 64],    # Bridge
    [128, 0, 0],     # Building
    [64, 0, 128],    # Car
    [64, 0, 192],    # CartLuggagePram
    [192, 128, 64],  # Child
    [192, 192, 128], # Column_Pole
    [64, 64, 128],   # Fence
    [128, 0, 192],   # LaneMkgsDriv
    [192, 0, 64],    # LaneMkgsNonDriv
    [128, 128, 64],  # Misc_Text
    [192, 0, 192],   # MotorcycleScooter
    [128, 64, 64],   # OtherMoving
    [64, 192, 128],  # ParkingBlock
    [64, 64, 0],     # Pedestrian
    [128, 64, 128],  # Road
    [128, 128, 192], # RoadShoulder
    [0, 0, 192],     # Sidewalk
    [192, 128, 128], # SignSymbol
    [128, 128, 128], # Sky
    [64, 128, 192],  # SUVPickupTruck
    [0, 0, 64],      # TrafficCone
    [0, 64, 64],     # TrafficLight
    [192, 64, 128],  # Train
    [128, 128, 0],   # Tree
    [192, 128, 192], # Truck_Bus
    [64, 0, 64],     # Tunnel
    [192, 192, 0],   # VegetationMisc
    [0, 0, 0],       # Void
    [64, 192, 0]     # Wall
  ]
}
gpu_memory_fraction = 0.7
strided = True
working_dataset = 'segnet-32'

Two kinds of architectures are supported at the moment: the original SegNet Encoder-Decoder (segnet), and a smaller version of the same (mini), which can be used for simpler segmentation problems. I suggest to use strided = True for faster and more reliable results.

The dataset_name needs to match the data directories you create in your input folder. You can use segnet-32 and segnet-13 to replicate the aforementioned Kendall et al. experiments.

Train and test

Generate your TFRecords using tfrecorder.py. In order to do so, put your PNG images in a raw folder, as follows:

input/
    raw/
        train/
        train-labels/
        test/
        test-labels/

Once you have your TFRecords, train SegNet with python src/train.py. Analogously, test it with python src/test.py.

segnet.tf's People

Contributors

andreaazzini 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

Watchers

 avatar  avatar  avatar  avatar  avatar

segnet.tf's Issues

VGG16 Weight Initialisation

Hi,
I notice in previous commits you have functionality to initialise the encoder weights from a pre-trained VGG16, but this does not appear to be in the latest version. Why has this been removed?

final outputs

Thanks a lot for sharing your great work.
Could you please, add some parts to describe the final outputs (i.e. the predicted labels) of the test and training images?
Best

The unpool is not standard right ?

Hello,

from the code I have read in your project, it the unpool operation is just an image resize. So basically, this
network is not really a segnet network (at least not in a 'canonical' way from the paper).
Do you plan to use the locations of the max-pool layers to implement the standard unpool op ?

Training issue

Hi @andreaazzini I'm trying to use your code and I'm getting issues related to the Queue Shuffling during training.

Do you know what should I do to proceed?

OutOfRangeError (see above for traceback): RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 12, current size 0)
	 [[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

OutOfRangeError revisited

hi,
i experience the same issue, namely -

tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '...' is closed and has insufficient elements (requested 12, current size 0)
File "src/train.py", line 25, in train
images, labels = inputs(FLAGS.batch, FLAGS.train, FLAGS.train_labels)
File "src/inputs.py", line 29, in inputs
shuffle_batch

but i fail to understand what is meant by "correct resolution" in the related closed issue #10 .
thanks!

Sample dataset

Can you please share your dataset so I can understand how the dataset has to be?

training issue: train-labels / test-labels format

Hello,

I'm getting the following error when I train my model after preparing my TFRecords files:
OutOfRangeError (see above for traceback): RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 5, current size 0) [[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

All my images are 224x224 .PNGs, so I'm assuming that there's either a formatting issue with my training and test labelled images, or an issue with me using me using the CPU version of TensorFlow.

If the issue isn't from using the CPU version of TensorFlow, what sort of transforming is needed for the image annotations before using the tfrecorder to convert them? Does it involve converting the annotated images into color-mapped images using the colors from the config.py file?

Thanks!!

Varaibles init errors

I get the error
RandomShuffleQueue '_3_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 12, current size 0)
in train.py train().inputs() call. If I move the init variables statement to before inputs() is called, pool, unpool variables are initialized properly, but during AdamOptimizer init, I get the error for uninitialized variables beta1.

Can you please help fix the variables initialization? I'm on Win 10, python 3.6 x64, TensorFlow 1.2.0

OutOfRangeError

Hi
I'm training your net with camvid dataset. I followed your instructions but I get this error:

OutOfRangeError (see above for traceback): RandomShuffleQueue '_3_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 2, current size 0)

I think its not finding the training images which I did with your script. Could you please explain what you mean with this:

The dataset_name needs to match the data directories you create in your input folder. You can use segnet-32 and segnet-13 to replicate the aforementioned Kendall et al. experiments.

cheers

Error while training

when I try to train the model I obtain this error could somebody help me?

Saving results to input
Launching 1 threads for spacings: [[0, 71]]
2018-02-13 15:15:23.414452: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "tfrecorder.py", line 96, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "tfrecorder.py", line 53, in _process_image
image_data = f.read()
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 126, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 94, in _prepare_value
return compat.as_str_any(val)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 106, in as_str_any
return as_str(value)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

2018-02-13 15:15:24.444012: Finished writing all 71 images in data set.
Launching 1 threads for spacings: [[0, 39]]
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "tfrecorder.py", line 96, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "tfrecorder.py", line 53, in _process_image
image_data = f.read()
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 126, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 94, in _prepare_value
return compat.as_str_any(val)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 106, in as_str_any
return as_str(value)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

2018-02-13 15:15:25.452242: Finished writing all 39 images in data set.
Launching 1 threads for spacings: [[0, 76]]
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "tfrecorder.py", line 96, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "tfrecorder.py", line 53, in _process_image
image_data = f.read()
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 126, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 94, in _prepare_value
return compat.as_str_any(val)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 106, in as_str_any
return as_str(value)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

2018-02-13 15:15:26.460194: Finished writing all 76 images in data set.
Launching 1 threads for spacings: [[0, 82]]
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "tfrecorder.py", line 96, in _process_image_files_batch
image_buffer, height, width = _process_image(filename, coder)
File "tfrecorder.py", line 53, in _process_image
image_data = f.read()
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 126, in read
pywrap_tensorflow.ReadFromStream(self._read_buf, length, status))
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 94, in _prepare_value
return compat.as_str_any(val)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 106, in as_str_any
return as_str(value)
File "/home/cedriq/.local/lib/python3.5/site-packages/tensorflow/python/util/compat.py", line 84, in as_text
return bytes_or_text.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

2018-02-13 15:15:27.467536: Finished writing all 82 images in data set.

Missing call to self.decode()

In the latest commit (with the addition of --strided) the call to self.decode() went missing in the refactor.

BW

M

input and dataset

Hi,

I just found your project. Actually, it looks pretty cool/good.

I have some questions to ask you. One of them is if you could show me the structure of your input folder.
Another one is related to that folder too. I really can't find the segnet-32 dataset, do you still have it? or do you have any dataset avaidable?

I've also seen you've been updating your projecto to tensorflow v1.0. Is the proyect fully updated or at least does the current version work fine?

I would be very gratefull if you could help me.

Thanks!

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.