Skip to content

Commit

Permalink
Merge pull request #13 from hmorimitsu/plotly
Browse files Browse the repository at this point in the history
Plotly
  • Loading branch information
hmorimitsu authored Jul 12, 2021
2 parents bb9318f + 2a3e9c9 commit a068a50
Show file tree
Hide file tree
Showing 18 changed files with 368 additions and 40 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ ptlflow_logs/
ptlflow_scripts/
outputs/

docs/source/_*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
64 changes: 64 additions & 0 deletions docs/source/_static/kitti_2012_epe_outlier-drop_kitti_sintel.html

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions docs/source/_static/kitti_2015_epe_outlier-drop_kitti_sintel.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions docs/source/_static/speed_plot-all.html

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions docs/source/results/accuracy_plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ EPE vs. Outliers
Sintel Clean
============

.. image:: sintel_clean_epe_outlier-drop_kitti_sintel.png
:width: 600
:alt: Plot of end-point-error vs. outliers of the available models on the Sintel Clean dataset.
.. raw:: html

<iframe src="../_static/sintel_clean_epe_outlier-drop_kitti_sintel.html" height="600px" width="100%"></iframe>

Sintel Final
============

.. image:: sintel_final_epe_outlier-drop_kitti_sintel.png
:width: 600
:alt: Plot of end-point-error vs. outliers of the available models on the Sintel Final dataset.
.. raw:: html

<iframe src="../_static/sintel_final_epe_outlier-drop_kitti_sintel.html" height="600px" width="100%"></iframe>

KITTI 2012
==========
.. image:: kitti_2012_epe_outlier-drop_kitti_sintel.png
:width: 600
:alt: Plot of end-point-error vs. outliers of the available models on the Kitti 2012 dataset.

.. raw:: html

<iframe src="../_static/kitti_2012_epe_outlier-drop_kitti_sintel.html" height="600px" width="100%"></iframe>

KITTI 2015
==========
.. image:: kitti_2015_epe_outlier-drop_kitti_sintel.png
:width: 600
:alt: Plot of end-point-error vs. outliers of the available models on the Kitti 2015 dataset.

.. raw:: html

<iframe src="../_static/kitti_2015_epe_outlier-drop_kitti_sintel.html" height="600px" width="100%"></iframe>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed docs/source/results/speed_plot-all.png
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/source/results/speed_plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Inference speed vs. Trainable parameters
========================================

.. image:: speed_plot-all.png
:width: 600
:alt: Plot of inference speed vs. trainable parameters of the available models.
.. raw:: html

<iframe src="../_static/speed_plot-all.html" height="600px" width="100%"></iframe>

Environment
-----------
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
matplotlib >= 3.0
numpy >= 1.17.0
opencv-python >= 4.0.0.21
pandas >= 1.1.0
pillow >= 5.0
plotly >= 5.0.0
pypng >= 0.0.16
pytorch-lightning >= 1.1.0
requests >= 2.0.0
scipy >= 1.0.0
seaborn >= 0.9
tabulate >= 0.8.3
torch >= 1.7.0
torchmetrics >= 0.2
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,15 @@ classifiers =
packages = find:
include_package_data = True
install_requires =
matplotlib >= 3.0
numpy >= 1.17.0
opencv-python >= 4.0.0.21
pandas >= 1.1.0
pillow >= 5.0
plotly >= 5.0.0
pypng >= 0.0.16
pytorch-lightning >= 1.1.0
requests >= 2.0.0
scipy >= 1.0.0
seaborn >= 0.9
tabulate >= 0.8.3
torch >= 1.7.0
torchmetrics >= 0.2
Expand Down
24 changes: 15 additions & 9 deletions speed_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
from pathlib import Path
from typing import Union

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import plotly.express as px
import torch
from tqdm import tqdm

Expand Down Expand Up @@ -156,13 +155,19 @@ def save_plot(
log10_col = TABLE_COLS[1]+'(Log10)'
df_tmp = df.copy()
df_tmp[log10_col] = np.log10(df[TABLE_COLS[1]])
plt.figure(figsize=(10, 10))
sns.scatterplot(data=df_tmp, x=log10_col, y=TABLE_COLS[2], hue=TABLE_COLS[0], style=TABLE_COLS[0], s=300)
plt.legend(loc=2, borderaxespad=0)
plt.title('Parameters x Forward time')
plt.tight_layout()
plt.savefig(output_dir / f'speed_plot-{model_name}.png')
plt.close()

fig = px.scatter(
df, x=TABLE_COLS[1], y=TABLE_COLS[2], color=TABLE_COLS[0], symbol=TABLE_COLS[0], log_x=True,
title='Parameters x Forward time')
fig.update_traces(
marker={
'size': 20,
'line': {'width': 2, 'color': 'DarkSlateGrey'}},
selector={'mode': 'markers'})
fig.update_layout(
title_font_size=30
)
fig.write_html(output_dir / f'speed_plot-{model_name}.html')


if __name__ == '__main__':
Expand All @@ -173,5 +178,6 @@ def save_plot(
df = benchmark(args)
else:
df = pd.read_csv(args.csv_path)
Path(args.output_path).mkdir(parents=True, exist_ok=True)
save_plot(args.output_path, args.model, df)
print(f'Results saved to {str(args.output_path)}.')
22 changes: 13 additions & 9 deletions summary_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
import argparse
from pathlib import Path

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import plotly.express as px


def _init_parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -110,16 +109,21 @@ def save_plots(

for dataset_name, col_pair_dict in metric_pairs.items():
col1, col2 = col_pair_dict.values()
plt.figure(figsize=(10, 10))
sns.scatterplot(data=df, x=col1, y=col2, hue=df.columns[0], style=df.columns[1], s=300)
plt.legend(loc=4, borderaxespad=0)
plt.title(f'{dataset_name} - {args.chosen_metrics[0]} x {args.chosen_metrics[1]}')
plt.tight_layout()
fig = px.scatter(
df, x=col1, y=col2, color=df.columns[0], symbol=df.columns[1],
title=f'{dataset_name} - {args.chosen_metrics[0]} x {args.chosen_metrics[1]}')
fig.update_traces(
marker={
'size': 20,
'line': {'width': 2, 'color': 'DarkSlateGrey'}},
selector={'mode': 'markers'})
fig.update_layout(
title_font_size=30
)
file_name = f'{dataset_name}_{args.chosen_metrics[0]}_{args.chosen_metrics[1]}'
if args.drop_checkpoints is not None and len(args.drop_checkpoints) > 0:
file_name += f'-drop_{"_".join(args.drop_checkpoints)}'
plt.savefig(args.output_dir / (file_name+'.png'))
plt.close()
fig.write_html(args.output_dir / (file_name+'.html'))


def summarize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_summary_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def test_summary(tmp_path: Path) -> None:

assert len(list(tmp_path.glob('**/*.md'))) > 0
assert len(list(tmp_path.glob('**/*.csv'))) > 0
assert len(list(tmp_path.glob('**/*.png'))) > 0
assert len(list(tmp_path.glob('**/*.html'))) > 0

shutil.rmtree(tmp_path)

0 comments on commit a068a50

Please sign in to comment.