How to export annotations to COCO format or similar to refine annotations? #347
Unanswered
Xavier-Waters
asked this question in
Q&A
Replies: 1 comment 1 reply
-
There is a Disclaimer: The following code snippets will give you an idea of how to do it. I haven't tested it and might require some (slight) modifications. import deepdoctection as dd
df = dd.SerializerFiles.load(path="your/path/to/json-dir") # loading a path to your json-file
df = dd.MapData(df , dd.Image.from_file) # loading the .json file and converting into the deepdoctection format
df = dd.MapData(df, dd.image_to_coco) # converting the image object into a COCO-snippet. If this function is not available under this namespace, it has been implemented in `deepdoctection.mapper.cocostruct`
df.reset_state()
coco_format = {"info": {...}, # your info to be specified
"licenses": [...], # your license to be specified
"images": [],
"annotations": [],
"categories": []}. # your categories to be specified
for img, anns in df: # image_to_coco returns a tuple: img: dict, anns: list[dict] that must be collected to generate the COCO-structure.
coco_format["images"].append(img)
coco_format["annotations"].append(anns)
# finally saving coco_format to JSON. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello I am currently working a on a project using this project and am wondering how to export the annotations created by page.save() to a standard format so I can use the model to create more annotations when I have a model that is 90% there and just needs a little refinement, I looked all over the docs and the internet but could not find anything.
Beta Was this translation helpful? Give feedback.
All reactions