Skip to content

Commit

Permalink
Merge pull request #32 from josephvanpeltkw/dev/fix_mapping
Browse files Browse the repository at this point in the history
change method of loading mapping file
  • Loading branch information
Purg authored Oct 18, 2024
2 parents 0db093b + d57602e commit 4c3effa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tcn_hpl/models/ptg_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def __init__(

# Get Action Names
mapping_file = f"{self.hparams.data_dir}/{mapping_file_name}"
file_ptr = open(mapping_file, "r")
actions = file_ptr.read().split("\n")[:-1]
file_ptr.close()
actions_dict = dict()
for a in actions:
actions_dict[a.split()[1]] = int(a.split()[0])
with open(mapping_file, "r") as file_ptr:
actions = file_ptr.readlines()
actions = [a.strip() for a in actions] # drop leading/trailing whitespace
for a in actions:
parts = a.split() # split on any number of whitespace
actions_dict[parts[1]] = int(parts[0])

self.class_ids = list(actions_dict.values())
self.classes = list(actions_dict.keys())
Expand Down

0 comments on commit 4c3effa

Please sign in to comment.