Skip to content

Torchgeo mlm#102

Merged
fmigneault merged 32 commits into
stac-extensions:mainfrom
Nazim-crim:torchgeo-mlm
Aug 21, 2025
Merged

Torchgeo mlm#102
fmigneault merged 32 commits into
stac-extensions:mainfrom
Nazim-crim:torchgeo-mlm

Conversation

@Nazim-crim
Copy link
Copy Markdown
Contributor

@Nazim-crim Nazim-crim commented Jul 18, 2025

Description

  • This MR introduces the from_torch function in torch/ a utility to programmatically generate a STAC Item with the Machine Learning Model (MLM) Extension from a PyTorch nn.Module.
  • Add an exemple json of a parsed torchgeo unet using SENTINEL2_2CLASS_NC_FTW default weights

Related Issue

Type of Change

  • 📚 Examples, docs, tutorials or dependencies update;
  • 🔧 Bug fix (non-breaking change which fixes an issue);
  • 🥂 Improvement (non-breaking change which improves an existing feature);
  • 🚀 New feature (non-breaking change which adds functionality);
  • 💥 Breaking change (fix or feature that would cause existing functionality to change);
  • 🔐 Security fix.

Checklist

  • I've read the CONTRIBUTING.md guide;
  • I've updated the code style using make check;
  • I've written tests for all new methods and classes that I created;
  • I've written the docstring in Google format for all the methods and classes that I used.

@Nazim-crim
Copy link
Copy Markdown
Contributor Author

Following previous comment on crim-ca/mlm-extension#41 , here's my up to date change. Let me know if other fixes are needed. Thanks

@fmigneault fmigneault requested review from fmigneault and rbavery and removed request for rbavery July 19, 2025 02:55
Comment thread tests/test_unet_mlm.py Outdated
Comment thread examples/item_pytorch_geo_unet.json
Comment thread examples/item_pytorch_geo_unet.json
Comment thread examples/item_pytorch_geo_unet.json Outdated
Comment thread examples/item_pytorch_geo_unet.json Outdated
Comment thread stac_model/frameworks/torch/export.py Outdated
Comment thread stac_model/examples.py Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
]
license = {text = "Apache Software License 2.0"}
requires-python = "<4.0,>=3.10"
requires-python = "<4.0,>=3.11"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Self Note

Merge other features and release MLM 1.5.0 & stac_model 0.4.0 before merging this to avoid the potentially breaking change for users employing the package.

Comment thread CHANGELOG.md
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Self-note

Make sure the items are ordered correctly considering the intermediate release of MLM / stac_model.

Comment thread stac_model/examples.py Outdated
Comment thread stac_model/examples.py Outdated
@Nazim-crim Nazim-crim requested a review from fmigneault August 12, 2025 19:44
@fmigneault fmigneault mentioned this pull request Aug 13, 2025
11 tasks
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread stac_model/frameworks/torch_impl/__init__.py Outdated
Comment thread stac_model/frameworks/torch_impl/export.py
Comment thread stac_model/input.py Outdated
Comment thread CHANGELOG.md
Comment thread stac_model/schema.py
Comment thread tests/torch_impl/test_unet_mlm.py Outdated
@fmigneault
Copy link
Copy Markdown
Collaborator

@Nazim-crim
The linting check fails for the same reason as moregeo-it/stac-node-validator#78 (see the run outputs that converts 0.0 -> 0 and 3000.0 -> 3000). Since there is no planed fix for it, can you try to explicitly use int values and see if that patches the example?

The other failures for Python 3.10 should be handled properly when merging with #97.

@fmigneault
Copy link
Copy Markdown
Collaborator

fmigneault commented Aug 20, 2025

Temp fix for STAC validation is to used stac_version: 1.0.0 instead of 1.1.0.

@Nazim-crim Nazim-crim requested a review from fmigneault August 20, 2025 20:14
Comment thread README_STAC_MODEL.md Outdated
Comment thread README_STAC_MODEL.md Outdated
Comment thread stac_model/schema.py
@fmigneault
Copy link
Copy Markdown
Collaborator

fmigneault commented Aug 20, 2025

See # pragma: has-torch for conditional resolution of 3.10 coverage.

has-torch = "is_installed('torch')"

@Nazim-crim Nazim-crim requested a review from fmigneault August 21, 2025 14:11
@fmigneault fmigneault merged commit a235e39 into stac-extensions:main Aug 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request inference example in pytorch/lightning

2 participants