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

ObjectDetectionTask: explicit batch size #1928

Merged
merged 1 commit into from
Mar 3, 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
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ filterwarnings = [
"ignore:Skipping device Apple Paravirtual device that does not support Metal 2.0:UserWarning",

# Unexpected warnings, worth investigating
# Lightning is having trouble inferring the batch size for ChesapeakeCVPRDataModule and CycloneDataModule for some reason
"ignore:Trying to infer the `batch_size` from an ambiguous collection:UserWarning",
# https://github.com/pytest-dev/pytest/issues/11461
"ignore::pytest.PytestUnraisableExceptionWarning",
]
Expand Down
6 changes: 3 additions & 3 deletions torchgeo/trainers/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def training_step(
]
loss_dict = self(x, y)
train_loss: Tensor = sum(loss_dict.values())
self.log_dict(loss_dict)
self.log_dict(loss_dict, batch_size=batch_size)
return train_loss

def validation_step(
Expand All @@ -267,7 +267,7 @@ def validation_step(
# https://github.com/Lightning-AI/torchmetrics/pull/1832#issuecomment-1623890714
metrics.pop("val_classes", None)

self.log_dict(metrics)
self.log_dict(metrics, batch_size=batch_size)

if (
batch_idx < 10
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_step(self, batch: Any, batch_idx: int, dataloader_idx: int = 0) -> None
# https://github.com/Lightning-AI/torchmetrics/pull/1832#issuecomment-1623890714
metrics.pop("test_classes", None)

self.log_dict(metrics)
self.log_dict(metrics, batch_size=batch_size)

def predict_step(
self, batch: Any, batch_idx: int, dataloader_idx: int = 0
Expand Down
Loading