torchwm 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torchwm-0.2.1/LICENSE +21 -0
- torchwm-0.2.1/PKG-INFO +146 -0
- torchwm-0.2.1/README.md +111 -0
- torchwm-0.2.1/pyproject.toml +38 -0
- torchwm-0.2.1/setup.cfg +4 -0
- torchwm-0.2.1/setup.py +46 -0
- torchwm-0.2.1/tests/test_agents.py +0 -0
- torchwm-0.2.1/tests/test_controller.py +0 -0
- torchwm-0.2.1/tests/test_decoder.py +0 -0
- torchwm-0.2.1/tests/test_encoder.py +0 -0
- torchwm-0.2.1/tests/test_envs.py +30 -0
- torchwm-0.2.1/tests/test_memory.py +0 -0
- torchwm-0.2.1/tests/test_observations.py +0 -0
- torchwm-0.2.1/tests/test_rewards.py +0 -0
- torchwm-0.2.1/tests/test_trainers.py +0 -0
- torchwm-0.2.1/tests/test_transforms.py +0 -0
- torchwm-0.2.1/tests/test_utils.py +0 -0
- torchwm-0.2.1/torchwm.egg-info/PKG-INFO +146 -0
- torchwm-0.2.1/torchwm.egg-info/SOURCES.txt +62 -0
- torchwm-0.2.1/torchwm.egg-info/dependency_links.txt +1 -0
- torchwm-0.2.1/torchwm.egg-info/not-zip-safe +1 -0
- torchwm-0.2.1/torchwm.egg-info/requires.txt +20 -0
- torchwm-0.2.1/torchwm.egg-info/top_level.txt +1 -0
- torchwm-0.2.1/world_models/__init__.py +0 -0
- torchwm-0.2.1/world_models/controller/__init__.py +0 -0
- torchwm-0.2.1/world_models/controller/rollout_generator.py +118 -0
- torchwm-0.2.1/world_models/controller/rssm_policy.py +58 -0
- torchwm-0.2.1/world_models/datasets/__init__.py +0 -0
- torchwm-0.2.1/world_models/datasets/cifar10.py +41 -0
- torchwm-0.2.1/world_models/datasets/imagenet1k.py +252 -0
- torchwm-0.2.1/world_models/datasets/nuplan.py +0 -0
- torchwm-0.2.1/world_models/envs/__init__.py +33 -0
- torchwm-0.2.1/world_models/envs/ale_atari_env.py +54 -0
- torchwm-0.2.1/world_models/envs/ale_atari_vector_env.py +44 -0
- torchwm-0.2.1/world_models/envs/dmc.py +55 -0
- torchwm-0.2.1/world_models/envs/mujoco_env.py +93 -0
- torchwm-0.2.1/world_models/envs/unity_env.py +0 -0
- torchwm-0.2.1/world_models/envs/wrappers.py +269 -0
- torchwm-0.2.1/world_models/memory/__init__.py +0 -0
- torchwm-0.2.1/world_models/memory/dreamer_memory.py +57 -0
- torchwm-0.2.1/world_models/memory/planet_memory.py +170 -0
- torchwm-0.2.1/world_models/models/__init__.py +6 -0
- torchwm-0.2.1/world_models/models/dreamer.py +618 -0
- torchwm-0.2.1/world_models/models/dreamer_rssm.py +179 -0
- torchwm-0.2.1/world_models/models/jepa_agent.py +23 -0
- torchwm-0.2.1/world_models/models/planet.py +322 -0
- torchwm-0.2.1/world_models/models/rssm.py +167 -0
- torchwm-0.2.1/world_models/models/vit.py +603 -0
- torchwm-0.2.1/world_models/reward/__init__.py +4 -0
- torchwm-0.2.1/world_models/reward/dreamer_v1_reward.py +22 -0
- torchwm-0.2.1/world_models/reward/dreamer_v1_value.py +23 -0
- torchwm-0.2.1/world_models/training/__init__.py +0 -0
- torchwm-0.2.1/world_models/training/train_jepa.py +432 -0
- torchwm-0.2.1/world_models/training/train_planet.py +189 -0
- torchwm-0.2.1/world_models/training/train_rssm.py +172 -0
- torchwm-0.2.1/world_models/utils/__init__.py +0 -0
- torchwm-0.2.1/world_models/utils/dreamer_utils.py +115 -0
- torchwm-0.2.1/world_models/utils/jepa_utils.py +277 -0
- torchwm-0.2.1/world_models/utils/utils.py +700 -0
- torchwm-0.2.1/world_models/vision/__init__.py +0 -0
- torchwm-0.2.1/world_models/vision/dreamer_decoder.py +235 -0
- torchwm-0.2.1/world_models/vision/dreamer_encoder.py +49 -0
- torchwm-0.2.1/world_models/vision/planet_decoder.py +28 -0
- torchwm-0.2.1/world_models/vision/planet_encoder.py +28 -0
torchwm-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Param Thakkar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
torchwm-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: torchwm
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A Modular Pytorch Based library for training world models
|
|
5
|
+
Author:
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: world-models,pytorch,mbrl
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.13
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: ale-py>=0.11.2
|
|
14
|
+
Requires-Dist: gym>=0.26.2
|
|
15
|
+
Requires-Dist: gymnasium>=1.2.2
|
|
16
|
+
Requires-Dist: mlagents-envs>=0.28.0
|
|
17
|
+
Requires-Dist: moviepy>=2.2.1
|
|
18
|
+
Requires-Dist: myst-parser>=5.0.0
|
|
19
|
+
Requires-Dist: nbsphinx>=0.9.8
|
|
20
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
21
|
+
Requires-Dist: plotly>=6.5.0
|
|
22
|
+
Requires-Dist: pre-commit>=4.5.0
|
|
23
|
+
Requires-Dist: pygame>=2.6.1
|
|
24
|
+
Requires-Dist: sphinx>=9.1.0
|
|
25
|
+
Requires-Dist: sphinx-autodoc-typehints>=3.6.2
|
|
26
|
+
Requires-Dist: sphinx-copybutton>=0.5.2
|
|
27
|
+
Requires-Dist: sphinx-rtd-theme>=3.1.0
|
|
28
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.6.5
|
|
29
|
+
Requires-Dist: sphinxext-opengraph>=0.13.0
|
|
30
|
+
Requires-Dist: tensorboard>=2.20.0
|
|
31
|
+
Requires-Dist: tensorboardx>=2.6.4
|
|
32
|
+
Requires-Dist: tqdm>=4.67.1
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
|
|
36
|
+
# TorchWM
|
|
37
|
+
|
|
38
|
+
A modular PyTorch library for learning, training, and deploying world models across various environments. This package provides minimal implementations of popular world model algorithms, enabling researchers and developers to experiment with predictive modeling in reinforcement learning and beyond.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Modular Design**: Easily extensible components for encoders, decoders, transition models, and reward predictors.
|
|
43
|
+
- **Supported Algorithms**:
|
|
44
|
+
- Dreamer (v1 and v2 variants)
|
|
45
|
+
- PlaNet
|
|
46
|
+
- World Model-based agents for custom environments
|
|
47
|
+
- **Integration**: Compatible with MuJoCo, Atari, and custom gym environments.
|
|
48
|
+
- **Evaluation Tools**: Built-in scripts for training, evaluation, and visualization.
|
|
49
|
+
- **PyTorch Native**: Leverages PyTorch's dynamic computation graphs for efficient training.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
- Python 3.8+
|
|
55
|
+
- PyTorch 1.9+
|
|
56
|
+
- MuJoCo (for physics simulations)
|
|
57
|
+
|
|
58
|
+
### Install from PyPI
|
|
59
|
+
```bash
|
|
60
|
+
pip install torchwm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Install from Source
|
|
64
|
+
Clone the repository and install in editable mode:
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/ParamThakkar123/torchwm.git
|
|
67
|
+
cd torchwm
|
|
68
|
+
pip install -e .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For development dependencies (testing, linting):
|
|
72
|
+
```bash
|
|
73
|
+
pip install -e ".[dev]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
### Training a Dreamer Agent
|
|
79
|
+
```python
|
|
80
|
+
from world_models.dreamer import DreamerAgent
|
|
81
|
+
import gym
|
|
82
|
+
|
|
83
|
+
env = gym.make('Pendulum-v1')
|
|
84
|
+
agent = DreamerAgent(env.observation_space, env.action_space)
|
|
85
|
+
agent.train(env, num_episodes=1000)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Evaluating a Trained Model
|
|
89
|
+
Use the provided evaluation script:
|
|
90
|
+
```bash
|
|
91
|
+
python dreamer_eval.py --model_path results/dreamer_v1_custom_env/model.pth --env Pendulum-v1
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Custom Environment Example
|
|
95
|
+
```python
|
|
96
|
+
from world_models import WorldModel
|
|
97
|
+
import torch
|
|
98
|
+
|
|
99
|
+
# Define your custom environment
|
|
100
|
+
class CustomEnv:
|
|
101
|
+
def __init__(self):
|
|
102
|
+
self.obs_dim = 10
|
|
103
|
+
self.act_dim = 2
|
|
104
|
+
|
|
105
|
+
env = CustomEnv()
|
|
106
|
+
model = WorldModel(obs_dim=env.obs_dim, act_dim=env.act_dim)
|
|
107
|
+
# Train or load model...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Project Structure
|
|
111
|
+
|
|
112
|
+
- `world_models/`: Core library modules (encoders, decoders, agents)
|
|
113
|
+
- `dreamer_eval.py`: Evaluation script for Dreamer agents
|
|
114
|
+
- `dreamer_try.py`: Quick try-out script for Dreamer
|
|
115
|
+
- `main.py`: Main entry point for training
|
|
116
|
+
- `results/`: Directory for storing trained models and logs
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
For detailed API documentation, see the [Wiki](https://github.com/ParamThakkar123/torchwm/wiki) or docstrings in the source code.
|
|
121
|
+
|
|
122
|
+
## Contributing
|
|
123
|
+
|
|
124
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Key areas:
|
|
125
|
+
- Adding new world model algorithms
|
|
126
|
+
- Improving existing implementations
|
|
127
|
+
- Bug fixes and performance optimizations
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
132
|
+
|
|
133
|
+
## Citation
|
|
134
|
+
|
|
135
|
+
If you use this library for your research, please cite:
|
|
136
|
+
|
|
137
|
+
```bibtex
|
|
138
|
+
@misc{Thakkar_GitHub_-_ParamThakkar123_torchwm,
|
|
139
|
+
author = {Thakkar, Param},
|
|
140
|
+
title = {{GitHub - ParamThakkar123/torchwm: A modular PyTorch library designed for learning, training, and deploying world models across various environments.}},
|
|
141
|
+
year = {2025},
|
|
142
|
+
url = {https://github.com/ParamThakkar123/torchwm}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Package link: [TorchWM](https://pypi.org/project/torchwm/)
|
torchwm-0.2.1/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# TorchWM
|
|
2
|
+
|
|
3
|
+
A modular PyTorch library for learning, training, and deploying world models across various environments. This package provides minimal implementations of popular world model algorithms, enabling researchers and developers to experiment with predictive modeling in reinforcement learning and beyond.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Modular Design**: Easily extensible components for encoders, decoders, transition models, and reward predictors.
|
|
8
|
+
- **Supported Algorithms**:
|
|
9
|
+
- Dreamer (v1 and v2 variants)
|
|
10
|
+
- PlaNet
|
|
11
|
+
- World Model-based agents for custom environments
|
|
12
|
+
- **Integration**: Compatible with MuJoCo, Atari, and custom gym environments.
|
|
13
|
+
- **Evaluation Tools**: Built-in scripts for training, evaluation, and visualization.
|
|
14
|
+
- **PyTorch Native**: Leverages PyTorch's dynamic computation graphs for efficient training.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
- Python 3.8+
|
|
20
|
+
- PyTorch 1.9+
|
|
21
|
+
- MuJoCo (for physics simulations)
|
|
22
|
+
|
|
23
|
+
### Install from PyPI
|
|
24
|
+
```bash
|
|
25
|
+
pip install torchwm
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Install from Source
|
|
29
|
+
Clone the repository and install in editable mode:
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/ParamThakkar123/torchwm.git
|
|
32
|
+
cd torchwm
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For development dependencies (testing, linting):
|
|
37
|
+
```bash
|
|
38
|
+
pip install -e ".[dev]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
### Training a Dreamer Agent
|
|
44
|
+
```python
|
|
45
|
+
from world_models.dreamer import DreamerAgent
|
|
46
|
+
import gym
|
|
47
|
+
|
|
48
|
+
env = gym.make('Pendulum-v1')
|
|
49
|
+
agent = DreamerAgent(env.observation_space, env.action_space)
|
|
50
|
+
agent.train(env, num_episodes=1000)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Evaluating a Trained Model
|
|
54
|
+
Use the provided evaluation script:
|
|
55
|
+
```bash
|
|
56
|
+
python dreamer_eval.py --model_path results/dreamer_v1_custom_env/model.pth --env Pendulum-v1
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Custom Environment Example
|
|
60
|
+
```python
|
|
61
|
+
from world_models import WorldModel
|
|
62
|
+
import torch
|
|
63
|
+
|
|
64
|
+
# Define your custom environment
|
|
65
|
+
class CustomEnv:
|
|
66
|
+
def __init__(self):
|
|
67
|
+
self.obs_dim = 10
|
|
68
|
+
self.act_dim = 2
|
|
69
|
+
|
|
70
|
+
env = CustomEnv()
|
|
71
|
+
model = WorldModel(obs_dim=env.obs_dim, act_dim=env.act_dim)
|
|
72
|
+
# Train or load model...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Project Structure
|
|
76
|
+
|
|
77
|
+
- `world_models/`: Core library modules (encoders, decoders, agents)
|
|
78
|
+
- `dreamer_eval.py`: Evaluation script for Dreamer agents
|
|
79
|
+
- `dreamer_try.py`: Quick try-out script for Dreamer
|
|
80
|
+
- `main.py`: Main entry point for training
|
|
81
|
+
- `results/`: Directory for storing trained models and logs
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
For detailed API documentation, see the [Wiki](https://github.com/ParamThakkar123/torchwm/wiki) or docstrings in the source code.
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Key areas:
|
|
90
|
+
- Adding new world model algorithms
|
|
91
|
+
- Improving existing implementations
|
|
92
|
+
- Bug fixes and performance optimizations
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
97
|
+
|
|
98
|
+
## Citation
|
|
99
|
+
|
|
100
|
+
If you use this library for your research, please cite:
|
|
101
|
+
|
|
102
|
+
```bibtex
|
|
103
|
+
@misc{Thakkar_GitHub_-_ParamThakkar123_torchwm,
|
|
104
|
+
author = {Thakkar, Param},
|
|
105
|
+
title = {{GitHub - ParamThakkar123/torchwm: A modular PyTorch library designed for learning, training, and deploying world models across various environments.}},
|
|
106
|
+
year = {2025},
|
|
107
|
+
url = {https://github.com/ParamThakkar123/torchwm}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Package link: [TorchWM](https://pypi.org/project/torchwm/)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "torchwm"
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "A Modular Pytorch Based library for training world models"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"ale-py>=0.11.2",
|
|
9
|
+
"gym>=0.26.2",
|
|
10
|
+
"gymnasium>=1.2.2",
|
|
11
|
+
"mlagents-envs>=0.28.0",
|
|
12
|
+
"moviepy>=2.2.1",
|
|
13
|
+
"myst-parser>=5.0.0",
|
|
14
|
+
"nbsphinx>=0.9.8",
|
|
15
|
+
"opencv-python>=4.12.0.88",
|
|
16
|
+
"plotly>=6.5.0",
|
|
17
|
+
"pre-commit>=4.5.0",
|
|
18
|
+
"pygame>=2.6.1",
|
|
19
|
+
"sphinx>=9.1.0",
|
|
20
|
+
"sphinx-autodoc-typehints>=3.6.2",
|
|
21
|
+
"sphinx-copybutton>=0.5.2",
|
|
22
|
+
"sphinx-rtd-theme>=3.1.0",
|
|
23
|
+
"sphinxcontrib-bibtex>=2.6.5",
|
|
24
|
+
"sphinxext-opengraph>=0.13.0",
|
|
25
|
+
"tensorboard>=2.20.0",
|
|
26
|
+
"tensorboardx>=2.6.4",
|
|
27
|
+
"tqdm>=4.67.1",
|
|
28
|
+
]
|
|
29
|
+
license = "MIT"
|
|
30
|
+
keywords = ["world-models", "pytorch", "mbrl"]
|
|
31
|
+
classifiers = [
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["setuptools>=61.0", "wheel", "build"]
|
|
38
|
+
build-backend = "setuptools.build_meta"
|
torchwm-0.2.1/setup.cfg
ADDED
torchwm-0.2.1/setup.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
HERE = Path(__file__).parent
|
|
5
|
+
|
|
6
|
+
README = (
|
|
7
|
+
(HERE / "README.md").read_text(encoding="utf-8")
|
|
8
|
+
if (HERE / "README.md").exists()
|
|
9
|
+
else ""
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
setup(
|
|
13
|
+
name="torchwm",
|
|
14
|
+
version="0.1.0",
|
|
15
|
+
description="A Pytorch Based library for training world models",
|
|
16
|
+
long_description=README,
|
|
17
|
+
long_description_content_type="text/markdown",
|
|
18
|
+
author="",
|
|
19
|
+
license="MIT",
|
|
20
|
+
packages=find_packages(exclude=("tests", "results", "envs", ".venv", "venv")),
|
|
21
|
+
include_package_data=True,
|
|
22
|
+
python_requires=">=3.13",
|
|
23
|
+
install_requires=[
|
|
24
|
+
"ale-py>=0.11.2",
|
|
25
|
+
"gym>=0.26.2",
|
|
26
|
+
"gymnasium>=1.2.2",
|
|
27
|
+
"mlagents-envs>=0.28.0",
|
|
28
|
+
"moviepy>=2.2.1",
|
|
29
|
+
"opencv-python>=4.12.0.88",
|
|
30
|
+
"plotly>=6.5.0",
|
|
31
|
+
"pre-commit>=4.5.0",
|
|
32
|
+
"pygame>=2.6.1",
|
|
33
|
+
"tensorboard>=2.20.0",
|
|
34
|
+
"tensorboardx>=2.6.4",
|
|
35
|
+
"tqdm>=4.67.1",
|
|
36
|
+
"torch>=1.13.0",
|
|
37
|
+
"torchvision>=0.14.0",
|
|
38
|
+
],
|
|
39
|
+
classifiers=[
|
|
40
|
+
"Programming Language :: Python :: 3",
|
|
41
|
+
"License :: OSI Approved :: MIT License",
|
|
42
|
+
"Operating System :: OS Independent",
|
|
43
|
+
],
|
|
44
|
+
keywords="world-models pytorch",
|
|
45
|
+
zip_safe=False,
|
|
46
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from world_models.envs.dmc import DeepMindControlEnv
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TestDeepMindControlEnv:
|
|
5
|
+
def test_env_creation(self):
|
|
6
|
+
env = DeepMindControlEnv(name="cartpole-swingup", seed=42, size=(64, 64))
|
|
7
|
+
assert env.observation_space is not None
|
|
8
|
+
assert env.action_space is not None
|
|
9
|
+
|
|
10
|
+
def test_env_step_and_reset(self):
|
|
11
|
+
env = DeepMindControlEnv(name="cartpole-swingup", seed=42, size=(64, 64))
|
|
12
|
+
obs = env.reset()
|
|
13
|
+
assert "image" in obs
|
|
14
|
+
action = env.action_space.sample()
|
|
15
|
+
next_obs, reward, done, info = env.step(action)
|
|
16
|
+
assert "image" in next_obs
|
|
17
|
+
assert isinstance(reward, float)
|
|
18
|
+
assert isinstance(done, bool)
|
|
19
|
+
assert "discount" in info
|
|
20
|
+
|
|
21
|
+
def test_env_render(self):
|
|
22
|
+
env = DeepMindControlEnv(name="cartpole-swingup", seed=42, size=(64, 64))
|
|
23
|
+
env.reset()
|
|
24
|
+
frame = env.render()
|
|
25
|
+
assert frame.shape == (64, 64, 3)
|
|
26
|
+
env.close()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TestMujocoEnv:
|
|
30
|
+
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: torchwm
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A Modular Pytorch Based library for training world models
|
|
5
|
+
Author:
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: world-models,pytorch,mbrl
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.13
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: ale-py>=0.11.2
|
|
14
|
+
Requires-Dist: gym>=0.26.2
|
|
15
|
+
Requires-Dist: gymnasium>=1.2.2
|
|
16
|
+
Requires-Dist: mlagents-envs>=0.28.0
|
|
17
|
+
Requires-Dist: moviepy>=2.2.1
|
|
18
|
+
Requires-Dist: myst-parser>=5.0.0
|
|
19
|
+
Requires-Dist: nbsphinx>=0.9.8
|
|
20
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
21
|
+
Requires-Dist: plotly>=6.5.0
|
|
22
|
+
Requires-Dist: pre-commit>=4.5.0
|
|
23
|
+
Requires-Dist: pygame>=2.6.1
|
|
24
|
+
Requires-Dist: sphinx>=9.1.0
|
|
25
|
+
Requires-Dist: sphinx-autodoc-typehints>=3.6.2
|
|
26
|
+
Requires-Dist: sphinx-copybutton>=0.5.2
|
|
27
|
+
Requires-Dist: sphinx-rtd-theme>=3.1.0
|
|
28
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.6.5
|
|
29
|
+
Requires-Dist: sphinxext-opengraph>=0.13.0
|
|
30
|
+
Requires-Dist: tensorboard>=2.20.0
|
|
31
|
+
Requires-Dist: tensorboardx>=2.6.4
|
|
32
|
+
Requires-Dist: tqdm>=4.67.1
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
|
|
36
|
+
# TorchWM
|
|
37
|
+
|
|
38
|
+
A modular PyTorch library for learning, training, and deploying world models across various environments. This package provides minimal implementations of popular world model algorithms, enabling researchers and developers to experiment with predictive modeling in reinforcement learning and beyond.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Modular Design**: Easily extensible components for encoders, decoders, transition models, and reward predictors.
|
|
43
|
+
- **Supported Algorithms**:
|
|
44
|
+
- Dreamer (v1 and v2 variants)
|
|
45
|
+
- PlaNet
|
|
46
|
+
- World Model-based agents for custom environments
|
|
47
|
+
- **Integration**: Compatible with MuJoCo, Atari, and custom gym environments.
|
|
48
|
+
- **Evaluation Tools**: Built-in scripts for training, evaluation, and visualization.
|
|
49
|
+
- **PyTorch Native**: Leverages PyTorch's dynamic computation graphs for efficient training.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
- Python 3.8+
|
|
55
|
+
- PyTorch 1.9+
|
|
56
|
+
- MuJoCo (for physics simulations)
|
|
57
|
+
|
|
58
|
+
### Install from PyPI
|
|
59
|
+
```bash
|
|
60
|
+
pip install torchwm
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Install from Source
|
|
64
|
+
Clone the repository and install in editable mode:
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/ParamThakkar123/torchwm.git
|
|
67
|
+
cd torchwm
|
|
68
|
+
pip install -e .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For development dependencies (testing, linting):
|
|
72
|
+
```bash
|
|
73
|
+
pip install -e ".[dev]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
### Training a Dreamer Agent
|
|
79
|
+
```python
|
|
80
|
+
from world_models.dreamer import DreamerAgent
|
|
81
|
+
import gym
|
|
82
|
+
|
|
83
|
+
env = gym.make('Pendulum-v1')
|
|
84
|
+
agent = DreamerAgent(env.observation_space, env.action_space)
|
|
85
|
+
agent.train(env, num_episodes=1000)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Evaluating a Trained Model
|
|
89
|
+
Use the provided evaluation script:
|
|
90
|
+
```bash
|
|
91
|
+
python dreamer_eval.py --model_path results/dreamer_v1_custom_env/model.pth --env Pendulum-v1
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Custom Environment Example
|
|
95
|
+
```python
|
|
96
|
+
from world_models import WorldModel
|
|
97
|
+
import torch
|
|
98
|
+
|
|
99
|
+
# Define your custom environment
|
|
100
|
+
class CustomEnv:
|
|
101
|
+
def __init__(self):
|
|
102
|
+
self.obs_dim = 10
|
|
103
|
+
self.act_dim = 2
|
|
104
|
+
|
|
105
|
+
env = CustomEnv()
|
|
106
|
+
model = WorldModel(obs_dim=env.obs_dim, act_dim=env.act_dim)
|
|
107
|
+
# Train or load model...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Project Structure
|
|
111
|
+
|
|
112
|
+
- `world_models/`: Core library modules (encoders, decoders, agents)
|
|
113
|
+
- `dreamer_eval.py`: Evaluation script for Dreamer agents
|
|
114
|
+
- `dreamer_try.py`: Quick try-out script for Dreamer
|
|
115
|
+
- `main.py`: Main entry point for training
|
|
116
|
+
- `results/`: Directory for storing trained models and logs
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
For detailed API documentation, see the [Wiki](https://github.com/ParamThakkar123/torchwm/wiki) or docstrings in the source code.
|
|
121
|
+
|
|
122
|
+
## Contributing
|
|
123
|
+
|
|
124
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Key areas:
|
|
125
|
+
- Adding new world model algorithms
|
|
126
|
+
- Improving existing implementations
|
|
127
|
+
- Bug fixes and performance optimizations
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
132
|
+
|
|
133
|
+
## Citation
|
|
134
|
+
|
|
135
|
+
If you use this library for your research, please cite:
|
|
136
|
+
|
|
137
|
+
```bibtex
|
|
138
|
+
@misc{Thakkar_GitHub_-_ParamThakkar123_torchwm,
|
|
139
|
+
author = {Thakkar, Param},
|
|
140
|
+
title = {{GitHub - ParamThakkar123/torchwm: A modular PyTorch library designed for learning, training, and deploying world models across various environments.}},
|
|
141
|
+
year = {2025},
|
|
142
|
+
url = {https://github.com/ParamThakkar123/torchwm}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Package link: [TorchWM](https://pypi.org/project/torchwm/)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
tests/test_agents.py
|
|
6
|
+
tests/test_controller.py
|
|
7
|
+
tests/test_decoder.py
|
|
8
|
+
tests/test_encoder.py
|
|
9
|
+
tests/test_envs.py
|
|
10
|
+
tests/test_memory.py
|
|
11
|
+
tests/test_observations.py
|
|
12
|
+
tests/test_rewards.py
|
|
13
|
+
tests/test_trainers.py
|
|
14
|
+
tests/test_transforms.py
|
|
15
|
+
tests/test_utils.py
|
|
16
|
+
torchwm.egg-info/PKG-INFO
|
|
17
|
+
torchwm.egg-info/SOURCES.txt
|
|
18
|
+
torchwm.egg-info/dependency_links.txt
|
|
19
|
+
torchwm.egg-info/not-zip-safe
|
|
20
|
+
torchwm.egg-info/requires.txt
|
|
21
|
+
torchwm.egg-info/top_level.txt
|
|
22
|
+
world_models/__init__.py
|
|
23
|
+
world_models/controller/__init__.py
|
|
24
|
+
world_models/controller/rollout_generator.py
|
|
25
|
+
world_models/controller/rssm_policy.py
|
|
26
|
+
world_models/datasets/__init__.py
|
|
27
|
+
world_models/datasets/cifar10.py
|
|
28
|
+
world_models/datasets/imagenet1k.py
|
|
29
|
+
world_models/datasets/nuplan.py
|
|
30
|
+
world_models/envs/__init__.py
|
|
31
|
+
world_models/envs/ale_atari_env.py
|
|
32
|
+
world_models/envs/ale_atari_vector_env.py
|
|
33
|
+
world_models/envs/dmc.py
|
|
34
|
+
world_models/envs/mujoco_env.py
|
|
35
|
+
world_models/envs/unity_env.py
|
|
36
|
+
world_models/envs/wrappers.py
|
|
37
|
+
world_models/memory/__init__.py
|
|
38
|
+
world_models/memory/dreamer_memory.py
|
|
39
|
+
world_models/memory/planet_memory.py
|
|
40
|
+
world_models/models/__init__.py
|
|
41
|
+
world_models/models/dreamer.py
|
|
42
|
+
world_models/models/dreamer_rssm.py
|
|
43
|
+
world_models/models/jepa_agent.py
|
|
44
|
+
world_models/models/planet.py
|
|
45
|
+
world_models/models/rssm.py
|
|
46
|
+
world_models/models/vit.py
|
|
47
|
+
world_models/reward/__init__.py
|
|
48
|
+
world_models/reward/dreamer_v1_reward.py
|
|
49
|
+
world_models/reward/dreamer_v1_value.py
|
|
50
|
+
world_models/training/__init__.py
|
|
51
|
+
world_models/training/train_jepa.py
|
|
52
|
+
world_models/training/train_planet.py
|
|
53
|
+
world_models/training/train_rssm.py
|
|
54
|
+
world_models/utils/__init__.py
|
|
55
|
+
world_models/utils/dreamer_utils.py
|
|
56
|
+
world_models/utils/jepa_utils.py
|
|
57
|
+
world_models/utils/utils.py
|
|
58
|
+
world_models/vision/__init__.py
|
|
59
|
+
world_models/vision/dreamer_decoder.py
|
|
60
|
+
world_models/vision/dreamer_encoder.py
|
|
61
|
+
world_models/vision/planet_decoder.py
|
|
62
|
+
world_models/vision/planet_encoder.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
ale-py>=0.11.2
|
|
2
|
+
gym>=0.26.2
|
|
3
|
+
gymnasium>=1.2.2
|
|
4
|
+
mlagents-envs>=0.28.0
|
|
5
|
+
moviepy>=2.2.1
|
|
6
|
+
myst-parser>=5.0.0
|
|
7
|
+
nbsphinx>=0.9.8
|
|
8
|
+
opencv-python>=4.12.0.88
|
|
9
|
+
plotly>=6.5.0
|
|
10
|
+
pre-commit>=4.5.0
|
|
11
|
+
pygame>=2.6.1
|
|
12
|
+
sphinx>=9.1.0
|
|
13
|
+
sphinx-autodoc-typehints>=3.6.2
|
|
14
|
+
sphinx-copybutton>=0.5.2
|
|
15
|
+
sphinx-rtd-theme>=3.1.0
|
|
16
|
+
sphinxcontrib-bibtex>=2.6.5
|
|
17
|
+
sphinxext-opengraph>=0.13.0
|
|
18
|
+
tensorboard>=2.20.0
|
|
19
|
+
tensorboardx>=2.6.4
|
|
20
|
+
tqdm>=4.67.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
world_models
|
|
File without changes
|
|
File without changes
|