HamiFormer commited on
Commit
08099e9
·
1 Parent(s): a555044

Add usage and data documentation

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ library_name: pytorch
5
+ tags:
6
+ - physics
7
+ - physical-simulation
8
+ - trajectory-prediction
9
+ - hamiltonian
10
+ - diffusion
11
+ datasets:
12
+ - HamiFormer/Hamiballs
13
+ ---
14
+
15
+ # HamiFormer models
16
+
17
+ Inference weights for HamiFormer and baseline models on HamiBalls-1 and HamiBalls-2. HamiFormer combines whole-window diffusion prediction with Hamiltonian propagation through affine symplectic maps and regime-conditioned corrections.
18
+
19
+ [Code and instructions](https://github.com/HamiFormer/HamiFormer) · [HamiBalls datasets](https://huggingface.co/datasets/HamiFormer/Hamiballs)
20
+
21
+ ## Available weights
22
+
23
+ | File under `weights/` | Dataset | Method | Evaluation argument |
24
+ |---|---|---|---|
25
+ | `hami1_ours.pt` | HamiBalls-1 | HamiFormer | `--dataset h1 --method ours` |
26
+ | `hami1_physiformer.pt` | HamiBalls-1 | PhysiFormer | `--dataset h1 --method physiformer` |
27
+ | `hami1_hgdpf.pt` | HamiBalls-1 | Hamiltonian-Guided Diffusion Fields | `--dataset h1 --method hgdpf` |
28
+ | `hami2_ours.pt` | HamiBalls-2 | HamiFormer | `--dataset h2 --method ours` |
29
+ | `hami2_physiformer.pt` | HamiBalls-2 | PhysiFormer | `--dataset h2 --method physiformer` |
30
+ | `hami2_dit.pt` | HamiBalls-2 | Diffusion Transformer | `--dataset h2 --method dit` |
31
+ | `hami2_transformer_ar1.pt` | HamiBalls-2 | Transformer-AR, context 1 | `--dataset h2 --method transformer_ar1` |
32
+ | `hami2_transformer_ar4.pt` | HamiBalls-2 | Transformer-AR, context 4 | `--dataset h2 --method transformer_ar4` |
33
+
34
+ Files contain tensor dictionaries loaded by the corresponding implementations in the code repository.
35
+
36
+ ## Download and evaluate
37
+
38
+ Use Python 3.10–3.12, PyTorch 2.5.1, and a compatible CUDA environment.
39
+
40
+ ```sh
41
+ git clone https://github.com/HamiFormer/HamiFormer.git
42
+ cd HamiFormer
43
+ python -m pip install -e ".[test,data,analysis]"
44
+ python -m pip install huggingface_hub
45
+ ```
46
+
47
+ Download the weights and datasets from Python:
48
+
49
+ ```python
50
+ from huggingface_hub import snapshot_download
51
+
52
+ snapshot_download(
53
+ repo_id="HamiFormer/HamiFormer-Assets",
54
+ allow_patterns="weights/*.pt",
55
+ local_dir="assets",
56
+ )
57
+ snapshot_download(
58
+ repo_id="HamiFormer/Hamiballs",
59
+ repo_type="dataset",
60
+ allow_patterns="*.h5",
61
+ local_dir="assets/data",
62
+ )
63
+ ```
64
+
65
+ Run a small evaluation on each dataset:
66
+
67
+ ```sh
68
+ python run.py evaluate --dataset h1 --method ours --data assets/data/hamiballs1.h5 --weights assets/weights --limit 2 --output results/h1_ours
69
+ python run.py evaluate --dataset h2 --method ours --data assets/data/hamiballs2.h5 --weights assets/weights --limit 2 --output results/h2_ours
70
+ ```
71
+
72
+ Omit `--limit` to evaluate all 512 validation trajectories. The default protocol uses two noise seeds and 192 predicted transitions. HamiFormer predicts four consecutive 48-transition windows. The evaluator reports normalized state, position, and momentum MSE, contact-conditioned metrics, and disjoint-interval metrics, and writes `metrics.json` and `trajectories.npz` to the requested output directory. Use a new output directory for each run.
73
+
74
+ ## Inputs and outputs
75
+
76
+ Inputs are an initial phase-space state, object attributes, and physical times. HamiBalls-2 additionally supplies object and spring-graph information. Each object's state is ordered as `[q, p]`, where `p` is momentum. The evaluation entry point handles normalization using the model's stored scales and returns trajectories in the dataset's physical coordinates.
77
+
78
+ For direct component loading:
79
+
80
+ ```python
81
+ from hamiformer.models.hamiformer import HamiFormer
82
+
83
+ model = HamiFormer.from_pretrained("assets/weights", dataset="h2", device="cuda")
84
+ components = model.components()
85
+ ```
86
+
87
+ ## Intended use
88
+
89
+ These models support research on learned physical simulation and trajectory prediction in the HamiBalls spring-and-contact environments. The matching dataset conventions, physical time step, and object representation are described in the [dataset card](https://huggingface.co/datasets/HamiFormer/Hamiballs).
90
+
91
+ The project code is distributed under the [MIT license](https://github.com/HamiFormer/HamiFormer/blob/main/LICENSE). See [third-party notices](https://github.com/HamiFormer/HamiFormer/blob/main/THIRD_PARTY_NOTICES.md) for baseline references and attribution.