Unreal environments for reinforcement learning
This project integrates Unreal Engine with OpenAI Gym for visual reinforcement learning based on UnrealCV.
In this project, you can run (Multi-Agent) Reinforcement Learning algorithms in various realistic UE4 environments easily without any knowledge of Unreal Engine and UnrealCV.
A number of environments have been released for robotic vision tasks, including Active object tracking
, Searching for objects
, and Robot arm control
.
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
The framework of this project is shown below:
UnrealCV
is the basic bridge between Unreal Engine
and OpenAI Gym
.OpenAI Gym
is a toolkit for developing an RL algorithm, compatible with most numerical computation libraries, such as TensorFlow or PyTorch. We recommend you use anaconda to install and manage your Python environment.CV2
is used for image processing, like extracting object masks and bounding boxes. Matplotlib
is used for visualization.
It is easy to install gym-unrealcv, just run
git clone https://github.com/zfw1226/gym-unrealcv.git
cd gym-unrealcv
pip install -e .
While installing gym-unrealcv, dependencies including OpenAI Gym, unrealcv, numpy and matplotlib are installed.Opencv
should be installed additionally.
If you use anaconda
, you can run
conda update conda
conda install --channel menpo opencv
or
pip install opencv-python
Before running the environments, you need to prepare unreal binaries.
You can load them from clouds by running load_env.py
python load_env.py -e {ENV_NAME}
ENV_NAME
can be RealisticRoom
, RandomRoom
, Arm
, etc.
After that, it will automatically download a related env binary
to the UnrealEnv directory.
Please refer the binary_list
in load_env.py for more available example environments.
Once gym-unrealcv
is installed successfully, you will see that your agent is walking randomly in first-person view to find a door, after you run:
cd example/random
python random_agent.py -e UnrealSearch-RealisticRoomDoor-DiscreteColor-v0
After that, if all goes well, a pre-defined gym environment UnrealSearch-RealisticRoomDoor-DiscreteColor-v0
will be launched.
And then you will see that your agent is moving around the room randomly.
We list the pre-defined environments in this page, for object searching and active object tracking.
To demonstrate how to train an agent in gym-unrealcv, we provide DQN (Keras) and DDPG (Keras) codes in .example.
Moreover, you can also refer to some recent projects for more advanced usages, as follows:
control a robot arm
via DDPG (PyTorch).single-agent RL
, adversarial RL
, and multi-agent games
.multiple PTZ cameras single target environments
.We provide a set of tutorials to help you get started with Gym-UnrealCV.
You can follow the modify_env_tutorial to modify the configuration of the pre-defined environment.
You can follow the add_new_env_tutorial to add a new unreal environment for your RL task.
🎉 Please feel free to pull requests or open an issue to add papers.
If you use Gym-UnrealCV in your academic research, we would be grateful if you could cite it as follow:
@misc{gymunrealcv2017,
author = {Fangwei Zhong, Weichao Qiu, Tingyun Yan, Alan Yuille, Yizhou Wang},
title = {Gym-UnrealCV: Realistic virtual worlds for visual reinforcement learning},
howpublished={Web Page},
url = {https://github.com/unrealcv/gym-unrealcv},
year = {2017}
}
If you have any suggestions or are interested in using Gym-UnrealCV, get in touch at zfw1226@gmail.com">zfw1226 [at] gmail [dot] com.