Skip to content

mariameraz/traitly

Repository files navigation


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.


Important

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


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 ᯓ★


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

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.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors