Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from trackastra.utils import (
blockwise_causal_norm,
blockwise_sum,
none_or_path,
none_or_str,
normalize,
preallocate_memory,
random_label_cmap,
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def parse_train_args():
)
parser.add_argument(
"--cachedir",
type=none_or_path,
type=none_or_str,
default=".cache",
help="cache dir for CTCData. Set to `None` to disable caching.",
)
Expand Down
1 change: 1 addition & 0 deletions trackastra/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
blockwise_causal_norm,
blockwise_sum,
none_or_path,
none_or_str,
normalize,
preallocate_memory,
random_label_cmap,
Expand Down
8 changes: 8 additions & 0 deletions trackastra/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ def str2path(x: str) -> Path:
return Path(x).expanduser().resolve()


def none_or_str(x: str | None) -> str | None:
"""Allow for none value in string parsing."""
if x in (None, "None", "none"):
return None
else:
return str(x)


def none_or_path(x: str | None) -> Path | None:
"""Cast string to resolved absolute path or return None."""
if x in (None, "None", "none"):
Expand Down
Loading