This guide provides instructions on running inference with Cosmos-Predict2.5/robot/action-cond models.
We recommend first reading the Inference Guide.
Action conditioned inference does not yet support multi-GPU.
Run inference with example asset:
python examples/action_conditioned.py -i assets/action_conditioned/basic/inference_params.json -o outputs/action_conditioned/basicFor an explanation of all the available parameters run:
python examples/action_conditioned.py --helpThe configuration is split into two parts:
-
Setup Arguments (
ActionConditionedSetupArguments): Model-related configuration that typically stays the same across runsmodel: Model variant to use (default: robot/multiview)context_parallel_size: Context parallelism is not supported for action conditioned model. Set context_parallel_size to 1.output_dir: Output directory for resultsconfig_file: Model configuration file
-
Inference Arguments (
ActionConditionedInferenceArguments): Per-run parameters that can varyinput_root: Root directory containing videos and annotationsinput_json_sub_folder: Subdirectory containing JSON annotationschunk_size: Action chunk size for processingguidance: Guidance scale for generationaction_load_fn: Function to load action data- And many more...
Create a JSON file with your inference parameters:
{
"name": "my_inference",
"input_root": "/path/to/input/data",
"input_json_sub_folder": "annotations",
"save_root": "/path/to/output",
"chunk_size": 12,
"guidance": 7,
"camera_id": "base",
"start": 0,
"end": 100,
"action_load_fn": "cosmos_predict2.action_conditioned.load_default_action_fn"
}To use a custom action loading function, implement a function following this signature:
def custom_action_load_fn():
def load_fn(json_data: dict, video_path: str, args: ActionConditionedInferenceArguments) -> dict:
# Your custom action loading logic here
return {
"actions": actions, # numpy array of actions
"initial_frame": img_array, # first frame
"video_array": video_array, # full video
"video_path": video_path,
}
return load_fnThen specify it in your JSON config:
{
"action_load_fn": "my_module.custom_action_load_fn"
}