This commit is contained in:
0
.dockerignore
Normal file → Executable file
0
.dockerignore
Normal file → Executable file
0
.github/CODEOWNERS
vendored
Normal file → Executable file
0
.github/CODEOWNERS
vendored
Normal file → Executable file
0
.github/workflows/pre-commit.yml
vendored
Normal file → Executable file
0
.github/workflows/pre-commit.yml
vendored
Normal file → Executable file
0
.github/workflows/test.yml
vendored
Normal file → Executable file
0
.github/workflows/test.yml
vendored
Normal file → Executable file
2
.gitignore
vendored
Normal file → Executable file
2
.gitignore
vendored
Normal file → Executable file
@@ -12,6 +12,8 @@ __pycache__/
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
third-party/*
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
|
||||
0
.gitmodules
vendored
Normal file → Executable file
0
.gitmodules
vendored
Normal file → Executable file
0
.pre-commit-config.yaml
Normal file → Executable file
0
.pre-commit-config.yaml
Normal file → Executable file
0
.python-version
Normal file → Executable file
0
.python-version
Normal file → Executable file
0
.vscode/settings.json
vendored
Normal file → Executable file
0
.vscode/settings.json
vendored
Normal file → Executable file
0
CONTRIBUTING.md
Normal file → Executable file
0
CONTRIBUTING.md
Normal file → Executable file
0
docs/docker.md
Normal file → Executable file
0
docs/docker.md
Normal file → Executable file
0
docs/norm_stats.md
Normal file → Executable file
0
docs/norm_stats.md
Normal file → Executable file
0
docs/remote_inference.md
Normal file → Executable file
0
docs/remote_inference.md
Normal file → Executable file
0
examples/aloha_real/Dockerfile
Normal file → Executable file
0
examples/aloha_real/Dockerfile
Normal file → Executable file
0
examples/aloha_real/README.md
Normal file → Executable file
0
examples/aloha_real/README.md
Normal file → Executable file
0
examples/aloha_real/compose.yml
Normal file → Executable file
0
examples/aloha_real/compose.yml
Normal file → Executable file
0
examples/aloha_real/constants.py
Normal file → Executable file
0
examples/aloha_real/constants.py
Normal file → Executable file
0
examples/aloha_real/convert_aloha_data_to_lerobot.py
Normal file → Executable file
0
examples/aloha_real/convert_aloha_data_to_lerobot.py
Normal file → Executable file
0
examples/aloha_real/env.py
Normal file → Executable file
0
examples/aloha_real/env.py
Normal file → Executable file
0
examples/aloha_real/main.py
Normal file → Executable file
0
examples/aloha_real/main.py
Normal file → Executable file
0
examples/aloha_real/real_env.py
Normal file → Executable file
0
examples/aloha_real/real_env.py
Normal file → Executable file
0
examples/aloha_real/requirements.in
Normal file → Executable file
0
examples/aloha_real/requirements.in
Normal file → Executable file
0
examples/aloha_real/requirements.txt
Normal file → Executable file
0
examples/aloha_real/requirements.txt
Normal file → Executable file
0
examples/aloha_real/robot_utils.py
Normal file → Executable file
0
examples/aloha_real/robot_utils.py
Normal file → Executable file
0
examples/aloha_real/video_display.py
Normal file → Executable file
0
examples/aloha_real/video_display.py
Normal file → Executable file
0
examples/aloha_sim/Dockerfile
Normal file → Executable file
0
examples/aloha_sim/Dockerfile
Normal file → Executable file
0
examples/aloha_sim/README.md
Normal file → Executable file
0
examples/aloha_sim/README.md
Normal file → Executable file
0
examples/aloha_sim/compose.yml
Normal file → Executable file
0
examples/aloha_sim/compose.yml
Normal file → Executable file
0
examples/aloha_sim/env.py
Normal file → Executable file
0
examples/aloha_sim/env.py
Normal file → Executable file
0
examples/aloha_sim/main.py
Normal file → Executable file
0
examples/aloha_sim/main.py
Normal file → Executable file
0
examples/aloha_sim/requirements.in
Normal file → Executable file
0
examples/aloha_sim/requirements.in
Normal file → Executable file
0
examples/aloha_sim/requirements.txt
Normal file → Executable file
0
examples/aloha_sim/requirements.txt
Normal file → Executable file
0
examples/aloha_sim/saver.py
Normal file → Executable file
0
examples/aloha_sim/saver.py
Normal file → Executable file
0
examples/droid/README.md
Normal file → Executable file
0
examples/droid/README.md
Normal file → Executable file
0
examples/droid/main.py
Normal file → Executable file
0
examples/droid/main.py
Normal file → Executable file
0
examples/inference.ipynb
Normal file → Executable file
0
examples/inference.ipynb
Normal file → Executable file
0
examples/libero/Dockerfile
Normal file → Executable file
0
examples/libero/Dockerfile
Normal file → Executable file
0
examples/libero/README.md
Normal file → Executable file
0
examples/libero/README.md
Normal file → Executable file
0
examples/libero/compose.yml
Normal file → Executable file
0
examples/libero/compose.yml
Normal file → Executable file
0
examples/libero/convert_libero_data_to_lerobot.py
Normal file → Executable file
0
examples/libero/convert_libero_data_to_lerobot.py
Normal file → Executable file
0
examples/libero/main.py
Normal file → Executable file
0
examples/libero/main.py
Normal file → Executable file
0
examples/libero/requirements.in
Normal file → Executable file
0
examples/libero/requirements.in
Normal file → Executable file
0
examples/libero/requirements.txt
Normal file → Executable file
0
examples/libero/requirements.txt
Normal file → Executable file
32
examples/lyt_simple_client/Dockerfile
Executable file
32
examples/lyt_simple_client/Dockerfile
Executable file
@@ -0,0 +1,32 @@
|
||||
# Dockerfile for the simple client.
|
||||
|
||||
# Build the container:
|
||||
# docker build . -t simple_client -f examples/simple_client/Dockerfile
|
||||
|
||||
# Run the container:
|
||||
# docker run --rm -it --network=host -v .:/app simple_client /bin/bash
|
||||
|
||||
FROM python:3.7-slim
|
||||
COPY --from=ghcr.io/astral-sh/uv:0.5.1 /uv /uvx /bin/
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy from the cache instead of linking since it's a mounted volume
|
||||
ENV UV_LINK_MODE=copy
|
||||
|
||||
# Write the virtual environment outside of the project directory so it doesn't
|
||||
# leak out of the container when we mount the application code.
|
||||
ENV UV_PROJECT_ENVIRONMENT=/.venv
|
||||
|
||||
# Copy the requirements files so we can install dependencies.
|
||||
# The rest of the project is mounted as a volume, so we don't need to rebuild on changes.
|
||||
# This strategy is best for development-style usage.
|
||||
COPY ./examples/simple_client/requirements.txt /tmp/requirements.txt
|
||||
COPY ./packages/openpi-client/pyproject.toml /tmp/openpi-client/pyproject.toml
|
||||
|
||||
# Install python dependencies.
|
||||
RUN uv venv --python 3.7 $UV_PROJECT_ENVIRONMENT
|
||||
RUN uv pip sync /tmp/requirements.txt /tmp/openpi-client/pyproject.toml
|
||||
ENV PYTHONPATH=/app:/app/src:/app/packages/openpi-client/src
|
||||
|
||||
CMD /bin/bash -c "source /.venv/bin/activate && python examples/simple_client/main.py $SERVER_ARGS"
|
||||
30
examples/lyt_simple_client/README.md
Executable file
30
examples/lyt_simple_client/README.md
Executable file
@@ -0,0 +1,30 @@
|
||||
# Simple Client
|
||||
|
||||
A minimal client that sends observations to the server and prints the inference rate.
|
||||
|
||||
You can specify which runtime environment to use using the `--env` flag. You can see the available options by running:
|
||||
|
||||
```bash
|
||||
uv run examples/simple_client/main.py --help
|
||||
```
|
||||
|
||||
## With Docker
|
||||
|
||||
```bash
|
||||
export SERVER_ARGS="--env ALOHA_SIM"
|
||||
docker compose -f examples/simple_client/compose.yml up --build
|
||||
```
|
||||
|
||||
## Without Docker
|
||||
|
||||
Terminal window 1:
|
||||
|
||||
```bash
|
||||
uv run examples/simple_client/main.py --env DROID
|
||||
```
|
||||
|
||||
Terminal window 2:
|
||||
|
||||
```bash
|
||||
uv run scripts/serve_policy.py --env DROID
|
||||
```
|
||||
42
examples/lyt_simple_client/compose.yml
Executable file
42
examples/lyt_simple_client/compose.yml
Executable file
@@ -0,0 +1,42 @@
|
||||
# Run with:
|
||||
# docker compose -f examples/simple_client/compose.yml up --build
|
||||
services:
|
||||
runtime:
|
||||
image: simple_client
|
||||
depends_on:
|
||||
- openpi_server
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: examples/simple_client/Dockerfile
|
||||
init: true
|
||||
tty: true
|
||||
network_mode: host
|
||||
volumes:
|
||||
- $PWD:/app
|
||||
environment:
|
||||
- SERVER_ARGS
|
||||
|
||||
openpi_server:
|
||||
image: openpi_server
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: scripts/docker/serve_policy.Dockerfile
|
||||
init: true
|
||||
tty: true
|
||||
network_mode: host
|
||||
volumes:
|
||||
- $PWD:/app
|
||||
- ${OPENPI_DATA_HOME:-~/.cache/openpi}:/openpi_assets
|
||||
environment:
|
||||
- SERVER_ARGS
|
||||
- OPENPI_DATA_HOME=/openpi_assets
|
||||
- IS_DOCKER=true
|
||||
|
||||
# Comment out this block if not running on a machine with GPUs.
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: 1
|
||||
capabilities: [gpu]
|
||||
90
examples/lyt_simple_client/main.py
Executable file
90
examples/lyt_simple_client/main.py
Executable file
@@ -0,0 +1,90 @@
|
||||
import dataclasses
|
||||
import enum
|
||||
import logging
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from openpi_client import websocket_client_policy as _websocket_client_policy
|
||||
import tyro
|
||||
|
||||
|
||||
class EnvMode(enum.Enum):
|
||||
"""Supported environments."""
|
||||
|
||||
ALOHA = "aloha"
|
||||
ALOHA_SIM = "aloha_sim"
|
||||
DROID = "droid"
|
||||
LIBERO = "libero"
|
||||
AGILEX_ALOHA = "agilex_aloha"
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Args:
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8000
|
||||
|
||||
env: EnvMode = EnvMode.ALOHA_SIM
|
||||
num_steps: int = 10
|
||||
|
||||
|
||||
def main(args: Args) -> None:
|
||||
obs_fn = {
|
||||
EnvMode.ALOHA: _random_observation_aloha,
|
||||
EnvMode.ALOHA_SIM: _random_observation_aloha,
|
||||
EnvMode.DROID: _random_observation_droid,
|
||||
EnvMode.LIBERO: _random_observation_libero,
|
||||
}[args.env]
|
||||
|
||||
policy = _websocket_client_policy.WebsocketClientPolicy(
|
||||
host=args.host,
|
||||
port=args.port,
|
||||
)
|
||||
logging.info(f"Server metadata: {policy.get_server_metadata()}")
|
||||
|
||||
# Send 1 observation to make sure the model is loaded.
|
||||
policy.infer(obs_fn())
|
||||
|
||||
start = time.time()
|
||||
for _ in range(args.num_steps):
|
||||
policy.infer(obs_fn())
|
||||
end = time.time()
|
||||
|
||||
print(f"Total time taken: {end - start:.2f} s")
|
||||
print(f"Average inference time: {1000 * (end - start) / args.num_steps:.2f} ms")
|
||||
|
||||
|
||||
def _random_observation_aloha() -> dict:
|
||||
return {
|
||||
"state": np.ones((14,)),
|
||||
"images": {
|
||||
"cam_high": np.random.randint(256, size=(3, 224, 224), dtype=np.uint8),
|
||||
"cam_low": np.random.randint(256, size=(3, 224, 224), dtype=np.uint8),
|
||||
"cam_left_wrist": np.random.randint(256, size=(3, 224, 224), dtype=np.uint8),
|
||||
"cam_right_wrist": np.random.randint(256, size=(3, 224, 224), dtype=np.uint8),
|
||||
},
|
||||
"prompt": "do something",
|
||||
}
|
||||
|
||||
|
||||
def _random_observation_droid() -> dict:
|
||||
return {
|
||||
"observation/exterior_image_1_left": np.random.randint(256, size=(224, 224, 3), dtype=np.uint8),
|
||||
"observation/wrist_image_left": np.random.randint(256, size=(224, 224, 3), dtype=np.uint8),
|
||||
"observation/joint_position": np.random.rand(7),
|
||||
"observation/gripper_position": np.random.rand(1),
|
||||
"prompt": "do something",
|
||||
}
|
||||
|
||||
|
||||
def _random_observation_libero() -> dict:
|
||||
return {
|
||||
"observation/state": np.random.rand(8),
|
||||
"observation/image": np.random.randint(256, size=(224, 224, 3), dtype=np.uint8),
|
||||
"observation/wrist_image": np.random.randint(256, size=(224, 224, 3), dtype=np.uint8),
|
||||
"prompt": "do something",
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
main(tyro.cli(Args))
|
||||
2
examples/lyt_simple_client/requirements.in
Executable file
2
examples/lyt_simple_client/requirements.in
Executable file
@@ -0,0 +1,2 @@
|
||||
numpy
|
||||
tyro
|
||||
27
examples/lyt_simple_client/requirements.txt
Executable file
27
examples/lyt_simple_client/requirements.txt
Executable file
@@ -0,0 +1,27 @@
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile examples/simple_client/requirements.in -o examples/simple_client/requirements.txt --python-version 3.7
|
||||
backports-cached-property==1.0.2
|
||||
# via tyro
|
||||
docstring-parser==0.16
|
||||
# via tyro
|
||||
eval-type-backport==0.1.3
|
||||
# via tyro
|
||||
markdown-it-py==2.2.0
|
||||
# via rich
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
numpy==1.21.6
|
||||
# via -r examples/simple_client/requirements.in
|
||||
pygments==2.17.2
|
||||
# via rich
|
||||
rich==13.8.1
|
||||
# via tyro
|
||||
shtab==1.7.1
|
||||
# via tyro
|
||||
typing-extensions==4.7.1
|
||||
# via
|
||||
# markdown-it-py
|
||||
# rich
|
||||
# tyro
|
||||
tyro==0.9.1
|
||||
# via -r examples/simple_client/requirements.in
|
||||
0
examples/policy_records.ipynb
Normal file → Executable file
0
examples/policy_records.ipynb
Normal file → Executable file
0
examples/simple_client/Dockerfile
Normal file → Executable file
0
examples/simple_client/Dockerfile
Normal file → Executable file
0
examples/simple_client/README.md
Normal file → Executable file
0
examples/simple_client/README.md
Normal file → Executable file
0
examples/simple_client/compose.yml
Normal file → Executable file
0
examples/simple_client/compose.yml
Normal file → Executable file
0
examples/simple_client/main.py
Normal file → Executable file
0
examples/simple_client/main.py
Normal file → Executable file
0
examples/simple_client/requirements.in
Normal file → Executable file
0
examples/simple_client/requirements.in
Normal file → Executable file
0
examples/simple_client/requirements.txt
Normal file → Executable file
0
examples/simple_client/requirements.txt
Normal file → Executable file
0
examples/ur5/README.md
Normal file → Executable file
0
examples/ur5/README.md
Normal file → Executable file
0
packages/openpi-client/pyproject.toml
Normal file → Executable file
0
packages/openpi-client/pyproject.toml
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/__init__.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/__init__.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/action_chunk_broker.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/action_chunk_broker.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/base_policy.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/base_policy.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/image_tools.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/image_tools.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/image_tools_test.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/image_tools_test.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/msgpack_numpy.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/msgpack_numpy.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/msgpack_numpy_test.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/msgpack_numpy_test.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/agent.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/agent.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/agents/policy_agent.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/agents/policy_agent.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/environment.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/environment.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/runtime.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/runtime.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/subscriber.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/runtime/subscriber.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/websocket_client_policy.py
Normal file → Executable file
0
packages/openpi-client/src/openpi_client/websocket_client_policy.py
Normal file → Executable file
0
pyproject.toml
Normal file → Executable file
0
pyproject.toml
Normal file → Executable file
0
scripts/__init__.py
Normal file → Executable file
0
scripts/__init__.py
Normal file → Executable file
0
scripts/compute_norm_stats.py
Normal file → Executable file
0
scripts/compute_norm_stats.py
Normal file → Executable file
0
scripts/docker/compose.yml
Normal file → Executable file
0
scripts/docker/compose.yml
Normal file → Executable file
0
scripts/docker/serve_policy.Dockerfile
Normal file → Executable file
0
scripts/docker/serve_policy.Dockerfile
Normal file → Executable file
0
scripts/serve_policy.py
Normal file → Executable file
0
scripts/serve_policy.py
Normal file → Executable file
0
scripts/train.py
Normal file → Executable file
0
scripts/train.py
Normal file → Executable file
0
scripts/train_test.py
Normal file → Executable file
0
scripts/train_test.py
Normal file → Executable file
0
src/openpi/__init__.py
Normal file → Executable file
0
src/openpi/__init__.py
Normal file → Executable file
0
src/openpi/conftest.py
Normal file → Executable file
0
src/openpi/conftest.py
Normal file → Executable file
0
src/openpi/models/__init__.py
Normal file → Executable file
0
src/openpi/models/__init__.py
Normal file → Executable file
0
src/openpi/models/gemma.py
Normal file → Executable file
0
src/openpi/models/gemma.py
Normal file → Executable file
0
src/openpi/models/gemma_fast.py
Normal file → Executable file
0
src/openpi/models/gemma_fast.py
Normal file → Executable file
0
src/openpi/models/lora.py
Normal file → Executable file
0
src/openpi/models/lora.py
Normal file → Executable file
0
src/openpi/models/lora_test.py
Normal file → Executable file
0
src/openpi/models/lora_test.py
Normal file → Executable file
0
src/openpi/models/model.py
Normal file → Executable file
0
src/openpi/models/model.py
Normal file → Executable file
0
src/openpi/models/model_test.py
Normal file → Executable file
0
src/openpi/models/model_test.py
Normal file → Executable file
0
src/openpi/models/pi0.py
Normal file → Executable file
0
src/openpi/models/pi0.py
Normal file → Executable file
0
src/openpi/models/pi0_fast.py
Normal file → Executable file
0
src/openpi/models/pi0_fast.py
Normal file → Executable file
0
src/openpi/models/pi0_test.py
Normal file → Executable file
0
src/openpi/models/pi0_test.py
Normal file → Executable file
0
src/openpi/models/siglip.py
Normal file → Executable file
0
src/openpi/models/siglip.py
Normal file → Executable file
0
src/openpi/models/tokenizer.py
Normal file → Executable file
0
src/openpi/models/tokenizer.py
Normal file → Executable file
0
src/openpi/models/tokenizer_test.py
Normal file → Executable file
0
src/openpi/models/tokenizer_test.py
Normal file → Executable file
0
src/openpi/models/vit.py
Normal file → Executable file
0
src/openpi/models/vit.py
Normal file → Executable file
0
src/openpi/policies/aloha_policy.py
Normal file → Executable file
0
src/openpi/policies/aloha_policy.py
Normal file → Executable file
0
src/openpi/policies/droid_policy.py
Normal file → Executable file
0
src/openpi/policies/droid_policy.py
Normal file → Executable file
0
src/openpi/policies/libero_policy.py
Normal file → Executable file
0
src/openpi/policies/libero_policy.py
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user