This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:18.04 | |
WORKDIR /home | |
ENV HOME /home | |
RUN cd ~ | |
RUN apt-get update | |
RUN apt-get install -y git nano python3-pip python-dev pkg-config wget usbutils curl | |
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" \ | |
| tee /etc/apt/sources.list.d/coral-edgetpu.list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM arm64v8/debian:latest | |
WORKDIR /home | |
ENV HOME /home | |
RUN cd ~ | |
RUN apt-get update | |
RUN apt-get install -y git nano python3-pip python-dev pkg-config wget usbutils curl | |
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" \ | |
| tee /etc/apt/sources.list.d/coral-edgetpu.list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dts-v1/; | |
/plugin/; | |
/ { | |
compatible = "fsl,imx8mq-hdmi"; | |
fragment@0 { | |
target-path = "/hdmi@32c00000"; | |
__overlay__ { | |
status = "disabled"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from here: https://github.com/googlecreativelab/teachablemachine-community/blob/master/snippets/markdown/image/edgetpu/python.md just fixed some bugs | |
from edgetpu.classification.engine import ClassificationEngine | |
from PIL import Image | |
import cv2 | |
import re | |
import os | |
import sys | |
# the TFLite converted to be used with edgetpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install the edgetpu compiler. | |
!curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
!echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list | |
!sudo apt-get update | |
!sudo apt-get install edgetpu-compiler | |
# Compile our model and make a tarball of the finished trained model. | |
%cd /content/output_model | |
!edgetpu_compiler -s ssdlite_mobiledet_custom.tflite | |
%cd /content/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install tflite_runtime package to evaluate the model. | |
!pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp36-cp36m-linux_x86_64.whl | |
# Now we do evaluation on the tflite model. | |
import os | |
import numpy as np | |
from tflite_runtime.interpreter import Interpreter | |
from tflite_runtime.interpreter import load_delegate | |
from PIL import Image | |
from PIL import ImageDraw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Now we can convert this custom trained model to a CPU tflite model | |
!tflite_convert \ | |
--output_file="/content/output_model/ssdlite_mobiledet_dog_vs_cat.tflite" \ | |
--graph_def_file="/content/output_model/tflite_graph.pb" \ | |
--inference_type=QUANTIZED_UINT8 \ | |
--input_arrays="normalized_input_image_tensor" \ | |
--output_arrays="TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3" \ | |
--mean_values=128 \ | |
--std_dev_values=128 \ | |
--input_shapes=1,320,320,3 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Now we export this model to tflite_graph format. | |
%cd /content/models/research | |
!mkdir /content/output_model | |
!python3 object_detection/export_tflite_ssd_graph.py \ | |
--pipeline_config_path=/content/models/research/object_detection/samples/configs/ssdlite_mobiledet_edgetpu_320x320_coco_sync_4x4.config \ | |
--trained_checkpoint_prefix=/content/train/model.ckpt-25000 \ | |
--output_directory=/content/output_model \ | |
--add_postprocessing_op=true | |
# Make sure to change the model-ckpt-# to match the checkpoint number you used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do a Quick Evaluation on the inference graph model. | |
import numpy as np | |
import os | |
import sys | |
import tensorflow as tf | |
from collections import defaultdict | |
from matplotlib import pyplot as plt | |
from PIL import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's download some test data from flickr. | |
!mkdir /content/test | |
!cd /content/test | |
!wget https://live.staticflickr.com/7921/46683787864_86c9501c24_c_d.jpg -O /content/test/image1.jpg | |
!wget https://live.staticflickr.com/4/8451898_8bedb2ae53_c_d.jpg -O /content/test/image2.jpg | |
!wget https://live.staticflickr.com/2654/3997966238_f454845087_c_d.jpg -O /content/test/image3.jpg | |
!wget https://live.staticflickr.com/2818/34032378096_5309537c9f_c_d.jpg -O /content/test/image4.jpg | |
!wget https://live.staticflickr.com/8682/28214087384_4c7711584d_c_d.jpg -O /content/test/image5.jpg |
NewerOlder