Skip to content

Sycamorers/SASP

Repository files navigation

SASP: Segment Any Strawberry Plant

SASP is an end-to-end pipeline for strawberry canopy volume estimation from multi-view RGB images. The workflow combines PGSR reconstruction, SAGA-based 3D segmentation, YOLO-assisted object localization, automated color-based prompt selection, and concave-hull volume estimation with reference-box calibration to recover real-world canopy volume. This repository is structured as a clean, reproducible open-source package with a single CLI for all major stages.

Paper: https://www.sciencedirect.com/science/article/pii/S2772375525002503

Pipeline (Text Diagram)

multi-view image acquisition -> PGSR reconstruction -> SAGA training -> scene sampling -> YOLOv8 detection (plants + reference box) -> color-based auto prompt selection -> SAGA segmentation -> clustering -> concave hull volume -> reference box calibration -> final canopy volume outputs

Repository Layout

  • src/sasp/: canonical Python package and pipeline implementation
  • scripts/: thin command wrappers
  • configs/: example YAML configuration files
  • docs/: method details and troubleshooting
  • tests/: lightweight CPU-only unit tests
  • data/: placeholder directories only (no real data committed)
  • third_party/: preserved upstream/legacy code and licenses

Installation

Environment

  • OS: Linux/macOS (tested on Linux)
  • Python: 3.10+
  • GPU/CUDA: required for full PGSR/SAGA training and large-scene inference; not required for CLI import/help and unit tests

Install

git clone https://github.com/Sycamorers/SASP.git
cd SASP
pip install -e .

Optional extras:

pip install -e .[volume]   # alpha-shape volume dependencies
pip install -e .[vision]   # YOLO-related dependencies

CLI Quickstart

All stages write to --out_dir (default under outputs/, which is gitignored).

1) Reconstruct (PGSR)

python -m sasp reconstruct \
  --legacy_root third_party/saga_pgsr \
  --command "python train_PGSR.py --help" \
  --out_dir outputs/reconstruct

2) Train SAGA

python -m sasp train_saga \
  --legacy_root third_party/saga_pgsr \
  --command "python train_contrastive_feature.py --help" \
  --out_dir outputs/train_saga

3) Detect (YOLO plants + reference box)

python -m sasp detect \
  --detections_file /path/to/yolo_detections.json \
  --out_dir outputs/detect

4) Segment (SAGA inference + auto prompts)

python -m sasp segment \
  --sample_points /path/to/scene_points.npy \
  --out_dir outputs/segment

5) Cluster

python -m sasp cluster \
  --segment_points outputs/segment/plant_segment_points.npy \
  --radius 0.03 \
  --min_points 50 \
  --out_dir outputs/cluster

6) Volume (concave hull + calibration)

python -m sasp volume \
  --plant_points outputs/segment/plant_segment_points.npy \
  --box_points outputs/segment/reference_box_segment_points.npy \
  --alpha 0.02 \
  --reference_gt_volume_cm3 789.36 \
  --out_dir outputs/volume

7) End-to-end

python -m sasp run_all --config configs/example_run_all.yaml --out_dir outputs/run_all

Reproducibility Notes

Important parameters that affect results:

  • HSV thresholds for automatic prompt point selection (plant_hsv, box_hsv)
  • Concave hull alpha parameter (alpha)
  • Clustering radius and minimum cluster size (radius, min_points)
  • Reference box ground-truth volume for calibration
  • Image resolution/downsampling and camera-view coverage

Output Files

Typical outputs by stage:

  • detect/detections.json: YOLO detections for plants and reference box
  • segment/plant_segment_points.npy: segmented canopy points
  • segment/reference_box_segment_points.npy: segmented reference box points
  • cluster/cluster_*.npy: clustered canopy components
  • volume/volume_results.json and volume/volume_results.csv: calibrated canopy volume, scale factor, and metadata
  • run_all/run_all_manifest.json: stage output manifest

Citation

Please cite the SASP paper and include this repository citation metadata (CITATION.cff).

@article{huang2025sasp,
  title={SASP: Segment any strawberry plant, an end-to-end strawberry canopy volume estimation},
  author={Huang, Zijing and Lee, Won Suk and Zhang, Peigeng and Jeon, Hongyoung and Zhu, Heping},
  journal={Smart Agricultural Technology},
  volume={11},
  pages={101017},
  year={2025},
  doi={10.1016/j.atech.2025.101017},
  url={https://www.sciencedirect.com/science/article/pii/S2772375525002503}
}

About

Segment any strawberry plant, an end-to-end strawberry canopy volume estimation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors