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

Reg metric fix #118

Merged
merged 3 commits into from
Nov 11, 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
8 changes: 4 additions & 4 deletions configs/dataset/biomassters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root_path: ./data/Biomassters
download_url:
auto_download: False
img_size: 256
temp: 6 #6 (select month to use if single temporal (multi_temp : 1))
temp: 6 #6 (select month to use if single temporal (multi_temporal : 1))
multi_temporal: 12
multi_modal: True

Expand Down Expand Up @@ -35,12 +35,12 @@ bands:
- B12
- CLP
sar:
- ASC_VV
- ASC_VH
- VV #set band name to match the input band name of the model e.g. VV for CROMA, ASC_VV for DOFA
- VH #set band name to match the input band name of the model e.g. VH for CROMA, ASC_VH for DOFA
- DSC_VV
- DSC_VH

# TODO: fix the normalization
# TODO: add mean and std normalization values
data_mean:
optical: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
sar: [0, 0, 0, 0]
Expand Down
6 changes: 3 additions & 3 deletions pangaea/engine/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,16 @@ def evaluate(self, model, model_name='model', model_ckpt_path=None):
if self.inference_mode == "sliding":
input_size = model.module.encoder.input_size
logits = self.sliding_inference(model, image, input_size, output_shape=target.shape[-2:],
max_batch=self.sliding_inference_batch)
max_batch=self.sliding_inference_batch).squeeze(dim=1)
elif self.inference_mode == "whole":
logits = model(image, output_shape=target.shape[-2:]).squeeze(dim=1)
else:
raise NotImplementedError((f"Inference mode {self.inference_mode} is not implemented."))

mse += F.mse_loss(logits, target, reduction='sum')
mse += F.mse_loss(logits, target)

torch.distributed.all_reduce(mse, op=torch.distributed.ReduceOp.SUM)
mse = mse / len(self.val_loader.dataset)
mse = mse / len(self.val_loader)

metrics = {"MSE": mse.item(), "RMSE": torch.sqrt(mse).item()}
self.log_metrics(metrics)
Expand Down
Loading