Skip to content

Instantly share code, notes, and snippets.

View ShawnHymel's full-sized avatar

Shawn Hymel ShawnHymel

View GitHub Profile
@ShawnHymel
ShawnHymel / tflite_sinewave_training.ipynb
Created March 18, 2020 17:42
TensorFlow Lite Sinewave Regression Training and Conversion
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShawnHymel
ShawnHymel / fred_bot.ino
Last active May 26, 2025 20:15
Use two magnetic encoders to make a robot drive in a straight line for 1 meter
/**
* Adventures in Science: Fred Bot
* SparkFun Electronics
* Author: M. Hord (October 8, 2013)
* Modified by: B. Huang (October 31, 2014)
* Modified by: Shawn Hymel (July 21, 2017)
*
* Use two magnetic encoders on Fred's motor shafts (48:1
* gearbox, 60mm wheels) to make him move in a straight line for
* 1m.
@ShawnHymel
ShawnHymel / ollama-light-assistant.py
Last active May 17, 2025 11:04
Ollama Tool (Function Calling) Example on Raspberry Pi 5
"""
Ollama Light Assistant
Test the ability for LLMs to call tools (i.e. functions) from within the Ollama
environment on a Raspberry Pi with speech-to-text. Tested with a Raspberry Pi 5
(8 GB) and this USB microphone: https://www.adafruit.com/product/3367.
Connect an LED to GPIO 17 (physical pin 11 on the board) in an active high
configuration:
@ShawnHymel
ShawnHymel / tflite-runtime-example.md
Created July 2, 2024 18:55
tflite-runtime example

To perform object detection inference using a TensorFlow Lite model (.tflite) on a JPG image with tflite-runtime, you need to follow several steps including installation of the necessary packages, loading the model, preprocessing the input image, running inference, and handling the output. Here's a comprehensive guide:

1. Install tflite-runtime and Image Processing Library

You'll need to install tflite-runtime and Pillow for image processing. If you haven't installed these, you can do so using pip:

pip install tflite-runtime pillow

2. Prepare Your Model and Image

@ShawnHymel
ShawnHymel / quantized-inference-example.py
Last active October 22, 2024 14:11
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 / esp32_websocket_host.ino
Created March 3, 2019 22:23
ESP32 WebSocket Host
#include <WiFi.h>
#include <SPIFFS.h>
#include <ESPAsyncWebServer.h>
#include <WebSocketsServer.h>
// Constants
const char *ssid = "ESP32-AP";
const char *password = "LetMeInPlz";
const char *msg_toggle_led = "toggleLED";
const char *msg_get_led = "getLEDState";
@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 / 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 / GridEYE_LEDs.ino
Created May 2, 2018 20:24
Demo of the Grid-EYE IR sensor using an LED array
/**
* GridEye LED Array Demo
* Author: Shawn Hymel (SparkFun Electronics)
* Date: May 1, 2018
*
* Displays a heat map of what the GridEye sees (8x8 pixels).
*
* Required Components
* - Arduino: https://www.sparkfun.com/products/13975
* - Qwiic Shield: https://www.sparkfun.com/products/14352
@ShawnHymel
ShawnHymel / ei_json_to_csv.ipynb
Last active September 22, 2023 10:15
Edge Impulse JSON to CSV
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.