Skip to main content

Computer vision toolkit for high-throughput fruit phenotyping.

Project description


Página disponible en: Spanish

Traitly is an open-source Python tool for automated, high-throughput fruit phenotyping from digital images. Using computer vision methods, it quantifies morphological, symmetry, and color traits across both internal structures and the external appearance of the fruit.

It supports both single-image analysis and batch processing workflows, making it easy to handle large image datasets with just a few lines of code, which is especially useful in plant breeding programs and research.


What can Traitly do?

Traitly processes fruit images to measure:

  • Fruit morphology: Area, perimeter, circularity, dimensions, and aspect ratio
  • Locule anatomy: Locule number, size distribution, and spatial arrangement
  • Pericarp structure: Thickness, uniformity (CV), and surface irregularity (lobedness)
  • Color phenotypes: Multi-channel analysis (RGB, HSV, Lab) across different fruit regions

Publications & Presentations

Posters related to Traitly can be found in this folder:

These materials provide additional methodological details and results from research derived from our package.


Usage

Traitly can be run in different ways:

Environment Status
Jupyter Notebook ✔ Available
Command line (CLI) ✔ Available
Web app (Shiny) ✔ Available

⤷ You can also try our interactive demo onlineˎˊ˗


Below is a basic example of how to use Traitly.

⋆ Python usage

Internal fruit morphology analysis

from traitly.fruit_phenotyping import FruitInternalAnalyzer

# Single image analysis
path = 'PATH/my_image.jpg'
analyzer = FruitInternalAnalyzer(path)  # Initialize the FruitInternalAnalyzer class
analyzer.load_image()                   # Read the image
analyzer.setup_measurements()           # Obtain label and reference size information
analyzer.generate_fruit_mask()          # Create a binary mask to segment fruits and locules
analyzer.detect_fruits()                # Filter detected fruits
analyzer.analyze_morphology()           # Run the morphology analysis
analyzer.analyze_color()                # Run the color analysis
analyzer.results.save_all()             # Save results (color and morphology .csv files and annotated image)
analyzer.save_parameters()              # Save session parameters as .txt and .json files

# Batch analysis
path = 'PATH/my_folder'
json = 'my_parameters.json'
analyzer = FruitInternalAnalyzer(path)
analyzer.analyze_folder(json_path = json)

External fruit morphology analysis

from traitly.fruit_phenotyping import FruitExternalAnalyzer

# Single image analysis
path = 'PATH/my_image.jpg'
analyzer = FruitExternalAnalyzer(path)       # Initialize the FruitExternalAnalyzer class
analyzer.load_image()                        # Read the image
analyzer.setup_measurements()                # Obtain label and reference size information
analyzer.generate_fruit_mask()               # Create a binary mask to segment fruits
analyzer.detect_fruits()                     # Filter detected fruits
analyzer.analyze_morphology()                # Run the morphology analysis
analyzer.analyze_color(color_channel='RGB')  # Extract mean RGB channel values for each fruit
analyzer.results.save_all()                  # Save results (color and morphology .csv files and annotated image)
analyzer.save_parameters()                   # Save session parameters as .txt and .json files

# Batch analysis
path = 'PATH/my_folder'
json = 'my_parameters.json'
analyzer = FruitExternalAnalyzer(path)
analyzer.analyze_folder(json_path = json)

⋆ Command-line usage

# Run the web app
traitly-app

# Internal morphology analysis (single image or folder)
traitly --fruit_internal -i tests/sample_data/
traitly --fruit_internal -i tests/sample_data/ -o results/ --num_cores 4
traitly --fruit_internal -i tests/sample_data/ --json config.json

# External morphology analysis (single image or folder)
traitly --fruit_external -i tests/sample_data/
traitly --fruit_external -i tests/sample_data/ -o results/ --json config.json --num_cores 4

For more detailed examples, check our tutorials ᯓ★


Citation

We are working on a manuscript describing this software and its applications, expected to be submitted in Spring–Summer 2026. In the meantime, if you use Traitly in your research, please cite it as:

Torres-Meraz, M. A., Lopez-Moreno, H., & Zalapa, J. (2026). Traitly: A Python Toolkit for High-Throughput Fruit Phenotyping. Zenodo. https://doi.org/10.5281/zenodo.18738366


Contact

For questions or comments about the project, feel free to reach out to:

We are open to collaborations, including adding new traits, and creating tutorials or workflows for specific crops or plant tissues.


Contributions

Inspired by All Contributors, we recognize all kinds of contributions, not just code:

Contributor Role
 María Meraz 💻 📆 🚧 📓 ✅ 🐛 📖 ⚠️ 🤔 🌍
 Héctor López 📖 📓 ✅ 🤔 🐛 🔣 🌍
Juan Zalapa 🔣

Acknowledgements ♡

We thank the developers of OpenCV, Ultralytics, EasyOCR, NumPy, Pandas, Matplotlib, and Shiny, as well as all open-source libraries that made this project possible.

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

traitly-0.1.1.tar.gz (12.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traitly-0.1.1-py3-none-any.whl (11.5 MB view details)

Uploaded Python 3

File details

Details for the file traitly-0.1.1.tar.gz.

File metadata

  • Download URL: traitly-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for traitly-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5ac8e9baed6d26f2a20437b5ff324c364ceb34e0540184590531fb0874eb460b
MD5 1387596c9dc0ae8818b2da80cd92173c
BLAKE2b-256 56f126d9859d82b7ea60cd4b8961af8ab71753c7eb28fd8d64ccc3afd437bc0f

See more details on using hashes here.

File details

Details for the file traitly-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: traitly-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for traitly-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78723f02fe5f9b3bc2889fc1637ded47c9e6cc5b0997a7f204dec66a42900026
MD5 28c0537e35d0e0495bee0f3322092e7c
BLAKE2b-256 5eae26229cda0387ea8230ebdb46d7c13448bd33070800e3fdbf2a053f28ccc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page