Find a file
milesial 50cbf66b21 Tweaked README
Former-commit-id: f49d66e44456731f0f10cebe8b6d9d2be985fdb2
2017-11-30 08:38:14 +01:00
unet Added CLI for predict, cleaned up code, updated README 2017-11-30 06:45:19 +01:00
utils Cleaned code, added image to README.md 2017-11-30 07:47:43 +01:00
.gitignore Added CLI for predict, cleaned up code, updated README 2017-11-30 06:45:19 +01:00
eval.py Cleaned code, added image to README.md 2017-11-30 07:47:43 +01:00
LICENSE Create LICENSE 2017-11-30 08:23:15 +01:00
main.py Cleaned code, added image to README.md 2017-11-30 07:47:43 +01:00
MODEL.pth.REMOVED.git-id Added simple trained model 2017-08-23 17:38:55 +02:00
myloss.py Created a basic train loop + changed a bit loss and utils 2017-08-17 21:16:19 +02:00
predict.py Cleaned code, added image to README.md 2017-11-30 07:47:43 +01:00
README.md Tweaked README 2017-11-30 08:38:14 +01:00
submit.py Modified to take any image size (with even width, height > width/2) 2017-11-30 07:19:52 +01:00
train.py Cleaned code, added image to README.md 2017-11-30 07:47:43 +01:00

Pytorch-UNet

input and output for a random image in the test dataset

Customized implementation of the U-Net in Pytorch for Kaggle's Carvana Image Masking Challenge from a high definition image. This was used with only one output class but it can be scaled easily.

This model was trained from scratch with 5000 images (no data augmentation) and scored a dice coefficient of 0.988423 (511 out of 735) on over 100k test images. This score is not quite good but could be improved with more training, data augmentation, fine tuning, playing with CRF post-processing, and applying more weights on the edges of the masks.

The model used for the last submission is stored in the MODEL.pth file, if you wish to play with it. The data is available on the Kaggle website.

Usage

Prediction

You can easily test the output masks on your images via the CLI.

To see all options: python predict.py -h

To predict a single image and save it:

python predict.py -i image.jpg -o ouput.jpg

To predict a multiple images and show them without saving them:

python predict.py -i image1.jpg image2.jpg --viz --no-save

You can use the cpu-only version with --cpu.

You can specify which model file to use with --model MODEL.pth.

Training

python train.py -h should get you started. A proper CLI is yet to be added.

Warning

In order to process the image, it is splitted into two squares (a left on and a right one), and each square is passed into the net. The two square masks are then merged again to produce the final image. As a consequence, the height of the image must be strictly superior than half the width. Make sure the width is even too.

Dependencies

This package depends on pydensecrf, available via pip install.