-
Notifications
You must be signed in to change notification settings - Fork 4
Detailed documentation: step by step for Flowers
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
plantclef_preprocessing.py
Training data
|-images
|-fruit
|-branch
|-stem
|-entire
|-leaf
|-xmls
|-flower
|-fruit
|-branch
|-stem
|-entire
|-leaf
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
flowers_train.ipynb
Training data
|-images
|-fruit
|-branch
|-stem
|-entire
|-leaf
saved_model.pb
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
classification_display_test.ipynb
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)
flower_tags_20K.tsv
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.