Skip to content

Instantly share code, notes, and snippets.

View Namburger's full-sized avatar
😃
segfault

Nam Vu Namburger

😃
segfault
View GitHub Profile
@Namburger
Namburger / multi_crash.py
Created October 30, 2019 15:52
crashing Edgetpu Accelerator with multi-thread access
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(
@Namburger
Namburger / Makefile
Created November 5, 2019 15:19
This makefile for edgetpu will include the minimal.cc example as well as the glibc_compat.h needed for the build
# 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,
@Namburger
Namburger / switch.py
Last active November 8, 2019 17:08
roughly measuring the "switch" time between 2 models
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
@Namburger
Namburger / cv_obj_coral.py
Last active January 20, 2020 17:06
An example of doing object detection with open cv on the dev board
# Copyright 2019 Google LLC
#
# Changes made by Nam Vu 01/20/2020
#
# 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
#
@Namburger
Namburger / classify.py
Last active January 29, 2020 17:58
classify image with tensorflow's load delegate
# 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
@Namburger
Namburger / object_detection_2cameras.py
Created January 31, 2020 15:04
Doing object detection with 2 cameras with the Coral Dev Board
# Copyright 2019 Google LLC
#
# Changes made by Nam Vu 01/20/2020
#
# 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
#
@Namburger
Namburger / Dockerfile.edgetpu.tensorflow.1.15.0-py3
Last active January 31, 2020 17:37
minimal Dockerfile for running some edgetpu demos
# 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
@Namburger
Namburger / object_csv.py
Created February 25, 2020 16:45
This program write does live object detection and write output to a csv file.
# Copyright 2019 Google LLC
#
# Changes made by Nam Vu 02/25/2020
#
# 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
#
@Namburger
Namburger / Dockerfile
Last active March 24, 2020 18:31
minimal Dockerfile for running some edgetpu demos
# 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
@Namburger
Namburger / edgetpu_face_detector.py
Last active May 13, 2020 01:43
An example to run the edgetpu's face detection model
import os, argparse, cv2, sys, time, numpy
from tflite_runtime.interpreter import Interpreter
from tflite_runtime.interpreter import load_delegate
'''
Requirements:
1) Install the tflite_runtime package from here:
https://www.tensorflow.org/lite/guide/python
2) Camera to take inputs
3) Install libedgetpu