Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hellochick committed Nov 18, 2017
2 parents e6a01be + 0658cb4 commit 6cd4fbf
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
This is an implementation of ICNet in TensorFlow for semantic segmentation on the [cityscapes](https://www.cityscapes-dataset.com/) dataset. We first convert weight from [Original Code](https://github.com/hszhao/ICNet) by using [caffe-tensorflow](https://github.com/ethereon/caffe-tensorflow) framework.

## Update
#### 2017/11/15:
1. Support `training phase`, you can train on your own dataset. Please read the guide below.

#### 2017/11/13:
1. Add `bnnomerge model` which reparing for training phase. Choose different model using flag `--model=train, train_bn, trainval, trainval_bn` (Upload model in google drive).
2. Change `tf.nn.batch_normalization` to `tf.layers.batch_normalization`.
Expand All @@ -26,6 +29,7 @@ List of Args:
--model=trainval - To select trainval_90k model
--model=train_bn - To select train_30k_bn model
--model=trainval_bn - To select trainval_90k_bn model
--model=others - To select your own checkpoint
```
Inference time: ~0.02s, I have no idea why it's faster than caffe implementation

Expand Down Expand Up @@ -57,6 +61,50 @@ Input image | Output image
:-------------------------:|:-------------------------:
![](https://github.com/hellochick/ICNet_tensorflow/blob/master/input/test_1024x2048.png) |  ![](https://github.com/hellochick/ICNet_tensorflow/blob/master/output/test_1024x2048.png)

## Training on your own dataset
> Note: This implementation is different from the details descibed in ICNet paper, since I did not re-produce model compression part. Instead, we train on the half kernel directly.
### Step by Step
**1. Change the `DATA_LIST_PATH`** in line 22, make sure the list contains the absolute path of your data files, in `list.txt`:
```
/ABSOLUTE/PATH/TO/image /ABSOLUTE/PATH/TO/label
```
**2. Set Hyperparameters** (line 21-35) in `train.py`
```
BATCH_SIZE = 48
IGNORE_LABEL = 0
INPUT_SIZE = '480,480'
LEARNING_RATE = 1e-3
MOMENTUM = 0.9
NUM_CLASSES = 27
NUM_STEPS = 60001
POWER = 0.9
RANDOM_SEED = 1234
WEIGHT_DECAY = 0.0001
```
Also **set the loss function weight** (line 38-40) descibed in the paper:
```
# Loss Function = LAMBDA1 * sub4_loss + LAMBDA2 * sub24_loss + LAMBDA3 * sub124_loss
LAMBDA1 = 0.16
LAMBDA2 = 0.4
LAMBDA3 = 1.0
```
**3.** Run following command and **decide whether to update mean/var or train beta/gamma variable**. Remember to choose `--model=others`.
```
python train.py --update-mean-var --train-beta-gamma --model=others
```
After training the dataset, you can run following command to get the result:
```
python inference.py --img-path=YOUR_OWN_IMAGE --model=others
```
### Result ( inference with my own data )

Input | Output
:-------------------------:|:-------------------------:
![](https://github.com/hellochick/ICNet_tensorflow/blob/master/input/indoor1.jpg) |  ![](https://github.com/hellochick/ICNet-tensorflow/blob/master/output/indoor1.jpg)
![](https://github.com/hellochick/ICNet_tensorflow/blob/master/input/indoor3.jpg) |  ![](https://github.com/hellochick/ICNet-tensorflow/blob/master/output/indoor3.jpg)


## Citation
@article{zhao2017icnet,
author = {Hengshuang Zhao and
Expand Down

0 comments on commit 6cd4fbf

Please sign in to comment.