Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The CLI argument --data.init_args.predict_output_bands was missing #116

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion terratorch/cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ def from_config(
config_path: Path,
checkpoint_path: Path | None = None,
predict_dataset_bands: list[str] | None = None,
predict_output_bands: list[str] | None = None,
):
"""
Args:
Expand All @@ -416,6 +417,10 @@ def from_config(
arguments.extend([ "--data.init_args.predict_dataset_bands",
"[" + ",".join(predict_dataset_bands) + "]",])

if predict_output_bands is not None:
arguments.extend([ "--data.init_args.predict_output_bands",
"[" + ",".join(predict_output_bands) + "]",])

cli = build_lightning_cli(arguments, run=False)
trainer = cli.trainer
# disable logging metrics
Expand Down Expand Up @@ -467,4 +472,4 @@ def inference(self, file_path: Path) -> torch.Tensor:
prediction, file_name = self.inference_on_dir(
tmpdir,
)
return prediction.squeeze(0)
return prediction.squeeze(0)
6 changes: 4 additions & 2 deletions terratorch/datamodules/generic_pixel_wise_data_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def setup(self, stage: str) -> None:
self.predict_root,
self.num_classes,
dataset_bands=self.predict_dataset_bands,
output_bands=self.output_bands,
output_bands=self.predict_output_bands,
constant_scale=self.constant_scale,
rgb_indices=self.rgb_indices,
transform=self.test_transform,
Expand Down Expand Up @@ -335,6 +335,7 @@ def __init__(
allow_substring_split_file: bool = True,
dataset_bands: list[HLSBands | int | tuple[int, int] | str ] | None = None,
predict_dataset_bands: list[HLSBands | int | tuple[int, int] | str ] | None = None,
predict_output_bands: list[HLSBands | int | tuple[int, int] | str ] | None = None,
output_bands: list[HLSBands | int | tuple[int, int] | str ] | None = None,
constant_scale: float = 1,
rgb_indices: list[int] | None = None,
Expand Down Expand Up @@ -426,6 +427,7 @@ def __init__(

self.dataset_bands = dataset_bands
self.predict_dataset_bands = predict_dataset_bands if predict_dataset_bands else dataset_bands
self.predict_output_bands = predict_output_bands if predict_output_bands else dataset_bands
Joao-L-S-Almeida marked this conversation as resolved.
Show resolved Hide resolved
self.output_bands = output_bands
self.rgb_indices = rgb_indices

Expand Down Expand Up @@ -507,7 +509,7 @@ def setup(self, stage: str) -> None:
self.predict_dataset = self.dataset_class(
self.predict_root,
dataset_bands=self.predict_dataset_bands,
output_bands=self.output_bands,
output_bands=self.predict_output_bands,
constant_scale=self.constant_scale,
rgb_indices=self.rgb_indices,
transform=self.test_transform,
Expand Down
Loading