From 68c6276caa3832382d202dc261d1051d8336bc21 Mon Sep 17 00:00:00 2001 From: Charles Beauville Date: Wed, 9 Jun 2021 16:23:00 +0200 Subject: [PATCH] Dark theme only with webcam (#65) * Only dark theme with webcam * Fixed axes colors * Update printer.py * Fixed axes in printer.py * Fixed test images names * Fixed README * Fixed README * Fixed bird view * Linting * Linting --- .github/workflows/tests.yml | 6 ++++-- README.md | 20 +++++++++--------- docs/{test_000840.png => 000840.png} | Bin ...test_000840_right.png => 000840_right.png} | Bin docs/{test_002282.png => 002282.png} | Bin docs/{test_frame0032.jpg => frame0032.jpg} | Bin docs/{out_test_000840.jpg => out_000840.jpg} | Bin ..._000840_multi.jpg => out_000840_multi.jpg} | Bin ...png.multi.jpg => out_002282.png.multi.jpg} | Bin ...i_all.jpg => out_002282.png.multi_all.jpg} | Bin ...02282_pifpaf.jpg => out_002282_pifpaf.jpg} | Bin ..._bird.jpg => out_frame0032_front_bird.jpg} | Bin monoloco/visuals/printer.py | 16 ++++++++------ tests/test_train_mono.py | 12 +++++------ tests/test_train_stereo.py | 4 ++-- 15 files changed, 32 insertions(+), 26 deletions(-) rename docs/{test_000840.png => 000840.png} (100%) rename docs/{test_000840_right.png => 000840_right.png} (100%) rename docs/{test_002282.png => 002282.png} (100%) rename docs/{test_frame0032.jpg => frame0032.jpg} (100%) rename docs/{out_test_000840.jpg => out_000840.jpg} (100%) rename docs/{out_test_000840_multi.jpg => out_000840_multi.jpg} (100%) rename docs/{out_test_002282.png.multi.jpg => out_002282.png.multi.jpg} (100%) rename docs/{out_test_002282.png.multi_all.jpg => out_002282.png.multi_all.jpg} (100%) rename docs/{out_test_002282_pifpaf.jpg => out_002282_pifpaf.jpg} (100%) rename docs/{out_test_frame0032_front_bird.jpg => out_frame0032_front_bird.jpg} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9ea76d3..80adf7b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,14 +10,16 @@ on: paths: - 'monoloco/**' - 'test/**' - - 'docs/test*' + - 'docs/00*.png' + - 'docs/frame0032.jpg' - '.github/workflows/tests.yml' pull_request: paths: - 'monoloco/**' - 'test/**' - - 'docs/test*' + - 'docs/00*.png' + - 'docs/frame0032.jpg' - '.github/workflows/tests.yml' jobs: diff --git a/README.md b/README.md index 3fab5dc..cf44dd2 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This library is based on three research projects for monocular/stereo 3D human l [T. Mordan](https://people.epfl.ch/taylor.mordan/?lang=en), [A. Alahi](https://scholar.google.com/citations?user=UIhXQ64AAAAJ&hl=en)_, ICRA 2021
__[Article](https://arxiv.org/abs/2008.10913)__                 __[Citation](#Citation)__                 __[Video](https://www.youtube.com/watch?v=pGssROjckHU)__ - + --- @@ -125,24 +125,24 @@ If you provide a ground-truth json file to compare the predictions of the networ For an example image, run the following command: ```sh -python3 -m monoloco.run predict docs/test_002282.png \ +python3 -m monoloco.run predict docs/002282.png \ --path_gt names-kitti-200615-1022.json \ -o \ --long-edge --n_dropout <50 to include epistemic uncertainty, 0 otherwise> ``` -![predict](docs/out_test_002282.png.multi.jpg) +![predict](docs/out_002282.png.multi.jpg) To show all the instances estimated by MonoLoco add the argument `--show_all` to the above command. -![predict_all](docs/out_test_002282.png.multi_all.jpg) +![predict_all](docs/out_002282.png.multi_all.jpg) It is also possible to run [openpifpaf](https://github.com/vita-epfl/openpifpaf) directly by using `--mode keypoints`. All the other pifpaf arguments are also supported and can be checked with `python3 -m monoloco.run predict --help`. -![predict](docs/out_test_002282_pifpaf.jpg) +![predict](docs/out_002282_pifpaf.jpg) **Stereo Examples**
@@ -156,12 +156,12 @@ You can load one or more image pairs using glob expressions. For example: ```sh python3 -m monoloco.run predict --mode stereo \ ---glob docs/test_000840*.png +--glob docs/000840*.png --path_gt \ -o data/output -long_edge 2500 ``` -![Crowded scene](docs/out_test_000840_multi.jpg) +![Crowded scene](docs/out_000840_multi.jpg) ```sh python3 -m monoloco.run predict --glob docs/005523*.png \ --output_types multi \ @@ -183,7 +183,7 @@ For more info, run: **Examples**
An example from the Collective Activity Dataset is provided below. - + To visualize social distancing run the below, command: @@ -192,11 +192,11 @@ pip3 install scipy ``` ```sh -python3 -m monoloco.run predict docs/test_frame0032.jpg \ +python3 -m monoloco.run predict docs/frame0032.jpg \ --activities social_distance --output_types front bird ``` - + ## C) Hand-raising detection To detect raised hand, you can add the argument `--activities raise_hand` to the prediction command. diff --git a/docs/test_000840.png b/docs/000840.png similarity index 100% rename from docs/test_000840.png rename to docs/000840.png diff --git a/docs/test_000840_right.png b/docs/000840_right.png similarity index 100% rename from docs/test_000840_right.png rename to docs/000840_right.png diff --git a/docs/test_002282.png b/docs/002282.png similarity index 100% rename from docs/test_002282.png rename to docs/002282.png diff --git a/docs/test_frame0032.jpg b/docs/frame0032.jpg similarity index 100% rename from docs/test_frame0032.jpg rename to docs/frame0032.jpg diff --git a/docs/out_test_000840.jpg b/docs/out_000840.jpg similarity index 100% rename from docs/out_test_000840.jpg rename to docs/out_000840.jpg diff --git a/docs/out_test_000840_multi.jpg b/docs/out_000840_multi.jpg similarity index 100% rename from docs/out_test_000840_multi.jpg rename to docs/out_000840_multi.jpg diff --git a/docs/out_test_002282.png.multi.jpg b/docs/out_002282.png.multi.jpg similarity index 100% rename from docs/out_test_002282.png.multi.jpg rename to docs/out_002282.png.multi.jpg diff --git a/docs/out_test_002282.png.multi_all.jpg b/docs/out_002282.png.multi_all.jpg similarity index 100% rename from docs/out_test_002282.png.multi_all.jpg rename to docs/out_002282.png.multi_all.jpg diff --git a/docs/out_test_002282_pifpaf.jpg b/docs/out_002282_pifpaf.jpg similarity index 100% rename from docs/out_test_002282_pifpaf.jpg rename to docs/out_002282_pifpaf.jpg diff --git a/docs/out_test_frame0032_front_bird.jpg b/docs/out_frame0032_front_bird.jpg similarity index 100% rename from docs/out_test_frame0032_front_bird.jpg rename to docs/out_frame0032_front_bird.jpg diff --git a/monoloco/visuals/printer.py b/monoloco/visuals/printer.py index 6ce0b88..56ecf84 100644 --- a/monoloco/visuals/printer.py +++ b/monoloco/visuals/printer.py @@ -114,7 +114,8 @@ class Printer: def factory_axes(self, dic_out): """Create axes for figures: front bird multi""" - plt.style.use('dark_background') + if self.webcam: + plt.style.use('dark_background') axes = [] figures = [] @@ -217,7 +218,8 @@ class Printer: def _bird_loop(self, iterator, axes, colors, number): for idx in iterator: if any(xx in self.output_types for xx in ['bird', 'multi']) and self.zz_pred[idx] > 0: - draw_orientation(axes[1], self.xz_centers, [], self.angles, colors, mode='bird') + draw_orientation(axes[1], self.xz_centers[:len(iterator)], [], + self.angles[:len(iterator)], colors, mode='bird') # Draw ground truth and uncertainty self._draw_uncertainty(axes, idx) @@ -424,17 +426,19 @@ class Printer: ax.get_yaxis().set_visible(False) else: + line_style = 'w--' if self.webcam else 'k--' uv_max = [0., float(self.height)] xyz_max = pixel_to_camera(uv_max, self.kk, self.z_max) x_max = abs(xyz_max[0]) # shortcut to avoid oval circles in case of different kk corr = round(float(x_max / 3)) - ax.plot([0, x_max], [0, self.z_max], 'w--') - ax.plot([0, -x_max], [0, self.z_max], 'w--') + ax.plot([0, x_max], [0, self.z_max], line_style) + ax.plot([0, -x_max], [0, self.z_max], line_style) ax.set_xlim(-x_max + corr, x_max - corr) ax.set_ylim(0, self.z_max + 1) ax.set_xlabel("X [m]") - ax.set_box_aspect(.8) - plt.xlim((-x_max, x_max)) + if self.webcam: + ax.set_box_aspect(.8) + plt.xlim((-x_max, x_max)) plt.xticks(fontsize=self.attr['fontsize_ax']) plt.yticks(fontsize=self.attr['fontsize_ax']) return ax diff --git a/tests/test_train_mono.py b/tests/test_train_mono.py index 0e9f309..af08a10 100644 --- a/tests/test_train_mono.py +++ b/tests/test_train_mono.py @@ -24,7 +24,7 @@ TRAIN_COMMAND = [ PREDICT_COMMAND = [ 'python3', '-m', 'monoloco.run', 'predict', - 'docs/test_002282.png', + 'docs/002282.png', '--output_types', 'multi', 'json', '--decoder-workers=0' # for windows ] @@ -32,7 +32,7 @@ PREDICT_COMMAND = [ PREDICT_COMMAND_SOCIAL_DISTANCE = [ 'python3', '-m', 'monoloco.run', 'predict', - 'docs/test_frame0032.jpg', + 'docs/frame0032.jpg', '--activities', 'social_distance', '--output_types', 'front', 'bird', '--decoder-workers=0' # for windows' @@ -64,8 +64,8 @@ def test_train_mono(tmp_path): print(' '.join(predict_cmd)) subprocess.run(predict_cmd, check=True, capture_output=True) print(os.listdir(tmp_path)) - assert 'out_test_002282.png.multi.png' in os.listdir(tmp_path) - assert 'out_test_002282.png.monoloco.json' in os.listdir(tmp_path) + assert 'out_002282.png.multi.png' in os.listdir(tmp_path) + assert 'out_002282.png.monoloco.json' in os.listdir(tmp_path) predict_cmd_sd = PREDICT_COMMAND_SOCIAL_DISTANCE + [ '--model={}'.format(model), @@ -75,5 +75,5 @@ def test_train_mono(tmp_path): print(' '.join(predict_cmd_sd)) subprocess.run(predict_cmd_sd, check=True, capture_output=True) print(os.listdir(tmp_path)) - assert 'out_test_frame0032.jpg.front.png' in os.listdir(tmp_path) - assert 'out_test_frame0032.jpg.bird.png' in os.listdir(tmp_path) + assert 'out_frame0032.jpg.front.png' in os.listdir(tmp_path) + assert 'out_frame0032.jpg.bird.png' in os.listdir(tmp_path) diff --git a/tests/test_train_stereo.py b/tests/test_train_stereo.py index d3b196f..9f0bf2f 100644 --- a/tests/test_train_stereo.py +++ b/tests/test_train_stereo.py @@ -26,7 +26,7 @@ PREDICT_COMMAND = [ 'python3', '-m', 'monoloco.run', 'predict', '--mode=stereo', - '--glob', 'docs/test_000840*.png', + '--glob', 'docs/000840*.png', '--output_types', 'multi', 'json', '--decoder-workers=0', # for windows' ] @@ -56,4 +56,4 @@ def test_train_stereo(tmp_path): print(' '.join(predict_cmd)) subprocess.run(predict_cmd, check=True, capture_output=True) print(os.listdir(tmp_path)) - assert 'out_test_000840.png.multi.png' in os.listdir(tmp_path) + assert 'out_000840.png.multi.png' in os.listdir(tmp_path)