CropEdgeAI 🌱
CropEdgeAI is a Computer Vision pipeline for crop and weed detection, with tools for dataset processing, data augmentation, hyperparameter optimization, and NCNN export for edge deployment.
Attribution
This project uses data from:
- Weed-crop dataset in precision agriculture by Upadhyay et al., North Dakota State University
- Licensed under Creative Commons Attribution 4.0 International (CC BY 4.0)
- DOI: 10.17632/mthv4ppwyw.2 Please check NOTICE for further details.
Table of Contents
Features
- Data loading, validation, splitting, augmentation
- EDA: dataset statistics and visualizations
- HPO with Optuna
- YOLO v8/v9/v10/v11/v12 training and benchmarking
- NCNN export for edge devices
- Batch inference with stats export
- Google Drive backup
Supported Crops
Black bean, Canola, Corn, Field pea, Flax, Lentil, Soybean, Sugar beet
Installation
- Python 3.11 or 3.12
- CUDA GPU (optional)
- 40GB+ disk space
git clone https://github.com/manueljesus/cropedgeai.git
cd cropedgeai
pip install uv
uv sync
For development: uv sync --group dev
Quick Start
1. Data Preparation
from cropedgeai.dataset import WeedCropDatasetLoader
loader = WeedCropDatasetLoader("path/to/weed-crop-dataset")
dataset = loader()
print(f"Loaded {len(dataset)} annotations")
print(f"Classes: {dataset['class_name'].unique()}")
2. Exploratory Data Analysis
from cropedgeai.eda import WeedCropEDA, WeedCropVisualizer
eda = WeedCropEDA(dataset, dataset_name="My Dataset")
stats = eda.dataset_distribution()
visualizer = WeedCropVisualizer(eda)
visualizer.plot_class_balance()
visualizer.plot_spatial_distribution()
3. Dataset Splitting & Augmentation
from cropedgeai.dataset import DatasetSplitter, DatasetAugmenter
splitter = DatasetSplitter(dataset, validation_size=0.15, test_size=0.15, output_dir="./processed", organize_files=True)
train, val, test = splitter()
augmenter = DatasetAugmenter(train, "./augmented", "./processed")
augmented_dataset = augmenter(
run_overlay=True,
run_closeup=True,
overlay_images=1000,
weeds_per_image=5
)
4. Model Training & Benchmarking
from cropedgeai.experiments import YOLOExperiment
experiment = YOLOExperiment("config/baseline_experiment.yaml")
results = experiment()
5. Hyperparameter Optimization
from cropedgeai.experiments import YOLOHyperparameterOptimizer
optimizer = YOLOHyperparameterOptimizer("config/hpo_yolo11n.yaml")
hpo_results = optimizer()
6. Edge Deployment Optimization
from cropedgeai.experiments import YOLONCNNHyperparameterOptimizer
ncnn_optimizer = YOLONCNNHyperparameterOptimizer("config/ncnn_hpo.yaml")
results = ncnn_optimizer()
ncnn_path = ncnn_optimizer.export_ncnn(best_size) # Check results to confirm `best_size`
7. Batch Inference
cropedgeai model.pt input_folder/ output_folder/ \
--conf-threshold 0.35 \
--img-size 640 \
--stats-csv detections.csv
from cropedgeai.inference import YOLOBatchProcessor
processor = YOLOBatchProcessor(
model_path="best.pt",
input_folder="test_images/",
output_folder="results/",
stats_csv_file="detection_stats.csv",
conf_threshold=0.35
)
processor()
Configuration
Experiment
name: "My_Experiment"
dataset_yaml: "data/dataset.yaml"
models_to_test:
yolo11n: "yolo11n.pt"
yolo11s: "yolo11s.pt"
training_config:
epochs: 100
batch: 32
imgsz: 640
patience: 20
HPO
name: "crop_hpo"
dataset_yaml: "data/dataset.yaml"
base_model_path: "yolo11n.pt"
hyperparameter_search_space:
lr0:
type: "float"
min: 0.0001
max: 0.01
log: true
mosaic:
type: "float"
min: 0.0
max: 1.0
CLI
cropedgeai model.pt input/ output/
cropedgeai model.ncnn input/ output/ --conf-threshold 0.4 --img-size 416
cropedgeai --help
Metadata
Release files for cropedgeai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cropedgeai-0.1.0.tar.gz | 65.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cropedgeai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 135.2 kB
Release files / cropedgeai-0.1.0.tar.gz
| Download URL | cropedgeai-0.1.0.tar.gz |
|---|---|
| Size | 65.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4eff1c23ed88f4496a3b3a50a0c074513a51f692826d878c393145d081cba3c6
|
|
BLAKE2b-256 checksum How to use checksums |
060ef83cfc4827358eb60817189d69019ecabdfdd2bed5bd69b1e92a26d7ecb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cropedgeai-0.1.0-py3-none-any.whl
| Download URL | cropedgeai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 70.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2239d5ee76571ab98411be92164d3792f392dcc93651d9d56dcdd50d83ff61fa
|
|
BLAKE2b-256 checksum How to use checksums |
c0c8d4fdf3eb6ffb38e5618487c93f16b873fbc6767746c7e1050638dd1494eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cropedgeai 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.