This repository contains the code for reproducing the algorithms that we developed as part of the ESA's sponsored #HYPERVIEW Competition, challenging researchers to build AI-based methods for estimating soil parameters from hyperspectral images.
The regression model consists of a CNN built upon a modified EfficientNet-lite0 [1-2]. With just 734 million parameters, the network is capable of processing up to about 180 frames per second on a Coral Dev Board Mini microcomputer.
Our solution ranked 4th on the final leaderboard presented at the 2022 IEEE International Conference on Image Processing.
The following data preprocessing steps have been implemented: normalization, tiling, flipping, and corruption with gaussian noise.
Sample band from a random image: original (left), tiling and flipping (centre), noise corruption (right)
Authors - Achille Ballabeni, Alessandro Lotti, Alfredo Locarini, Dario Modenini, Paolo Tortora.
u3S Laboratory @ Alma Mater Studiorum UniversitĂ di Bologna.
The code has been tested on a Conda environment in WSL2 with Ubuntu 20.04, running on a Windows 11 computer with an RTX 3090 GPU. Nonetheless, the model is designed to be lightweight, and can be trained even without a GPU.
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
To install WSL2 in Windows launch powershell as administrator, run wsl --install
, and follow the instructions.
Further information can be found at this link.
- Download and install Visual Studio 2015, 2017, 2019 and 2022
- Download and install Miniconda
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh
Note that currently there is no official GPU support for TensorFlow on MacOS.
When setup is completed, it is suggested to reboot the system.
-
Clone this repository:
git clone https://github.com/Microsatellites-and-Space-Microsystems/hyperspectral-cnn-soil-estimation
cd hyperspectral-cnn-soil-estimation
-
If a dedicated NVIDIA GPU is available:
-
Create a new Conda environment:
conda env create -f environment_GPU.yml
-
Reboot the system
-
Activate the Conda environment:
conda activate hyperspectral-cnn-soil-estimation
-
Linux and WSL2 systems:
-
Execute the following commands to enable the GPU in TensorFlow:
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/' > $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
-
Reboot the system, and activate the Conda environment (
conda activate hyperspectral-cnn-soil-estimation
) -
Check that the GPU is configured properly by executing:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
-
-
Windows native:
- Check that the GPU is configured properly by executing:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
- Check that the GPU is configured properly by executing:
-
-
If no GPU is available:
-
Create a new Conda environment:
conda env create -f environment_CPU.yml
-
Reboot the system
-
Activate the Conda environment:
conda activate hyperspectral-cnn-soil-estimation
-
-
Launch Jupyter running:
jupyter notebook
-
Copy and paste the url
http://localhost:8888/tree
in a web browser. -
Navigate to the desired notebook and enjoy the code.
-
On WSL2 / Linux
- In case a permission denied error pops up, run:
sudo chown -R your_linux_username /home/your_linux_username/hyperspectral-cnn-soil-estimation
- In case a permission denied error pops up, run:
[1] Renjie Liu, "Higher accuracy on vision models with EfficientNet-Lite", TensorFlow Blog.
[2] Sebastian Szymanski, efficientnet-lite-keras.
[3] Paul Gavrikov, Visualkeras