metnet


Namemetnet JSON
Version 4.1.15 PyPI version JSON
download
home_pagehttps://github.com/openclimatefix/metnet
SummaryPyTorch MetNet Implementation
upload_time2023-06-16 11:35:57
maintainer
docs_urlNone
authorJacob Bieker
requires_python
licenseMIT License
keywords artificial intelligence deep learning transformer attention mechanism metnet forecasting remote-sensing
VCS
bugtrack_url
requirements No requirements were recorded.
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-6-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"><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"><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"><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"><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"><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"><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>
    </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": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "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/03/4e/cd7d8e4ed49c93f1de650c5d25323206ff92e55d7478e881e8598d91f071/metnet-4.1.15.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-6-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\"><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\"><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\"><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\"><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\"><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\"><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    </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.15",
    "project_urls": {
        "Homepage": "https://github.com/openclimatefix/metnet"
    },
    "split_keywords": [
        "artificial intelligence",
        "deep learning",
        "transformer",
        "attention mechanism",
        "metnet",
        "forecasting",
        "remote-sensing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f44424440af8a341873e2359e7c9dbc0440a33d6e580ed9181c3b6b6655d68c9",
                "md5": "2694197613b67ea67f68a94b63de77fa",
                "sha256": "1a5c9c29b39bf53148d31732dda8bef30f163cc7f17792ea30f5fe29b3225a56"
            },
            "downloads": -1,
            "filename": "metnet-4.1.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2694197613b67ea67f68a94b63de77fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 24542,
            "upload_time": "2023-06-16T11:35:55",
            "upload_time_iso_8601": "2023-06-16T11:35:55.933889Z",
            "url": "https://files.pythonhosted.org/packages/f4/44/24440af8a341873e2359e7c9dbc0440a33d6e580ed9181c3b6b6655d68c9/metnet-4.1.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "034ecd7d8e4ed49c93f1de650c5d25323206ff92e55d7478e881e8598d91f071",
                "md5": "ed2b49481b35a24223ca968c1d94c1c0",
                "sha256": "ba055ca9c338f356977bdf41166c968c632df085e1c5668d0ce12feb4d396121"
            },
            "downloads": -1,
            "filename": "metnet-4.1.15.tar.gz",
            "has_sig": false,
            "md5_digest": "ed2b49481b35a24223ca968c1d94c1c0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19036,
            "upload_time": "2023-06-16T11:35:57",
            "upload_time_iso_8601": "2023-06-16T11:35:57.111854Z",
            "url": "https://files.pythonhosted.org/packages/03/4e/cd7d8e4ed49c93f1de650c5d25323206ff92e55d7478e881e8598d91f071/metnet-4.1.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-16 11:35:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openclimatefix",
    "github_project": "metnet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "metnet"
}
        
Elapsed time: 0.08799s