Skip to content

Commit

Permalink
Merge pull request microsoft#61 from microsoft/users/dan/conversion_f…
Browse files Browse the repository at this point in the history
…ormat

Users/dan/conversion format
  • Loading branch information
agentmorris authored Jun 22, 2019
2 parents 74054cd + aa0f523 commit 021a392
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 16 additions & 4 deletions api/batch_processing/postprocessing/convert_output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def convert_json_to_csv(input_path,output_path):
detections = []
for d in i['detections']:
detection = d['bbox']

# Our .json format is xmin/ymin/w/h
#
# Our .csv format was ymin/xmin/ymax/xmax
xmin = detection[0]
ymin = detection[1]
xmax = detection[0] + detection[2]
ymax = detection[1] + detection[3]
detection = [ymin, xmin, ymax, xmax]

detection.append(d['conf'])
detection.append(int(d['category']))
detections.append(detection)
Expand Down Expand Up @@ -79,12 +89,14 @@ def convert_csv_to_json(input_path,output_path):

for iDetection,detection in enumerate(src_detections):

# Our .csv format was xmin/ymin/xmax/ymax
# Our .csv format was ymin/xmin/ymax/xmax
#
# Our .json format is xmin/ymin/w/h
bbox = detection[0:4]
bbox[2] = bbox[2] - bbox[0]
bbox[3] = bbox[3] - bbox[1]
ymin = detection[0]
xmin = detection[1]
ymax = detection[2]
xmax = detection[3]
bbox = [xmin, ymin, xmax-xmin, ymax-ymin]
conf = detection[4]
iClass = detection[5]
out_detection = {}
Expand Down
4 changes: 2 additions & 2 deletions visualization/visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def render_detection_bounding_boxes_old(boxes_scores_classes, image,
Args:
boxes_and_scores: outputs of generate_detections, in one of the following formats
[x_min, y_min, x_max, x_max, p]
[x_min, y_min, x_max, x_max, p, class]
[x_min, y_min, x_max, y_max, p]
[x_min, y_min, x_max, y_max, p, class]
...all in normalized coordinates, with the origin at the upper-left.
Expand Down

0 comments on commit 021a392

Please sign in to comment.