-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce label conversion and TFRecords encoding. Introduce independ…
…ent train and test files. Organize code into modules.
- Loading branch information
1 parent
5685e01
commit d0619a4
Showing
20 changed files
with
579 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
__pycache__/ | ||
logs/ | ||
input/old/ | ||
input/raw/ | ||
input/shuffled/ | ||
ckpts/ | ||
input/ | ||
logs/ | ||
|
||
*.pyc | ||
vgg16_weights.npz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
# SegNet | ||
|
||
SegNet is a TensorFlow implementation of the [segmentation network proposed by Kendall et al.](http://mi.eng.cam.ac.uk/projects/segnet/). | ||
|
||
## Configuration | ||
|
||
Before running, download the [VGG16 weights file](https://www.cs.toronto.edu/~frossard/vgg16/vgg16_weights.npz) | ||
and save it as `input/vgg16_weights.npz`. | ||
and save it as `input/vgg16_weights.npz` if you want to initialize the encoder weights with the VGG16 ones trained on ImageNet classification dataset. | ||
|
||
In `config.py`, choose your working dataset. 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 | ||
|
||
Train SegNet with `python segnet.py`. | ||
Train SegNet with `python -m src/train.py`. Analogously, test it with `python -m src/test.py`. |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
working_dataset = 'single-coke' |
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import config | ||
import tensorflow as tf | ||
import utils | ||
|
||
colors = tf.cast(tf.pack(utils.colors_of_dataset(config.working_dataset)), tf.float32) / 255 | ||
|
||
def color_mask(tensor, color): | ||
return tf.reduce_all(tf.equal(tensor, color), 3) | ||
|
||
def one_hot(labels): | ||
color_tensors = tf.unstack(colors) | ||
channel_tensors = list(map(lambda color: color_mask(labels, color), color_tensors)) | ||
one_hot_labels = tf.cast(tf.stack(channel_tensors, 3), 'float32') | ||
return one_hot_labels | ||
|
||
def rgb(logits): | ||
softmax = tf.nn.softmax(logits) | ||
argmax = tf.argmax(softmax, 3) | ||
n = colors.get_shape().as_list()[0] | ||
one_hot = tf.one_hot(argmax, n, dtype=tf.float32) | ||
one_hot_matrix = tf.reshape(one_hot, [-1, n]) | ||
rgb_matrix = tf.matmul(one_hot_matrix, colors) | ||
rgb_tensor = tf.reshape(rgb_matrix, [-1, 224, 224, 3]) | ||
return tf.cast(rgb_tensor, tf.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.