Skip to main content

Json2PascalVoc

Json2PascalVoc is a Python library for converting some special Json strings to PascalVOC format XML files.

Installation

Use the package manager pip to install Json2PascalVoc.

pip install Json2PascalVoc

Or download package from GitHub

Usage

from Json2PascalVoc.Converter import Converter

myConverter = Converter()
# returns a Converter Object
myConverter.convertJsonToPascal("data.json")
# Converts Json to PascalVOC XML and saves the XML file to the related file path

An example data.json file is :

{
   "data":[
      {
         "annotation":{
            "folder":"class1",
            "filename":"_ADC0362.jpg",
            "path":"~/Desktop/Dev/data/foo/train/class1/_ADC0362.jpg",
            "source":{
               "database":"Unknown"
            },
            "size":{
               "width":1500,
               "height":1500,
               "depth":3
            },
            "segmented":0,
            "object":[
               {
                  "name":"class1",
                  "pose":"Unspecified",
                  "truncated":0,
                  "difficult":0,
                  "bndbox":{
                     "xmin":579,
                     "ymin":584,
                     "xmax":924,
                     "ymax":1120
                  }
               },
               {
                  "name":"class1",
                  "pose":"Unspecified",
                  "truncated":0,
                  "difficult":0,
                  "bndbox":{
                     "xmin":120,
                     "ymin":400,
                     "xmax":1150,
                     "ymax":800
                  }
               }

            ]
         }
      },
      {
         "annotation":{
            "folder":"class1",
            "filename":"_ADC0373.jpg",
            "path":"~/Desktop/Dev/data/foo/train/class1/_ADC0373.jpg",
            "source":{
               "database":"Unknown"
            },
            "size":{
               "width":1500,
               "height":1500,
               "depth":3
            },
            "segmented":0,
            "object":[
               {
                  "name":"class1",
                  "pose":"Unspecified",
                  "truncated":0,
                  "difficult":0,
                  "bndbox":{
                     "xmin":487,
                     "ymin":558,
                     "xmax":798,
                     "ymax":942
                  }
               }
            ]
         }
      }
   ]
}

Notes:

1- "data" array of Json can contain multiple "annotation" objects for different images.

2- "annotation" objects can contain multiple "object" attributes for multi object detecting in a single image.

3- PascalVOC formatted XML files are saved to the path that is given in "annotation.path" for each image/"annotation"

The output XML for an image is like :

<?xml version="1.0" encoding="UTF-8"?>
<annotation>
   <folder name="folder">class1</folder>
   <filename name="filename">_ADC0362.jpg</filename>
   <path name="path">~/Desktop/Dev/data/foo/train/class1/_ADC0362.jpg</path>
   <source>
      <database name="database">Unknown</database>
   </source>
   <size>
      <width name="width">1500</width>
      <height name="height">1500</height>
      <depth name="depth">3</depth>
   </size>
   <segmented name="segmented">0</segmented>
   <object>
      <name name="name">class1</name>
      <pose name="pose">Unspecified</pose>
      <truncated name="truncated">0</truncated>
      <difficult name="difficult">0</difficult>
      <bndbox>
         <xmin name="xmin">579</xmin>
         <ymin name="ymin">584</ymin>
         <xmax name="xmax">924</xmax>
         <ymax name="ymax">1120</ymax>
      </bndbox>
   </object>
   <object>
      <name name="name">class1</name>
      <pose name="pose">Unspecified</pose>
      <truncated name="truncated">0</truncated>
      <difficult name="difficult">0</difficult>
      <bndbox>
         <xmin name="xmin">120</xmin>
         <ymin name="ymin">400</ymin>
         <xmax name="xmax">1150</xmax>
         <ymax name="ymax">800</ymax>
      </bndbox>
   </object>
</annotation>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Release files for Json2PascalVoc 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Json2PascalVoc 1.0.5
File Size Uploaded
Json2PascalVoc-1.0.5.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Json2PascalVoc 1.0.5
File Interpreter ABI Platform
Json2PascalVoc-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / Json2PascalVoc-1.0.5.tar.gz

Download URL Json2PascalVoc-1.0.5.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e87caf0ce1a71b50f736af11a13fd4af02ad01fc9c828408d0f42be6a82e62e9
BLAKE2b-256 checksum
How to use checksums
87811d8269fa7de83e0e41ad6c472e0685ef1999a5c7b2f4ba9bef50caecf443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

Release files / Json2PascalVoc-1.0.5-py3-none-any.whl

Download URL Json2PascalVoc-1.0.5-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cdd6a8492f2fee9abe33add1a4141f98a70a8d16bc22c730a13676abafe5e889
BLAKE2b-256 checksum
How to use checksums
20f53470346ea7ce131200a6b18161e457a53bee239c5a958b2839028f6d7afe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.6

2 release files

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page