Skip to content

Instantly share code, notes, and snippets.

@webtk
Created September 29, 2022 08:15
Show Gist options
  • Save webtk/896cad1062caea540ef847a1af70aad3 to your computer and use it in GitHub Desktop.
Save webtk/896cad1062caea540ef847a1af70aad3 to your computer and use it in GitHub Desktop.
Extraction polygon from annotation data of rendered.ai(synthetic dataset)
from PIL import ImageDraw as D
from PIL import Image
from PIL import ImagePath
import json
with open('syn_sample/annotations/0000000000-1-Image-ana.json','r') as f:
annotation = json.load(f)
i = Image.open("syn_sample/images/0000000000-1-Image.png")
draw = D.Draw(i)
objects = annotation['annotations']
for obj in objects:
#bbox=obj['bbox']
#draw.rectangle(bbox, outline="white")
parts = obj['segmentation']
for part in parts:
draw.polygon(part)
i.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment