Skip to content

Instantly share code, notes, and snippets.

View aallan's full-sized avatar

Alasdair Allan aallan

View GitHub Profile
@aallan
aallan / benchmark_intel_ncs.py
Created April 26, 2019 20:09
Benchmarking script for OpenVINO IR inferencing with the Intel Neural Compute Stick
#!/usr/bin/env python3
import platform
PLATFORM = platform.system().lower()
GOOGLE = 'edge_tpu'
INTEL = 'ncs2'
NVIDIA = 'jetson_nano'
PI = 'raspberry_pi'
IS_LINUX = (PLATFORM == 'linux')
@aallan
aallan / benchmark_tf_trt.py
Created April 26, 2019 15:36
Benchmarking script for TensorFlow + TensorRT inferencing on the NVIDIA Jetson Nano
#!/usr/bin/env python3
import platform
PLATFORM = platform.system().lower()
GOOGLE = 'edge_tpu'
INTEL = 'ncs2'
NVIDIA = 'jetson_nano'
PI = 'raspberry_pi'
IS_LINUX = (PLATFORM == 'linux')
@aallan
aallan / benchmark_tf.py
Created April 26, 2019 14:56
Benchmarking script for TensorFlow inferencing on Raspberry Pi, Darwin, and NVIDIA Jetson Nano
#!/usr/bin/env python3
import platform
PLATFORM = platform.system().lower()
GOOGLE = 'edge_tpu'
INTEL = 'ncs2'
NVIDIA = 'jetson_nano'
PI = 'raspberry_pi'
MAC = 'darwin'
IS_LINUX = (PLATFORM == 'linux')
@aallan
aallan / coco_labels.txt
Created April 22, 2019 14:23
Labels for the Mobilenet v2 SSD model trained with the COCO (2018/03/29) dataset.
1 person
2 bicycle
3 car
4 motorcycle
5 airplane
6 bus
7 train
8 truck
9 boat
10 traffic light
@aallan
aallan / CMakeLists.txt
Last active April 15, 2019 15:29
A CMakeList.txt file for the NVIDIA Jetson Nano object_recognition.cpp example, https://gist.github.com/aallan/4de3a74676d4ff10a476c2d6c20b9255
# require CMake 2.8 or greater
cmake_minimum_required(VERSION 2.8)
# declare my-recognition project
project(object_recognition)
# import jetson-inference and jetson-utils packages.
# note that if you didn't do "sudo make install"
# while building jetson-inference, this will error.
find_package(jetson-utils)
@aallan
aallan / object_recognition.cpp
Last active April 15, 2019 15:26
Obejct recognition example code for the NVIDIA Jetson Nano.
// Object Recognition example code from NVIDIA
// See https://github.com/dusty-nv/jetson-inference/blob/master/examples/my-recognition/my-recognition.cpp
#include <jetson-inference/imageNet.h>
#include <jetson-utils/loadImage.h>
int main( int argc, char** argv ){
if( argc < 2 ) {
printf("object_recognition: expected image filename as argument\n");
printf("example usage: ./object_recognition image.jpg\n");
@aallan
aallan / throttled.sh
Last active May 11, 2025 18:07
Script to parse the output of the 'vcgencmd get_throttled' command on a Raspberry Pi
#!/bin/bash
# https://retropie.org.uk/forum/topic/2295/runcommand-warning-if-voltage-temperature-throttling
#Flag Bits
UNDERVOLTED=0x1
CAPPED=0x2
THROTTLED=0x4
HAS_UNDERVOLTED=0x10000
HAS_CAPPED=0x20000
@aallan
aallan / object_detection_with_labels.py
Created March 8, 2019 19:54
Object detection python demonstration code for use with Google's Edge TPU (now with labelling)
import argparse
import platform
import subprocess
from edgetpu.detection.engine import DetectionEngine
from PIL import Image
from PIL import ImageFont, ImageDraw
# Function to draw a rectangle with width > 1
def draw_rectangle(draw, coordinates, color, width=1):
for i in range(width):
@aallan
aallan / object_detection.py
Created March 8, 2019 16:45
Object detection python demonstration code for use with Google's Edge TPU
"""A demo for object detection.
For Raspberry Pi, you need to install 'feh' as image viewer:
sudo apt-get install feh
Example (Running in /usr/lib/python3/dist-packages/edgetpu):
- Face detection:
python3 demo/object_detection.py \
--model='test_data/mobilenet_ssd_v2_face_quant_postprocess_edgetpu.tflite' \
@aallan
aallan / classify_image.py
Created March 8, 2019 12:26
Image classifier python demonstration code for use with Google's Edge TPU
"""A demo to classify image."""
import argparse
from edgetpu.classification.engine import ClassificationEngine
from PIL import Image
# Function to read labels from text files.
def ReadLabelFile(file_path):
with open(file_path, 'r') as f:
lines = f.readlines()
ret = {}