Pytorch implementation for the paper:
Data-driven Crowd Simulation with Generative Adversarial Networks
Authors: Javad Amirian,
Wouter van-Toll,
Jean-Bernard Hayet,
Julien Pettre
Presented at CASA 2019 (Computer Animation and Social Agents) [arxiv], [slides]
Generally a GAN system is composed of a Generator and a Discriminator. On the left side of the figure below, you see the Trajectory Generator and on the right side, you see the Trajectory Discriminator.
However for implementation we use two separate GANs:
- Entry-Point GAN: which is responsible just for generating the first two points of a trajectory
- Predictor GAN: which takes the beginning of a trajectory and predicts the rest of it step-by-step.
We tested our system on ETH walking pedestrians dataset:
- Left: Using Gaussian Mixture Model
- Middle: Using Vanilla-GAN
- Right: Using Unrolled-GAN (our implementation)
- Left: Real Agents
- Right: Fake (Generated) Agents
In order to training the system, you need to train Entry-Point GAN
and Predictor GAN
separately:
$ cd src
$ python entrypointGAN.py
$ python predictorGAN.py
- Hyper-parameters: All the hyper-parameters are stored in
config.yaml
After training, to generate the trajectories you need to run the following command:
$ python simulation.py
On Windows, execute the program WASP-ConsoleApplication.exe via the command line. If you run it without arguments, a help text will appear that hopefully speaks for itself. With the correct arguments, the program will run a simulation and write the output to a new ".trajectories" file. The filename contains a timestamp so that it won't overwrite an existing result.
The program requires:
-
an
.env
file that describes the obstacles of an environment. You don't have to worry about this; I've already prepared such a file for each scene that we care about. -
also a
.trajectories
file that contains the input trajectories of the simulation. These should be the trajectories computed by our GAN, combined with the right start times provided by a simple scheduler.- The
XXX-filtered.trajectories
files contain the original datasets, filtered to match a certain region of interest. - The
XXX-simulation.trajectories
files contain the simulation output usingXXX.env
andXXX-filtered.trajectories
input. That is, they are the results of the command:
- The
$ WASP-ConsoleApplication "XXX.env" "XXX-filtered.trajectories" 1000 4
where XXX is of course replaced by a dataset name.
By the way, WASP means "Wouter's Agent-based Simulation Platform", and I chose this name because the orange disks in my GUI demo remind me of flying insects ;)
This is comparable the BIWI format, but with a few adjustments/simplifications.
A .trajectories
file starts with three special lines:
MATRIX 1 0 0 0 0 1 0 1 0
= A 3x3 transformation matrix (written row by row) to apply to all coordinates in the file. In our example files, you may assume that the matrix always looks like the one above, so there will be coordinates in the format "x 0 z" which denote a 2D point (x,z).FPS 10
= The number of frames per second in the simulation. In our example files, this will always be 10. Use this to translate a frame number to a timestamp.ROI 0 -12 10 0
= An axis-aligned bounding box (xmin ymin xmax ymax) describing the region of interest. Watch out: the ROI will probably be different for each scenario! Even zara01 and zara02 don't use the same coordinates. In our paper, all generated trajectories should start and end on the boundary of this region, approximately. (For each trajectory, the first and last samples will be either on this boundary or just outside it.)
After this header, the file contains many rows in the following format: frameNr agentID x y z
- To convert a frameNr to a concrete timestamp (in seconds), divide it by the FPS value.
- Agent IDs should be unique and non-negative.
- For the y-coordinate, you can most likely just print a 0 every time (if you use the same matrix given above).
- You may add more data to a line (e.g. velocities such as in the BIWI format), but it will be ignored by WASP.
Watch out: The points on a trajectory should be given in chronological order, otherwise the program won't work. However, it doesn't matter how much time there is between samples; this interval can even change during the trajectory. Also, it doesn't matter if you order the lines per frame or per agent, although I expect that an ordering per agent is easiest to make (simply write the full trajectories one by one).
On Windows, execute the program TrajectoryFileConverter.exe via the command line. If you run it without arguments, a help text will appear that hopefully speaks for itself. With the correct arguments, the program will read a ".trajectories" file and convert it to separate ".csv" files (one for each agent) to use in the ChAOS visualization program.
Watch out: The output folder should already exist, because the program does not have the right to create this folder on its own.
If you use this code for your research, please cite our paper:
@inproceedings{amirian2019crowdgan,
title={Data-Driven Crowd Simulation with Generative Adversarial Networks},
author={Amirian, Javad and Van Toll, Wouter and Hayet, Jean-Bernard and Pettr{\'e}, Julien},
booktitle={Proceedings of the 32nd International Conference on Computer Animation and Social Agents},
pages={7--10},
year={2019}
}