Skip to content

Crop-Simulator/Python-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python-API

CI

Install

Python Version

The build is tested on Python 3.10.2 and is our recommended Python version. We use pyenv to manage our Python versions and Poetry to manage our packages and dependencies.

Pyenv Setup

Once installed, use the following command in commandline to install the supported Python version.

pyenv install 3.10.2

After the Python version has been installed, type pyenv local and ensure the output is 3.10.2

Poetry Setup

After installing the pyenv, install poetry using the official instructions.

Activating the virtual environment

Once poetry is installed, type the following to activate the virtual environment:

poetry shell

To deactivate the venv and exit this new shell type exit

Dependency Installation

While in the active venv, use the following command to install the dependencies.

poetry install

Managing Dependencies

To add a new dependency use poetry add <dependency name>

  • For more guidance on dependency management refer to poetry's official website.

Launch API

While in the active venv, use the following command to run the code

poetry run python .\src\launch.py .\data.yml

Installing Blender

To install Blender following these instructions. The build is tested on Blender 3.5 and is our recommended version.

Linting

To lint the code we use ruff. Use the following command to run Ruff over the project

ruff check .

If Ruff considers an error "fixable" it can be resolved by running the following

ruff check --fix .

Testing

While in the active venv, to run the all the unit tests use the following command from the root directory of your checkout

poetry run pytest 

To run a single unit test file use

poetry run pytest tests/test_launch.py

Interactive Annotator

A semi-automation tool for conducting pixel-level segmentation annotation. Currently, supports "ground", "crop", and "weed" types.

Start Annotator

poetry run python .\src\machine_learning\utilities\interactive_annotator.py

Initialisation and Configuration

Upon first execution, it will generate a interactive_annotator_config.ini file besides it and quit. Open the ini file, change the "source image folder" and "output image folder" to your desired paths.

Usage

The annotator automatically extracts ground pixels, and then you need to manually mark weed pixels out of crop pixels using various tools provided.

Keyboard operations (this guideline also appears in the title of window)

  • b: switch to brush
  • e: switch to eraser
  • r: switch to rectangle fill
  • g: switch to rectangle erase
  • x: clear all annotation
  • space: save current annotation and proceed to next
  • esc/q: quit

Settings

The annotator has a dedicated Tools Window for change various settings:

  • Disp Width: zoom in or out of the image
  • Disp Mode: switch between different display modes:
    • 0: overlay mode: ground pixels darken, weed pixels in red
    • 1: original image
    • 2: ground in grey, weed in red
    • 3: high contrast: ground in red, weed in black
  • Lower/Upper HSV: adjust the parameters for extracting ground pixels
  • Smoothing: 0 means no smoothing
  • Brush Size: in pixels

The settings and your progress will be memorised when you press space to save and continue, so that you can enjoy your favourite settings and continue your work upon next run.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7