-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
219 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2020-2021 CrowdBot | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in the | ||
Software without restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the | ||
Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Author: Javad Amirian | ||
# Email: [email protected] | ||
|
||
import datetime | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import matplotlib | ||
from adjustText import adjust_text | ||
import matplotlib.dates as mdates | ||
# import seaborn as sns | ||
# matplotlib.use('TkAgg') | ||
|
||
# Read the table | ||
table_file = '/home/cyrus/Dropbox/OpenTraj-paper/presentation/trajnet-leaders.xls' | ||
data = pd.read_excel(table_file, header=0) | ||
ADEs = data["ADE"] | ||
FDEs = data["FDE"] | ||
date_objs = [] | ||
for date in data["Date"]: | ||
year_month = date.split('-') | ||
date_obj = datetime.datetime(year=int(year_month[0]), month=int(year_month[1]), day=1) | ||
date_objs.append(date_obj) | ||
dates = matplotlib.dates.date2num(date_objs) | ||
|
||
# Plots | ||
fig, ax = plt.subplots(nrows=1, ncols=1) | ||
|
||
# matplotlib.pyplot.plot_date(dates, FDEs, 'bx', label="FDE") | ||
# name_texts = [plt.text(dates[i], FDEs[i], pred_name, horizontalalignment='center') | ||
# for i, pred_name in enumerate(data["Predictor"])] | ||
|
||
matplotlib.pyplot.plot_date(dates, ADEs, 'bo', | ||
label="Average Displacement Error") | ||
name_texts = [plt.text(dates[i], ADEs[i], pred_name, | ||
color="magenta" if "DCNet" in pred_name else "black") | ||
for i, pred_name in enumerate(data["Predictor"])] | ||
plt.ylim([0.21, 0.53]) | ||
arrows = adjust_text(name_texts, arrowprops=dict(arrowstyle='->', color='red')) | ||
|
||
plt.grid(axis='both', linestyle='--') | ||
plt.ylabel("Prediction Error", fontweight='bold') | ||
|
||
|
||
plt.xlim([min(dates)-500, max(dates) + 300]) | ||
plt.xticks([datetime.datetime(1995, 1, 1), | ||
datetime.datetime(2016, 1, 1), | ||
datetime.datetime(2018, 1, 1), | ||
datetime.datetime(2019, 1, 1), | ||
datetime.datetime(2020, 1, 1), | ||
datetime.datetime(2021, 1, 1)], rotation=45) | ||
myFmt = mdates.DateFormatter('%Y') | ||
ax.xaxis.set_major_formatter(myFmt) | ||
plt.xlabel("Origin of the Idea", labelpad=-15, fontweight='bold') | ||
|
||
ax.set_facecolor((0.90, 0.97, 0.82)) | ||
plt.legend(loc="lower left") | ||
plt.title("Trajnet Benchmark (World Plane Human-Human Dataset)") | ||
plt.show() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Author: Javad Amirian | ||
# Email: [email protected] | ||
|
||
# Run this app with `python app.py` and | ||
import os | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import dash | ||
import dash_core_components as dcc | ||
import dash_html_components as html | ||
import dash_bootstrap_components as dbc | ||
import plotly.express as px | ||
import plotly.graph_objects as go | ||
from dash.dependencies import Input, Output | ||
|
||
from toolkit.loaders.loader_crowds import load_crowds | ||
from toolkit.benchmarking.load_all_datasets import all_dataset_names, get_datasets, get_trajlets | ||
|
||
# Application | ||
# =========================================== | ||
# see https://plotly.com/python/px-arguments/ for more options | ||
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | ||
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | ||
# ---------------------- | ||
|
||
|
||
# default values | ||
# ---------------------- | ||
traj_dataset = pd.DataFrame({}) | ||
cur_time = 0 | ||
time_horizon = [-4.8, 4.8] | ||
traj_fig = go.Figure() | ||
graph_height = 800 | ||
time_horizon_marks = [0.4, 0.8, 1.6, 3.2, 4.8, 9.6] | ||
time_horizon_marks = [-x for x in time_horizon_marks[::-1]] + [0] + time_horizon_marks | ||
cur_time_slider = dcc.Slider(id='cur_time', min=0, max=1000, step=0.1, value=0, updatemode='drag') | ||
|
||
# Biuld the layout | ||
# dbc.Spinner() | ||
app.layout = html.Div(children=[ | ||
html.H2('OpenTraj'), | ||
html.H5('Benchmarking Human Trajectory Prediction Datasets'), | ||
html.Hr(), | ||
dbc.Container(['OpenTraj Root: ', | ||
dcc.Input(id='opentraj_root', type='text', spellCheck='false', | ||
placeholder='Enter path to the root directory of OpenTraj', | ||
# value='Enter the path to the root directory of OpenTraj', | ||
value='/home/cyrus/workspace2/OpenTraj', | ||
inputMode="url", style={'width': 360})], | ||
fluid=True, id='opentraj_root_container'), | ||
dcc.Dropdown(id='select_dataset', placeholder='Select Dataset...', | ||
options=[{'label': ds_name, 'value': ds_name} for ds_name in all_dataset_names], multi=False), | ||
dcc.Graph(id='traj_graph', figure=traj_fig, style={'height': graph_height}), | ||
cur_time_slider, | ||
dcc.RangeSlider(id='time_horizon', min=time_horizon_marks[0], max=time_horizon_marks[-1], step=0.1, | ||
marks=dict( | ||
zip(time_horizon_marks, ['%s%.1fs' % (["", "+"][x > 0.001], x) for x in time_horizon_marks])), | ||
value=[-4.8, 4.8], updatemode='drag') | ||
]) | ||
|
||
|
||
@app.callback(Output('cur_time', 'max'), | ||
Input('opentraj_root', 'value'), | ||
Input('select_dataset', 'value')) | ||
def load_dataset(opentraj_root, dataset_name): | ||
if os.path.exists(opentraj_root) \ | ||
and os.path.exists(os.path.join(opentraj_root, 'datasets')) and dataset_name: | ||
global traj_dataset, traj_fig, cur_time | ||
cur_time = 0 | ||
traj_datasets = get_datasets(opentraj_root, [dataset_name]) | ||
if dataset_name in traj_datasets: | ||
traj_dataset = traj_datasets[dataset_name].data | ||
return np.max(traj_dataset["timestamp"]) | ||
return 0 | ||
|
||
|
||
@app.callback(Output('traj_graph', 'figure'), | ||
Input('cur_time', 'value'), | ||
Input('time_horizon', 'value'), | ||
Input('opentraj_root', 'value'), | ||
Input('select_dataset', 'value') | ||
) | ||
def update_graph(cur_time_, time_horizon_, _, __): | ||
global cur_time, time_horizon | ||
cur_time, time_horizon = cur_time_, time_horizon_ | ||
fig = go.Figure() | ||
if len(traj_dataset): | ||
print("Scatter Trajs...") | ||
selected_data = traj_dataset[(traj_dataset["timestamp"] >= cur_time + time_horizon[0]) | ||
& (traj_dataset["timestamp"] <= cur_time + time_horizon[1])] | ||
print("len selected data = ", len(selected_data)) | ||
trajs = selected_data.groupby(["scene_id", "agent_id"]) | ||
trajs = [(scene_id, agent_id, tr) for (scene_id, agent_id), tr in trajs] | ||
|
||
cur_poss = [] | ||
for scene_id, agent_id, traj in trajs: | ||
fig.add_scatter(x=traj["pos_x"], y=traj["pos_y"], name="%s[%d]" % (scene_id, agent_id), | ||
mode="lines+markers") | ||
if len(traj): | ||
# print(agent_id) | ||
# print(traj[traj["timestamp"] <= cur_time]) | ||
cur_poss.append(traj[traj["timestamp"] <= cur_time].iloc[-1][["pos_x", "pos_y"]].to_numpy()) | ||
cur_poss = np.stack(cur_poss) | ||
fig.add_scatter(x=cur_poss[:, 0], y=cur_poss[:, 1], mode="markers", showlegend=False) | ||
fig['layout']['xaxis'].update(title='', range=[np.min(traj_dataset["pos_x"]), np.max(traj_dataset["pos_x"])], | ||
dtick=2.5, autorange=False) | ||
fig['layout']['yaxis'].update(title='', range=[np.min(traj_dataset["pos_y"]), np.max(traj_dataset["pos_y"])], | ||
dtick=2.5, autorange=False) | ||
fig.update_yaxes(scaleanchor="x", scaleratio=1) | ||
return fig | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run_server(debug=True, port=8051) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='opentraj', | ||
version='0.1.0', | ||
author='Javad Amirian', | ||
author_email='[email protected]', | ||
packages=['package_name', 'package_name.test'], | ||
scripts=['bin/script1','bin/script2'], | ||
url='https://github.com/crowdbotp/OpenTraj', | ||
license='MIT', | ||
description='Tools for working with trajectory datasets', | ||
long_description=open('README.txt').read(), | ||
install_requires=[ | ||
"pytest", | ||
], | ||
) |