metnet


Namemetnet JSON
Version 4.1.18 PyPI version JSON
download
home_pagehttps://github.com/openclimatefix/metnet
SummaryPyTorch MetNet Implementation
upload_time2025-03-28 12:36:08
maintainerNone
docs_urlNone
authorJacob Bieker
requires_pythonNone
licenseMIT License
keywords artificial intelligence deep learning transformer attention mechanism metnet forecasting remote-sensing
VCS
bugtrack_url
requirements einops numpy torchvision antialiased_cnns axial_attention pytorch_msssim huggingface_hub
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MetNet and MetNet-2
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

PyTorch Implementation of Google Research's MetNet for short term weather forecasting (https://arxiv.org/abs/2003.12140), inspired from https://github.com/tcapelle/metnet_pytorch/tree/master/metnet_pytorch

MetNet-2 (https://arxiv.org/pdf/2111.07470.pdf) is a further extension of MetNet that takes in a larger context image to predict up to 12 hours ahead, and is also implemented in PyTorch here.

## Installation

Clone the repository, then run
```shell
pip install -r requirements.txt
pip install -e .
````

Alternatively, you can also install a usually older version through ```pip install metnet```

Please ensure that you're using Python version 3.9 or above.

## Data

While the exact training data used for both MetNet and MetNet-2 haven't been released, the papers do go into some detail as to the inputs, which were GOES-16 and MRMS precipitation data, as well as the time period covered. We will be making those splits available, as well as a larger dataset that covers a longer time period, with [HuggingFace Datasets](https://huggingface.co/datasets/openclimatefix/goes-mrms)! Note: The dataset is not available yet, we are still processing data!

```python
from datasets import load_dataset

dataset = load_dataset("openclimatefix/goes-mrms")
```

This uses the publicly avaiilable GOES-16 data and the MRMS archive to create a similar set of data to train and test on, with various other splits available as well.

## Pretrained Weights
Pretrained model weights for MetNet and MetNet-2 have not been publicly released, and there is some difficulty in reproducing their training. We release weights for both MetNet and MetNet-2 trained on cloud mask and satellite imagery data with the same parameters as detailed in the papers on HuggingFace Hub for [MetNet](https://huggingface.co/openclimatefix/metnet) and [MetNet-2](https://huggingface.co/openclimatefix/metnet-2). These weights can be downloaded and used using:

```python
from metnet import MetNet, MetNet2
model = MetNet().from_pretrained("openclimatefix/metnet")
model = MetNet2().from_pretrained("openclimatefix/metnet-2")
```

## Example Usage

MetNet can be used with:

```python
from metnet import MetNet
import torch
import torch.nn.functional as F

model = MetNet(
        hidden_dim=32,
        forecast_steps=24,
        input_channels=16,
        output_channels=12,
        sat_channels=12,
        input_size=32,
        )
# MetNet expects original HxW to be 4x the input size
x = torch.randn((2, 12, 16, 128, 128))
out = []
for lead_time in range(24):
        out.append(model(x, lead_time))
out = torch.stack(out, dim=1)
# MetNet creates predictions for the center 1/4th
y = torch.randn((2, 24, 12, 8, 8))
F.mse_loss(out, y).backward()
```

And MetNet-2 with:

```python
from metnet import MetNet2
import torch
import torch.nn.functional as F

model = MetNet2(
        forecast_steps=8,
        input_size=64,
        num_input_timesteps=6,
        upsampler_channels=128,
        lstm_channels=32,
        encoder_channels=64,
        center_crop_size=16,
        )
# MetNet expects original HxW to be 4x the input size
x = torch.randn((2, 6, 12, 256, 256))
out = []
for lead_time in range(8):
        out.append(model(x, lead_time))
out = torch.stack(out, dim=1)
y = torch.rand((2,8,12,64,64))
F.mse_loss(out, y).backward()
```

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center" valign="top" width="14.28%"><a href="https://www.jacobbieker.com"><img src="https://avatars.githubusercontent.com/u/7170359?v=4?s=100" width="100px;" alt="Jacob Bieker"/><br /><sub><b>Jacob Bieker</b></sub></a><br /><a href="https://github.com/openclimatefix/metnet/commits?author=jacobbieker" title="Code">💻</a></td>
      <td align="center" valign="top" width="14.28%"><a href="http://jack-kelly.com"><img src="https://avatars.githubusercontent.com/u/460756?v=4?s=100" width="100px;" alt="Jack Kelly"/><br /><sub><b>Jack Kelly</b></sub></a><br /><a href="https://github.com/openclimatefix/metnet/commits?author=JackKelly" title="Code">💻</a></td>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/ValterFallenius"><img src="https://avatars.githubusercontent.com/u/21970939?v=4?s=100" width="100px;" alt="Valter Fallenius"/><br /><sub><b>Valter Fallenius</b></sub></a><br /><a href="#userTesting-ValterFallenius" title="User Testing">📓</a></td>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/terigenbuaa"><img src="https://avatars.githubusercontent.com/u/91317406?v=4?s=100" width="100px;" alt="terigenbuaa"/><br /><sub><b>terigenbuaa</b></sub></a><br /><a href="#question-terigenbuaa" title="Answering Questions">💬</a></td>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/NMC-DAVE"><img src="https://avatars.githubusercontent.com/u/26354668?v=4?s=100" width="100px;" alt="Kan.Dai"/><br /><sub><b>Kan.Dai</b></sub></a><br /><a href="#question-NMC-DAVE" title="Answering Questions">💬</a></td>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/SaileshBechar"><img src="https://avatars.githubusercontent.com/u/38445041?v=4?s=100" width="100px;" alt="Sailesh Bechar"/><br /><sub><b>Sailesh Bechar</b></sub></a><br /><a href="#question-SaileshBechar" title="Answering Questions">💬</a></td>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/rahul-maurya11b"><img src="https://avatars.githubusercontent.com/u/98907006?v=4?s=100" width="100px;" alt="Rahul Maurya"/><br /><sub><b>Rahul Maurya</b></sub></a><br /><a href="https://github.com/openclimatefix/metnet/commits?author=rahul-maurya11b" title="Tests">⚠️</a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/openclimatefix/metnet",
    "name": "metnet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, transformer, attention mechanism, metnet, forecasting, remote-sensing",
    "author": "Jacob Bieker",
    "author_email": "jacob@openclimatefix.org",
    "download_url": "https://files.pythonhosted.org/packages/a3/cf/33da3ce37e27643adfb79b951cf55ac53696ea16cca26d98895b09286e71/metnet-4.1.18.tar.gz",
    "platform": null,
    "description": "# MetNet and MetNet-2\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nPyTorch Implementation of Google Research's MetNet for short term weather forecasting (https://arxiv.org/abs/2003.12140), inspired from https://github.com/tcapelle/metnet_pytorch/tree/master/metnet_pytorch\n\nMetNet-2 (https://arxiv.org/pdf/2111.07470.pdf) is a further extension of MetNet that takes in a larger context image to predict up to 12 hours ahead, and is also implemented in PyTorch here.\n\n## Installation\n\nClone the repository, then run\n```shell\npip install -r requirements.txt\npip install -e .\n````\n\nAlternatively, you can also install a usually older version through ```pip install metnet```\n\nPlease ensure that you're using Python version 3.9 or above.\n\n## Data\n\nWhile the exact training data used for both MetNet and MetNet-2 haven't been released, the papers do go into some detail as to the inputs, which were GOES-16 and MRMS precipitation data, as well as the time period covered. We will be making those splits available, as well as a larger dataset that covers a longer time period, with [HuggingFace Datasets](https://huggingface.co/datasets/openclimatefix/goes-mrms)! Note: The dataset is not available yet, we are still processing data!\n\n```python\nfrom datasets import load_dataset\n\ndataset = load_dataset(\"openclimatefix/goes-mrms\")\n```\n\nThis uses the publicly avaiilable GOES-16 data and the MRMS archive to create a similar set of data to train and test on, with various other splits available as well.\n\n## Pretrained Weights\nPretrained model weights for MetNet and MetNet-2 have not been publicly released, and there is some difficulty in reproducing their training. We release weights for both MetNet and MetNet-2 trained on cloud mask and satellite imagery data with the same parameters as detailed in the papers on HuggingFace Hub for [MetNet](https://huggingface.co/openclimatefix/metnet) and [MetNet-2](https://huggingface.co/openclimatefix/metnet-2). These weights can be downloaded and used using:\n\n```python\nfrom metnet import MetNet, MetNet2\nmodel = MetNet().from_pretrained(\"openclimatefix/metnet\")\nmodel = MetNet2().from_pretrained(\"openclimatefix/metnet-2\")\n```\n\n## Example Usage\n\nMetNet can be used with:\n\n```python\nfrom metnet import MetNet\nimport torch\nimport torch.nn.functional as F\n\nmodel = MetNet(\n        hidden_dim=32,\n        forecast_steps=24,\n        input_channels=16,\n        output_channels=12,\n        sat_channels=12,\n        input_size=32,\n        )\n# MetNet expects original HxW to be 4x the input size\nx = torch.randn((2, 12, 16, 128, 128))\nout = []\nfor lead_time in range(24):\n        out.append(model(x, lead_time))\nout = torch.stack(out, dim=1)\n# MetNet creates predictions for the center 1/4th\ny = torch.randn((2, 24, 12, 8, 8))\nF.mse_loss(out, y).backward()\n```\n\nAnd MetNet-2 with:\n\n```python\nfrom metnet import MetNet2\nimport torch\nimport torch.nn.functional as F\n\nmodel = MetNet2(\n        forecast_steps=8,\n        input_size=64,\n        num_input_timesteps=6,\n        upsampler_channels=128,\n        lstm_channels=32,\n        encoder_channels=64,\n        center_crop_size=16,\n        )\n# MetNet expects original HxW to be 4x the input size\nx = torch.randn((2, 6, 12, 256, 256))\nout = []\nfor lead_time in range(8):\n        out.append(model(x, lead_time))\nout = torch.stack(out, dim=1)\ny = torch.rand((2,8,12,64,64))\nF.mse_loss(out, y).backward()\n```\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://www.jacobbieker.com\"><img src=\"https://avatars.githubusercontent.com/u/7170359?v=4?s=100\" width=\"100px;\" alt=\"Jacob Bieker\"/><br /><sub><b>Jacob Bieker</b></sub></a><br /><a href=\"https://github.com/openclimatefix/metnet/commits?author=jacobbieker\" title=\"Code\">\ud83d\udcbb</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://jack-kelly.com\"><img src=\"https://avatars.githubusercontent.com/u/460756?v=4?s=100\" width=\"100px;\" alt=\"Jack Kelly\"/><br /><sub><b>Jack Kelly</b></sub></a><br /><a href=\"https://github.com/openclimatefix/metnet/commits?author=JackKelly\" title=\"Code\">\ud83d\udcbb</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/ValterFallenius\"><img src=\"https://avatars.githubusercontent.com/u/21970939?v=4?s=100\" width=\"100px;\" alt=\"Valter Fallenius\"/><br /><sub><b>Valter Fallenius</b></sub></a><br /><a href=\"#userTesting-ValterFallenius\" title=\"User Testing\">\ud83d\udcd3</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/terigenbuaa\"><img src=\"https://avatars.githubusercontent.com/u/91317406?v=4?s=100\" width=\"100px;\" alt=\"terigenbuaa\"/><br /><sub><b>terigenbuaa</b></sub></a><br /><a href=\"#question-terigenbuaa\" title=\"Answering Questions\">\ud83d\udcac</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/NMC-DAVE\"><img src=\"https://avatars.githubusercontent.com/u/26354668?v=4?s=100\" width=\"100px;\" alt=\"Kan.Dai\"/><br /><sub><b>Kan.Dai</b></sub></a><br /><a href=\"#question-NMC-DAVE\" title=\"Answering Questions\">\ud83d\udcac</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/SaileshBechar\"><img src=\"https://avatars.githubusercontent.com/u/38445041?v=4?s=100\" width=\"100px;\" alt=\"Sailesh Bechar\"/><br /><sub><b>Sailesh Bechar</b></sub></a><br /><a href=\"#question-SaileshBechar\" title=\"Answering Questions\">\ud83d\udcac</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/rahul-maurya11b\"><img src=\"https://avatars.githubusercontent.com/u/98907006?v=4?s=100\" width=\"100px;\" alt=\"Rahul Maurya\"/><br /><sub><b>Rahul Maurya</b></sub></a><br /><a href=\"https://github.com/openclimatefix/metnet/commits?author=rahul-maurya11b\" title=\"Tests\">\u26a0\ufe0f</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "PyTorch MetNet Implementation",
    "version": "4.1.18",
    "project_urls": {
        "Homepage": "https://github.com/openclimatefix/metnet"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " transformer",
        " attention mechanism",
        " metnet",
        " forecasting",
        " remote-sensing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fd8b93d2c6042dc29985b4d16b9323e1b258e08866b913f30b8905049e60dd41",
                "md5": "95d3378f4af469fdb7170d4feb45b36e",
                "sha256": "7582ca02cd33e987e23fd9620603bfd657ed242c1c3b14238bbef0ac27730e28"
            },
            "downloads": -1,
            "filename": "metnet-4.1.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95d3378f4af469fdb7170d4feb45b36e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 36904,
            "upload_time": "2025-03-28T12:36:07",
            "upload_time_iso_8601": "2025-03-28T12:36:07.217128Z",
            "url": "https://files.pythonhosted.org/packages/fd/8b/93d2c6042dc29985b4d16b9323e1b258e08866b913f30b8905049e60dd41/metnet-4.1.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a3cf33da3ce37e27643adfb79b951cf55ac53696ea16cca26d98895b09286e71",
                "md5": "5db1f34fc4710fab32cd2ee9a272264f",
                "sha256": "c8342b0d864d66a3d58577fbad34b598fdf09aa51df1345e6bb9b75d96f907b6"
            },
            "downloads": -1,
            "filename": "metnet-4.1.18.tar.gz",
            "has_sig": false,
            "md5_digest": "5db1f34fc4710fab32cd2ee9a272264f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 28081,
            "upload_time": "2025-03-28T12:36:08",
            "upload_time_iso_8601": "2025-03-28T12:36:08.632484Z",
            "url": "https://files.pythonhosted.org/packages/a3/cf/33da3ce37e27643adfb79b951cf55ac53696ea16cca26d98895b09286e71/metnet-4.1.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-28 12:36:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openclimatefix",
    "github_project": "metnet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "einops",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.19.5"
                ]
            ]
        },
        {
            "name": "torchvision",
            "specs": [
                [
                    ">=",
                    "0.10.0"
                ]
            ]
        },
        {
            "name": "antialiased_cnns",
            "specs": []
        },
        {
            "name": "axial_attention",
            "specs": []
        },
        {
            "name": "pytorch_msssim",
            "specs": []
        },
        {
            "name": "huggingface_hub",
            "specs": []
        }
    ],
    "lcname": "metnet"
}
        
Elapsed time: 4.62818s