AdilZtn commited on
Commit
c3e4af7
·
verified ·
1 Parent(s): c516a0f

Migrate policy to PolicyProcessorPipeline system

Browse files

🤖 **Automated Policy Migration to PolicyProcessorPipeline**

This PR migrates your model to the new LeRobot policy format using the modern PolicyProcessorPipeline architecture.

## What Changed

### ✨ **New Architecture - PolicyProcessorPipeline**
Your model now uses external PolicyProcessorPipeline components for data processing instead of built-in normalization layers. This provides:
- **Modularity**: Separate preprocessing and postprocessing pipelines
- **Flexibility**: Easy to swap, configure, and debug processing steps
- **Compatibility**: Works with the latest LeRobot ecosystem

### 🔧 **Normalization Extraction**
We've extracted normalization statistics from your model's state_dict and removed the built-in normalization layers:
- **Extracted patterns**: `normalize_inputs.*`, `unnormalize_outputs.*`, `normalize.*`, `unnormalize.*`, `input_normalizer.*`, `output_normalizer.*`
- **Statistics preserved**: Mean, std, min, max values for all features
- **Clean model**: State dict now contains only core model weights

### 📦 **Files Added**
- **preprocessor_config.json**: Configuration for input preprocessing pipeline
- **postprocessor_config.json**: Configuration for output postprocessing pipeline
- **model.safetensors**: Clean model weights without normalization layers
- **config.json**: Updated model configuration
- **train_config.json**: Training configuration
- **README.md**: Updated model card with migration information

### 🚀 **Benefits**
- **Backward Compatible**: Your model behavior remains identical
- **Future Ready**: Compatible with latest LeRobot features and updates
- **Debuggable**: Easy to inspect and modify processing steps
- **Portable**: Processors can be shared and reused across models

### 💻 **Usage**
```python
# Load your migrated model
from lerobot.policies import get_policy_class
from lerobot.processor import PolicyProcessorPipeline

# The preprocessor and postprocessor are now external
preprocessor = PolicyProcessorPipeline.from_pretrained("your-model-repo", config_filename="preprocessor_config.json")
postprocessor = PolicyProcessorPipeline.from_pretrained("your-model-repo", config_filename="postprocessor_config.json")
policy = get_policy_class("your-policy-type").from_pretrained("your-model-repo")

# Process data through the pipeline
processed_batch = preprocessor(raw_batch)
action = policy(processed_batch)
final_action = postprocessor(action)
```

*Generated automatically by the LeRobot policy migration script*

README.md CHANGED
@@ -6,8 +6,8 @@ license: apache-2.0
6
  model_name: smolvla
7
  pipeline_tag: robotics
8
  tags:
9
- - lerobot
10
  - smolvla
 
11
  - robotics
12
  ---
13
 
 
6
  model_name: smolvla
7
  pipeline_tag: robotics
8
  tags:
 
9
  - smolvla
10
+ - lerobot
11
  - robotics
12
  ---
13
 
config.json CHANGED
@@ -8,7 +8,7 @@
8
  6
9
  ]
10
  },
11
- "observation.images.camera1": {
12
  "type": "VISUAL",
13
  "shape": [
14
  3,
@@ -16,7 +16,7 @@
16
  256
17
  ]
18
  },
19
- "observation.images.camera2": {
20
  "type": "VISUAL",
21
  "shape": [
22
  3,
@@ -24,7 +24,7 @@
24
  256
25
  ]
26
  },
27
- "observation.camera3": {
28
  "type": "VISUAL",
29
  "shape": [
30
  3,
 
8
  6
9
  ]
10
  },
11
+ "observation.image2": {
12
  "type": "VISUAL",
13
  "shape": [
14
  3,
 
16
  256
17
  ]
18
  },
19
+ "observation.image": {
20
  "type": "VISUAL",
21
  "shape": [
22
  3,
 
24
  256
25
  ]
26
  },
27
+ "observation.image3": {
28
  "type": "VISUAL",
29
  "shape": [
30
  3,
policy_postprocessor.json CHANGED
@@ -1,13 +1,6 @@
1
  {
2
  "name": "policy_postprocessor",
3
  "steps": [
4
- {
5
- "registry_name": "device_processor",
6
- "config": {
7
- "device": "cpu",
8
- "float_dtype": null
9
- }
10
- },
11
  {
12
  "registry_name": "unnormalizer_processor",
13
  "config": {
@@ -26,7 +19,14 @@
26
  "ACTION": "MEAN_STD"
27
  }
28
  },
29
- "state_file": "policy_postprocessor_step_1_unnormalizer_processor.safetensors"
 
 
 
 
 
 
 
30
  }
31
  ]
32
  }
 
1
  {
2
  "name": "policy_postprocessor",
3
  "steps": [
 
 
 
 
 
 
 
4
  {
5
  "registry_name": "unnormalizer_processor",
6
  "config": {
 
19
  "ACTION": "MEAN_STD"
20
  }
21
  },
22
+ "state_file": "policy_postprocessor_step_0_unnormalizer_processor.safetensors"
23
+ },
24
+ {
25
+ "registry_name": "device_processor",
26
+ "config": {
27
+ "device": "cpu",
28
+ "float_dtype": null
29
+ }
30
  }
31
  ]
32
  }
policy_postprocessor_step_0_unnormalizer_processor.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:490ab239d96e263687c0b2e386a0afbc235a2eceb9857c36ed32f2f162a3e7c8
3
+ size 640