{ "info": { "author": "Barak Nehoran", "author_email": "bnehoran@users.noreply.github.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering" ], "description": "# torchfields\nA [PyTorch](https://github.com/pytorch/pytorch) add-on for working with image mappings and displacement fields, including Spatial Transformers\n\nTorchfields provides an abstraction that neatly encapsulates the functionality of displacement fields\nas used in [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025) and [Optical Flow Estimation](https://en.wikipedia.org/wiki/Optical_flow).\n\nFields can be treated as normal PyTorch tensors for most\npurposes, and also include additional functionality for composing\ndisplacements and sampling from tensors.\n\n### Installation\n\nTo install torchfields simply do\n\n```\npip install torchfields\n```\n\n\n### Introduction\n\nA **displacement field** represents a *mapping* or *flow* that indicates how an image should be warped.\n\nIt is essentially a spatial tensor containing displacement vectors at each pixel, where each displacement vector indicates the displacement distance and direction at that pixel.\n\n\n#### Displacement field conventions\n\n##### Units\n\nThe standard unit of displacement is a **half-image**, so a displacement vector of magnitude 2 means that the displacement distance is equal to the side length of the displaced image. \n\n**Note**: *This convention originates from the original [Spatial Transformer Networks](https://arxiv.org/abs/1506.02025) paper where such fields were presented as mappings, with -1 representing the left or top edge of the image, and +1 representing the right or bottom edge.*\n\n`torchfields` also supports seamlessly converting to and from units of **pixels** using the `pixels()` and `from_pixels()` functions.\n\n##### Displacement direction\n\nThe most common way to warp an image by a displacement field is by sampling from it at the points pointed to by the field vectors.\nThis is often referred to as the **Eulerian** or **pull** convention, since the vectors in the field point to the locations from which the image should be *pulled*.\nThis is achieved by calling the `sample()` function (which in fact wraps PyTorch's built-in `grid_sample()`, while converting the conventions as necessary).\n\nAn alternative way to warp an image by a displacement field is by sending each pixel of the image along the corresponding displacement vector to its new location. This is referred to as the **Lagrangian** or **push** convention, since the vectors of the field indicate where an image pixel should be *pushed* to. This direction, while seemingly intuitive, is much less straight-forward to implement, since there is no definitive way to handle the discretization (for instance, what to do when the destinations are not whole pixel coordinates, when two sources map to the same destination, and when nothing maps into a destination pixel).\nThe solution for warping in the Lagrangian direction is to **first invert the field** using `inverse()`, and then warp the image normally using `sample()`.\n\n*To read more about the two ways to describe flow fields, see the [Wikipedia article](https://en.wikipedia.org/wiki/Lagrangian_and_Eulerian_specification_of_the_flow_field) on the subject.*\n\n\n#### Relationship to PyTorch tensors\n\nDisplacement fields inherit from `torch.Tensor`, so all functionality from [PyTorch](https://github.com/pytorch/pytorch) tensors also works with displacement fields. That is, any PyTorch function that accepts a `torch.Tensor` type will also implicitly accept a `torchfields` displacement field.\n\nFurthermore, the module installs itself (through monkey patching) as \n\n```python\ntorch.Field\n```\n\nmirroring the `torch.Tensor` module, and all the functionality of the `torchfields` package can be conveniently accessed through that shortcut. This shortcut gets activated at the first import (using `import torchfields`).\n\nNote, however, that the `torchfields` package is neither endorsed by nor maintained by the PyTorch developer community, and is instead a separate project maintained by researchers at Princeton University.\n\n\n\n### Tutorial\n\nTo learn more and get started with using `torchfields` check out the [tutorial](https://colab.research.google.com/drive/1KrUjFbWjwwnsyNFTpNCZjjIJyMUP8eFx).\n\n\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/seung-lab/torchfields", "keywords": "", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "torchfields", "package_url": "https://pypi.org/project/torchfields/", "platform": "", "project_url": "https://pypi.org/project/torchfields/", "project_urls": { "Homepage": "https://github.com/seung-lab/torchfields" }, "release_url": "https://pypi.org/project/torchfields/0.0.4.post1/", "requires_dist": [ "torch (>=1.1.0)", "setuptools (>=34.0.0)" ], "requires_python": "", "summary": "A PyTorch add-on for working with image mappings and displacement fields, including Spatial Transformers", "version": "0.0.4.post1" }, "last_serial": 5782113, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "3169d3a53081e55ae60638254a7ed1b9", "sha256": "f4b73c99c4838c0abb2854672c834ce091e107d081c969333871e6cd1fd535e9" }, "downloads": -1, "filename": "torchfields-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3169d3a53081e55ae60638254a7ed1b9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 44055, "upload_time": "2019-08-09T03:02:38", "url": "https://files.pythonhosted.org/packages/de/8d/d0bca17a1d82547b68c7262845f1a5163c03ddde9f31ab55973efbf7a775/torchfields-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4e068d131bebbec148eff3c146e69b10", "sha256": "450266f05f6f8068184634d3333ebabde8b383144fadd1375841748e957166b7" }, "downloads": -1, "filename": "torchfields-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4e068d131bebbec148eff3c146e69b10", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31202, "upload_time": "2019-08-09T03:02:40", "url": "https://files.pythonhosted.org/packages/72/0d/c49bbc8166fbe1f22d1ec6513688f84cf2ad3345cd76d0dfc4e7c0055425/torchfields-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "d0612b97fa66a6f6230696bf6adc7fcc", "sha256": "da475b9f7b2a73636dc108b0ca84fe6a5fac0d92749ef126d0d50dd6c139d3f7" }, "downloads": -1, "filename": "torchfields-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "d0612b97fa66a6f6230696bf6adc7fcc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 44370, "upload_time": "2019-08-09T05:24:55", "url": "https://files.pythonhosted.org/packages/c4/0e/5c71bc49337266ab81cf0b9dfe4c452d29067509252d81a1e80eb2a1776b/torchfields-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08a991a3be2c8b0bb9c74321a128f58a", "sha256": "ee573828f9ddcf6e9af08e10ee0c8287f9a8eeb1bc067f81b9c1cab1c0b97855" }, "downloads": -1, "filename": "torchfields-0.0.2.tar.gz", "has_sig": false, "md5_digest": "08a991a3be2c8b0bb9c74321a128f58a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31555, "upload_time": "2019-08-09T05:24:57", "url": "https://files.pythonhosted.org/packages/97/b5/7e234cc2580e514b15f4122a30fe411c57723cc3b992868544aaba40b5b0/torchfields-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "9244f576efa9befd75e5e52784c8f6dd", "sha256": "4efd15e4f3722582489ffb1d7a9337a7200e0fef437d2104fa52c2e566306383" }, "downloads": -1, "filename": "torchfields-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "9244f576efa9befd75e5e52784c8f6dd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 44368, "upload_time": "2019-08-09T05:52:08", "url": "https://files.pythonhosted.org/packages/b5/f0/53d36395b18d69d20f2eaf1fec311b06cc203bc9c0d3f43dcc65026751ab/torchfields-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "43978f3744eb06395133c1301cd5f8ad", "sha256": "6b80c4f0d04d790e5e6b14e87f0dc45564d111c2199dfbda24c148ad2c985c43" }, "downloads": -1, "filename": "torchfields-0.0.3.tar.gz", "has_sig": false, "md5_digest": "43978f3744eb06395133c1301cd5f8ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31582, "upload_time": "2019-08-09T05:52:10", "url": "https://files.pythonhosted.org/packages/1f/72/530ceb166b06c7fde478bd13ae6e1ebd82568259d83b583bce4893901ad9/torchfields-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "3559575a0a40d6fd177d2c6c484634f5", "sha256": "165d3fab80cf04fcff49ba2dbb89a5d5adb363003076eccaae0b05fc3bf47ce9" }, "downloads": -1, "filename": "torchfields-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "3559575a0a40d6fd177d2c6c484634f5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 32420, "upload_time": "2019-09-04T01:03:27", "url": "https://files.pythonhosted.org/packages/76/e6/a13ef23ad502007757f5a312eaae1076e658a116bf760e85b00c59c4d6d1/torchfields-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "00b673af4b3528bcb1779d4cc908ce0d", "sha256": "57491dfe3884d15abfd768cca0593474f146e38464f8d8bd67c4d36fefeb82fb" }, "downloads": -1, "filename": "torchfields-0.0.4.tar.gz", "has_sig": false, "md5_digest": "00b673af4b3528bcb1779d4cc908ce0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32433, "upload_time": "2019-09-04T01:03:28", "url": "https://files.pythonhosted.org/packages/24/bd/16e8b14ebbc81de69945feb9d0accb27703530c947a7cde3719ecf5b06fd/torchfields-0.0.4.tar.gz" } ], "0.0.4.post1": [ { "comment_text": "", "digests": { "md5": "525aa26d92f389c82951a4feef7f6e1a", "sha256": "b4deb1489490f39c9c5344de5515fdeb4cb75a974c0d8551f4fb0cfc42e1fe83" }, "downloads": -1, "filename": "torchfields-0.0.4.post1-py3-none-any.whl", "has_sig": false, "md5_digest": "525aa26d92f389c82951a4feef7f6e1a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 32322, "upload_time": "2019-09-04T15:50:22", "url": "https://files.pythonhosted.org/packages/dd/6e/6c3ad37b7e1ec4309b22198de60c03531867b9d30548a0a4f7897f939e4d/torchfields-0.0.4.post1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a2c2d65bb3a0d8bb1af8c78a81c9d1a6", "sha256": "d843c9fce75668ca2c5e5c4255ddaaf33b2460638091ee29b0eb2d00f8dbf8aa" }, "downloads": -1, "filename": "torchfields-0.0.4.post1.tar.gz", "has_sig": false, "md5_digest": "a2c2d65bb3a0d8bb1af8c78a81c9d1a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32299, "upload_time": "2019-09-04T15:50:23", "url": "https://files.pythonhosted.org/packages/f9/7e/bedd5dc4621d77d800dcd81de0a4853d9311da55a11ab3d95850d0f309f8/torchfields-0.0.4.post1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "525aa26d92f389c82951a4feef7f6e1a", "sha256": "b4deb1489490f39c9c5344de5515fdeb4cb75a974c0d8551f4fb0cfc42e1fe83" }, "downloads": -1, "filename": "torchfields-0.0.4.post1-py3-none-any.whl", "has_sig": false, "md5_digest": "525aa26d92f389c82951a4feef7f6e1a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 32322, "upload_time": "2019-09-04T15:50:22", "url": "https://files.pythonhosted.org/packages/dd/6e/6c3ad37b7e1ec4309b22198de60c03531867b9d30548a0a4f7897f939e4d/torchfields-0.0.4.post1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a2c2d65bb3a0d8bb1af8c78a81c9d1a6", "sha256": "d843c9fce75668ca2c5e5c4255ddaaf33b2460638091ee29b0eb2d00f8dbf8aa" }, "downloads": -1, "filename": "torchfields-0.0.4.post1.tar.gz", "has_sig": false, "md5_digest": "a2c2d65bb3a0d8bb1af8c78a81c9d1a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32299, "upload_time": "2019-09-04T15:50:23", "url": "https://files.pythonhosted.org/packages/f9/7e/bedd5dc4621d77d800dcd81de0a4853d9311da55a11ab3d95850d0f309f8/torchfields-0.0.4.post1.tar.gz" } ] }