{ "info": { "author": "Piotr Rarus", "author_email": "piotr.rarus@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Degas\n\nFluent interface for `numpy` arrays. Really comfy for chaining methods from\ncomputer vision packages i.e. `skimage`, `opencv`.\n\n## Getting started\n\n```shell\npip install degas\n```\n\n## Chaining methods - FluentImage\n\n### Rationale\n\nThis pattern enables us to take some load off Python's internal memory\nmanagement mechanisms, and make code much more readable.\n\nLet's consider function like this (please keep in mind that images are quite heavy variables):\n\n```py\nfrom skimage.color import rgb2gray\nfrom skimage.exposure import equalize_adapthist\nfrom skimage.feature import canny\nfrom skimage.transform import rescale\n\n\ndef preprocess(src, scale_factor):\n\n gray = rgb2gray(src)\n downscaled = rescale(gray, scale_factor)\n equalized = equalize_adapthist(downscaled, clip_limit=0.2)\n edges = canny(equalized, sigma=2.0)\n\n return edges\n```\n\nIn this function we create 4 objects, each with unique reference label:\n\n- gray\n- downscaled\n- equalized\n\nWhile the interpreter enters `preprocess` scope, by the end of the function, all of these 4 objects live in memory, because their reference count is 1. Our memory consumption grows linear with each image operation. Considering images that can be even over 100MP, this is simply an overkill. How to manage that?\n\nWe introduce simple wrapper for an image `FluentImage`, that'll help us chain subsequent methods.\n\n\n\nAs we can't simply define new operator for python, we are overloading existing `rshift` operator `>>` (who uses it anyway?). I think it looks cool and resembles pipe `|>` operator from `F#`.\n\n### Example\n\n```py\nfrom degas import FluentImage\nfrom skimage.color import rgb2gray\nfrom skimage.exposure import equalize_adapthist\nfrom skimage.feature import canny\nfrom skimage.transform import rescale\n\n\ndef preprocess(src, scale_factor):\n with FluentImage(src) as thresh:\n preprocessed >> (\n rgb2gray\n ) >> (\n rescale,\n {\n 'scale_factor': scale_factor\n }\n ) >> (\n equalize_adapthist,\n {\n 'clip_limit': 0.2\n }\n ) >> (\n canny,\n {\n 'sigma': 2.0\n }\n )\n\n return preprocessed\n```\n\nWe simply pass reference to function, and a dictionary that contains all additional parameters.\n\nCode is much more readable now. `numpy` arrays exist only in narrow scopes, meaning they can be marked immediately for memory sweep. It's also much easier now to change pipeline ordering.\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/piotr-rarus/degas", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "degas", "package_url": "https://pypi.org/project/degas/", "platform": "", "project_url": "https://pypi.org/project/degas/", "project_urls": { "Homepage": "https://github.com/piotr-rarus/degas" }, "release_url": "https://pypi.org/project/degas/0.1.3/", "requires_dist": [ "numpy", "austen", "scikit-image" ], "requires_python": "", "summary": "Fluent interface for numpy arrays.", "version": "0.1.3" }, "last_serial": 5944149, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "ef58e582882d8440db289f36caab91df", "sha256": "898f2fd92eb65d9e9e30cc364671eafe287ceaa2f607ba77981cc123265ba360" }, "downloads": -1, "filename": "degas-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ef58e582882d8440db289f36caab91df", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5457, "upload_time": "2019-08-25T14:54:09", "url": "https://files.pythonhosted.org/packages/b3/f1/6c8a504cf3711dec68490f212a536055872d2700fb65cfcfccb8fe6c961e/degas-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8cb9b70e18bde48dbd487ac40a18617b", "sha256": "28e94556de6cd7d701279d99e215c0d987d4bf6052a7fd065043e5dbbe4efae3" }, "downloads": -1, "filename": "degas-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8cb9b70e18bde48dbd487ac40a18617b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3956, "upload_time": "2019-08-25T14:54:11", "url": "https://files.pythonhosted.org/packages/22/5b/eaa11c5d0f281d0524678e83e76112c970d22f2abe5d48a0cb6f1c9c53f4/degas-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3be69a858e6128bf429d5229c2ad9354", "sha256": "792f1640049daa5045011f7b7d622831a133840c493fce59b7ab9f93ba179346" }, "downloads": -1, "filename": "degas-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "3be69a858e6128bf429d5229c2ad9354", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5461, "upload_time": "2019-08-26T06:05:05", "url": "https://files.pythonhosted.org/packages/27/70/78a7f18ceda3439eb78b26b6b38d48f9048bcbcdf51338f5a4e8b5ae0f85/degas-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c518b7c2d65be9b78470938a21a095cf", "sha256": "6a4f4265a41d8d1ca089e44b7dd33d4e618370091bbac7d0e9da536169440631" }, "downloads": -1, "filename": "degas-0.1.2.tar.gz", "has_sig": false, "md5_digest": "c518b7c2d65be9b78470938a21a095cf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3958, "upload_time": "2019-08-26T06:05:07", "url": "https://files.pythonhosted.org/packages/d1/2f/e27c071af4a18417bf084fc627a53ae7495acee9bc09ee10af8f2de5add2/degas-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "06d25eab40ccd76edabdc39cdb334661", "sha256": "593c228f3816822838092113a83538f7e41c5fc1639311985531dc9113c28512" }, "downloads": -1, "filename": "degas-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "06d25eab40ccd76edabdc39cdb334661", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5454, "upload_time": "2019-10-08T10:25:13", "url": "https://files.pythonhosted.org/packages/69/60/9a9ebd1f1012c888c8cfdb39a0e36e8cbfca7d3209bc7ff86ea3a2f73c0f/degas-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "04d9d4195bfe6bb9338d4599598c7435", "sha256": "ea6f70b1219654d893a3422294702eb782fc07b1730eeb4a7871a4008114de00" }, "downloads": -1, "filename": "degas-0.1.3.tar.gz", "has_sig": false, "md5_digest": "04d9d4195bfe6bb9338d4599598c7435", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3952, "upload_time": "2019-10-08T10:25:14", "url": "https://files.pythonhosted.org/packages/26/e5/76a771eddb5b89a8fe12eaff5dec7230f1daf6666d8c23dead47ce121622/degas-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "06d25eab40ccd76edabdc39cdb334661", "sha256": "593c228f3816822838092113a83538f7e41c5fc1639311985531dc9113c28512" }, "downloads": -1, "filename": "degas-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "06d25eab40ccd76edabdc39cdb334661", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5454, "upload_time": "2019-10-08T10:25:13", "url": "https://files.pythonhosted.org/packages/69/60/9a9ebd1f1012c888c8cfdb39a0e36e8cbfca7d3209bc7ff86ea3a2f73c0f/degas-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "04d9d4195bfe6bb9338d4599598c7435", "sha256": "ea6f70b1219654d893a3422294702eb782fc07b1730eeb4a7871a4008114de00" }, "downloads": -1, "filename": "degas-0.1.3.tar.gz", "has_sig": false, "md5_digest": "04d9d4195bfe6bb9338d4599598c7435", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3952, "upload_time": "2019-10-08T10:25:14", "url": "https://files.pythonhosted.org/packages/26/e5/76a771eddb5b89a8fe12eaff5dec7230f1daf6666d8c23dead47ce121622/degas-0.1.3.tar.gz" } ] }