Package: agml
👨🏿‍💻👩🏽‍💻🌈🪴 Want to join theAI Institute for Food Systems teamand help lead AgML development? 🪴🌈👩🏼‍💻👨🏻‍💻We're looking to hire a postdoc with both Python library development and ML experience. Send your resume and GitHub profile link tojmearles@ucdavis.edu!OverviewAgML is a comprehensive library for agricultural machine learning. Currently, AgML provides
access to a wealth of public agricultural datasets for common agricultural deep learning tasks. In the future, AgML will provide ag-specific ML functionality related to data, training, and evaluation. Here's a conceptual diagram of the overall framework.AgML supports both theTensorFlowandPyTorchmachine learning frameworks.InstallationTo install the latest release of AgML, run the following command:pipinstallagmlQuick StartAgML is designed for easy usage of agricultural data in a variety of formats. You can start off by using theAgMLDataLoaderto
download and load a dataset into a container:importagmlloader=agml.data.AgMLDataLoader('apple_flower_segmentation')You can then use the in-built processing methods to get the loader ready for your training and evaluation pipelines. This includes, but
is not limited to, batching data, shuffling data, splitting data into training, validation, and test sets, and applying transforms.importalbumentationsasA# Batch the dataset into collections of 8 pieces of data:loader.batch(8)# Shuffle the data:loader.shuffle()# Apply transforms to the input images and output annotation masks:loader.mask_to_channel_basis()loader.transform(transform=A.RandomContrast(),dual_transform=A.Compose([A.RandomRotate90()]))# Split the data into train/val/test sets.loader.split(train=0.8,val=0.1,test=0.1)The split datasets can be accessed usingloader.train_data,loader.val_data, andloader.test_data. Any further processing applied to the
main loader will be applied to the split datasets, until the split attributes are accessed, at which point you need to apply processing independently
to each of the loaders. You can also turn toggle processing on and off using theloader.eval(),loader.reset_preprocessing(), andloader.disable_preprocessing()methods.You can visualize data using theagml.vizmodule, which supports multiple different types of visualization for different data types:# Disable processing and batching for the test data:test_ds=loader.test_datatest_ds.batch(None)test_ds.reset_prepreprocessing()# Visualize the image and mask side-by-side:agml.viz.visualize_image_and_mask(test_ds[0])# Visualize the mask overlaid onto the image:agml.viz.visualize_overlaid_masks(test_ds[0])AgML supports both the TensorFlow and PyTorch libraries as backends, and provides functionality to export your loaders to native TensorFlow and PyTorch
formats when you want to use them in a training pipeline. This includes both exporting theAgMLDataLoaderto atf.data.Datasetortorch.utils.data.DataLoader,
but also internally converting data within theAgMLDataLoaderitself, enabling access to its core functionality.# Export the loader as a `tf.data.Dataset`:train_ds=loader.train_data.export_tensorflow()# Convert to PyTorch tensors without exporting.train_ds=loader.train_datatrain_ds.as_torch_dataset()You're now ready to use AgML for training your own models!Public Dataset ListingDatasetTaskNumber of Imagesbean_disease_ugandaImage Classification1295carrot_weeds_germanySemantic Segmentation60plant_seedlings_aarhusImage Classification5539soybean_weed_uav_brazilImage Classification15336sugarcane_damage_usaImage Classification153crop_weeds_greeceImage Classification508sugarbeet_weed_segmentationSemantic Segmentation1931rangeland_weeds_australiaImage Classification17509fruit_detection_worldwideObject Detection565leaf_counting_denmarkImage Classification9372apple_detection_usaObject Detection2290mango_detection_australiaObject Detection1730apple_flower_segmentationSemantic Segmentation148apple_segmentation_minnesotaSemantic Segmentation670rice_seedling_segmentationSemantic Segmentation224plant_village_classificationImage Classification55448autonomous_greenhouse_regressionImage Regression389grape_detection_syntheticdayObject Detection448grape_detection_californiadayObject Detection126grape_detection_californianightObject Detection150guava_disease_pakistanImage Classification306apple_detection_spainObject Detection967apple_detection_drone_brazilObject Detection689plant_doc_classificationImage Classification2598plant_doc_detectionObject Detection2598wheat_head_countingObject Detection6512peachpear_flower_segmentationSemantic Segmentation42red_grapes_and_leaves_segmentationSemantic Segmentation258white_grapes_and_leaves_segmentationSemantic Segmentation273ghai_romaine_detectionObject Detection500ghai_green_cabbage_detectionObject Detection500ghai_iceberg_lettuce_detectionObject Detection500riseholme_strawberry_classification_2021Image Classification3520ghai_broccoli_detectionObject Detection500bean_synthetic_earlygrowth_aerialSemantic Segmentation2500ghai_strawberry_fruit_detectionObject Detection500Usage InformationUsing Public Agricultural DataAgML aims to provide easy access to a range of existing public agricultural datasets The core of AgML's public data pipeline isAgMLDataLoader. You can use theAgMLDataLoaderoragml.data.download_public_dataset()to download
the dataset locally from which point it will be automatically loaded from the disk on future runs.
From this point, the data within the loader can be split into train/val/test sets, batched, have augmentations and transforms
applied, and be converted into a training-ready dataset (including batching, tensor conversion, and image formatting).To see the various ways in which you can use AgML datasets in your training pipelines, check out
theexample notebook.Annotation FormatsA core aim of AgML is to provide datasets in a standardized format, enabling the synthesizing of multiple datasets
into a single training pipeline. To this end, we provide annotations in the following formats:Image Classification: Image-To-Label-NumberObject Detection:COCO JSONSemantic Segmentation: Dense Pixel-WiseContributionsWe welcome contributions! If you would like to contribute a new feature, fix an issue that you've noticed, or even just mention
a bug or feature that you would like to see implemented, please don't hesitate to use theIssuestab to bring it to our attention.
See thecontributing guidelinesfor more information.FundingThis project is partly funded by the [National AI Institute for Food Systems (AIFS)](https://aifs.ucdavis.ed