diff --git a/README.md b/README.md index efd5eedf..601a66d9 100644 --- a/README.md +++ b/README.md @@ -97,10 +97,13 @@ pip install -e . openrl --version ``` +**Tips**:无需安装,通过Colab在线试用OpenRL: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/15VBA-B7AJF8dBazzRcWAxJxZI7Pl9m-g?usp=sharing) + ## 使用Docker OpenRL目前也提供了包含显卡支持和非显卡支持的Docker镜像。 如果用户的电脑上没有英伟达显卡,则可以通过以下命令获取不包含显卡插件的镜像: + ```bash sudo docker pull openrllab/openrl-cpu ``` diff --git a/README_en.md b/README_en.md index f4b18264..7909295a 100644 --- a/README_en.md +++ b/README_en.md @@ -120,6 +120,8 @@ After installation, users can check the version of OpenRL through command line: openrl --version ``` +**Tips**: No installation required, try OpenRL online through Colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/15VBA-B7AJF8dBazzRcWAxJxZI7Pl9m-g?usp=sharing) + ## Use Docker OpenRL currently provides Docker images with and without GPU support. diff --git a/openrl/envs/vec_env/base_venv.py b/openrl/envs/vec_env/base_venv.py index b52f4ea1..1511d350 100644 --- a/openrl/envs/vec_env/base_venv.py +++ b/openrl/envs/vec_env/base_venv.py @@ -15,6 +15,7 @@ # limitations under the License. """""" +import sys import warnings from abc import ABC, abstractmethod from typing import Any, List, Optional, Sequence, Union @@ -24,6 +25,8 @@ from openrl.envs.vec_env.utils.util import tile_images +IN_COLAB = "google.colab" in sys.modules + class BaseVecEnv( ABC, @@ -158,10 +161,15 @@ def render(self, mode: Optional[str] = None) -> Optional[np.ndarray]: # Create a big image by tiling images from subprocesses bigimg = tile_images(imgs) if mode == "human": - import cv2 # pytype:disable=import-error + if IN_COLAB: + from google.colab.patches import cv2_imshow + + cv2_imshow(bigimg[:, :, ::-1]) + else: + import cv2 # pytype:disable=import-error - cv2.imshow("Vec_Env:{}".format(self.env_name), bigimg[:, :, ::-1]) - cv2.waitKey(1) + cv2.imshow("Vec_Env:{}".format(self.env_name), bigimg[:, :, ::-1]) + cv2.waitKey(1) elif mode in [None, "rgb_array"]: return bigimg else: