WIP: Treeformer#1371
Closed
jveitchmichaelis wants to merge 101 commits into
Closed
Conversation
Collaborator
Author
|
Closing in favour of simpler branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is marked as WIP as there's a lot to clean up, but the model architecture and training loop seem to be OK. It's mostly additive cruft than things that will require extensive rebasing...
Adds a point-detection model based on the TreeFormer architecture in https://arxiv.org/abs/2307.06118 which is based on DM-Count https://arxiv.org/abs/2009.13077.
This contribution is probably more in spirit with DM-Count than TreeFormer because it only implements the supervised path, but the code was heavily adapted from the TreeFormer repository.
The model is a segmentation backbone (here, PvTv2) which feeds into two heads. One, a Global Average Pool (GAP) which predicts a scalar tree count, and the other a density regression head (a multi-scale decoder).
TODO: add model checkpoints to huggingface and default to them when user picks the
treeformerconfig.TODO: big clean up of commits, obviously.
TODO: remove slurm scripts, etc.
Replication
Sample predictions trained and tested on the paper's KCL dataset (using Google Earth images):
Note: this dataset is probably overfit. The paper reports 500 epochs, but the dataset is only 400 images. Nevertheless, the implementation here beats the paper benchmark in supervised mode and also the unsupervised benchmark (likely due to backbone pretraining) based on MAE (paper: 16.7/18.5, ours: 18.24 using density sum / <15 with peak extraction). We get a peak F1 of around 0.68. Convergence is seen after around 200 epochs, but we train for 500 to match the original hyperparameters.
A single epoch on NEON LIDAR (purple are preds):
Model differences
PRs to be split - will update
Licensing
TreeFormer does not list a license, and the ancestral code from DM-Count (which is mostly copied verbatim in TreeFormer) is MIT-licensed. Here, the backbone model is taken directly from
transformersand the various heads are re-implemented in PyTorch with some optimization from the original.Related Issue(s)
#809
AI-Assisted Development
AI tools used (if applicable):
Claude (Opus/Sonnet 4.6) and Codex 5.3/5.4