Skip to content

Commit

Permalink
tested and fixed command line input for config file
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunchainani committed Sep 8, 2024
1 parent 0e73325 commit a221971
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions resspect/scripts/run_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def run_loop(args):
Default is 'original'.
-cf: str (optional)
Path to optional config file to specify labels for multiclass classification
File should contain label names along with numerical representations (comma separated)
The number of lines in the file will be used to calculate number of classes
File should contain all label names (comma separated)
Examples
--------
Expand All @@ -77,16 +75,20 @@ def run_loop(args):
n_classes = 0
class_info = {}

with open(args.config, "r") as config:
info = [line for line in config]
for label in info[0].split(','):
class_info[label] = n_classes
n_classes += 1

for num, label in enumerate(class_info.values()):
encoded = [0 for _ in range(n_classes)]
encoded[label] = 1
class_info[list(class_info)[num]] = encoded
if args.config is not None:
with open(args.config, "r") as config:
info = [line for line in config]
for label in info[0].split(','):
class_info[label] = n_classes
n_classes += 1

for num, label in enumerate(class_info.values()):
encoded = [0 for _ in range(n_classes)]
encoded[label] = 1
class_info[list(class_info)[num]] = encoded

print(f'class_info: {class_info}')
print(f'n_classes: {n_classes}')

if args.training == 'original':
train = 'original'
Expand Down

0 comments on commit a221971

Please sign in to comment.