Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

README.md 3.0 KB

You have to be logged in to leave a comment. Sign In

DeadTrees

PyTorch Lightning Config: Hydra FastAPI Streamlit


Description

Map dead trees from ortho photos. A Unet (semantic segmentation model) is trained on a ortho photo collection of Luxembourg (year: 2019). This repository contains the preprocessing pipeline, training scripts, models, and a docker-based demo app (backend: FastAPI, frontend: Streamlit).

Streamlit frontend Fig 1: Streamlit UI for interactive prediction of dead trees in ortho photos.

How to run

# clone project
git clone https://github.com/cwerner/deadtrees
cd deadtrees

# [OPTIONAL] create virtual environment (using venve, pyenv, etc.) and activate it. An easy way to get a base system configured is to use micromamba (a faster alternative to anaconda) and the fastchan channel to install the notoriously finicky pytorch base dependencies and cuda setup

wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-64/latest | tar -xvj bin/micromamba

# init shell (~/micromamba in the following line is the location where envs are stored, could be somewhere else)
./bin/micromamba shell init -s bash -p ~/micromamba
source ~/.bashrc

micromamba create -p deadtrees python=3.9 -c conda-forge
micromamba activate deadtrees
# install cuda-compiled foundational packages (force it for pytorch since the auto-detection often fails)
micromamba install "pytorch=*=*cuda*" torchvision albumentations -c fastchan -c conda-forge

# install requirements (basic requirements):
pip install -e . 

# [OPTIONAL] install extra requirements for training:
pip install -e ".[train]"

# [OPTIONAL] install extra requirements to preprocess the raw data
# (instead of reading preprocessed data from S3):
pip install -e ".[preprocess]"

# [ALTERNATIVE] install all subpackages:
pip install -e ".[all]"

Download the dataset from S3 (output of the createdataset dvc stage)

dvc pull createdataset

Specify the location of the training dataset on your system by creating the file .env with the following syntax:

export TRAIN_DATASET_PATH="/path_to_my_repos/deadtrees/data/dataset/train"

Train model with default configuration (you can adjust the training config on the commandline or by editing the hydra yaml files in configs):

python run.py

Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...