Skip to main content

Python API to communicate with the VirtualCity environment

Project description

docs docs

VirtualCity

VirtualCity is a powerful platform to simulate social activities. Agents can interact with the environment through low-level commands (turn left, go forward) or high-level instructions (drive to the park). The interactive environment is based in a densely populated photorealistic city with its own crowd and traffic system.

VirtualCity is built on the Unreal Engine. We provide the Python interface allowing users to change/add environments and control agents easily. Furthermore, the API also provides additional capabilities for training reinforcement learning and computer vision models. We also provide the code required to compile the project in the Unreal Engine 5 editor. The code is designed to be modular, making it easy for you to quickly add new features and capabilities for your research project.

Installation

Note: VirtualCity only supports Nvidia GPUs (Ampere, Turing, Volta, Pascal), and it is recommended to use CPU architectures with high single core performance.

Install using pip

Install the VirtualCity package:

pip install virtualcity

Please read the documentation for more details and alternatives (from source, using docker).

Example

Here is a quick example of how to train and run PPO on a VirtualCity environment:

import gym
import virtualcity
from stable_baselines3 import PPO

env = gym.make("VirtualCity")

model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10000)

obs = env.reset()
for i in range(1000):
    action, _states = model.predict(obs, deterministic=True)
    obs, reward, done, info = env.step(action)
    env.render()
    if done:
      obs = env.reset()

env.close()

Or you can train a model on the VirtualCity environment if the policy is registered in StableBaselines3:

import gym
import virtualcity
from stable_baselines3 import PPO

model = PPO('MlpPolicy', 'VirtualCity').learn(10000)

Please read the documentation for more examples.

Citing the Project

To cite this repository in publications:

@article{virtualcity,
  author  = {Shuang Li and Kabir Swain},
  title   = {VirtualCity},
  year    = {2022}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtualcity-0.0.5.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

virtualcity-0.0.5-py3-none-any.whl (2.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page