Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,38 @@ The **config** folder contains two parameter files for specifying system charact

Please note that annotated images and JSON annotation files are saved to the location where the package is installed. Check the **install** folder of the repository to find the annotation outputs.

## 🖥️ Using the Graphical User Interface (GUI)

AOC Fruit Detector includes a visual GUI for editing YAML configurations and launching predictions or training tasks without directly modifying YAML files.

### Features

- Edit all YAML parameters in a structured, visual layout
- Select between ROS and non-ROS prediction modes
- Launch model training or prediction with a button
- Tooltips available for every parameter
- Required fields are marked with a red `*`
- Shows result statistics and prediction output paths

### How to run the GUI

From inside the container:

```bash
cd fruit_detector_ws/
python src/aoc_fruit_detector/gui_predic_trainer/main.py
```

This will launch the GUI.

### GUI Screenshot

Make sure the following image exists in your repo at `docs/gui_screenshot.png`:

![GUI screenshot](./gui_predic_trainer/assets/gui_screenshot.png)

---

## Wiki

To get more information about the AOC Fruit Detector, please refer to [Wiki page][wiki_page]
Expand Down
19 changes: 9 additions & 10 deletions config/non_ros_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ datasets:
train_dataset_name: 'aoc_train_dataset'
test_dataset_name: 'aoc_test_dataset'
validation_dataset_name: 'aoc_validation_dataset'
dataset_train_annotation_url: 'https://lncn.ac/aocanntrain'
dataset_train_annotation_url: 'https://lncn.ac/aocanntrain'
dataset_train_images_url: 'https://lncn.ac/aocdatatrain'
dataset_test_annotation_url: 'https://lncn.ac/aocanntest'
dataset_test_annotation_url: 'https://lncn.ac/aocanntest'
dataset_test_images_url: 'https://lncn.ac/aocdatatest'
files:
# pretrained model used as a training base model, if set as empty, the config file will use imagenet trained model as base.
Expand All @@ -26,11 +26,11 @@ files:
train_catalog_url: 'https://lncn.ac/aoccat'
directories:
train_image_dir: './data/strawberry_dataset/train/'
test_image_dir: './data/bag/rgbd/' #'./data/strawberry_dataset/test/'
test_image_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/bag/rgbd' #'./data/strawberry_dataset/test/'
validation_image_dir: './data/tomato_dataset/val/'
training_output_dir: './data/training_output/'
prediction_output_dir: './data/prediction_output/test_images/'
prediction_json_dir: './data/annotations/predicted/'
prediction_output_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data'
prediction_json_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data'
training:
epochs: 40000
number_of_classes: 2
Expand All @@ -44,9 +44,8 @@ settings:
show_orientation: true
fruit_type: 'strawberry' # currently supported for "strawberry" or "tomato"
validation_period: 500 # Smaller validation will increase training time. The value is set to have 100 validation during training
confidence_threshold: 0.9 # removes annotations with confidence score lower than this value
filename_patterns:
rgb: "image"
depth: "depth" # filename patterns for rgb and depth images
confidence_threshold: 0.5 # removes annotations with confidence score lower than this value
filename_patterns:
rgb: "_rgb"
depth: "_depth" # filename patterns for rgb and depth images


2 changes: 1 addition & 1 deletion config/ros_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ aoc_fruit_detector:
verbose: [True, True, True, True, True] # To draw [centroid, bbox, mask, coordinate frames, text] annotations on image
pub_verbose: True # To publish annotated image
pub_markers: True # To publish RViz markers
use_ros: True # To subscribe RGBD data and publish output from/on ROS2 framework
use_ros: False # To subscribe RGBD data and publish output from/on ROS2 framework
51 changes: 51 additions & 0 deletions config/training_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#Call program with "python -O" O=Optimize directive for non debug mode. (it is not a zero :))
#When executed in Optimized mode, the program will neither output predicted images with bounding box/mask overlays nor it will write a respective json file. Moreover, the debug traces will not print at error event. In this mode json will be output in a variable.

# UZ: After training, the newly trained model should be place in the model folder, it should be renamed to aoc_model.pth
datasets:
train_dataset_name: 'flowers_train'
test_dataset_name: 'flowers_test'
validation_dataset_name: 'flowers_val'
dataset_train_annotation_url: '' #'https://lncn.ac/aocanntrain'
dataset_train_images_url: '' #'https://lncn.ac/aocdatatrain'
dataset_test_annotation_url: '' #'https://lncn.ac/aocanntest'
dataset_test_images_url: '' #'https://lncn.ac/aocdatatest'
files:
# pretrained model used as a training base model, if set as empty, the config file will use imagenet trained model as base.
pretrained_model_file: ''
# model_file: './model/aoc_tomato_ripeness_151_40k.pth'
model_file: './model/aoc_flowers.pth' #'./model/aoc_strawberry_class_ripeness.pth' #'./model/aoc_model.pth'
config_file: 'COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml'
test_metadata_catalog_file: './data/dataset_catalogs/flowers_test_metadata.pkl' #'./data/dataset_catalogs/tom_test_metadata_catalog.pkl'
train_dataset_catalog_file: './data/dataset_catalogs/flowers_train_metadata.pkl' #'./data/dataset_catalogs/tom_train_dataset_catalog.pkl'
train_annotation_file: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/annotations/train_annotations.json' #'./data/tomato_dataset/train/annotations/ripeness_class_annotations.json'
test_annotation_file: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/annotations/test_annotations.json' #'./data/tomato_dataset/test/annotations/ripeness_class_annotations.json'
validation_annotation_file: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/annotations/val_annotations.json' #'./data/tomato_dataset/val/annotations/ripeness_class_annotations.json'
model_url: '' #'https://lncn.ac/aocmodel'
meta_catalog_url: '' #'https://lncn.ac/aocmeta'
train_catalog_url: '' #'https://lncn.ac/aoccat'
directories:
train_image_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/train/' #'./data/strawberry_dataset/train/'
test_image_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/test/' #'./data/strawberry_dataset/test/'
validation_image_dir: '/home/ros/fruit_detector_ws/src/aoc_fruit_detector/scripts/data/flowers_dataset/val/' #'./data/tomato_dataset/val/'
training_output_dir: './data/training_output/'
prediction_output_dir: './data/prediction_output/test_images/'
prediction_json_dir: './data/annotations/predicted/'
training:
epochs: 40000
number_of_classes: 1
optimizer: 'SGD'
learning_rate: 0.0025
settings:
download_assets: false # if assets such as model and datasets should be downloaded
rename_pred_images: false #rename the predicted images in img_000001.png like format
segm_masks: false
bbox: true
show_orientation: false
fruit_type: '' # currently supported for "strawberry" or "tomato"
validation_period: 500 # Smaller validation will increase training time. The value is set to have 100 validation during training
confidence_threshold: 0.5 # removes annotations with confidence score lower than this value
filename_patterns:
rgb: "_rgb"
depth: "_depth" # filename patterns for rgb and depth images

Binary file added gui_predic_trainer/assets/gui_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions gui_predic_trainer/config_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ============================================================
# File: config_paths.py
# Author: Yael Vicente
# Date: 2025-May-06
# Description:
# Centralized configuration paths used across the GUI.
# Defines static paths to parameter files for training and prediction.
# ============================================================

# Paths to configuration files
TRAINING_CONFIG_PATH = "/home/ros/fruit_detector_ws/src/aoc_fruit_detector/config/training_parameters.yaml"
ROS_PARAMS_PATH = "/home/ros/fruit_detector_ws/src/aoc_fruit_detector/config/ros_params.yaml"
NON_ROS_PARAMS_PATH = "/home/ros/fruit_detector_ws/src/aoc_fruit_detector/config/non_ros_params.yaml"
73 changes: 73 additions & 0 deletions gui_predic_trainer/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ============================================================
# File: constants.py
# Author: Yael Vicente
# Date: 2025-May-06
# Description:
# Dictionary containing formal English descriptions for YAML configuration
# fields used in the AOC Fruit Detector GUI. These descriptions are
# displayed as tooltips to assist the user during configuration.
# ============================================================

FIELD_DESCRIPTIONS = {

# ROS-specific parameters (aoc_fruit_detector.ros__parameters.*)
"aoc_fruit_detector.ros__parameters.min_depth": "Minimum depth threshold (in meters) for considering objects during detection.",
"aoc_fruit_detector.ros__parameters.max_depth": "Maximum depth threshold (in meters) to validate detected objects.",
"aoc_fruit_detector.ros__parameters.constant_depth_value": "Fixed depth value to be used when depth data is not available.",
"aoc_fruit_detector.ros__parameters.fruit_type": "Specifies the type of fruit to detect within the ROS pipeline. Supported values: 'strawberry', 'tomato'.",
"aoc_fruit_detector.ros__parameters.pose3d_frame": "TF frame used to publish the 3D pose of detected fruits.",
"aoc_fruit_detector.ros__parameters.pose3d_tf": "Determines whether pose transformation between frames is required (True = apply transformation).",
"aoc_fruit_detector.ros__parameters.verbose": "List of boolean flags to enable visual annotations: [centroid, bounding box, mask, coordinate frame, text].",
"aoc_fruit_detector.ros__parameters.pub_verbose": "Enables publishing of annotated prediction images on a ROS topic.",
"aoc_fruit_detector.ros__parameters.pub_markers": "Enables publishing of RViz markers for 3D fruit pose visualization.",
"aoc_fruit_detector.ros__parameters.use_ros": "If enabled, the model will run within the ROS2 framework using topics for I/O.",

# Dataset-related fields
"datasets.train_dataset_name": "Name of the training dataset. Use the same name as the dataset used to train the selected model. Required.",
"datasets.test_dataset_name": "Name of the testing dataset. Use the same name as the dataset used to train the selected model. Required.",
"datasets.validation_dataset_name": "Name of the validation dataset. Use the same name as the dataset used to train the selected model. Required.",
"datasets.dataset_train_annotation_url": "URL for the training dataset's annotation file. Required if 'download_assets' is enabled.",
"datasets.dataset_train_images_url": "URL for the training dataset's image folder. Required if 'download_assets' is enabled.",
"datasets.dataset_test_annotation_url": "URL for the test dataset's annotation file. Required if 'download_assets' is enabled.",
"datasets.dataset_test_images_url": "URL for the test dataset's image folder. Required if 'download_assets' is enabled.",

# File paths
"files.pretrained_model_file": "Path to a pretrained model used for fine-tuning. Optional.",
"files.model_file": "Path to the trained model to be used. If training a new model, specify the desired output filename.",
"files.config_file": "Path to the Detectron2 configuration file (.yaml). Required. Do not change unless using a custom config.",
"files.test_metadata_catalog_file": "Path to the metadata catalog for testing. Optional, unless using a custom metadata structure.",
"files.train_dataset_catalog_file": "Path to the training dataset catalog. Optional, unless using a custom dataset setup.",
"files.train_annotation_file": "Path to the COCO-format annotation file for training. Required if 'download_assets' is disabled.",
"files.test_annotation_file": "Path to the COCO-format annotation file for testing. Required if 'download_assets' is disabled.",
"files.validation_annotation_file": "Path to the COCO-format annotation file for validation. Optional but recommended.",
"files.model_url": "URL to download model weights. Required if 'download_assets' is enabled and no local model is provided.",
"files.meta_catalog_url": "URL to download the metadata catalog. Required if 'download_assets' is enabled and no local catalog is provided.",
"files.train_catalog_url": "URL to download the training dataset catalog. Required if 'download_assets' is enabled and no local file is provided.",

# Directories
"directories.train_image_dir": "Directory containing images for training. Required for both training and evaluation.",
"directories.test_image_dir": "Directory containing images to be used for prediction. Required for inference mode.",
"directories.validation_image_dir": "Directory containing validation images. Optional unless validation is enabled.",
"directories.training_output_dir": "Directory where training logs and outputs will be saved.",
"directories.prediction_output_dir": "Directory where predicted images will be saved. Required in both training and prediction modes.",
"directories.prediction_json_dir": "Directory where prediction JSON files will be stored. Required in both training and prediction modes.",

# Training parameters
"training.epochs": "Number of training epochs to run. Must be a positive integer.",
"training.batch_size": "Number of samples per batch during training. Typical values range from 2 to 32.",
"training.number_of_classes": "Total number of classes the model should predict. Required.",
"training.optimizer": "Optimizer algorithm to use for training (e.g., 'SGD', 'Adam').",
"training.learning_rate": "Learning rate used by the optimizer. Typical values range from 0.001 to 0.01.",

# Model settings
"settings.download_assets": "Set to True to enable downloading of datasets and model files. Set to False if all assets are already available locally.",
"settings.rename_pred_images": "Set to True to rename predicted image files using a numbered pattern (e.g., img_000001.png).",
"settings.segm_masks": "Set to True to enable segmentation mask predictions. Set to False to disable.",
"settings.bbox": "Set to True to enable bounding box predictions. Set to False to disable.",
"settings.show_orientation": "Set to True to enable orientation estimation for detections. Only supported for strawberries and tomatoes.",
"settings.fruit_type": "Name of the fruit to be detected. Supported values: 'strawberry', 'tomato'. Leave empty if using a model trained on a different fruit.",
"settings.validation_period": "Applies during training. Smaller values increase validation frequency, which may increase training time.",
"settings.confidence_threshold": "Removes predictions with confidence scores below this threshold.",
"settings.filename_patterns.rgb": "Pattern used to identify RGB images by filename.",
"settings.filename_patterns.depth": "Pattern used to identify depth images by filename."
}
Empty file.
Loading
Loading