Instructions to use hchen657Naza/PWM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use hchen657Naza/PWM with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("hchen657Naza/PWM", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Download PWM_code/RISE_aux/docs/dynamics_model.md from hchen657Naza/PWM: direct link, hf CLI and curl.
- Browser
- Download file 5.78 kB
-
https://huggingface.co/hchen657Naza/PWM/resolve/main/PWM_code/RISE_aux/docs/dynamics_model.md
- Command line
-
hf download hf://hchen657Naza/PWM/PWM_code/RISE_aux/docs/dynamics_model.md
-
curl -L -o dynamics_model.md https://huggingface.co/hchen657Naza/PWM/resolve/main/PWM_code/RISE_aux/docs/dynamics_model.md
Dynamics Model
cd RISE/dynamics/dynamics_model
# Navigate to the dynamics model directory before running the following commands
Generated Samples
Data Format
The framework expects data in the LeRobot format. For optimal training performance, we strongly recommend pre-resizing videos to [256, 192] resolution.
Directory Structure
All tasks should be organized in the dataset directory with the following structure:
# copy your dataset under the dataset directory
cp -r path/to/your/dataset dataset/
Each dataset is organized as follows:
task_A/
βββ data/
β βββ chunk-000/
β βββ episode_000000.parquet
β βββ episode_000001.parquet
β βββ episode_000002.parquet
β βββ ...
βββ meta/
β βββ info.json
β βββ episodes.jsonl
β βββ episodes_stats.jsonl
β βββ tasks.jsonl
βββ videos/
βββ chunk-000/
βββ [video files]
Video Preprocessing
The preprocess.sh script resizes all videos in the dataset to 256x192 resolution using ffmpeg, preserving aspect ratio with center padding. Processed videos are saved in videos_small while maintaining the original directory structure.
Usage:
# Process specific datasets
./preprocess.sh dataset1 [dataset2](optional)
The output would be as follows with videos_small:
task_A/
βββ data/
βββ meta/
βββ videos/
βββ videos_small/
β βββ chunk-000/
β βββ [video files]
Model Checkpoints
Base LTX Backbone
Download the LTX-Video backbone components (Text Encoder, Tokenizer, and VAE) using the provided script:
./download.sh
This script automatically downloads all required components from the LTX-Video HuggingFace repository to the checkpoints directory.
Alternatively, you can manually download the following components:
- Text Encoder: text_encoder
- Tokenizer: tokenizer
- VAE: vae
- Pre-trained dynamics model: dynamics_model, pretrained on Galaxea Open World and AgiBot World Alpha jointly.
Place all downloaded weights in the same directory and update the pretrained_model_name_or_path field in your configuration file.
Training
Pre-training
Pre-training is performed on large-scale robotic datasets to learn general dynamics priors. We utilize the following datasets:
- Galaxea Open World Dataset: Galaxea-Open-World-Dataset
- AgiBot World Alpha: AgiBotWorld-Alpha
Steps
Prepare Data: Convert your datasets to the LeRobot format as described above.
Configure Training: Edit
configs/ltx_model/pretrain.yamlaccording to the comments:- Set
pretrained_model_name_or_pathto your LTX backbone checkpoint directory - Set
diffusion_model.model_pathto your pre-trained diffusion checkpoint - Configure
data.train.data_rootsanddata.val.data_rootsto point to your dataset directories
- Set
Launch Training:
bash train_task_centric.sh
Fine-tuning
Fine-tuning adapts the pre-trained model to specific task domains using domain-specific datasets.
Steps
Prepare Task-Specific Data: Organize your fine-tuning dataset in the LeRobot format.
Compute Action Normalization Statistics: Use
norm.pyto compute and save normalization statistics:python norm.py --datasets <your_finetune_dataset> --save-config data/utils/action_norm.jsonThis automatically computes min and max values for each dataset and saves them to a JSON configuration file.
Configure Fine-tuning: Edit
configs/ltx_model/finetune.yaml:- Set
pretrained_model_name_or_pathto your LTX backbone checkpoint directory - Set
diffusion_model.model_pathto your diffusion checkpoint - Configure
data.train.data_rootsanddata.val.data_rootsfor your fine-tuning dataset - Add
norm_config_path: data/utils/action_norm.jsonto bothdata.trainanddata.valsections - The data loader will automatically use the normalization values from the config file based on dataset names
- Set
Launch Fine-tuning:
bash task_finetune.sh
Inference
The inference pipeline generates future video sequences conditioned on initial observations and action sequences.
Steps
Configure Inference: Edit
configs/ltx_model/infer.yaml:- Set
pretrained_model_name_or_pathyour LTX backbone checkpoint directory - Set
diffusion_model.model_pathto your diffusion checkpoint
- Set
Update Inference Script: Edit
infer.shwith appropriate pathsRun Inference:
bash infer.sh
Inference Parameters
--config_file: Path to inference configuration file--image_root: Directory containing input observation images--output_path: Directory to save generated videos--act_tokens_path: Path to action token file (.ptformat)--norm_constant: Normalization constant for action tokens (e.g.,FINETUNE_TASK)