tensorflow / tensorflow/models

Is the area formula for bouding box used in the tfrecord code correct?

Open
#11,024 1 comment 0 reactions 1 assignee View on GitHub

@laxmareddyp is already working on this.

Since Jun 19, 2023.

models:research type:bug
Dominant language
Python
Stars
77.7k
Forks
44.8k
PR merge metrics
No merged PRs in 30d

Description

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am using the latest TensorFlow Model Garden release and TensorFlow 2.
  • I am reporting the issue to the correct repository. (research directory)
  • I checked to make sure that this issue has not already been filed.

1. The entire URL of the file you are using

research/object_detection/dataset_tools/context_rcnn/create_cococameratraps_tfexample_main.py

2. Describe the bug

"
for object_annotations in annotations:
if 'bbox' in object_annotations and self._keep_bboxes:
(x, y, width, height) = tuple(object_annotations['bbox'])
if width <= 0 or height <= 0:
num_annotations_skipped += 1
print(f"Skipping annotation for image ID: {image_id} - Invalid bounding box dimensions.")
continue
if x + width > image_width or y + height > image_height:
num_annotations_skipped += 1
print(f"Skipping annotation for image ID: {image_id} - Bounding box exceeds image boundaries.")
continue
xmin.append(float(x) / image_width)
xmax.append(float(x + width) / image_width)
ymin.append(float(y) / image_height)
ymax.append(float(y + height) / image_height)
if 'area' in object_annotations:
area.append(object_annotations['area'])
else:
# approximate area using lw/2
area.append(width
height/2.0)
"

Inside the code, I found that the formula of area for the bounding box being used is "widthheight/2.0". Since the bounding box is a rectangle, I am wondering why is the original formula of an area of a rectangle(area = widthheight) is being divided by 2? Is it correct?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.