This file is used to create a reproducing environment for the project. To train the model on a GPU
To build the docker image run this command
sudo docker build --tag 'tf_vision' .
to use it, we can create a shell into the docker image to the scripts to train and visualize the model
sudo docker run -it --rm --runtime=nvidia --gpus all -v $PWD:/app -w /app 'tf_vision' bash
python trainer.py
This reference was used in order to create this project and adapt for rubix cubes
https://www.tensorflow.org/tfmodels/vision/object_detection
all images should be converted to strip out any unwanted metadata
# install imagemagick
brew install imagemagick
# bulk convert multiple images striping meta data
magick mogrify -strip -monitor -format jpg *.JPG
python labelme2coco.py
ROOT_FOLDER="./images"
TRAIN_DATA_DIR="${ROOT_FOLDER}/train"
TRAIN_ANNOTATION_FILE_DIR="${TRAIN_DATA_DIR}/_annotations.coco.json"
OUTPUT_TFRECORD_TRAIN="./tfrecords/train"
# Need to provide
# 1. image_dir: where images are present
# 2. object_annotations_file: where annotations are listed in json format
# 3. output_file_prefix: where to write output convered TFRecords files
python -m official.vision.data.create_coco_tf_record --logtostderr \
--image_dir=${TRAIN_DATA_DIR} \
--object_annotations_file=${TRAIN_ANNOTATION_FILE_DIR} \
--output_file_prefix=$OUTPUT_TFRECORD_TRAIN \
--num_shards=1
VALID_DATA_DIR="${ROOT_FOLDER}/valid"
VALID_ANNOTATION_FILE_DIR="${VALID_DATA_DIR}/_annotations.coco.json"
OUTPUT_TFRECORD_VALID="./tfrecords/valid"
python -m official.vision.data.create_coco_tf_record --logtostderr \
--image_dir=$VALID_DATA_DIR \
--object_annotations_file=$VALID_ANNOTATION_FILE_DIR \
--output_file_prefix=$OUTPUT_TFRECORD_VALID \
--num_shards=1
TEST_DATA_DIR="${ROOT_FOLDER}/test"
TEST_ANNOTATION_FILE_DIR="${TEST_DATA_DIR}/_annotations.coco.json"
OUTPUT_TFRECORD_TEST='./tfrecords/test'
python -m official.vision.data.create_coco_tf_record --logtostderr \
--image_dir=$TEST_DATA_DIR \
--object_annotations_file=$TEST_ANNOTATION_FILE_DIR \
--output_file_prefix=$OUTPUT_TFRECORD_TEST \
--num_shards=1
tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model --signature_name=serving_default --saved_model_tags=serve ./exported_model ./web_model