{ "info": { "author": "Yusuke Matsui", "author_email": "matsui528@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Manga109 API\n\n[![PyPI version](https://badge.fury.io/py/manga109api.svg)](https://badge.fury.io/py/manga109api)\n\nSimple python API to read annotation data of [Manga109](http://www.manga109.org/en/).\n\nManga109 is the largest dataset for manga (Japanese comic) images,\nthat is made publicly available for academic research purpose with proper copyright notation.\n\nTo download images/annotations of Manga109, please visit [here](http://www.manga109.org/en/download) and send an application via the form.\nAfter that, you will receive the password for downloading images (109 titles of manga\nas jpeg files)\nand annotations (bounding box coordinates of face, body, frame, and speech balloon with texts,\nin the form of XML).\n\nThis package provides a simple Python API to read annotation data (i.e., parsing XML)\nwith some utility functions such as reading an image.\n\n## Links\n- [Manga109](http://www.manga109.org/en/)\n- [Details of annotation data](http://www.manga109.org/en/annotations)\n- The original reference paper for Manga109: [[Matsui+, MTAP 2017]](https://link.springer.com/content/pdf/10.1007%2Fs11042-016-4020-z.pdf)\n- The paper introducing the annotation data, with the application of object detection (SSD-fork): [[Ogawa+, arXiv 2018]](https://arxiv.org/pdf/1803.08670)\n\n## Installing\nYou can install the package via pip. The library works with Python 3.5+ on linux\n```bash\npip install manga109api\n```\n\n## Example\n\nYou can insantiate a parser with the path to the root directory of Manga109.\nThe annotations are available via the parser. \n\n```python\nimport manga109api\nfrom pprint import pprint\n\nmanga109_root_dir = \"YOUR_DIR/Manga109_2017_09_28\"\np = manga109api.Parser(root_dir=manga109_root_dir)\n```\nAfter parsing, you can see the book titles by `p.books`: \n```python\nprint(p.books)\n# ['ARMS', 'AisazuNihaIrarenai', 'AkkeraKanjinchou', 'Akuhamu', 'AosugiruHaru', ...\n```\nNote that all books are parsed by default. If you'd like to parse only some of them, you can specify the book titles, e.g.: `p = manga109api.Parser(root_dir=manga109_root_dir, book_titles=[\"ARMS\", \"AisazuNihaIrarenai\"])`, where the selected two books will be parsed.\n\n\nHere, you can access the annotations by `p.annotations`:\n```python\npprint(p.annotations[\"ARMS\"])\n# {'book': {'@title': 'ARMS',\n# 'characters': {'character': [{'@id': '00000003', '@name': '\u59731'},\n# {'@id': '00000010', '@name': '\u75371'},\n# {'@id': '00000090', '@name': '\u30ed\u30dc\u30c3\u30c81'},\n# {'@id': '000000fe', '@name': '\u30a8\u30ea\u30fc'},\n# {'@id': '0000010a', '@name': '\u30b1\u30a4\u30c8'},\n# {'@id': '0000010e', '@name': '\u5927\u4f50'},\n# ...\n# 'pages': {'page': [{'@height': 1170, '@index': 0, '@width': 1654},\n# {'@height': 1170, '@index': 1, '@width': 1654},\n# {'@height': 1170,\n# '@index': 2,\n# '@width': 1654,\n# 'body': {'@character': '00000003',\n# '@id': '00000002',\n# '@xmax': 548,\n# '@xmin': 178,\n# '@ymax': 965,\n# '@ymin': 660},\n# 'face': {'@character': '00000003',\n# '@id': '00000004',\n# '@xmax': 456,\n# '@xmin': 406,\n# ...\n```\nAs can be seen, you can see the parsed result as a dictionary.\nThe attributes of XML are denoted with an @ symbol.\nNote that the parsed result contains some redundant descriptions such as `'pages': {'page': ...`.\nIt is because the result is a direct translation from xml to python dict via `xmltodict` package,\nwhere we decided not to omit any information.\n\nThe following example shows the annotations of the 7th page of \"ARMS\".\n```python\npprint(p.annotations[\"ARMS\"][\"book\"][\"pages\"][\"page\"][6])\n# {'@height': 1170,\n# '@index': 6,\n# '@width': 1654,\n# 'body': [{'@character': '00000010',\n# '@id': '00000057',\n# '@xmax': 1155,\n# '@xmin': 1089,\n# '@ymax': 253,\n# '@ymin': 166},\n# {'@character': '00000003',\n# '@id': '0000005f',\n# '@xmax': 302,\n# '@xmin': 125,\n# '@ymax': 451,\n# '@ymin': 314},\n# ... \n```\n\nYou can know the path to the original image by the helper function `p.img_path()`.\nThe 7th page of \"ARMS\" can be specified by the following code.\n```python\nprint(p.img_path(book=\"ARMS\", index=6)) \n# YOUR_DIR/Manga109_2017_09_28/images/ARMS/006.jpg\n```\n\nThe text data is also available:\n```python\npprint([roi[\"#text\"] for roi in p.annotations[\"ARMS\"][\"book\"][\"pages\"][\"page\"][6][\"text\"]])\n# ['\u3069\u3053\u3078\u884c\u304d\u3084\u304c\u3063\u305f!?',\n# '\u30c6\u30a3\u30fc\u30b6\u30fc\uff1d\u96fb\u6c17\u30b7\u30e7\u30c3\u30af\u306b\u3088\u308b\u9ebb\u75fa\u9283',\n# '\u3048\u30fc\u3044\u3061\u3087\u308d\u3061\u3087\u308d\u3068',\n# '\u3042\u3064\u3063',\n# '\u305d\u3053\u3060!',\n# '\u51fa\u3066\u6765\u3066\u6b63\u3005\u5802\u3005\u3068\u6226\u3048!',\n# '!',\n# '\u79c1\u3092\u751f\u6355\u308a\u306b\u3059\u308b\u6c17!?',\n# '\u5351\u602f\u8005\u3063',\n# '\u30c6\u30a3\u30fc\u30b6\u30fc!!',\n# '\u3084\u308d\u30a9',\n# '\u30ad\u30e3\u30a2',\n# '\u3042\u3063\u307e\u305f\u9003\u3052\u305f',\n# '\u308f\u30fc\u3063']\n```\n\nAn example of visualization is as follows\n```python\nfrom PIL import Image, ImageDraw\n\ndef draw_rectangle(img, x0, y0, x1, y1, annotation_type):\n assert annotation_type in [\"body\", \"face\", \"frame\", \"text\"]\n color = {\"body\": \"#258039\", \"face\": \"#f5be41\",\n \"frame\": \"#31a9b8\", \"text\": \"#cf3721\"}[annotation_type]\n width = 10\n draw = ImageDraw.Draw(img)\n draw.line([x0 - width/2, y0, x1 + width/2, y0], fill=color, width=width)\n draw.line([x1, y0, x1, y1], fill=color, width=width)\n draw.line([x1 + width/2, y1, x0 - width/2, y1], fill=color, width=width)\n draw.line([x0, y1, x0, y0], fill=color, width=width)\n\n\nimg = Image.open(p.img_path(book=\"ARMS\", index=6))\nfor annotation_type in [\"body\", \"face\", \"frame\", \"text\"]:\n rois = p.annotations[\"ARMS\"][\"book\"][\"pages\"][\"page\"][6][annotation_type]\n for roi in rois:\n draw_rectangle(img, roi[\"@xmin\"], roi[\"@ymin\"], roi[\"@xmax\"], roi[\"@ymax\"], annotation_type)\n\nimg.show()\n```\n![](http://yusukematsui.me/project/sketch2manga/img/manga109_api_example.png)\nARMS, (c) Kato Masaki\n\n\n\n\n## Author\n- [Yusuke Matsui](http://yusukematsui.me/)\n\n## Citation\nWhen you make use of images in Manga109, please cite the following paper:\n\n @article{mtap_matsui_2017,\n author={Yusuke Matsui and Kota Ito and Yuji Aramaki and Azuma Fujimoto and Toru Ogawa and Toshihiko Yamasaki and Kiyoharu Aizawa},\n title={Sketch-based Manga Retrieval using Manga109 Dataset},\n journal={Multimedia Tools and Applications},\n volume={76},\n number={20},\n pages={21811--21838},\n year={2017}\n }\n\nWhen you use annotation data of Manga109, please cite this:\n\n @article{corr_ogawa_2018,\n author={Toru Ogawa and Atsushi Otsubo and Rei Narita and Yusuke Matsui and Toshihiko Yamasaki and Kiyoharu Aizawa},\n title={Object Detection for Comics using Manga109 Annotations},\n journal={CoRR},\n volume={abs/1803.08670},\n year={2018}\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/matsui528/manga109api", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "manga109api", "package_url": "https://pypi.org/project/manga109api/", "platform": "", "project_url": "https://pypi.org/project/manga109api/", "project_urls": { "Homepage": "https://github.com/matsui528/manga109api" }, "release_url": "https://pypi.org/project/manga109api/0.1.2/", "requires_dist": [ "xmltodict" ], "requires_python": "", "summary": "Simple python API to read annotation data of Manga109", "version": "0.1.2" }, "last_serial": 4894522, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5301a59f977da3fd7fc9c5017e20d952", "sha256": "3efcd0de317e420d2b8e4c0a93e6ba9fbc99edd988e537ae66cff83f513953f9" }, "downloads": -1, "filename": "manga109api-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5301a59f977da3fd7fc9c5017e20d952", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4752, "upload_time": "2018-09-01T10:48:35", "url": "https://files.pythonhosted.org/packages/83/05/07ea027987fcf781a8387766c8c5df1917ab5d5f2b81ed6fff62948684eb/manga109api-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "362a8cfe6267937611b8dc31b8b9b4b4", "sha256": "12bcd31b8e9073f0c628fe8b50936cea821c043b8effb232dd467e21424c188d" }, "downloads": -1, "filename": "manga109api-0.1.0.tar.gz", "has_sig": false, "md5_digest": "362a8cfe6267937611b8dc31b8b9b4b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5460, "upload_time": "2018-09-01T10:48:37", "url": "https://files.pythonhosted.org/packages/da/1d/972fb4043510d1e4a6b751e4e2a7ebc7aa202dee7d9b77ca1b26571280ec/manga109api-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "dc7c01c005c4a9a2b0fb1b5aaeba58a8", "sha256": "475a6065a594d298b5186a0b3bbe97805b15bbd081e726b9772a2b8ecc0ed852" }, "downloads": -1, "filename": "manga109api-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "dc7c01c005c4a9a2b0fb1b5aaeba58a8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5263, "upload_time": "2018-09-01T16:55:29", "url": "https://files.pythonhosted.org/packages/58/0e/0d5a2ff34640866cff74c32198779e9dfd78caf7453713e1d850193ac86a/manga109api-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cef3643e604f8fa8959a6995839b8218", "sha256": "18a7428ed51980c77cb28e9909b6aed09f6a7d45d03ca1beb2843b1c91652d32" }, "downloads": -1, "filename": "manga109api-0.1.1.tar.gz", "has_sig": false, "md5_digest": "cef3643e604f8fa8959a6995839b8218", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6047, "upload_time": "2018-09-01T16:55:31", "url": "https://files.pythonhosted.org/packages/4a/03/76324555ce8d78538a497b8254621a6c9a4225df330132d4545f7b55d75e/manga109api-0.1.1.tar.gz" } ], "0.1.1.dev1": [ { "comment_text": "", "digests": { "md5": "79d525ac0245cfcad28cc255e3af4000", "sha256": "1885617b226d8732d3030760244fcd81086e3f828bd8d3e7a607b7a8bd0906c2" }, "downloads": -1, "filename": "manga109api-0.1.1.dev1-py3-none-any.whl", "has_sig": false, "md5_digest": "79d525ac0245cfcad28cc255e3af4000", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5312, "upload_time": "2018-09-01T16:54:29", "url": "https://files.pythonhosted.org/packages/cd/e7/3a8fff0ed4805db2a90ae76ab30d4f6da93270041a19cce7c7c7dd7574b4/manga109api-0.1.1.dev1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1a9f1f203dbf78c6f4bc9a31baabdf06", "sha256": "d67884ddca387520e6b3faf5a022ee79c4cf12c7042fe251d00ba018dcbbced1" }, "downloads": -1, "filename": "manga109api-0.1.1.dev1.tar.gz", "has_sig": false, "md5_digest": "1a9f1f203dbf78c6f4bc9a31baabdf06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6064, "upload_time": "2018-09-01T16:54:30", "url": "https://files.pythonhosted.org/packages/21/1d/83c6030c9f10b85ffcac18a22f12c2788ff37046319ac6d077c77a44a4b2/manga109api-0.1.1.dev1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b1429754d66ebe34056d353acad9d36c", "sha256": "a759f107a36cc314c79e2728f917c5117b65241d9ce5a06cd9ad00df13b047bf" }, "downloads": -1, "filename": "manga109api-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b1429754d66ebe34056d353acad9d36c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6094, "upload_time": "2019-03-04T13:49:16", "url": "https://files.pythonhosted.org/packages/93/85/6b97f44e25fef46b1dcda7a27d9c25e1142ce7678744349a8a75e0418a0f/manga109api-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ddd22281d681403219bf01c4b038830", "sha256": "13202d2bdbdd2b3a1bbefc36520ebb9189794d0219f0835c9f3df410f3599e63" }, "downloads": -1, "filename": "manga109api-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2ddd22281d681403219bf01c4b038830", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6035, "upload_time": "2019-03-04T13:49:18", "url": "https://files.pythonhosted.org/packages/a8/22/2dae1dc627840636b962cf058b67bfe59cf8d3e6623472b664c1409d8b90/manga109api-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b1429754d66ebe34056d353acad9d36c", "sha256": "a759f107a36cc314c79e2728f917c5117b65241d9ce5a06cd9ad00df13b047bf" }, "downloads": -1, "filename": "manga109api-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b1429754d66ebe34056d353acad9d36c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6094, "upload_time": "2019-03-04T13:49:16", "url": "https://files.pythonhosted.org/packages/93/85/6b97f44e25fef46b1dcda7a27d9c25e1142ce7678744349a8a75e0418a0f/manga109api-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ddd22281d681403219bf01c4b038830", "sha256": "13202d2bdbdd2b3a1bbefc36520ebb9189794d0219f0835c9f3df410f3599e63" }, "downloads": -1, "filename": "manga109api-0.1.2.tar.gz", "has_sig": false, "md5_digest": "2ddd22281d681403219bf01c4b038830", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6035, "upload_time": "2019-03-04T13:49:18", "url": "https://files.pythonhosted.org/packages/a8/22/2dae1dc627840636b962cf058b67bfe59cf8d3e6623472b664c1409d8b90/manga109api-0.1.2.tar.gz" } ] }