1
0
Fork 0
PlantNetLibre-300K/README.md

3.5 KiB

PlantNet-300K Forklet

This is a forklet of the PlantNet-300K training repository.

Related repository:

Install

Install thusly.

Using Debian Stable (12/Bookworm).

Dependencies

Debian package dependencies.

sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev \
  libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils \
  tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
  python3-virtualenv python3-pip cmake-curses-gui cmake \
  libudev-dev libsystemd-dev

Python

The Python setup is a bit involved, but very flexible. This setup will allow for any particular version of Python to be installed and used. This will also set up a virtual environment for pip installs.

Firstly, setup pyenv to install and use any version of Python

curl https://pyenv.run | bash

Add these lines to the ~/.bashrc:

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Then log out and log back in. The following command should work:

pyenv versions

Now install various version(s) of Python:

pyenv install 3.11
pyenv install 3.10

PlantNetLibre-300K

Clone the repo and set up Python environment. Flavor Python version to taste.

git clone https://spacecruft.org/deepcrayon/PlantNetLibre-300K
cd PlantNetLibre-300K/
pyenv local 3.11
virtualenv -p python3.11.4 env
source env/bin/activate
python --version

Install PyTorch and dependencies. This is for NVidia CUDA. Install lit first or install fails (just repeat install to fix).

pip install --upgrade pip
pip install lit
pip install torch torchvision torchaudio \
  --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt

Images

Set up data archive of photo images from PlantNet. Archive is 31 gigabytes and contains the main images test, train, and val directories.

Download images from upstream, or this rsync, por ahora.

sudo mkdir /srv/ml
sudo chown jebba:jebba /srv/ml
mkdir -p /srv/ml/plantnet/files/

rsync -utla rsync://66.135.9.139/plantnet/files/ \
  /srv/ml/plantnet/files/

nvtop

It may be handy to have top for NVidia GPUs. Works with A16 and A40, partially works with A100.

In new directory:

git clone https://github.com/Syllo/nvtop
cd nvtop/
mkdir build
cd build
cmake ..
ccmake ..
make -j4
# Run:
./src/nvtop

In the ccmake menu, disable all except NVidia.

Run

Run thusly.

Train Model

Train a model:

./train.sh [model name]

Example:

./train.sh resnet50

Load Model

This repo is for training models, not using them. But there is a script that can load each model to verify it at least can load or not.

Edit source to test each model individually. Then run:

./load-model.py

Docs

See the Libre Office spreadsheet docs/train-plantnet.ods for info about each initial test run.

Development

The black formatting application is used. To install:

pip install -r requirements-dev.txt

Upstream

Upstream source repository, BSD 2-Clause License.

See README-upstream.md for upstream README.

Copyright

Unofficial project, not related to PlantNet. Upstream sources under their respective copyrights.

Source code license: BSD 2-Clause License.

Documentation license: Creative Commons CC by SA 4.0 International.

Data license: Creative Commons CC by SA 4.0 International.

Copyright © 2023, Jeff Moe.