Skip to content

Commit

Permalink
move examples to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bw4sz committed Oct 25, 2024
1 parent 2412f93 commit 12ce8bb
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 95 deletions.
5 changes: 3 additions & 2 deletions examples/DeepForest.py → DeepForest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from milliontrees import get_dataset
from milliontrees.common.data_loaders import get_train_loader
from deepforest import main
from deepforest.main import deepforest
from pytorch_lightning.loggers import CometLogger

def parse_args():
Expand Down Expand Up @@ -37,7 +37,8 @@ def main():
train_dataset = dataset.get_subset("train")
train_loader = get_train_loader("standard", train_dataset, batch_size=2)

m = main.deepforest(config_args=kwargs)
m = deepforest(config_args=kwargs)
m.config["train"]["csv_file"] ="<dummy file, existing dataloader>"

# Load the pre-trained tree model
m.load_model("Weecology/DeepForest-tree")
Expand Down
60 changes: 60 additions & 0 deletions deepforest_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Config file for DeepForest pytorch module

# Cpu workers for data loaders
# Dataloaders
workers: 0
devices: auto
accelerator: auto
batch_size: 2

# Model Architecture
architecture: 'retinanet'
num_classes: 1
nms_thresh: 0.05

# Architecture specific params
retinanet:
# Non-max supression of overlapping predictions
score_thresh: 0.1

train:
csv_file:
root_dir:

# Optimizer initial learning rate
lr: 0.00001
scheduler:
type:
params:
# Common parameters
T_max: 10
eta_min: 0.00001
lr_lambda: "lambda epoch: 0.95 ** epoch" # For lambdaLR and multiplicativeLR
step_size: 30 # For stepLR
gamma: 0.1 # For stepLR, multistepLR, and exponentialLR
milestones: [50, 100] # For multistepLR

# ReduceLROnPlateau parameters (used if type is not explicitly mentioned)
mode: "min"
factor: 0.1
patience: 10
threshold: 0.0001
threshold_mode: "rel"
cooldown: 0
min_lr: 0
eps: 1e-08

# Print loss every n epochs
epochs: 1
# Useful debugging flag in pytorch lightning, set to True to get a single batch of training to test settings.
fast_dev_run: False
# pin images to GPU memory for fast training. This depends on GPU size and number of images.
preload_images: False

validation:
# callback args
csv_file:
root_dir:
# Intersection over union evaluation
iou_threshold: 0.4
val_accuracy_interval: 20
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ Forests underlie many ecosystem services, agricultural systems and urban plannin
contributing
developer
source/modules.rst
examples/Datasets.ipynb

92 changes: 0 additions & 92 deletions examples/inspect.ipynb

This file was deleted.

2 changes: 1 addition & 1 deletion submit_DeepForest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export COMET_WORKSPACE=bw4sz
#Add to path
export PYTHONPATH=$PYTHONPATH:/home/b.weinstein/MillionTrees

python examples/DeepForest.py
python DeepForest.py

0 comments on commit 12ce8bb

Please sign in to comment.