"...git@developer.sourcefind.cn:OpenDAS/bitsandbytes.git" did not exist on "3a630c589dd4ab779d28067b17c87712c9f1a674"
Commit dcdf3dcf authored by Sam Tsai's avatar Sam Tsai Committed by Facebook GitHub Bot
Browse files

add segmentation points and use circular kp pattern

Summary:
1. Circular pattern segmentation points
2. Use circular pattern for kp patterns

Reviewed By: wat3rBro

Differential Revision: D29069224

fbshipit-source-id: c4c01d6d93de5abbdfceae07f1cd48fb56e05f57
parent 692a4fb3
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import contextlib import contextlib
import itertools import itertools
import json import json
import math
import os import os
import uuid import uuid
...@@ -22,7 +23,7 @@ ANN_FN = "annotation_file" ...@@ -22,7 +23,7 @@ ANN_FN = "annotation_file"
def create_toy_dataset( def create_toy_dataset(
image_generator, num_images, num_classes=-1, num_keypoints=0, is_rotated=False image_generator, num_images, num_classes=-1, num_keypoints=0, is_rotated=False
): ):
""" given image_generator, create a dataset with toy annotations and catagories """ """given image_generator, create a dataset with toy annotations and catagories"""
categories = [] categories = []
images = [] images = []
annotations = [] annotations = []
...@@ -47,28 +48,39 @@ def create_toy_dataset( ...@@ -47,28 +48,39 @@ def create_toy_dataset(
else [width / 2, height / 2, width / 2, height / 2, 45] # cXcYWHO_ABS else [width / 2, height / 2, width / 2, height / 2, 45] # cXcYWHO_ABS
) )
keypoints = list(
itertools.chain.from_iterable(
[
math.cos(2 * math.pi * x / num_keypoints) * width / 4 + width / 2,
math.sin(2 * math.pi * x / num_keypoints) * height / 4 + height / 2,
1,
]
for x in range(num_keypoints)
)
)
no_pts = 10
segmentation = list(
itertools.chain.from_iterable(
[
math.cos(2 * math.pi * x / no_pts) * width / 4 + width / 2,
math.sin(2 * math.pi * x / no_pts) * height / 4 + height / 2,
]
for x in range(no_pts)
)
)
annotations.append( annotations.append(
{ {
"image_id": i, "image_id": i,
"category_id": i % num_classes, "category_id": i % num_classes,
"id": i, "id": i,
"bbox": bbox, "bbox": bbox,
"keypoints": list( "keypoints": keypoints,
itertools.chain.from_iterable(
[
(
float(idx) / width / 2 + width / 4,
float(idx) / height / 2 + height / 4,
1,
)
for idx in range(num_keypoints)
]
)
),
"area": width * height, "area": width * height,
"iscrowd": 0, "iscrowd": 0,
"ignore": 0, "ignore": 0,
"segmentation": [], "segmentation": [segmentation],
} }
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment