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

More bugfixing #56

Merged
merged 3 commits into from
Aug 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def read_config(module_options):
]
if mask_pattern_match:
mask_rules[semantic_label] = {
raster_map: masks[mask_pattern_match[0]]
raster_map: masks[mask_pattern_match[0].string]
}

for label in config[config_key]:
Expand Down
10 changes: 7 additions & 3 deletions src/imagery/i.pytorch/pytorchlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import inspect
import json
import sys
from copy import deepcopy
from importlib import import_module

import grass.script as gs
Expand Down Expand Up @@ -108,8 +109,11 @@ def numpy2torch(np_array, device="cpu", precision="float"):
def torch2numpy(torch_tensor):
"""Create numpy array from torch variable"""
if torch_tensor.device != "cpu":
return torch.Tensor.cpu(torch_tensor).numpy()
return torch_tensor.numpy()
torch_tensor_numpy = deepcopy(torch.Tensor.cpu(torch_tensor).numpy())
else:
torch_tensor_numpy = deepcopy(torch_tensor.numpy())
del torch_tensor
return torch_tensor_numpy


def load_model_code(package_dir, object_name):
Expand Down Expand Up @@ -175,7 +179,7 @@ def predict_torch(data_cube, config_dict=None, device=None, dl_model=None):
with torch.no_grad():
data = numpy2torch(data_cube).to(device)
torch_out = dl_model(data)

del data
# Apply extra ouptut transformations
if "extra_ouptut_transformations" in config_dict["model"]:
if "apply_softmax" in config_dict["model"]["extra_ouptut_transformations"]:
Expand Down
1 change: 1 addition & 0 deletions src/temporal/t.pytorch.predict/t.pytorch.predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def process_scene_group(
output_name = os.path.commonprefix(list(map_dict["input"].values())).rstrip("_")
else:
output_name = f"{basename}_{temporal_extent[0].strftime('%Y%m%dT%H%M%S')}_{temporal_extent[1].strftime('%Y%m%dT%H%M%S')}"
output_name = output_name.split("@", 1)[0]

# Get semantic labels
output_bands = json.loads(
Expand Down
Loading