Read-only mirror of https://github.com/MeteoSwiss/swisspollen-training — MeteoSwiss. Issues & pull requests at the source.
  • Jupyter Notebook 91.4%
  • Python 8.1%
  • Dockerfile 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2023-05-16 10:22:55 +02:00
config Updated Dockerfile, JupyterLab NVTOP/HTOP extension 2022-10-18 11:35:06 +02:00
dependencies Updated Swisens training code & env. Filters, Maps, and Hirst Validation not fully functionnal yet. 2022-12-01 16:49:37 +01:00
validation_input/hirst add hirst file for spores measurements at Zollikofen and Reckenholz 2023-05-16 10:22:01 +02:00
.dockerignore minor changes to the validation code and adding validation_input to .dockerignore 2023-02-13 11:02:32 +01:00
.gitignore Fancy validation plots. 2022-12-22 11:06:04 +01:00
.gitmodules Updated Swisens training code & env. Filters, Maps, and Hirst Validation not fully functionnal yet. 2022-12-01 16:49:37 +01:00
Dockerfile First version of validation code. 2022-12-15 16:41:28 +01:00
format_hirst_file.ipynb add the file that format the original hirst data 2023-05-01 14:45:06 +02:00
merge_validation_files.ipynb deleting useless notebooks and add a file that merge validation data files 2023-05-01 14:34:02 +02:00
README.md Update README.md 2023-05-01 17:38:10 +02:00
save_model.ipynb add model from nina in guillaume's code 2023-02-17 08:51:48 +01:00
tensor_board.ipynb improve the way of displaying tensor board logs 2023-05-01 14:13:30 +02:00
training.ipynb improve the training file 2023-05-01 15:04:33 +02:00
training_new_accuracy_metric.ipynb add a training file with a new accuracy metric 2023-05-01 15:06:20 +02:00
validation.ipynb add the possibily to save the figures for timeseries comparison 2023-05-01 14:09:44 +02:00

swisspollen-training

Potential issue

  • Previous models had two inputs named input_1 and input_2. The new models' inputs are named rec0 and rec1 and the last layer's named target.

SSH

SSH config example:

Host gpu3-nb
  HostName 10.182.128.114
  User <user>
  ServerAliveInterval 60
  IdentityFile C:\Users\<user>\.ssh\id_rsa
  LocalForward <dest_port> 127.0.0.1:<dest_port>
  LocalForward <dest_port2> 127.0.0.1:<dest_port2>

where <dest_port> is the port you'll use to access Jupyter Lab, and <dest_port2> is the one you'll use to access TensorBoard.

Docker

If the Dockerfile has been modified, you need to re-build your Docker image using the following command in the swisspollen-training repository:

docker build --no-cache --build-arg HTTP_PROXY=http://proxy.meteoswiss.ch:8080 --build-arg HTTPS_PROXY=http://proxy.meteoswiss.ch:8080 -t <user>/swisspollen-training .

Use the following to start a Docker container and the Jupyter Lab server:

docker run -it --gpus all --rm -v `pwd`:/tf/home/ -p <dest_port>:8888 -p <dest_port2>:6006 <user>/swisspollen-training

Then open your local web browser and connect to the server with address localhost:<dest_port>. Note that <dest_port> should be forwarded in your SSH connection.

MySQL config file

To connect to the MySQL database, you need to setup a config file using this utility tool. An example of what the command could look like would be:

mysql_config_editor set --login-path=client --host=10.0.0.10 --port=3306 --user=root --password

This generates a file that you have to name .mylogin.cnf and move to the config/ folder.

Swisens dependencies disclaimer

This project requires three external dependencies:

The code of CharPyLS is static in the dependencies/ folder. The code of the two Swisens dependencies is NOT pushed on this repository. They are both "submodules" which means cloning this GitHub repository should recursively clone the two submodules.

BUT changes were made to the poleno-ml code (in GPU3:/scratch/chg/swisspollen-training/dependencies/poleno-ml/poleno_ml/database/query_interface_ml.py). Ideally, those changes should be submitted to Swisens through a pull request. They could then review the modifications before accepting and merging them to the main branch. These changes are necessary to run the training and validation code so it's essential to not override them until they're pushed to Swisens' GitLab.

A quick note about modification of these dependencies' code. If modifying these codes from the Docker container, you'll need to make the changes to the /tmp// files for them to take effect (and probably re-run a !pip install from the code). For these modifications to be saved after the container is killed, duplicate them to the dependencies// files.

Docker container's file structure

/tf
├── home
│   ├── Dockerfile
│   ├── README.md
│   ├── config
│   │   ├── .mylogin.cnf
│   │   ├── jupyter_lab_config.py
│   │   ├── plugin.jupyterlab-settings
│   │   ├── themes.jupyterlab-settings
│   │   └── tracker.jupyterlab-settings
│   ├── dependencies
│   │   ├── CharPyLS-master
│   │   ├── poleno-db-interface
│   │   └── poleno-ml
│   ├── models
│   │   ├── real1
│   │   │   ├── eval
│   │   │   │   ├── poleno-5_19022020-01112021.csv
│   │   │   │   └── poleno-5_19022020-20022020.csv
│   │   │   ├── model
│   │   │   │   ├── assets
│   │   │   │   ├── keras_metadata.pb
│   │   │   │   ├── model_info.json
│   │   │   │   ├── saved_model.pb
│   │   │   │   └── variables
│   │   │   │       ├── variables.data-00000-of-00001
│   │   │   │       └── variables.index
│   │   │   └── training
│   │   │       ├── checkpoints
│   │   │       ├── logs
│   │   │       ├── test_cache_new-pollens_other_spores_holo_aug.data-00000-of-00001
│   │   │       ├── test_cache_new-pollens_other_spores_holo_aug.index
│   │   │       ├── train_cache_new-pollens_other_spores_holo_aug.data-00000-of-00001
│   │   │       └── train_cache_new-pollens_other_spores_holo_aug.index
│   ├── training.ipynb
│   ├── validation.ipynb
│   └── validation_input
│       ├── hirst_pay_19022020-01112021.csv
│       └── hirst_pay_19022020-24052020.csv
├── tensorflow-tutorials
└── tmp
    ├── CharPyLS-master
    ├── poleno-db-interface
    └── poleno-ml

All files related to a model's training will be saved to /tf/home/models/<model_name>/. The cached training and validation sets, logs, and checkpoints are saved to training/. The trained model and its information file (model_info.json) are saved to model/. The model's predictions for a validation period are saved as CSV files to eval/.

Currently trained models

  • real1_bis: trained on the "newly" cleaned pollen datasets, and the "other" and "spores" collections.
  • real2: trained on the same data as real1_bis but with data augmentation.

Things to try

  • Try different image normalization (e.g. remove the mean pixel value).
  • Try different data augmentation techniques, data preprocessing and filters.
  • Train the models by swapping dataset collections in and out. Try different combinations.
  • Train with an additional "trash" class.
  • Train a binary neural network (or clustering algorithm) to replace filters which would separate "trash" from relevant particles.
  • Try other ConvNet architectures -> the model architecture does not have too many influence on the final performance
  • Instead of training 2 parallel networks (1 per holo image) and concat their results, try to stack the inputs to have a 3D input with 2 channels.
  • Try the objectosphere loss.
  • Explain the model with techniques such as this one.
  • Try ensemble classifiers (use multiple models and vote for the prediction).

Setup a new Docker environment

Install Docker

sudo apt update
sudo apt-get remove docker docker-engine docker.io
( sudo snap install docker )
sudo apt install docker.io
docker --version

If you do not want to use sudo each time: https://docs.docker.com/engine/install/linux-postinstall/

Setting up NVIDIA Container Toolkit

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

Proxy

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
	and write the following lines:
		[Service]
		Environment="HTTP_PROXY=http://proxy.meteoswiss.ch:8080/"
		Environment="HTTPS_PROXY=http://proxy.meteoswiss.ch:8080/"
sudo systemctl daemon-reload
sudo systemctl show --property Environment docker
sudo systemctl restart docker