U-Net Implementation in TensorFlow
Re implementation of U-Net in Tensorflow
- to check how image segmentations can be used for detection problems
Original Paper
Summary
Vehicle Detection using U-Net
Objective: detect vehicles Find a function f such that y = f(X)
Input | Shape | Explanation | Example |
---|---|---|---|
X: 3-D Tensor | (640, 960, 3) | RGB image in an array | |
y: 3-D Tensor | (640, 960, 1) | Binarized image. Bacground is 0 vehicle is masked as 255 |
Loss function: maximize IOU
(intersection of prediction & grount truth)
-------------------------------------------
(union of prediction & ground truth)
Examples on Test Data: trained for 3 epochs
Get Started
Download dataset
- the annotated driving dataset is provided by Udacity
- In total, 9,423 frames with 65,000 labels at 1920x1200 resolution.
make download
Resize image and generate mask images
- utils/data.py is used to resize images and generate masks
make generate
Train Test Split
Make sure masks and bounding boxes
jupyter notebook "Visualization & Train Test Split.ipynb"
Train
# Train for 1 epoch
python train.py
or
$ python train.py --help
usage: train.py [-h] [--epochs EPOCHS] [--batch-size BATCH_SIZE]
[--logdir LOGDIR] [--reg REG] [--ckdir CKDIR]
optional arguments:
-h, --help show this help message and exit
--epochs EPOCHS Number of epochs (default: 1)
--batch-size BATCH_SIZE
Batch size (default: 4)
--logdir LOGDIR Tensorboard log directory (default: logdir)
--reg REG L2 Regularizer Term (default: 0.1)
--ckdir CKDIR Checkpoint directory (default: models)
Test
- Open the Jupyter notebook file to run against test data
jupyter notebook "./Test Run After Training.ipynb"