Skip to content

Detailed documentation: step by step for Flowers

Katherine Wolcott edited this page Sep 14, 2022 · 4 revisions

Classification for image tagging: step-by-step documentation with input and output files

Flowers
For additional information, see github.com/aubricot/computer_vision_with_eol_images.
20 Jul 2020
-Update as of 31 Oct 2021--Flower classification pipelines are no longer being updated. As a result, this script is left in its state from 20 Jul 2020. Functions may become deprecated or lose functionality.--

Model used for final tags
custom-built

Step 1) Pre-process training data locally and upload to Google Drive

Script(s)

plantclef_preprocessing.py

Input file(s)

http://otmedia.lirmm.fr/LifeCLEF/PlantCLEF2015/Packages/TrainingPackage/PlantCLEF2015TrainingData.tar.gz

Output file(s)

Training data
   |-images
      |-fruit
      |-branch
      |-stem
      |-entire
      |-leaf
   |-xmls
      |-flower
      |-fruit
      |-branch
      |-stem
      |-entire
      |-leaf

Detailed steps

Download the PlantCLEF 2016 Image dataset locally. Unzip the folder containing the dataset. Move all xmls to their own folder using the terminal (mv flowers/PlantCLEF2015TrainingData/train/*.xml flowers/PlantCLEF2015TrainingData/xml). Then open plantclef_preprocessing.py. Before running plantclef_preprocessing.py, check that you have completed the directions for Steps 1-3 listed at the header of the code. Next, run the script to randomly select 6,000 images and sort them into folders based on image classes contained within xmls of the training dataset (flower, fruit, entire, stem, leaf, branch). You will be prompted to enter the source and destination directories (source: 'classification_for_image_tagging/data_files/input/flowers/PlantCLEF2015TrainingData/train'; destination='classification_for_image_tagging/data_files/input/flowers/PlantCLEF2015TrainingData/image_subset'). After running plantclef_preprocessing.py, zip the folder containing all image class subfolders. Upload the zipped folder to Google Drive (uploading the zipped folder will save time, because uploading to Drive can be slow) and unzip it before running flowers_train.ipynb in Step 2. To unzip the folder, use a command like this in a Colab notebook: !unzip images.zip -d images.

Step 2) Build & train classification models

Script(s)

flowers_train.ipynb

Input file(s)

Training data
   |-images
      |-fruit
      |-branch
      |-stem
      |-entire
      |-leaf

Output file(s)

saved_model.pb

Detailed steps

After preparing the training dataset locally and uploading it to Google Drive in Step 1, build and train classification models using flowers_train.ipynb. Form fields and dropdown menus within the notebook walk you through model selection, adjusting hyperparameters, training, and the display of trained models.

Step 3) Display classification results on images & export results for tagging

Script(s)

classification_display_test.ipynb

Input file(s)

saved_model.pb
Angiosperm breakdown files 1-31 (ex: https://editors.eol.org/other_files/bundle_images/files/images_for_Angiosperms_20K_breakdown_000001.txt)

Output file(s)

flower_tags_20K.tsv

Detailed steps

To display classification results from Step 2 on images and verify that they are as expected (or to further fine tune the classification model accordingly, ex: adjust hyperparameters from drop-down menus and re-train) using classification_display_test.ipynb.

Clone this wiki locally