Skip to content

Instantly share code, notes, and snippets.

View StanCallewaert's full-sized avatar

StanCallewaert StanCallewaert

View GitHub Profile
@StanCallewaert
StanCallewaert / convert_for_edge_tpu_use.sh
Last active April 3, 2019 12:13
Convert our current model to a model for the Edge TPU
python object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path="pipeline.config" \
--trained_checkpoint_prefix="model.ckpt-500" \
--output_directory="output" \
--add_postprocessing_op=true
bazel run -c opt tensorflow/contrib/lite/toco:toco -- \
--input_file=output/tflite_graph.pb \
--output_file=output/detect.tflite \
--input_shapes=1,300,300,3 \
@StanCallewaert
StanCallewaert / package_object_detection.sh
Last active April 3, 2019 12:13
Package the Object Detection API, pycocotools, and TF Slim
bash object_detection/dataset_tools/create_pycocotools_package.sh /tmp/pycocotools
python setup.py sdist
(cd slim && python setup.py sdist)
@StanCallewaert
StanCallewaert / train_model.sh
Last active April 3, 2019 12:10
Train the Tensorflow detection model
gcloud ml-engine jobs submit training training_job \
--job-dir=gs://edge-tpu-demo/train \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz,/tmp/pycocotools/pycocotools-2.0.tar.gz
--module-name object_detection.model_tpu_main \
--runtime-version 1.9 \
--scale-tier BASIC_TPU \
--region europe-west4 \
-- \
--model_dir=gs://edge-tpu-demo/train
--tpu_zone europe-west4 \
@StanCallewaert
StanCallewaert / label_map.pbtxt
Last active April 2, 2019 20:54
label_map.pbtxt
item {
id: 1
name: 'cutter'
}
item {
id: 2
name: 'plier'
}
item {
id: 3
@StanCallewaert
StanCallewaert / pipeline.config
Last active April 2, 2019 21:23
pipeline.config
model {
ssd {
num_classes: 3
...
train_config {
batch_size: 24
fine_tune_checkpoint: "gs://edge-tpu-demo/model.ckpt"
freeze_variables: [
'FeatureExtractor/MobilenetV2/Conv',
'FeatureExtractor/MobilenetV2/expanded_conv_1',
@StanCallewaert
StanCallewaert / data_to_tfrecords.sh
Last active April 3, 2019 12:14
Convert our data to the TFRecords file format
git clone git@github.com:datitran/raccoon_dataset.git
# Load your images and annotations in the correct folder
rm raccoon_dataset/annotations/* raccoon_dataset/images/*
mv image*.xml raccoon_dataset/annotations/
mv image*.jpg raccoon_dataset/images/
# Convert your XML files to a CSV file
cd raccoon_dataset
python3 xml_to_csv.py
@StanCallewaert
StanCallewaert / spin_up_labelimg.sh
Last active April 3, 2019 12:16
Spinning up LabelImg
git clone git@github.com:tzutalin/labelImg.git
cd labelImg
brew install qt
brew install libxml2
make qt5py3
python3 labelImg.py
@StanCallewaert
StanCallewaert / extract_images_from_video.sh
Last active September 20, 2019 11:10
Extract images from video
# First install ffmpeg
# Then set the following 2 variables
FILENAME=your_file.mp4
NUMBER_OF_IMAGES=50
VIDEO_LENGTH_IN_SECONDS=`ffprobe -i $FILENAME -show_entries format=duration -v quiet -of csv="p=0"`
ffmpeg -i $FILENAME -vf fps=$NUMBER_OF_SECONDS/$NUMBER_OF_IMAGES image%04d.jpg