{ "info": { "author": "Eugene Khvedchenya", "author_email": "ekhvedchenya@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Image Recognition", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Pytorch-toolbelt\n\n[![Build Status](https://travis-ci.org/BloodAxe/pytorch-toolbelt.svg?branch=develop)](https://travis-ci.org/BloodAxe/pytorch-toolbelt)\n[![Documentation Status](https://readthedocs.org/projects/pytorch-toolbelt/badge/?version=latest)](https://pytorch-toolbelt.readthedocs.io/en/latest/?badge=latest)\n\n\nA `pytorch-toolbelt` is a Python library with a set of bells and whistles for PyTorch for fast R&D prototyping and Kaggle farming:\n\n## What's inside\n\n* Easy model building using flexible encoder-decoder architecture.\n* Modules: CoordConv, SCSE, Hypercolumn, Depthwise separable convolution and more.\n* GPU-friendly test-time augmentation TTA for segmentation and classification\n* GPU-friendly inference on huge (5000x5000) images\n* Every-day common routines (fix/restore random seed, filesystem utils, metrics)\n* Losses: BinaryFocalLoss, Focal, ReducedFocal, Lovasz, Jaccard and Dice losses, Wing Loss and more.\n* Extras for [Catalyst](https://github.com/catalyst-team/catalyst) library (Visualization of batch predictions, additional metrics) \n\nShowcase: [Catalyst, Albumentations, Pytorch Toolbelt example: Semantic Segmentation @ CamVid](https://colab.research.google.com/drive/1OUPJYU7TzH5Vz1si6FBkooackuIlzaGr#scrollTo=GUWuiO5K3aUm)\n\n# Why\n\nHonest answer is \"I needed a convenient way to re-use code for my Kaggle career\". \nDuring 2018 I achieved a [Kaggle Master](https://www.kaggle.com/bloodaxe) badge and this been a long path. \nVery often I found myself re-using most of the old pipelines over and over again. \nAt some point it crystallized into this repository. \n\nThis lib is not meant to replace catalyst / ignite / fast.ai. Instead it's designed to complement them.\n\n# Installation\n\n`pip install pytorch_toolbelt`\n\n# Showcase\n\n## Encoder-decoder models construction\n\n```python\nfrom pytorch_toolbelt.modules import encoders as E\nfrom pytorch_toolbelt.modules import decoders as D\n\nclass FPNSegmentationModel(nn.Module):\n def __init__(self, encoder:E.EncoderModule, num_classes, fpn_features=128):\n self.encoder = encoder\n self.decoder = D.FPNDecoder(encoder.output_filters, fpn_features=fpn_features)\n self.fuse = D.FPNFuse()\n input_channels = sum(self.decoder.output_filters)\n self.logits = nn.Conv2d(input_channels, num_classes,kernel_size=1)\n \n def forward(self, input):\n features = self.encoder(input)\n features = self.decoder(features)\n features = self.fuse(features)\n logits = self.logits(features)\n return logits\n \ndef fpn_resnext50(num_classes):\n encoder = E.SEResNeXt50Encoder()\n return FPNSegmentationModel(encoder, num_classes)\n \ndef fpn_mobilenet(num_classes):\n encoder = E.MobilenetV2Encoder()\n return FPNSegmentationModel(encoder, num_classes)\n```\n\n## Compose multiple losses\n\n```python\nfrom pytorch_toolbelt import losses as L\n\nloss = L.JointLoss(L.FocalLoss(), 1.0, L.LovaszLoss(), 0.5)\n```\n\n## Test-time augmentation\n\n```python\nfrom pytorch_toolbelt.inference import tta\n\n# Truly functional TTA for image classification using horizontal flips:\nlogits = tta.fliplr_image2label(model, input)\n\n# Truly functional TTA for image segmentation using D4 augmentation:\nlogits = tta.d4_image2mask(model, input)\n\n# TTA using wrapper module:\ntta_model = tta.TTAWrapper(model, tta.fivecrop_image2label, crop_size=512)\nlogits = tta_model(input)\n```\n\n## Inference on huge images:\n\n```python\nimport numpy as np\nimport torch\nimport cv2\n\nfrom pytorch_toolbelt.inference.tiles import ImageSlicer, CudaTileMerger\nfrom pytorch_toolbelt.utils.torch_utils import tensor_from_rgb_image, to_numpy\n\n\nimage = cv2.imread('really_huge_image.jpg')\nmodel = get_model(...)\n\n# Cut large image into overlapping tiles\ntiler = ImageSlicer(image.shape, tile_size=(512, 512), tile_step=(256, 256), weight='pyramid')\n\n# HCW -> CHW. Optionally, do normalization here\ntiles = [tensor_from_rgb_image(tile) for tile in tiler.split(image)]\n\n# Allocate a CUDA buffer for holding entire mask\nmerger = CudaTileMerger(tiler.target_shape, 1, tiler.weight)\n\n# Run predictions for tiles and accumulate them\nfor tiles_batch, coords_batch in DataLoader(list(zip(tiles, tiler.crops)), batch_size=8, pin_memory=True):\n tiles_batch = tiles_batch.float().cuda()\n pred_batch = model(tiles_batch)\n\n merger.integrate_batch(pred_batch, coords_batch)\n\n# Normalize accumulated mask and convert back to numpy\nmerged_mask = np.moveaxis(to_numpy(merger.merge()), 0, -1).astype(np.uint8)\nmerged_mask = tiler.crop_to_orignal_size(merged_mask)\n```\n\n## Advanced examples\n\n1. [Inria Sattelite Segmentation](https://github.com/BloodAxe/Catalyst-Inria-Segmentation-Example)\n1. [CamVid Semantic Segmentation](https://github.com/BloodAxe/Catalyst-CamVid-Segmentation-Example)\n\n\n## Citation\n\n```\n@misc{Khvedchenya_Eugene_2019_PyTorch_Toolbelt,\n author = {Khvedchenya, Eugene},\n title = {PyTorch Toolbelt},\n year = {2019},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/BloodAxe/pytorch-toolbelt}},\n commit = {cc5e9973cdb0dcbf1c6b6e1401bf44b9c69e13f3}\n}\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/BloodAxe/pytorch-toolbelt", "keywords": "PyTorch,Kaggle,Deep Learning,Machine Learning,ResNet,VGG,ResNext,Unet,Focal", "license": "License :: OSI Approved :: MIT License", "maintainer": "", "maintainer_email": "", "name": "pytorch-toolbelt", "package_url": "https://pypi.org/project/pytorch-toolbelt/", "platform": "", "project_url": "https://pypi.org/project/pytorch-toolbelt/", "project_urls": { "Homepage": "https://github.com/BloodAxe/pytorch-toolbelt" }, "release_url": "https://pypi.org/project/pytorch-toolbelt/0.2.1/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "PyTorch extensions for fast R&D prototyping and Kaggle farming", "version": "0.2.1" }, "last_serial": 5941049, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "2b5d300c85449002ad331afad0e5dbb4", "sha256": "03756f036d3822088327e466a66621ae3680f2f0a4b41ee3ad8f7efe19c94828" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.3.tar.gz", "has_sig": false, "md5_digest": "2b5d300c85449002ad331afad0e5dbb4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 40655, "upload_time": "2019-04-22T12:56:39", "url": "https://files.pythonhosted.org/packages/e8/35/b624a1e2eb907d964c3f5c4ec62bcf80de642ad784b3d79419383e836258/pytorch_toolbelt-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "a64b6c3183f91beda58e0f939af96b34", "sha256": "b09f83d6d0902c75a7d57080b109fe68bf953fc9a255ffa9e08bf52eefbb1cb4" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.4.tar.gz", "has_sig": false, "md5_digest": "a64b6c3183f91beda58e0f939af96b34", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 43252, "upload_time": "2019-04-25T19:08:31", "url": "https://files.pythonhosted.org/packages/24/eb/0a7f0291e4ec5c8dee87ca1e673ef046884a18ddd246cb92343a309c43ab/pytorch_toolbelt-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "194fbd5fd949e549d3fb8d49328b8c1d", "sha256": "43f3619b2c926bc52befe33d98964e8ca4638c866793c6fb5a095126ce12d1a3" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.5.tar.gz", "has_sig": false, "md5_digest": "194fbd5fd949e549d3fb8d49328b8c1d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 43598, "upload_time": "2019-04-26T15:56:48", "url": "https://files.pythonhosted.org/packages/f2/a3/9451cc5702777a9447826aaa70ed9b0df954f3afab4419433a563fc04755/pytorch_toolbelt-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "34b92eb98d7572679bc3144b4ffa9da7", "sha256": "e9d47ec70ce7b7a5742b41c6c19100612eeb32acba7451855bad0628eea6f207" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.6.tar.gz", "has_sig": false, "md5_digest": "34b92eb98d7572679bc3144b4ffa9da7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 46733, "upload_time": "2019-05-06T21:36:36", "url": "https://files.pythonhosted.org/packages/39/75/95a9c6b237e9490f2a2ed63a19045221f46aa4d6f61a5c1c4513d757bfb1/pytorch_toolbelt-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "d6bf3ffd9a5e53efbd0c67c06da5c95b", "sha256": "f07421181c58a2f4ef4ee284091e644746a7912c1c810303ad1c568f1667d27c" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.7.tar.gz", "has_sig": false, "md5_digest": "d6bf3ffd9a5e53efbd0c67c06da5c95b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 50123, "upload_time": "2019-05-08T20:52:09", "url": "https://files.pythonhosted.org/packages/97/9e/c1b22d6c216a6401021c63c9dfeeb46b305f64ab8b48396452a3e3c308b7/pytorch_toolbelt-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "17fc31cdaea17b6575575804c0fd10ee", "sha256": "32ebafbc96e023e4ff6d96b1c2307563e6af65bca9fd9d4754db7811d6cea86d" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.8.tar.gz", "has_sig": false, "md5_digest": "17fc31cdaea17b6575575804c0fd10ee", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 50806, "upload_time": "2019-05-19T08:21:17", "url": "https://files.pythonhosted.org/packages/aa/38/726e9391750a98ed847209a606a96124f13da830b54fd7a0b273b9fe30d7/pytorch_toolbelt-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "f83d6153f4749ef75e5996f1b5fabc56", "sha256": "87e4305b70f8867c8cdf4e38b1abe2ed020c2217cedf3571d752e60a7d577a5b" }, "downloads": -1, "filename": "pytorch_toolbelt-0.0.9.tar.gz", "has_sig": false, "md5_digest": "f83d6153f4749ef75e5996f1b5fabc56", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 51547, "upload_time": "2019-06-03T19:32:53", "url": "https://files.pythonhosted.org/packages/75/48/0d0e5d993c4b2df528cd78c1f6bf85e11a6461167ebb234f2025723ff1cc/pytorch_toolbelt-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "fd8fdd40fcdc0d1b0a07b7c31eecc0e2", "sha256": "04ed8e056ea430c40d46a3f5ea16101e872940381e529fb8951d4e6b6e1cad75" }, "downloads": -1, "filename": "pytorch_toolbelt-0.1.0.tar.gz", "has_sig": false, "md5_digest": "fd8fdd40fcdc0d1b0a07b7c31eecc0e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 56306, "upload_time": "2019-06-12T20:09:21", "url": "https://files.pythonhosted.org/packages/ac/c8/0c19c9d96a9f660cf9f286817cac5cd5c93e7623093542933eec5e6f5605/pytorch_toolbelt-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2fcc31ae2f86dbfd8679295e7c1227d5", "sha256": "2d0cb639fbf00e3fcb1ccd0cd37937e3207d39790f26e5487ad4060799e1a8b8" }, "downloads": -1, "filename": "pytorch_toolbelt-0.1.1.tar.gz", "has_sig": false, "md5_digest": "2fcc31ae2f86dbfd8679295e7c1227d5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 59289, "upload_time": "2019-06-29T14:14:08", "url": "https://files.pythonhosted.org/packages/15/04/78f2237dae2f0b55bb0416b68e5f3707b5d228090f0c1eaad2c754835364/pytorch_toolbelt-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f8f666c49161c4c8d8f714e5de4755b2", "sha256": "4e292a9867c25b5844cf12be318eab89a05bac72fa115c19b433e51fe35a7abd" }, "downloads": -1, "filename": "pytorch_toolbelt-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f8f666c49161c4c8d8f714e5de4755b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 59397, "upload_time": "2019-07-01T00:21:59", "url": "https://files.pythonhosted.org/packages/73/37/c5cde0e02fec372ed77b3547c385a32d900cc6f02fbd050e8b6668240145/pytorch_toolbelt-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "d7a5569d85849786c8236fd1bd9e8f79", "sha256": "559d3fad6d87ca846533b491e4222a690d7867ec80728776c7dc0e5d17361e70" }, "downloads": -1, "filename": "pytorch_toolbelt-0.1.3.tar.gz", "has_sig": false, "md5_digest": "d7a5569d85849786c8236fd1bd9e8f79", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 59531, "upload_time": "2019-07-24T10:49:26", "url": "https://files.pythonhosted.org/packages/63/00/2459d5f8abbd48b0f1a9af1d34f92ba84d7b3d28341e17e8ebe414aaa367/pytorch_toolbelt-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "88b324f104a7d37606171af2f21e6e45", "sha256": "25e8122967f1e3cb5419c3bd35aec3931dbdbfb02ea71ff8879e18c2a5cb31f0" }, "downloads": -1, "filename": "pytorch_toolbelt-0.1.4.tar.gz", "has_sig": false, "md5_digest": "88b324f104a7d37606171af2f21e6e45", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 59580, "upload_time": "2019-09-12T09:43:11", "url": "https://files.pythonhosted.org/packages/c7/5c/3109f40bba8c056e4ad413f2dcad86a80013e56f3bdc2fc41b2a9589ae3a/pytorch_toolbelt-0.1.4.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "64ea7d586aa7d8fe22ba1b10613bbfde", "sha256": "8a7f91468fde49ce329bd8bd44e3d53d6a5690218f4774a136b2399604c0b8e6" }, "downloads": -1, "filename": "pytorch_toolbelt-0.2.0.tar.gz", "has_sig": false, "md5_digest": "64ea7d586aa7d8fe22ba1b10613bbfde", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 62750, "upload_time": "2019-10-04T20:54:07", "url": "https://files.pythonhosted.org/packages/f8/cc/1cfbe81580deb7f5197fb26e8a310f922083896a2c8c796a4d4fa15553f4/pytorch_toolbelt-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9c9a0fdf2f40750772cbc2f12873334e", "sha256": "9bae901f8d8a5f077a3a708e54fafb52b7b588096295d31c93da577740e3e79a" }, "downloads": -1, "filename": "pytorch_toolbelt-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9c9a0fdf2f40750772cbc2f12873334e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 62592, "upload_time": "2019-10-07T19:50:23", "url": "https://files.pythonhosted.org/packages/30/00/eb830ae0eb3f46751c1927d69e8e9eebd36bf63c2c9d259fcec4eecd5f4e/pytorch_toolbelt-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9c9a0fdf2f40750772cbc2f12873334e", "sha256": "9bae901f8d8a5f077a3a708e54fafb52b7b588096295d31c93da577740e3e79a" }, "downloads": -1, "filename": "pytorch_toolbelt-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9c9a0fdf2f40750772cbc2f12873334e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 62592, "upload_time": "2019-10-07T19:50:23", "url": "https://files.pythonhosted.org/packages/30/00/eb830ae0eb3f46751c1927d69e8e9eebd36bf63c2c9d259fcec4eecd5f4e/pytorch_toolbelt-0.2.1.tar.gz" } ] }