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
import argparse | |
from edgetpu.classification.engine import ClassificationEngine | |
from edgetpu.utils import dataset_utils | |
from PIL import Image | |
import multiprocessing | |
from multiprocessing import Process | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument( |
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
# Copyright 2019 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
import threading | |
import time | |
import cv2 | |
import cv2 as cv | |
import tensorflow as tf | |
from tensorflow.lite.python.interpreter import load_delegate | |
from edgetpu.basic import edgetpu_utils | |
from collections import namedtuple | |
import numpy as np |
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
import tensorflow as tf | |
if not str(tf.__version__).startswith('1.15'): | |
print('please use tensorflow 1.15') | |
exit() | |
from tensorflow.keras.models import Model | |
from tensorflow.keras.layers import Input, Conv2D | |
tf.enable_eager_execution() | |
image_shape = (64,64,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
# More infro here on Post Training Quantization here: | |
# https://www.tensorflow.org/lite/performance/post_training_quantization | |
# from_frozen_graph api is not n tf2.0 but can still be use with tf.compat.v1.lite, more on this api: | |
# https://www.tensorflow.org/api_docs/python/tf/compat/v1/lite/TFLiteConverter#from_frozen_graph | |
# This is an example for converting a frozen graph model to a fully quantized tflite model | |
# The model used here is http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_0.25_192.tgz | |
# Note that with post training quantization, sometimes it is not guarantee that the model will be fully quantized. | |
import sys, os, glob | |
import tensorflow as tf |
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
# 1) create this dockerfile | |
# 2) build: docker build -t "coral-edgetpu" . | |
# 3) run: docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb coral-edgetpu /bin/bash | |
# 4) download install requriements: cd ~/tflite/python/examples/classification/ && bash install_requirements.sh | |
# 5) run example: python3 classify_image.py \ | |
# > --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \ | |
# > --labels models/inat_bird_labels.txt \ | |
# > --input images/parrot.jpg | |
FROM tensorflow/tensorflow:1.15.0-py3 |
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
# 1) create this dockerfile | |
# 2) build: docker build -t "coral-edgetpu" . | |
# 3) run: docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb coral-edgetpu /bin/bash | |
# 4) download install requriements: cd ~/tflite/python/examples/classification/ && bash install_requirements.sh | |
# 5) run example: python3 classify_image.py \ | |
# > --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \ | |
# > --labels models/inat_bird_labels.txt \ | |
# > --input images/parrot.jpg | |
FROM tensorflow/tensorflow:1.15.0-py3 |
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
THIS IS DEPRECATED | |
# docker can be installed on the dev board following these instructions: | |
# https://github.com/f0cal/google-coral/issues/32#issuecomment-571629174 | |
# 1) create this dockerfile | |
# 2) build: docker build -t "coral" . | |
# 3) run: docker run -it --device /dev/apex_0:/dev/apex_0 coral /bin/bash | |
# 4) Try the classify_image demo: | |
# apt-get install edgetpu-examples |
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
# https://www.apache.org/licenses/LICENSE-2.0 | |
# Copyright 2019 Google LLC | |
# Modified by Nam Vu | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
r""" Example using tf.compat.v2.lite to classify |
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
# This is an example of starting a systemd object detection service on boot on the Coral Dev Board. | |
# 1) create a file call detects.service with the following contents: | |
[Unit] | |
Description=systemd object detection service | |
After=weston.target | |
[Service] | |
PAMName=login |
OlderNewer