{ "info": { "author": "Sigve Rokenes", "author_email": "me@evgiz.net", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "\n# AI Figures\n\n## Purpose\n\nAIFIG is a python library for generating figures of machine learning models.\n\nThe libary allows you to generate figures such as the following, which may be useful for use in presentations, papers etc.\n\n\n\n**AIFIG** is a refactored version of some of my personal code. Functionality will naturally be limited and not suited for every use. I encourage anyone who is interested to contribute with additional features.\n\nIf you use AIFIG in a paper, you can cite the library like this (bibtex):\n\n```latex\n@misc{aifig,\n author = {Sigve Rokenes},\n title = {AI-FIG},\n year = {2019},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/evgiz/aifig}}\n}\n```\n\n## Install\n\nAI-FIG library with svg export:\n```bash\npip install aifig\n```\n\nIf you need to export as png or pdf:\n```bash\npip install svglib\n```\n\n## Usage\n\n#### Simple example\n\n```python\n# Import library\nimport aifig\n\n# Create new figure, title and author is optional\nmy_figure = aifig.figure(\"Figure 1\", \"Sigve Rokenes\")\n\n# Figures consist of graphs (eg. each network in a model)\nmy_graph = aifig.graph(\"gen\")\n\n# Graphs contain elements (inputs, outputs, layers)\nmy_graph.add(aifig.dense(\"input\", 16))\nmy_graph.add(aifig.dense(\"hidden_1\", 64))\nmy_graph.add(aifig.dense(\"hidden_2\", 128))\nmy_graph.add(aifig.dense(\"hidden_3\", 64))\nmy_graph.add(aifig.dense(\"output\", 1))\nmy_graph.add(aifig.arrow(\"prediction\"))\n\n# Add the graph to the figure at position (0,0)\nmy_figure.add(graph, 0, 0)\n\n# Save the figure \nmy_figure.save_png(\"my_figure.png\", scale=1)\nmy_figure.save_svg(\"my_figure.svg\")\nmy_figure.save_pdf(\"my_figure.pdf\")\n```\n\n*The above code generates this figure:*\n\n\n\n#### Multi-graph example (GAN model)\n\n```python\nimport aifig\nfigure = aifig.figure()\n\n# Define generator network\ngenerator_elements = [\n aifig.dense(\"noise_vector\", 128, comment=\"norm_dist\", simple=True),\n aifig.conv(\"tconv_1\", 48, comment=\"5x5\"),\n aifig.conv(\"tconv_2\", 32, comment=\"5x5\"),\n aifig.conv(\"tconv_3\", 8, comment=\"5x5\"),\n aifig.conv(\"tconv_4\", 3, comment=\"5x5\"),\n aifig.image(\"gen_result\", comment=\"(fake image)\")\n]\n\n# Define discriminator network\ndiscriminator_elements = [\n aifig.image(\"image_input\", comment=\"real/fake\"),\n aifig.conv(\"conv_1\", 16, comment=\"5x5\"),\n aifig.pool(\"max_pool\")\n aifig.conv(\"conv_2\", 32, comment=\"5x5\"),\n aifig.pool(\"max_pool\"),\n aifig.conv(\"conv_3\", 48, comment=\"5x5\"),\n aifig.dense(\"dense_1\", 64),\n aifig.dense(\"output\", 1),\n aifig.arrow(\"prediction\", comment=\"log prob\")\n]\n\n# Create graphs with elements\ngen_graph = aifig.graph(\"gen\", generator_elements)\ndsc_graph = aifig.graph(\"dsc\", discriminator_elements)\ndat_graph = aifig.graph(\"dat\", [aifig.image(\"real_image\", comment=\"(dataset)\")])\n\n# Add graphs to figure\nfigure.add(gen_graph, 0, 0)\nfigure.add(dat_graph, 1, 0)\nfigure.add(dsc_graph, 0, 1)\n\n# Connect inputs to discriminator network\nfigure.connect(\"gen\", \"dsc\")\nfigure.connect(\"dat\", \"dsc\")\n\n# Save figure as png\nfigure.save_png(\"gan.png\")\n```\n\n*This code generates the following figure:*\n\n\n\n## API\n\nA figure consists of one or more graphs. These graphs are placed in a grid using `figure.add(graph, x, y)`. You can add elements to graphs using `mygraph.add(element)`, and you can connect graphs with arrows using `figure.connect(\"graph_name1\", \"graph_name2\")`. Finally, to save a figure, use `my_figure.save_svg(\"fig.svg\")` or variants for different formats.\n\n```python\n# ===================== #\n# Figure #\n# ===================== #\n# title\t\t\tfigure title\n# author\t\t\tfigure author\nmy_figure = aifig.figure()\n\n# figure.add\n# graph\t\t\tgraph to add\n# x\t\t\t\tx position in grid\n# y\t\t\t\ty position in grid\nmy_figure.add(graph, 0, 0)\n\n# figure.connect\n# from\t\t\t\tname of first graph\n# to\t\t\t\tname of second graph\n# position\t\t\tgrid position of arrow, use this if \n#\t\t\t\tdifferent arrows overlap\n# offset\t\t\tarrow offset in units, useful to\n#\t\t\t\tdistinguish different arrows at same position\nmy_figure.connect(\"graph1\", \"graph2\")\n\n# figure.save (path)\n# path\t\t\t\tfile path to save to\n# scale\t\t\tupscale (png only)\n# debug\t\t\tenable debug draw mode\nmy_figure.save_png(\"my_figure.png\", scale=1)\nmy_figure.save_svg(\"my_figure.svg\")\nmy_figure.save_pdf(\"my_figure.pdf\")\n\n# ===================== #\n# Graph #\n# ===================== #\n# \tname\t\t\t(required)\n# \telements\t\t[list of elements]\n# \tspacing\t\t\t(between elements, default 32)\n\nmy_graph = aifig.graph(\"graph_name\")\nmy_graph.add(element)\n\n# ===================== #\n# Layer elements #\n# ===================== #\n# \tlabel\t\t\ttext label, use None to hide\n# \tsize\t\t\tsize of layer (nodes, filters)\n#\tcomment\t\t\tadditional comment text\n#\tsize_label\t\tset to False to hide size label\n#\tsimple\t\t\t(dense only) set True to render as simple rectangle\n\ndense = aifig.dense()\t\t# Dense (fully connected)\nconv = aifig.conv()\t\t# Convolutional layer\n\n# ===================== #\n# Simple elements #\n# ===================== #\n#\tlabel\t\t\ttext label, use None to hide\n#\tcomment\t\t\tadditional comment text\n\npool = aifig.pool()\t\t# Pooling layer\nimage = aifig.image()\t\t# Image (usually input)\narrow = aifig.arrow()\t\t# Arrow\n\n# ===================== #\n# Special elements #\n# ===================== #\n# \twidth\t\t\twidth of padding (use negative to reduce)\n\npadding = aifig.padding(10) \n```\n\n\n\n### Dependencies\n\n- svgwrite \n- svglib (only to save as pdf/png)\n- reportlab (only to save as pdf/png)\n\n\n\n\n\n\n\n\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/evgiz/aifig", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "aifig", "package_url": "https://pypi.org/project/aifig/", "platform": "", "project_url": "https://pypi.org/project/aifig/", "project_urls": { "Homepage": "https://github.com/evgiz/aifig" }, "release_url": "https://pypi.org/project/aifig/0.1.6/", "requires_dist": [ "svgwrite" ], "requires_python": "", "summary": "A machine learning figure generation library", "version": "0.1.6" }, "last_serial": 5165785, "releases": { "0.1.5": [ { "comment_text": "", "digests": { "md5": "235ac0759646abcae026e619e170d5bc", "sha256": "afe198f9730f168ae3122be6a5041424644be02a5c6e83396f4910d6e9a2a550" }, "downloads": -1, "filename": "aifig-0.1.5-py3-none-any.whl", "has_sig": false, "md5_digest": "235ac0759646abcae026e619e170d5bc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9770, "upload_time": "2019-04-19T18:39:40", "url": "https://files.pythonhosted.org/packages/54/b2/3345e8d5576991c7d9d72a42e1dcafdfae10dd5a56ed472981d6e204bd61/aifig-0.1.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f6c2015040ff506848cf69c08c329ad7", "sha256": "618b7817ce5f9e4384f8f45ab56b8412711043a4296040fb51fb6a8a16919d2d" }, "downloads": -1, "filename": "aifig-0.1.5.tar.gz", "has_sig": false, "md5_digest": "f6c2015040ff506848cf69c08c329ad7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10370, "upload_time": "2019-04-19T18:39:42", "url": "https://files.pythonhosted.org/packages/9a/83/6ae00ea406387518befae07bc48bc831978ed90675fda5ec559101cbc929/aifig-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "2a0f55ad9ba7b737b7739d32af7dd498", "sha256": "9f34aadba9835604f419b5a0bae3eddfe59af6204d4244fb3de2ea5c64e85657" }, "downloads": -1, "filename": "aifig-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "2a0f55ad9ba7b737b7739d32af7dd498", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9775, "upload_time": "2019-04-19T18:45:33", "url": "https://files.pythonhosted.org/packages/3e/82/d6c14ddc0e316e3e3039ea8290fe085df755c4a25e5ff627f57017967afa/aifig-0.1.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20598db9ee397e780e54b11b16489494", "sha256": "7df12429cd383f0799578dbc7591b59a3cbdced8601444e7e1eb60fd78853a11" }, "downloads": -1, "filename": "aifig-0.1.6.tar.gz", "has_sig": false, "md5_digest": "20598db9ee397e780e54b11b16489494", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10385, "upload_time": "2019-04-19T18:45:35", "url": "https://files.pythonhosted.org/packages/94/e3/2d8dfa44806268293cacc7a1dcfc40410253d0a5ce91abc21599f66c3c24/aifig-0.1.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2a0f55ad9ba7b737b7739d32af7dd498", "sha256": "9f34aadba9835604f419b5a0bae3eddfe59af6204d4244fb3de2ea5c64e85657" }, "downloads": -1, "filename": "aifig-0.1.6-py3-none-any.whl", "has_sig": false, "md5_digest": "2a0f55ad9ba7b737b7739d32af7dd498", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9775, "upload_time": "2019-04-19T18:45:33", "url": "https://files.pythonhosted.org/packages/3e/82/d6c14ddc0e316e3e3039ea8290fe085df755c4a25e5ff627f57017967afa/aifig-0.1.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "20598db9ee397e780e54b11b16489494", "sha256": "7df12429cd383f0799578dbc7591b59a3cbdced8601444e7e1eb60fd78853a11" }, "downloads": -1, "filename": "aifig-0.1.6.tar.gz", "has_sig": false, "md5_digest": "20598db9ee397e780e54b11b16489494", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10385, "upload_time": "2019-04-19T18:45:35", "url": "https://files.pythonhosted.org/packages/94/e3/2d8dfa44806268293cacc7a1dcfc40410253d0a5ce91abc21599f66c3c24/aifig-0.1.6.tar.gz" } ] }