U-Net for HD images, because blurry masks are embarrassing
A straightforward PyTorch implementation of the classic U-Net architecture, tuned for high-definition semantic segmentation and battle-tested on Kaggle’s Carvana challenge.

What it does Implements the venerable U-Net architecture in PyTorch for pixel-level semantic segmentation. It was originally built for Kaggle’s Carvana Image Masking Challenge, where it achieved a Dice coefficient of 0.988423 on over 100,000 test images after training on just 5,000. The codebase handles training, prediction, and mask generation for high-definition images, and it claims to adapt readily to multiclass, portrait, or medical segmentation tasks.
The interesting bit
The project is resolutely old-school in a good way: it is a customized but direct implementation of the 2015 paper, augmented with modern conveniences like automatic mixed precision (--amp) and Weights & Biases logging rather than a heavy framework. A pretrained model is loadable directly via torch.hub, which turns the repo into a surprisingly practical drop-in segmentation tool.
Key highlights
- Ships with a pretrained Carvana model loadable through
torch.hubat scales of 0.5 or 1.0. - Supports automatic mixed precision training to reduce GPU memory and speed up computation on newer hardware.
- Integrates with Weights & Biases for real-time loss curves, gradient histograms, and predicted mask visualization.
- Offers an official Docker image with NVIDIA GPU support for environment reproducibility.
- Defaults to a 0.5 image scale to save memory, but can run at full 1.0 resolution when accuracy matters more.
Caveats
- The data loader is described as “greedy”: your
data/imgsanddata/masksdirectories must contain exactly the image files and zero subfolders or extraneous files. - While the README suggests easy adaptation to medical or portrait segmentation, the codebase and pretrained weights are explicitly tailored to the Carvana dataset’s RGB images and black-and-white masks.
- Requires CUDA and PyTorch 1.13+; CPU-only workflows are not the focus.
Verdict Worth a look if you need a clean, hackable U-Net baseline for high-resolution segmentation or want a pretrained Carvana mask generator. Skip it if you are hunting for a generic, framework-agnostic solution or need out-of-the-box support for messy, nested datasets.
Frequently asked
- What is milesial/Pytorch-UNet?
- A straightforward PyTorch implementation of the classic U-Net architecture, tuned for high-definition semantic segmentation and battle-tested on Kaggle’s Carvana challenge.
- Is Pytorch-UNet open source?
- Yes — milesial/Pytorch-UNet is open source, released under the GPL-3.0 license.
- What language is Pytorch-UNet written in?
- milesial/Pytorch-UNet is primarily written in Python.
- How popular is Pytorch-UNet?
- milesial/Pytorch-UNet has 11.6k stars on GitHub.
- Where can I find Pytorch-UNet?
- milesial/Pytorch-UNet is on GitHub at https://github.com/milesial/Pytorch-UNet.