-
Notifications
You must be signed in to change notification settings - Fork 4
Detailed documentation: step by step for Chiroptera
For additional information, see github.com/aubricot/computer_vision_with_eol_images/object_detection_for_image_cropping
1 September 2025
Model used for final crops
Faster-RCNN
Only do Steps 1-2 if training new object detector. To run images through pre-trained EOL object detector, proceed to Step 3.
chiroptera_preprocessing.ipynb
image_crops_withEOL_pk.txt.zip
chiroptera_crops.tsv
chiroptera_crops_train.tsv
chiroptera_crops_test.tsv
chiroptera_crops_train_aug.tsv
chiroptera_crops_train_aug_oob_rem_fin.tsv
chiroptera_crops_test_notaug.tsv
chiroptera_crops_test_notaug_oob_rem_fin.tsv
Set up train and test datasets
Get all cropping data for Chiroptera from EOL user crops file (image_crops_withEOL_pk.txt). Split crop dimensions into multiple columns (height, width, ymin, ymax, xmin, xmax). Export Chiroptera crops subset (chiroptera_crops.tsv). Following the Pareto principle, split 80% of the original EOL crops dataset (consisting of images and cropping dimensions) to create the train dataset (chiroptera_crops_train.tsv) and use the remaining 20% for the test dataset (chiroptera_crops_test.tsv).
Pre-process train images & Pre-process test images
Test and train datasets are pre-processed and transformed to formatting standards for use with YOLO via Darkflow and SSD and Faster-RCNN object detection models implemented in Tensorflow. All train and test images are also downloaded to Google Drive for use training and testing. Before reformatting to object detection model standards, training data is augmented using the imgaug library. Image augmentation is used to increase training data sample size and diversity to reduce overfitting when training object detection models. Both images and cropping coordinates are augmented. After augmentation, out of bounds values are removed. The final train dataset consists of augmented and unaugmented images and cropping coordinates. The final test dataset contains only un-augmented images and cropping coordinates.
Inspect pre-processed crops on images
Visualize and evaluate bounding box transformations in steps 1b and 1c. If needed, adjust "iaa.Sequential" augmentation parameters and/or "remove_oob" transformations above and re-visualize until desired results are achieved.
chiroptera_train_tf2_ssd_rcnn.ipynb
Chiroptera_crops_test_notaug_oob_rem_fin.csv Chiroptera_crops_train_aug_oob_rem_fin.csv
tf.record (in images/ and test_images/) pipeline.config labelmap.pbtxt frozen_inference_graph.pb
Model preparation (only run once)
Pre-trained models are downloaded and files needed for training the model are made (Chiroptera crop data input files are converted to tf.record annotation files; a label map for 'Chiroptera,' and model config files are modified).
Train the model
Faster-RCNN model is trained until loss<1, for up to 30 hours (Faster-RCNN was trained for 200,000 steps).
To run images through pre-trained EOL object detector, follow steps below
--<>--<>--<>--<>--<>--<>--<>--<>--<>--<>--<>--<>--<>---
chiroptera_generate_crops_tf2.ipynb
frozen_inference_graph.pb
labelmap.pbtxt
https://editors.eol.org/other_files/bundle_images/files/images_for_Chiroptera_20K_breakdown_download_000001.txt
chiroptera_cropcoords_tf2_rcnn_a.tsv chiroptera_cropcoords_tf2_rcnn_b.tsv chiroptera_cropcoords_tf2_rcnn_c.tsv chiroptera_cropcoords_tf2_rcnn_d.tsv chiroptera_cropcoords_tf2_rcnn_concat.tsv chiroptera_cropcoords_tf2_rcnn_concat_displaytest.tsv chiroptera_cropcoords_tf2_rcnn_concat_20k_final.tsv
Run EOL 20k bundle images through trained object detector in 4 batches to get detection boxes (ex: chiroptera_cropcoords_tf2_rcnn_a.tsv). Then, post-process detection results to combine batches to one file (ex: chiroptera_cropcoords_tf2_rcnn_concat.tsv), convert individual boxes to one "superbox" per image, remove out of bounds values, convert dimensions to square, and re-format results to EOL crop coordinate formatting standards (ex: chiroptera_cropcoords_tf2_rcnn_concat_20k_final.tsv). Export square, padded cropping dimensions to display test file (ex: chiroptera_crops_rcnn_1000img_display_test.tsv). Finally, display square, padded crop coordinates on images and verify that the transformations in "Post-process detection results" are appropriate (or to fine tune accordingly, ex: adjust percent_pad).