Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HM3DSem category mappings file #2004

Merged
merged 2 commits into from
Feb 17, 2023

Conversation

srama2512
Copy link
Contributor

Motivation and Context

This PR adds a file to map raw HM3DSem category names to 40 standard MP3D categories. The first column contains the raw name from HM3DSem annotations, the second column contains the typo fix to the raw name (if any), and the third column contains one of 40 standard MP3D categories. This is particularly useful in generating HM3DSem ObjectNav episodes, where we used the following code snippet to map raw names to an HM3D ObjectNav category.

# Create mapping from raw names to categories
HM3D_RAW_TO_CAT_MAPPING = {}
with open("<PATH_TO_HABITAT_SIM>/data/hm3d_semantics/hm3dsem_category_mappings.tsv", "r") as tsv_file:
    tsv_reader = csv.reader(tsv_file, delimiter="\t")
    is_first_row = True
    for row in tsv_reader:
        if is_first_row:
            is_first_row = False
            continue
        orig_raw_name = row[0].strip().lower()
        fixed_raw_name = row[1].strip().lower()
        cat_name = row[2]
        # Override the category name for plant
        if "plant" in fixed_raw_name or "flower" in fixed_raw_name:
            cat_name = "plant"
        HM3D_RAW_TO_CAT_MAPPING[orig_raw_name] = cat_name
        HM3D_RAW_TO_CAT_MAPPING[fixed_raw_name] = cat_name

# For a given raw name, decide whether the object is an ObjectNav goal
GOAL_CATEGORIES = ["chair", "bed", "plant", "toilet", "tv_monitor", "sofa"]
is_goal_object = HM3D_RAW_TO_CAT_MAPPING[given_raw_name.strip().lower()] in GOAL_CATEGORIES

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 10, 2023
Copy link
Contributor

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to run pre-commit on this.

@srama2512
Copy link
Contributor Author

srama2512 commented Feb 14, 2023

You'll need to run pre-commit on this.

@Skylion007 - I ran pre-commit. But it removed tabs and replaced them with spaces, which goes against the definition of the tsv file. How do I prevent this from happening?

@Skylion007
Copy link
Contributor

Oh, you probably need to add an exclude to the replace tabs pre-commit hook in the pre-commit config.

@Skylion007
Copy link
Contributor

@srama2512 Just add it to this regex:

exclude: "(^(.git|setup.cfg))|(.(json|scn)$)"

@aclegg3 aclegg3 merged commit 138ef59 into facebookresearch:main Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants