Skip to content

Instantly share code, notes, and snippets.

View ShawnHymel's full-sized avatar

Shawn Hymel ShawnHymel

View GitHub Profile
@ShawnHymel
ShawnHymel / classify-directory.py
Last active February 28, 2024 21:58
Edge Impulse - Classify all images in a directory
#!/usr/bin/env python
import device_patches # Device specific patches for Jetson Nano (needs to be before importing cv2)
import cv2
import os
import sys, getopt
import numpy as np
from edge_impulse_linux.image import ImageImpulseRunner
@ShawnHymel
ShawnHymel / ei_json_to_csv.ipynb
Last active September 22, 2023 10:15
Edge Impulse JSON to CSV
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShawnHymel
ShawnHymel / gym-recorder-demo.py
Last active December 11, 2022 22:44
OpenAI Gym Video Recorder
# This works for gym 0.26.2. It might not work on previous versions.
import gym
import cv2
fps = 30
# Create environment
env = gym.make('CartPole-v1', render_mode='rgb_array')
@ShawnHymel
ShawnHymel / magic_wand_standardized_inference.ino
Created October 10, 2022 19:38
Edge Impulse magic wand inference example
/**
* Magic Wand Inference Demo
*
* Attach a button to pin 2. Press button to start collection. Raw data will be
* collected and fed to the impulse for inference. Inference results are printed
* to the serial terminal.
*
* Author: Shawn Hymel (EdgeImpulse, Inc.)
* Date: October 10, 2022
* License: Apache-2.0 (apache.org/licenses/LICENSE-2.0)
@ShawnHymel
ShawnHymel / pygame-display-test.py
Created September 21, 2022 21:22
PyGame Display Test
"""
PyGame Display Test
Run to see if you can draw things in Pygame. Press 'esc` to exit. Run with
root privileges to draw on external monitor (e.g. from SSH).
"""
import pygame
# Initialize pygame
@ShawnHymel
ShawnHymel / printf_test.ino
Created August 28, 2022 18:02
Arduino printf test
#include <stdarg.h>
// Makeshift printf for the Serial terminal
void aprintf(const char *format, ...) {
static char print_buf[1024] = { 0 };
va_list args;
va_start(args, format);
int r = vsnprintf(print_buf, sizeof(print_buf), format, args);
va_end(args);
@ShawnHymel
ShawnHymel / time_series_dataset_curation.ipynb
Last active May 1, 2023 14:20
CSV Time Series Dataset Curation and Standardization
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShawnHymel
ShawnHymel / quantized-inference-example.py
Last active December 9, 2023 07:47
TensorFlow Lite (TFLite) Python Inference Example with Quantization
# TFLite quantized inference example
#
# Based on:
# https://www.tensorflow.org/lite/performance/post_training_integer_quant
# https://www.tensorflow.org/lite/api_docs/java/org/tensorflow/lite/Tensor.QuantizationParams
import numpy as np
import tensorflow as tf
# Location of tflite model file (float32 or int8 quantized)
@ShawnHymel
ShawnHymel / eye_test_01.py
Last active December 30, 2021 18:46
Adafruit HT16K33 LED matrix backpack test for Raspberry Pi
import board
import busio
import time
from random import random
from adafruit_ht16k33 import matrix
# Initialize LED matrix
i2c = busio.I2C(board.SCL, board.SDA)
eye =matrix.Matrix8x8(i2c)
@ShawnHymel
ShawnHymel / cnn-live-inference-lcd.py
Created September 26, 2021 19:33
OpenMV Electronic Component CNN Live Classification with LCD
"""
OpenMV Live Image Inference
Continuously captures images and performs image using provided TFLite model
file. Outputs probabilities in console. Displays preview on LCD backpack along
with predicted label.
Author: EdgeImpulse, Inc.
Modified: Shawn Hymel
Date: September 26, 2021