diff --git a/dexbotic/client.py b/dexbotic/client.py index 02f7c38..6895a85 100644 --- a/dexbotic/client.py +++ b/dexbotic/client.py @@ -1,10 +1,13 @@ from collections import deque +import logging import requests import math import numpy as np import cv2 +logger = logging.getLogger(__name__) + class DexClient: def __init__(self, @@ -86,4 +89,4 @@ def delta_action(self, last_action, delta_action): action = client.act( observation, "What action should the robot take to put both moka pots on the stove?") - print("Action taken:", action) + logger.info("Action taken: %s", action) diff --git a/dexbotic/rl/_embodied_cli.py b/dexbotic/rl/_embodied_cli.py index 73be450..8a7d92c 100644 --- a/dexbotic/rl/_embodied_cli.py +++ b/dexbotic/rl/_embodied_cli.py @@ -1,11 +1,14 @@ from __future__ import annotations import json +import logging import os import torch.multiprocessing as mp from omegaconf import OmegaConf +logger = logging.getLogger(__name__) + from rlinf.config import validate_cfg from rlinf.runners.embodied_runner import EmbodiedRunner from rlinf.scheduler import Cluster @@ -25,12 +28,10 @@ def run_embodied_rl(cfg) -> None: register_all() - print( - "[Dexbotic RL] Launching from Dexbotic entrypoint with RLinf as backend." - ) + logger.info("[Dexbotic RL] Launching from Dexbotic entrypoint with RLinf as backend.") cfg = validate_cfg(cfg) - print(json.dumps(OmegaConf.to_container(cfg, resolve=True), indent=2)) + logger.info(json.dumps(OmegaConf.to_container(cfg, resolve=True), indent=2)) cluster = Cluster( cluster_cfg=cfg.cluster, distributed_log_dir=cfg.runner.per_worker_log_path diff --git a/playground/example_navila_exp.py b/playground/example_navila_exp.py index 4dec4ea..7e2a87f 100644 --- a/playground/example_navila_exp.py +++ b/playground/example_navila_exp.py @@ -6,11 +6,14 @@ """ import argparse +import logging from collections import deque from dataclasses import dataclass, field from datetime import datetime from typing import Optional +logger = logging.getLogger(__name__) + from dexbotic.data.dataset.transform.common import Pipeline, ToDict, ToList, ToNumpy from dexbotic.data.dataset.transform.multimodal import LoadMultiModal from dexbotic.exp.navila_exp import ( @@ -139,7 +142,7 @@ def inference_single( with open(image_path, "rb") as f: image_bytes = f.read() except FileNotFoundError: - print(f"Error: image file not found {image_path}") + logger.error("Error: image file not found %s", image_path) return None images_list = self.inference_config._prepare_images(image_bytes) @@ -150,7 +153,7 @@ def inference_single( text=prompt, images=images_list, ) - print(f"Inference result: {result}") + logger.info("Inference result: %s", result) return result