Skip to content
Open
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: 8 additions & 0 deletions src/deepforest/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ model:
name: 'weecology/deepforest-tree'
revision: 'main'

# Trainer precision. Override to 16-mixed for faster training, 32-true for full precision.
precision:

# On CUDA, setting the matmul precision can provide speed up without affecting model performance
# Start with 'high' for initial tests.
matmul_precision: highest

# Specify a label_dict to override model settings.
# By default, this will be populated from the model
# checkpoint that is selected in model.name/revision.
Expand Down Expand Up @@ -77,6 +84,7 @@ train:
# preload images to GPU memory for fast training. This depends on GPU size and number of images.
preload_images: False


validation:
csv_file:
root_dir:
Expand Down
2 changes: 2 additions & 0 deletions src/deepforest/conf/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class Config:
devices: int | str = "auto"
accelerator: str = "auto"
batch_size: int = 1
precision: str | None = None
matmul_precision: str = "highest"

architecture: str = "retinanet"
num_classes: int | None = None
Expand Down
5 changes: 5 additions & 0 deletions src/deepforest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ def create_trainer(self, logger=None, callbacks=None, **kwargs):
else:
enable_checkpointing = False

if torch.cuda.is_available():
torch.set_float32_matmul_precision(self.config.matmul_precision)

trainer_args = {
"logger": logger,
"max_epochs": self.config.train.epochs,
Expand All @@ -243,6 +246,8 @@ def create_trainer(self, logger=None, callbacks=None, **kwargs):
"num_sanity_val_steps": num_sanity_val_steps,
"default_root_dir": self.config.log_root,
}
if self.config.precision is not None:
trainer_args["precision"] = self.config.precision
# Update with kwargs to allow them to override config
trainer_args.update(kwargs)

Expand Down
Loading