[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9701":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},9701,"Pytorch-UNet","milesial\u002FPytorch-UNet","milesial","PyTorch implementation of the U-Net for image semantic segmentation with high quality images","",null,"Python",11480,2751,71,115,0,10,53,4,45,"GNU General Public License v3.0",false,"master",[25,26,27,28,29,30,31,32,33,34,35],"convolutional-networks","convolutional-neural-networks","deep-learning","kaggle","pytorch","pytorch-unet","semantic-segmentation","tensorboard","unet","wandb","weights-and-biases","2026-06-12 02:02:11","# U-Net: Semantic segmentation with PyTorch\n\u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002Fmilesial\u002FPyTorch-UNet\u002Fmain.yml?logo=github&style=for-the-badge\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fhub.docker.com\u002Fr\u002Fmilesial\u002Funet\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fdocker%20image-available-blue?logo=Docker&style=for-the-badge\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fpytorch.org\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPyTorch-v1.13+-red.svg?logo=PyTorch&style=for-the-badge\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-v3.6+-blue.svg?logo=python&style=for-the-badge\" \u002F>\u003C\u002Fa>\n\n![input and output for a random image in the test dataset](https:\u002F\u002Fi.imgur.com\u002FGD8FcB7.png)\n\n\nCustomized implementation of the [U-Net](https:\u002F\u002Farxiv.org\u002Fabs\u002F1505.04597) in PyTorch for Kaggle's [Carvana Image Masking Challenge](https:\u002F\u002Fwww.kaggle.com\u002Fc\u002Fcarvana-image-masking-challenge) from high definition images.\n\n- [Quick start](#quick-start)\n  - [Without Docker](#without-docker)\n  - [With Docker](#with-docker)\n- [Description](#description)\n- [Usage](#usage)\n  - [Docker](#docker)\n  - [Training](#training)\n  - [Prediction](#prediction)\n- [Weights & Biases](#weights--biases)\n- [Pretrained model](#pretrained-model)\n- [Data](#data)\n\n## Quick start\n\n### Without Docker\n\n1. [Install CUDA](https:\u002F\u002Fdeveloper.nvidia.com\u002Fcuda-downloads)\n\n2. [Install PyTorch 1.13 or later](https:\u002F\u002Fpytorch.org\u002Fget-started\u002Flocally\u002F)\n\n3. Install dependencies\n```bash\npip install -r requirements.txt\n```\n\n4. Download the data and run training:\n```bash\nbash scripts\u002Fdownload_data.sh\npython train.py --amp\n```\n\n### With Docker\n\n1. [Install Docker 19.03 or later:](https:\u002F\u002Fdocs.docker.com\u002Fget-docker\u002F)\n```bash\ncurl https:\u002F\u002Fget.docker.com | sh && sudo systemctl --now enable docker\n```\n2. [Install the NVIDIA container toolkit:](https:\u002F\u002Fdocs.nvidia.com\u002Fdatacenter\u002Fcloud-native\u002Fcontainer-toolkit\u002Finstall-guide.html)\n```bash\ndistribution=$(. \u002Fetc\u002Fos-release;echo $ID$VERSION_ID) \\\n   && curl -s -L https:\u002F\u002Fnvidia.github.io\u002Fnvidia-docker\u002Fgpgkey | sudo apt-key add - \\\n   && curl -s -L https:\u002F\u002Fnvidia.github.io\u002Fnvidia-docker\u002F$distribution\u002Fnvidia-docker.list | sudo tee \u002Fetc\u002Fapt\u002Fsources.list.d\u002Fnvidia-docker.list\nsudo apt-get update\nsudo apt-get install -y nvidia-docker2\nsudo systemctl restart docker\n```\n3. [Download and run the image:](https:\u002F\u002Fhub.docker.com\u002Frepository\u002Fdocker\u002Fmilesial\u002Funet)\n```bash\nsudo docker run --rm --shm-size=8g --ulimit memlock=-1 --gpus all -it milesial\u002Funet\n```\n\n4. Download the data and run training:\n```bash\nbash scripts\u002Fdownload_data.sh\npython train.py --amp\n```\n\n## Description\nThis model was trained from scratch with 5k images and scored a [Dice coefficient](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FS%C3%B8rensen%E2%80%93Dice_coefficient) of 0.988423 on over 100k test images.\n\nIt can be easily used for multiclass segmentation, portrait segmentation, medical segmentation, ...\n\n\n## Usage\n**Note : Use Python 3.6 or newer**\n\n### Docker\n\nA docker image containing the code and the dependencies is available on [DockerHub](https:\u002F\u002Fhub.docker.com\u002Frepository\u002Fdocker\u002Fmilesial\u002Funet).\nYou can download and jump in the container with ([docker >=19.03](https:\u002F\u002Fdocs.docker.com\u002Fget-docker\u002F)):\n\n```console\ndocker run -it --rm --shm-size=8g --ulimit memlock=-1 --gpus all milesial\u002Funet\n```\n\n\n### Training\n\n```console\n> python train.py -h\nusage: train.py [-h] [--epochs E] [--batch-size B] [--learning-rate LR]\n                [--load LOAD] [--scale SCALE] [--validation VAL] [--amp]\n\nTrain the UNet on images and target masks\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --epochs E, -e E      Number of epochs\n  --batch-size B, -b B  Batch size\n  --learning-rate LR, -l LR\n                        Learning rate\n  --load LOAD, -f LOAD  Load model from a .pth file\n  --scale SCALE, -s SCALE\n                        Downscaling factor of the images\n  --validation VAL, -v VAL\n                        Percent of the data that is used as validation (0-100)\n  --amp                 Use mixed precision\n```\n\nBy default, the `scale` is 0.5, so if you wish to obtain better results (but use more memory), set it to 1.\n\nAutomatic mixed precision is also available with the `--amp` flag. [Mixed precision](https:\u002F\u002Farxiv.org\u002Fabs\u002F1710.03740) allows the model to use less memory and to be faster on recent GPUs by using FP16 arithmetic. Enabling AMP is recommended.\n\n\n### Prediction\n\nAfter training your model and saving it to `MODEL.pth`, you can easily test the output masks on your images via the CLI.\n\nTo predict a single image and save it:\n\n`python predict.py -i image.jpg -o output.jpg`\n\nTo predict a multiple images and show them without saving them:\n\n`python predict.py -i image1.jpg image2.jpg --viz --no-save`\n\n```console\n> python predict.py -h\nusage: predict.py [-h] [--model FILE] --input INPUT [INPUT ...] \n                  [--output INPUT [INPUT ...]] [--viz] [--no-save]\n                  [--mask-threshold MASK_THRESHOLD] [--scale SCALE]\n\nPredict masks from input images\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --model FILE, -m FILE\n                        Specify the file in which the model is stored\n  --input INPUT [INPUT ...], -i INPUT [INPUT ...]\n                        Filenames of input images\n  --output INPUT [INPUT ...], -o INPUT [INPUT ...]\n                        Filenames of output images\n  --viz, -v             Visualize the images as they are processed\n  --no-save, -n         Do not save the output masks\n  --mask-threshold MASK_THRESHOLD, -t MASK_THRESHOLD\n                        Minimum probability value to consider a mask pixel white\n  --scale SCALE, -s SCALE\n                        Scale factor for the input images\n```\nYou can specify which model file to use with `--model MODEL.pth`.\n\n## Weights & Biases\n\nThe training progress can be visualized in real-time using [Weights & Biases](https:\u002F\u002Fwandb.ai\u002F).  Loss curves, validation curves, weights and gradient histograms, as well as predicted masks are logged to the platform.\n\nWhen launching a training, a link will be printed in the console. Click on it to go to your dashboard. If you have an existing W&B account, you can link it\n by setting the `WANDB_API_KEY` environment variable. If not, it will create an anonymous run which is automatically deleted after 7 days.\n\n\n## Pretrained model\nA [pretrained model](https:\u002F\u002Fgithub.com\u002Fmilesial\u002FPytorch-UNet\u002Freleases\u002Ftag\u002Fv3.0) is available for the Carvana dataset. It can also be loaded from torch.hub:\n\n```python\nnet = torch.hub.load('milesial\u002FPytorch-UNet', 'unet_carvana', pretrained=True, scale=0.5)\n```\nAvailable scales are 0.5 and 1.0.\n\n## Data\nThe Carvana data is available on the [Kaggle website](https:\u002F\u002Fwww.kaggle.com\u002Fc\u002Fcarvana-image-masking-challenge\u002Fdata).\n\nYou can also download it using the helper script:\n\n```\nbash scripts\u002Fdownload_data.sh\n```\n\nThe input images and target masks should be in the `data\u002Fimgs` and `data\u002Fmasks` folders respectively (note that the `imgs` and `masks` folder should not contain any sub-folder or any other files, due to the greedy data-loader). For Carvana, images are RGB and masks are black and white.\n\nYou can use your own dataset as long as you make sure it is loaded properly in `utils\u002Fdata_loading.py`.\n\n\n---\n\nOriginal paper by Olaf Ronneberger, Philipp Fischer, Thomas Brox:\n\n[U-Net: Convolutional Networks for Biomedical Image Segmentation](https:\u002F\u002Farxiv.org\u002Fabs\u002F1505.04597)\n\n![network architecture](https:\u002F\u002Fi.imgur.com\u002FjeDVpqF.png)\n","该项目是一个基于PyTorch实现的U-Net模型，用于高分辨率图像的语义分割。它支持高质量图像的处理，并且可以轻松应用于多类分割、肖像分割以及医学影像分割等多种场景。核心功能包括使用卷积神经网络进行深度学习，通过Kaggle竞赛中的Carvana图像掩码挑战验证了其有效性。技术特点方面，项目提供了Docker镜像以简化部署过程，并且支持混合精度训练来提高性能。适用于需要对图像进行精细分类和分割的应用场合，如自动驾驶、医疗图像分析等领域。",2,"2026-06-11 03:24:18","top_topic"]