Skip to content

Commit

Permalink
Visualization updates (#5)
Browse files Browse the repository at this point in the history
* Made visualization load lazy
* Updated eval version

---------

Co-authored-by: Ishan Khatri <[email protected]>
  • Loading branch information
kylevedder and ikhatri authored Mar 9, 2024
1 parent 96722bc commit d39f6f2
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 257 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfile
RUN pip install yapf==0.40.1
RUN pip install pyarrow pyquaternion open3d tensorboard pytorch-lightning==1.9.4 imageio black isort nntime
RUN pip install mmcv==2.1.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.12.0/index.html
RUN pip install bucketed-scene-flow-eval==1.0.1
RUN pip install bucketed-scene-flow-eval==1.0.4
RUN apt install -y unzip

ENV PYTHONPATH=/project:/bucketed_scene_flow_eval:/:${PYTHONPATH}
Expand Down
1 change: 1 addition & 0 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ docker run --gpus=all --rm -it \
--shm-size=16gb \
-v `pwd`:/project \
-v /efs:/efs \
-v /efs2:/efs2 \
-v /bigdata:/bigdata \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /tmp/frame_results:/tmp/frame_results \
Expand Down
51 changes: 25 additions & 26 deletions visualization/dataset_count_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from loader_utils import load_pickle, load_json
import numpy as np
from typing import Dict, List, Any
from bucketed_scene_flow_eval.datasets.argoverse2.av2_metacategories import METACATAGORIES
from bucketed_scene_flow_eval.datasets.argoverse2.av2_metacategories import BUCKETED_METACATAGORIES
import matplotlib.pyplot as plt
from visualization.figures.plot_lib import *

# Load the saved count data
raw_class_speed_count_info = load_json('/efs/argoverse2/val_dataset_stats/dataset_count_info.json')
raw_class_speed_count_info = load_json("/efs/argoverse2/val_dataset_stats/dataset_count_info.json")


def merge_classes(class_a: Dict[float, int], class_b: Dict[float, int]):
Expand All @@ -22,15 +22,13 @@ def merge_classes(class_a: Dict[float, int], class_b: Dict[float, int]):


def collapse_into_meta_classes(
count_info: Dict[str, Dict[float,
int]]) -> Dict[str, Dict[float, int]]:
count_info: Dict[str, Dict[float, int]]
) -> Dict[str, Dict[float, int]]:
# Create a new dictionary to hold the meta classes
meta_class_count_info = {}
# For each meta class, merge the classes that belong to it
for meta_class_name, meta_class_entries in METACATAGORIES.items():
entries_list = [
count_info[category_name] for category_name in meta_class_entries
]
for meta_class_name, meta_class_entries in BUCKETED_METACATAGORIES.items():
entries_list = [count_info[category_name] for category_name in meta_class_entries]
# Merge the classes
merged_class = entries_list[0]
for class_to_merge in entries_list[1:]:
Expand All @@ -49,8 +47,7 @@ def collapse_speed_buckets(entry: Dict[float, int]) -> int:
meta_class_speed_info = collapse_into_meta_classes(raw_class_speed_count_info)
meta_class_count_info = {
meta_class_name: collapse_speed_buckets(meta_class_speed_info)
for meta_class_name, meta_class_speed_info in
meta_class_speed_info.items()
for meta_class_name, meta_class_speed_info in meta_class_speed_info.items()
}


Expand All @@ -60,39 +57,41 @@ def plot_meta_class_counts(meta_class_count_info: Dict[str, int]):

total_points = sum(meta_class_count_info.values())

entries = sorted(meta_class_count_info.items(),
key=lambda x: x[1],
reverse=True)
entries = sorted(meta_class_count_info.items(), key=lambda x: x[1], reverse=True)
labels, values = zip(*entries)
labels = [label.replace("_", " ") for label in labels]

bars = ax.bar(labels, values, color=color(0, 1))
ax.set_xlabel("Meta Class")
ax.set_ylabel("Lidar points in semantic class")
ax.set_title("Meta Class Counts")
# ax.set_xlabel("Meta Class")
ax.set_ylabel("Lidar points in metaclass")
# ax.set_title("Meta Class Counts")

# Make the X axis labels at 30 Degrees
plt.xticks(rotation=30, ha='right')
plt.xticks(rotation=30, ha="right")
# Make the Y axis log scale
ax.set_yscale('log')
ax.set_yscale("log")

# Annotate bars with percentage
for bar in bars:
height = bar.get_height()
percentage = 100 * height / total_points
ax.text(bar.get_x() + bar.get_width() / 2,
height,
f'{percentage:.2f}%',
ha='center',
va='bottom')
ax.text(
bar.get_x() + bar.get_width() / 2,
height,
f"{percentage:.2f}%",
ha="center",
va="bottom",
)

# fig.savefig("meta_class_counts.pdf", bbox_inches='tight')
# Save as a png as well

# Remove the top and right axes
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
savefig("validation_results", "meta_class_counts")

set_font(12)

plot_meta_class_counts(meta_class_count_info)

Expand Down
87 changes: 0 additions & 87 deletions visualization/figures/plot_lib.py

This file was deleted.

104 changes: 0 additions & 104 deletions visualization/figures/plot_performance.py

This file was deleted.

19 changes: 19 additions & 0 deletions visualization/threeway_epe_eval/copy_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Define the source and target directories
SOURCE_DIR="/efs2/argoverse2_submission_evals"
TARGET_DIR="/home/k/code/offline_sceneflow_eval/visualization/perf_data/threeway_epe"

# Iterate over each subfolder in the source directory
for SUBFOLDER in "$SOURCE_DIR"/*; do
# Extract the name of the subfolder
FOLDER_NAME=$(basename "$SUBFOLDER")
# Define the source file path
SOURCE_FILE="${SUBFOLDER}/eval_results/per_class_results_35.json"
# Define the target file path, appending the subfolder name for uniqueness
TARGET_FILE="${TARGET_DIR}/${FOLDER_NAME}_per_class_results_35.json"
# Copy the file from the source to the target directory
cp "$SOURCE_FILE" "$TARGET_FILE"
done

echo "Copy completed."
7 changes: 7 additions & 0 deletions visualization/threeway_epe_eval/run_evals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
for f in /efs2/argoverse2_submission_evals/*; do
echo "Processing $f file..."
# Extract the full filename without the path
filename=$(basename -- "$f")
python ~/code/bucketed_scene_flow_eval/scripts/evals/av2_eval.py /efs/argoverse2/test/ /efs/argoverse2/test_sceneflow_feather "/efs2/argoverse2_submission_evals/$filename/submission" "/efs2/argoverse2_submission_evals/$filename/eval_results" --eval_type threeway_epe --cache_root /tmp/av2_evals --cpu_count 46
done
10 changes: 10 additions & 0 deletions visualization/threeway_epe_eval/setup_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for f in /efs/argoverse2/test_*_submission.zip; do
echo "Processing $f file..."
# Extract the full filename without the path
filename=$(basename -- "$f")
# Remove the .zip extension to get the stem
stem="${filename%.zip}"
python ~/code/bucketed_scene_flow_eval/scripts/evals/setup_sparse_user_submission.py "/efs2/argoverse2_submission_evals/$stem/" $f /efs/argoverse2/test_sceneflow_feather
done
Loading

0 comments on commit d39f6f2

Please sign in to comment.