chadwallacehart / aiy_custom_cat_detector

Custom object detection model on the AIY Vision Kit
13 stars 4 forks source link

Can you share more details on the transfer learning/fine-tune training script ? #2

Closed saket424 closed 6 years ago

saket424 commented 6 years ago

In your blog post https://cogint.ai/custom-vision-training-on-the-aiy-vision-kit/ is your quote "Then zhoujustin saved the day and shared a trained model based on the 20-class VOC dataset. I set this as the fine_tune_checkpoint and my results have been pretty good."

I attempted to use this pre-trained model from zhoujustin and am going in circles. His pipeline.config file appears different than the embedded_ssd_mobilenet_v1_coco.config including the steps sizes and slooow to converge etc.

Any more details you can share of how you used his model to bootstrap your cat detection task would be most helpful. Preferably a copy of your training script itself

Thanks in advance

saket424 commented 6 years ago

diff zhoujustin/pipeline.config ../samples/configs/embedded_ssd_mobilenet_v1_coco.config 9c9 << num_classes: 20

num_classes: 90

141c141 < batch_size: 100

batch_size: 32 146c146 < initial_learning_rate: 1e-7

      initial_learning_rate: 0.004

148c148 < decay_factor: 0.1

      decay_factor: 0.95

156,157c156 < fine_tune_checkpoint: "/tmp/VOCdevkit/trainning-1/model.ckpt-165764" < from_detection_checkpoint: true

fine_tune_checkpoint: "/PATH_TO_BE_CONFIGURED/model.ckpt" 163,198d161 < random_vertical_flip { < } < } < data_augmentation_options { < random_adjust_contrast { < } < } < data_augmentation_options { < random_adjust_saturation { < } < } < data_augmentation_options { < random_rotation90 { < } < } < data_augmentation_options { < random_adjust_brightness { < } < } < data_augmentation_options { < random_distort_color { < } < } < data_augmentation_options { < random_jitter_boxes { < } < } < data_augmentation_options { < random_image_scale { < } < } < data_augmentation_options { < random_black_patches { < } < } < data_augmentation_options { 206c169 < input_path: "/tmp/VOCdevkit/pascal_train.record"

input_path: "PATH_TO_BE_CONFIGURED/mscoco_train.record"

208c171 < label_map_path: "/tmp/VOCdevkit/pascal_label_map.pbtxt"

label_map_path: "PATH_TO_BE_CONFIGURED/mscoco_label_map.pbtxt" 218c181 < input_path: "/tmp/VOCdevkit/pascal_test.record"

input_path: "PATH_TO_BE_CONFIGURED/mscoco_val.record"

220c183 < label_map_path: "/tmp/VOCdevkit/pascal_label_map.pbtxt"

label_map_path: "PATH_TO_BE_CONFIGURED/mscoco_label_map.pbtxt"

saket424 commented 6 years ago

My short term goal is to get the aiy visionkit to recognize the 6 class card detector described here https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10

chadwallacehart commented 6 years ago

See my zip file I linked to in #1. The pipeline.config file is saved in the ZIP. You should be able to see that for comparison.

saket424 commented 6 years ago

Thanks Chad. With your pipeline.config and zhoujustin's model.ckpt-870894 model as the begin point for the fine_tune, I was able to train a model and generate an inference graph for the 6-class card task

screenshot from 2018-07-16 20-45-34

saket424 commented 6 years ago

I am eager to try it on the aiy bonnet next. thanks to your blog ! 1) First export the inference graph so you get the .pb file python export_inference_graph.py --input_type image_tensor --pipeline_config_path training/card.config --trained_checkpoint_prefix training/model.ckpt-45598 --output_directory inference_graph

2) Copy the .pb file cp /home/anand/objd/tensorflow1/models/research/object_detection/inference_graph/frozen_inference_graph.pb aiy_card6.pb

3) Run the compiler for visionbonnet ./bonnet_model_compiler.par \ --frozen_graph_path=aiy_card6.pb \ --output_graph_path=card6_detector.binaryproto \ --input_tensor_name="Preprocessor/sub" \ --output_tensor_names="concat,concat_1" \ --input_tensor_size=256 VisionBonnet model binary card6_detector.binaryproto generated.

4) Follow the end of your blog (AIY Object Detection code changes) from https://cogint.ai/custom-vision-training-on-the-aiy-vision-kit/

Thanks again!

chadwallacehart commented 6 years ago

@saket424: great to hear you got this working too - thanks for sharing.

saket424 commented 6 years ago

aiy_custom_card_detector.zip