DEV Community

Cover image for My First Open Source Contribution @microsoft
Inderpreet Singh Parmar
Inderpreet Singh Parmar

Posted on

My First Open Source Contribution @microsoft

Issue Worked On:
Add Consistent Bands Metadata to Vision Transformer and ResNet Weights #2376
This week, I worked on a GitHub issue to add consistent band metadata across Vision Transformer (ViT) and ResNet weight classes in the torchgeo library. The goal was to ensure uniform metadata across different weight classes, specifically supporting various satellite datasets like Landsat and Sentinel.

Overview of the Issue:
The issue focused on improving usability by ensuring that each weight class had clear and consistent band metadata. This enhancement aimed to address missing information that users need to ensure compatibility when applying these weights in their workflows. The metadata needed to align closely with the Sentinel and Landsat datasetsโ€™ specifications, which are commonly used in geospatial applications.

Preparation and Setup:
I began by cloning the repository and setting up the environment, ensuring I was familiar with the metadata definitions in torchgeo. I studied the structure and naming conventions used in resnet.py and vit.py to determine where to add the new metadata. I also reviewed related documentation on Landsat and Sentinel datasets to ensure accuracy.

Learning Requirements:
Understanding the structure and conventions for the different satellite bands was essential. I researched how Landsat and Sentinel datasets represent bands to ensure that I correctly implemented each set of metadata for these satellite data sources. Additionally, learning to interpret feedback from the maintainers regarding variable naming conventions and formatting was an important part of the process.

Explanation of the Fix:
To implement the fix:

  1. Added Band Metadata: I added band metadata to the Vision Transformer and ResNet weight classes, following the structure set in the swin.py file for consistency.
  2. Standardized Variable Naming: I adopted naming conventions that clearly indicated the dataset associated with each band, such as _landsat_tm_toa_bands, _sentinel2_rgb_bands, etc.
  3. Removed Inconsistent Variables: The final review involved removing the fMoW bands metadata as these bands were inconsistent across satellites, per feedback from the maintainer.

Demo of Code Before/After Fix:
Before the fix, the band metadata was either missing or inconsistently named, making it difficult for users to identify which bands were needed for each weight class. After the update, the band metadata is now clear and consistent across weight classes, and each dataset is properly represented with standardized naming conventions.

Research and Challenges:
In addition to researching Landsat and Sentinel band specifications, I faced challenges with Git, particularly with rebase conflicts while addressing feedback. Some metadata, like the fMoW bands, was particularly challenging due to inconsistent satellite band usage, which led to the eventual removal of this metadata.

Interactions with Maintainers:
Throughout the process, I received helpful feedback from the project maintainer, adamjstewart, who provided specific requests to:

  1. Alphabetize imports and variables for better readability.
  2. Move comments to improve code organization.
  3. Remove fMoW metadata due to inconsistencies across satellites. The maintainer's insights on metadata formatting and code organization helped refine the final solution.

Overcoming Difficulties:
Handling Git conflicts was challenging, but I used commands like git rebase and git rebase --continue to resolve these issues. Additionally, interpreting the feedback regarding metadata names required careful review and adjustment. I implemented each change step-by-step and tested to ensure the updated metadata did not introduce errors.

Link to the Pull Request:
Add Consistent Bands Metadata to Vision Transformer and ResNet Weights #2376

Reflection and Learning:

This experience highlighted the importance of clear metadata and code organization in collaborative projects. For future contributions, I would ensure that I understand naming conventions from the start to avoid rework. The alphabetical organization and standardized naming practices were particularly useful and something I would apply in future coding projects. Additionally, I gained valuable experience in handling complex Git workflows, which will be beneficial for similar projects.

Outcome:

The PR was successfully merged, with the "hacktoberfest-accepted" label added, allowing my contribution to be counted toward Hacktoberfest. The maintainer acknowledged the timing, ensuring the merge was completed in October. This contribution enhanced the usability of torchgeo for geospatial applications, and Iโ€™m grateful for the learning experience this project provided.

Top comments (0)