{ "info": { "author": "Adam Bouhenguel", "author_email": "adam@bouhenguel.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "======================================================\nTFI: Use any TensorFlow model in a single line of code\n======================================================\n\n.. teaser-begin\n\nTFI provides a simple Python interface to any TensorFlow model. It does this by automatically generating a Python class on the fly.\n\n.. -spiel-end-\n\nHere's an example of using TFI with a SavedModel based on `Inception v1 `_. This particular SavedModel has a single ``predict`` method and a `SignatureDef `_ that looks something like: ``predict(images float <1,224,224,3>) -> (categories string <1001>, scores float <1,1001>)``\n\nTFI in Action\n=============\n\n.. code-block:: pycon\n\n >>> import tfi\n >>> InceptionV1 = tfi.saved_model.as_class(\"./inception-v1.saved_model\")\n\nPassing in data\n===============\n\nTFI can automatically adapt any data you provide to the shape expected by the graph. Let's take a random photo of a dog I found on the internet...\n\n.. image:: https://www.royalcanin.com/~/media/Royal-Canin/Product-Categories/dog-medium-landing-hero.ashx\n :alt: dog\n\n.. code-block:: pycon\n\n >>> model = InceptionV1()\n >>> image = tfi.data.file(\"./dog-medium-landing-hero.jpg\")\n >>> result = model.predict(images=[image])\n >>> categories, scores = result.categories, result.scores[0]\n\nIf we print the top 5 probabilities, we see:\n\n.. code-block:: pycon\n\n >>> [(scores[i], categories[i].decode('utf-8')) for i in scores.argsort()[:-5:-1]]\n [(0.80796158, 'bloodhound, sleuthhound'),\n (0.10305813, 'English foxhound'),\n (0.064740285, 'redbone'),\n (0.009166114, 'beagle')]\n\nNot bad!\n\nImage data\n==========\nThe ``tf.data.file`` function uses `mimetypes `_ to discover the right data decoder to use. If an input to a graph is an ``\"image/*\"``, TFI will automatically decode and resize the image to the proper size. In the example above, the JPEG image of a dog is automatically decoded and resized to 224x224.\n\nBatches\n=======\nIf you look closely at the example code above, you'll see that the images argument is actually an array. The class generated by TFI is smart enough to convert an array of images to an appropriately sized batch of Tensors.\n\nGraphs with variables\n=====================\nEach instance of the class has separate variables from other instances. If a graph's variables are mutated during a session in a useful way, you can continue to use those mutations by calling methods again on that same instance.\n\nIf you'd like to have multiple instances that do not interfere with one another, you can create a second instance and call methods on each of them separately.\n\nTFI and SavedModels\n===================\n\nTFI uses the information in a SavedModel's SignatureDefs to generate methods on the resulting class. The keyword argument names for each method are also pulled from info in the SignatureDef.\n\nThe SavedModel used in the example was created using the `tf.estimator.Estimator#export_savedmodel `_ function.\n\nGetting Started\n===============\n`TFI is on PyPI `_, install it with ``pip install tfi``.\n\nFuture work\n===========\n\nAdapting ``tfi.data`` functions to handle queues and datasets wouldn't require much effort. If this is something you'd like me to do, please `file an issue `_ with your specific use case!\n\nExtending `tfi.data` to support more formats is also quite straightforward. `File an issue `_ with a specific format you'd like to see. For bonus points, include the expected tensor dtype and shape. For double bonus points, include a way for me to test it in a real model.\n\nIt's not very easy to create well-formed SavedModels today. If this is something you'd like TFI to do in the future... `file an issue `_. ;)\n\nAcknowledgements\n================\nIf you're curious, the photo used above was from `a random Google image search `_.\n\nPyPI packaging was way easier because of `this fantastic guide `_.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ajbouh/tfi", "keywords": "tensorflow,savedmodel,boilerplate", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "tfi", "package_url": "https://pypi.org/project/tfi/", "platform": "", "project_url": "https://pypi.org/project/tfi/", "project_urls": { "Homepage": "https://github.com/ajbouh/tfi" }, "release_url": "https://pypi.org/project/tfi/0.4/", "requires_dist": [ "tensorflow (>=1.3)" ], "requires_python": "", "summary": "Use any TensorFlow model in a single line of code", "version": "0.4" }, "last_serial": 3174902, "releases": { "0.4": [ { "comment_text": "", "digests": { "md5": "67558006c23da8047968a3e6ec68d44a", "sha256": "177e789f45224e16c29fecab2a7c57fe1439262bd65aad50d216263074972864" }, "downloads": -1, "filename": "tfi-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "67558006c23da8047968a3e6ec68d44a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9943, "upload_time": "2017-09-14T22:53:45", "url": "https://files.pythonhosted.org/packages/6f/03/8c273630fee9690c10fb330c7646db31854b44714cdaed298741805f55e6/tfi-0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "47e081d737864595863f2ee6eff67492", "sha256": "3ae3fa81fb64b6dbe4bd044b2d590986a159a1c0a387171ea3a9ffed7809eb08" }, "downloads": -1, "filename": "tfi-0.4.tar.gz", "has_sig": false, "md5_digest": "47e081d737864595863f2ee6eff67492", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7463, "upload_time": "2017-09-14T22:53:46", "url": "https://files.pythonhosted.org/packages/64/ef/eb268e7f73845e2dbb238b53de2ee54b105150d1da9439520647658771a5/tfi-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "67558006c23da8047968a3e6ec68d44a", "sha256": "177e789f45224e16c29fecab2a7c57fe1439262bd65aad50d216263074972864" }, "downloads": -1, "filename": "tfi-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "67558006c23da8047968a3e6ec68d44a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9943, "upload_time": "2017-09-14T22:53:45", "url": "https://files.pythonhosted.org/packages/6f/03/8c273630fee9690c10fb330c7646db31854b44714cdaed298741805f55e6/tfi-0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "47e081d737864595863f2ee6eff67492", "sha256": "3ae3fa81fb64b6dbe4bd044b2d590986a159a1c0a387171ea3a9ffed7809eb08" }, "downloads": -1, "filename": "tfi-0.4.tar.gz", "has_sig": false, "md5_digest": "47e081d737864595863f2ee6eff67492", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7463, "upload_time": "2017-09-14T22:53:46", "url": "https://files.pythonhosted.org/packages/64/ef/eb268e7f73845e2dbb238b53de2ee54b105150d1da9439520647658771a5/tfi-0.4.tar.gz" } ] }