Summon the secrets of the soil with PyRootMancer - the enchanting way to master root phenotyping.
Project description
PyRootMancer - Root Segmentation Project
Welcome to PyRootMancer, the magical tool for all your root segmentation needs! ๐ฑโจ Whether you're a plant physiologist, agronomist, or ecologist, PyRootMancer is here to help you unravel the mysteries of root systems with the power of deep learning.
Harnessing the enchanting capabilities of the U-Net model architecture, PyRootMancer ensures that your root images are segmented with pinpoint accuracy. This wizardry not only facilitates precise detection and segmentation of root structures but also aids in comprehensive analyses and research.
Root system analysis has never been this easy and fun! By automating the segmentation process, PyRootMancer allows you to efficiently process large datasets, extract meaningful data, and conduct thorough analyses with minimal manual intervention. Get ready to streamline your workflow, enhance segmentation accuracy, and accelerate your discoveries in plant science.
Table of Contents
Installation
- Clone the repository:
git clone https://github.com/BredaUniversityADSAI/2023-24d-fai2-adsai-group-cv5.git
- Navigate to the project directory:
cd 2023-24d-fai2-adsai-group-cv5
- Install Poetry if you haven't already:
pip install poetry
- Install the project dependencies:
poetry install - Activate the virtual environment:
poetry shell
Alternatively, you can install PyRootMancer using pip:
pip install pyrootmancer
Dependencies
The project dependencies are managed using Poetry. Below is a list of key dependencies:
- python:
>3.10.0, <=3.10.14 - tensorflow-io-gcs-filesystem:
0.30.0 - tensorflow:
2.16.1 - tensorflow-intel:
2.16.1 - opencv-python:
^4.9.0.80 - pandas:
^2.2.2 - patchify:
^0.2.3 - matplotlib:
^3.8.4 - scikit-image:
^0.23.2 - skan:
^0.11.1 - numpy:
1.23.5 - pytest:
^8.2.0 - pytest-mock:
^3.14.0 - sphinx:
^7.3.7 - coverage:
^7.5.3 - sphinx_rtd_theme:
2.0.0 - networkx:
^3.3
For a complete list of dependencies, refer to the pyproject.toml file.
Usage
Data Preprocessing
The DataPipelineSetup class handles data preprocessing tasks such as creating folders, unzipping files, cropping images, and patchifying images.
Example usage:
from src.data.data_preprocessing import DataPipelineSetup
processor = DataPipelineSetup()
processor.create_folders()
processor.unzip("train")
processor.unzip("test")
processor.unzip("masks")
processor.crop("path/to/folder")
processor.img_patchify("path/to/img_dir", "path/to/save_dir")
Model Training
The ModelTraining class handles the training of the U-Net model for image segmentation.
Example usage:
from src.models.model_training import ModelTraining
trainer = ModelTraining()
trainer.training(epochs=10, image_folder="path/to/images", mask_folder="path/to/masks", model_folder="path/to/models", model_name="unet_model")
Instance Segmentation
The InstanceSegmentation class performs instance segmentation tasks including noise removal, overlaying masks, and resizing predicted masks to match the size of original images.
Example usage:
from src.features.instance_segmentation import InstanceSegmentation
segmenter = InstanceSegmentation()
# Perform noise removal on an image
clean_image = segmenter.opening_closing(image)
# Overlay a predicted mask on a test image
blended_image = segmenter.test_overlaying(image_path="path/to/image.png", output_folder="path/to/output", model_folder="path/to/model", model_name="model_name")
# Resize predicted masks to match original image size and overlay them
resized_image = segmenter.return_original_size_image(image_path="path/to/image.png", output_folder="path/to/output")
Root Coordinate Extraction
The LandmarkExtraction class extracts landmarks and coordinates from root images, processes and filters them based on certain criteria.
Example usage:
from src.features.root_coord_extraction import LandmarkExtraction
extractor = LandmarkExtraction()
# Remove small components from a mask
clean_mask = extractor.remove_small_components(mask)
# Get bottom coordinates of roots in an image
coords_0, coords_1 = extractor.get_bottom_coordinates(input_folder="path/to/input", num_img=0)
# Display root landmarks on an image
extractor.display_root_landmarks(input_folder="path/to/input", test_folder="path/to/test", num_img=0)
Root Length Calculation
The RootLengthCalculator class calculates the length of roots from segmented images using a trained model.
Example usage:
from src.features.root_length import RootLengthCalculator
from src.models.model_evaluation import f1, iou
img_dir = "path/to/images"
model_path = "path/to/model"
custom_objects = {"f1": f1, "iou": iou}
csv_filename = "path/to/results.csv"
calculator = RootLengthCalculator(img_dir, model_path, custom_objects)
calculator.process_images()
calculator.save_results(csv_filename)
Model Evaluation
The model_evaluation.py script provides functions for calculating F1 score and Intersection over Union (IoU).
Example usage:
from src.models.model_evaluation import f1, iou
Configuration
The configuration.py script provides the folder and parameter configurations used throughout the project.
Project Structure
2023-24d-fai2-adsai-group-cv5/
โโโ data/
โ โโโ external/
โ โโโ processed/
โ โโโ data_predictions
โ โโโ data_predictions_clean
โ โโโ raw/
โ โโโ data_unpatched/
โ โโโ data_patched/
โโโ models/
โ โโโ best_model
โโโ src/
โ โโโ data/
โ โ โโโ data_preprocessing.py
โ โโโ features/
โ โ โโโ instance_segmentation.py
โ โ โโโ root_coord_extraction.py
โ โ โโโ root_length.py
โ โโโ models/
โ โ โโโ model_definitions.py
โ โ โโโ model_evaluation.py
โ โ โโโ model_training.py
โ โโโ utils/
โ โ โโโ configuration.py
โโโ README.md
โโโ pyproject.toml
Authors
- Simona Dimitrova (222667@buas.nl) -
data_preprocessing.py - Jakub Cyba (223860@buas.nl) -
model_training.py - Cรฉdric Verhaegh (221350@buas.nl) -
instance_segmentation.py - Thomas Pichardo (223834@buas.nl) -
root_coord_extraction.py - Samuel Vieira Vasconcelos (211941@buas.nl) -
root_length.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrootmancer-0.1.4.tar.gz.
File metadata
- Download URL: pyrootmancer-0.1.4.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c820255968efdf8b4b27903dbc4a97e514c8adfad8fe14e74694448a9d761fd
|
|
| MD5 |
262b64058e84610d4c9279bce7d0eb1b
|
|
| BLAKE2b-256 |
e227652db610fdf4999f9c14a9fe38b2d2d8f53d60c9286d0541ede79e0bc703
|
File details
Details for the file pyrootmancer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pyrootmancer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
349c33356e13f4e9c30a2dab14a8d2f6667a38de47b7eec4843ccbab4492b0a9
|
|
| MD5 |
c432a3fbe63cfd2bd2212924d4d91b4a
|
|
| BLAKE2b-256 |
deb74065a7cba0a348f797de0194522a964900a44d90f847b53daa2b197cb5b2
|