| Name | pascal-voc JSON |
| Version |
2.1.11
JSON |
| download |
| home_page | |
| Summary | Tool to work with annotation formats |
| upload_time | 2023-12-12 12:44:13 |
| maintainer | |
| docs_url | None |
| author | Alexander Barmin |
| requires_python | >=3.6 |
| license | MIT License Copyright (c) 2023 Alexandr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
Pillow
transliterate
typing_extensions
xmlobj
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
### pascal
Python utility to work with PascalVoc annotation format
Image examples from [PascalVoc2007](hhttp://host.robots.ox.ac.uk/pascal/VOC/voc2007/) dataset
##### Code Example
```
import json
from pathlib import Path
from PIL import Image
from pascal import annotation_from_xml
from pascal.utils import save_xml
ds_path = Path("/home/VOCtest_06-Nov-2007/VOCdevkit/VOC2007")
img_src = ds_path / "JPEGImages"
ann_src = ds_path / "Annotations"
out_labelme = ds_path / "converted_labelme"
attr_type_spec = {"truncated": bool, "difficult": bool}
label_map = {"car": 1, "dog": 0, "person": 2, "train": 3}
if __name__ == "__main__":
for file in img_src.glob("*.jpg"):
# Get annotation file path
ann_file = (ann_src / file.name).with_suffix(".xml")
# Make pascal annotation object
ann = annotation_from_xml(ann_file, attr_type_spec)
print(ann)
# Save to xml file (same as ann_file)
xml = ann.to_xml()
out_xml_name = file.with_suffix(".xml").name
save_xml(out_xml_name, xml)
# Save yolo annotation
yolo_ann = ann.to_yolo(label_map)
out_yolo_name = file.with_suffix(".txt").name
with open(out_yolo_name, "w") as f:
f.write(yolo_ann)
# Convert to labelme and save json file
res = ann.to_labelme(file, save_img_data=False)
with open((out_labelme / file.name).with_suffix(".json"), "w") as f:
json.dump(res, f, indent=2)
# Draw objects
img = Image.open(file)
draw_img = ann.draw_boxes(img)
draw_img.show()
```
##### Visualization example:
```
draw_img = ann.draw_boxes(img)
draw_img.show()
```

#### Installation
From source
```
python setup.py install
```
Using pip
```
pip install pascal-voc
```
Raw data
{
"_id": null,
"home_page": "",
"name": "pascal-voc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Alexander Barmin",
"author_email": "Alexander Barmin <barmin1@mail.ru>",
"download_url": "https://files.pythonhosted.org/packages/1e/a8/91c6b706fdc319257300f767c9ac0d42242d0638f20b64440f80fb53142b/pascal_voc-2.1.11.tar.gz",
"platform": null,
"description": "### pascal\n\nPython utility to work with PascalVoc annotation format\n\nImage examples from [PascalVoc2007](hhttp://host.robots.ox.ac.uk/pascal/VOC/voc2007/) dataset\n\n##### Code Example\n\n```\nimport json\nfrom pathlib import Path\n\nfrom PIL import Image\n\nfrom pascal import annotation_from_xml\nfrom pascal.utils import save_xml\n\nds_path = Path(\"/home/VOCtest_06-Nov-2007/VOCdevkit/VOC2007\")\n\nimg_src = ds_path / \"JPEGImages\"\nann_src = ds_path / \"Annotations\"\n\nout_labelme = ds_path / \"converted_labelme\"\n\nattr_type_spec = {\"truncated\": bool, \"difficult\": bool}\n\nlabel_map = {\"car\": 1, \"dog\": 0, \"person\": 2, \"train\": 3}\n\nif __name__ == \"__main__\":\n for file in img_src.glob(\"*.jpg\"):\n # Get annotation file path\n ann_file = (ann_src / file.name).with_suffix(\".xml\")\n # Make pascal annotation object\n ann = annotation_from_xml(ann_file, attr_type_spec)\n print(ann)\n # Save to xml file (same as ann_file)\n xml = ann.to_xml()\n out_xml_name = file.with_suffix(\".xml\").name\n save_xml(out_xml_name, xml)\n # Save yolo annotation\n yolo_ann = ann.to_yolo(label_map)\n out_yolo_name = file.with_suffix(\".txt\").name\n with open(out_yolo_name, \"w\") as f:\n f.write(yolo_ann)\n # Convert to labelme and save json file\n res = ann.to_labelme(file, save_img_data=False)\n with open((out_labelme / file.name).with_suffix(\".json\"), \"w\") as f:\n json.dump(res, f, indent=2)\n # Draw objects\n img = Image.open(file)\n draw_img = ann.draw_boxes(img)\n draw_img.show()\n```\n\n##### Visualization example:\n```\ndraw_img = ann.draw_boxes(img)\ndraw_img.show()\n```\n\n\n#### Installation\nFrom source \n```\npython setup.py install\n```\nUsing pip\n```\npip install pascal-voc\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Alexandr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Tool to work with annotation formats",
"version": "2.1.11",
"project_urls": {
"Homepage": "https://github.com/Alek-dr/PascalVOC",
"Issues": "https://github.com/Alek-dr/PascalVOC/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3500d6f1891fa6960d5b53cbdc46a2947b494adaf672f2593cea5ea2f4125582",
"md5": "629238622030ec4b83a5a4fbb77c7484",
"sha256": "849f5b5b3725fe09fe1831573d618a544b75b2981ce02d4931bfd82930b57e6d"
},
"downloads": -1,
"filename": "pascal_voc-2.1.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "629238622030ec4b83a5a4fbb77c7484",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 427612,
"upload_time": "2023-12-12T12:44:10",
"upload_time_iso_8601": "2023-12-12T12:44:10.872606Z",
"url": "https://files.pythonhosted.org/packages/35/00/d6f1891fa6960d5b53cbdc46a2947b494adaf672f2593cea5ea2f4125582/pascal_voc-2.1.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1ea891c6b706fdc319257300f767c9ac0d42242d0638f20b64440f80fb53142b",
"md5": "b436d491a9c91b1a2dbe59410368ec5c",
"sha256": "0409f323a861acf1f19d5591eb99bb709d34bb87dac2997f958a768e22be7c44"
},
"downloads": -1,
"filename": "pascal_voc-2.1.11.tar.gz",
"has_sig": false,
"md5_digest": "b436d491a9c91b1a2dbe59410368ec5c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 220942,
"upload_time": "2023-12-12T12:44:13",
"upload_time_iso_8601": "2023-12-12T12:44:13.668273Z",
"url": "https://files.pythonhosted.org/packages/1e/a8/91c6b706fdc319257300f767c9ac0d42242d0638f20b64440f80fb53142b/pascal_voc-2.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-12 12:44:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Alek-dr",
"github_project": "PascalVOC",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Pillow",
"specs": [
[
">=",
"10.0.0"
]
]
},
{
"name": "transliterate",
"specs": [
[
">=",
"1.10.2"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
">=",
"4.1.0"
]
]
},
{
"name": "xmlobj",
"specs": [
[
">=",
"1.2.2"
]
]
}
],
"lcname": "pascal-voc"
}