Skip to content

Commit

Permalink
Work on eval_single_similarity.py
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
bmmtstb committed May 13, 2024
1 parent 3b88acd commit 109498f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ cython_debug/
*.pt
*.pth
*.weights
*.pickle

# automatically generated files for docs
/docs/dgs_autosummary
Expand Down
7 changes: 5 additions & 2 deletions configs/DGS/eval_sim_indep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ test:
dl_rcnn:
module_name: "KeypointRCNNImageBackbone"
dataset_path: "./data/"
# data_path: # will be set in python script
base_path: "./data/PoseTrack21/images/val/"
batch_size: 8
threshold: 0.75
return_lists: true
crop_size: !!python/tuple [256, 192]
crop_mode: "zero-pad"
# data_path: # will be set in python script

dl_gt:
module_name: "PoseTrack21_Image"
dataset_path: "./data/PoseTrack21/"
# data_path: # will be set in python script
crops_folder: "./data/PoseTrack21/crops/256x192/val/"
base_path: "./data/PoseTrack21/posetrack_data/val/"
batch_size: 8
return_lists: true
# data_path: # will be set in python script

# ####### #
# MODULES #
Expand Down
27 changes: 14 additions & 13 deletions scripts/own/eval_single_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@
from dgs.models.loader import module_loader
from dgs.utils.config import load_config
from dgs.utils.torchtools import close_all_layers, memory_analysis
from dgs.utils.types import Config
from dgs.utils.utils import HidePrint

CONFIG_FILE = "./configs/DGS/eval_sim_indep.yaml"


@memory_analysis
@torch.no_grad()
def run(dl_key: str, paths: list[str]) -> None:
def run(config: Config, dl_key: str, paths: list[str]) -> None:
"""Main function to run the code."""
# get sub folders or files and analyse them one-by-one
for sub_datapath in tqdm(paths, desc="ds_sub_dir"):
# IoU, OKS, and visual similarity
for dgs_key in tqdm(["dgs_box", "dgs_pose", "dgs_vis_3", "dgs_vis_2", "dgs_vis_3"], desc="similarities"):
# for dgs_key in tqdm(["dgs_vis_3", "dgs_vis_2", "dgs_vis_3"], desc="similarities"):

config[dl_key]["data_path"] = sub_datapath
# get sub folders or files and analyse them one-by-one
for sub_datapath in tqdm(paths, desc="ds_sub_dir"):

# IoU, OKS, and visual similarity
for dgs_key in tqdm(["dgs_box", "dgs_pose", "dgs_vis_3", "dgs_vis_2", "dgs_vis_3"], desc="similarities"):
config[dl_key]["data_path"] = sub_datapath

# make sure to have a unique log dir every time
orig_log_dir = config["log_dir"]
Expand All @@ -57,15 +59,14 @@ def run(dl_key: str, paths: list[str]) -> None:
if __name__ == "__main__":
print(f"Cuda available: {torch.cuda.is_available()}")

print(f"Loading configuration: {CONFIG_FILE}")
config = load_config(CONFIG_FILE)

print("Evaluating on the PT21 ground-truth evaluation dataset")
base_path = config["dl_gt"]["base_path"]
cfg = load_config(CONFIG_FILE)
base_path = cfg["dl_gt"]["base_path"]
data_paths = [f.path for f in os.scandir(base_path) if f.is_file()]
run(dl_key="dl_gt", paths=data_paths)
run(config=cfg, dl_key="dl_gt", paths=data_paths)

print("Evaluating on the PT21 eval-dataset using KeypointRCNN as prediction backbone")
base_path = config["dl_rcnn"]["base_path"]
cfg = load_config(CONFIG_FILE)
base_path = cfg["dl_rcnn"]["base_path"]
data_paths = [f.path for f in os.scandir(base_path) if f.is_dir()]
run(dl_key="dl_rcnn", paths=data_paths)
run(config=cfg, dl_key="dl_rcnn", paths=data_paths)

0 comments on commit 109498f

Please sign in to comment.