Skip to content

Instantly share code, notes, and snippets.

Being a Machine Learning beast

Gant Laborde GantMan

Being a Machine Learning beast
View GitHub Profile
GantMan /
Created July 17, 2021 16:22
Neopixel Trinkie April Fools Code
import time
import board
import neopixel
# Mouse stuff
import usb_hid
from adafruit_hid.mouse import Mouse
mouse = Mouse(usb_hid.devices)
# Annoying config
jump_distance = 75 # jump 75 pixels
delay_time = 60 # every 60 seconds
GantMan /
Created August 10, 2020 22:27
create React Native bundles from yarn command
# Generate your Android production bundle (just code no assets)
$ yarn react-native bundle --platform android --dev false --entry-file index.js --bundle-output ./
# Generate your iOS production bundle (just code no assets)
$ yarn react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ./index.ios.bundle
GantMan / custom.html
Created June 3, 2020 21:09
teachable custom certificate code
View custom.html
<!DOCTYPE html>
<link href="" rel="stylesheet">
.cert, .cert * {
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
GantMan / ElaborateExample.js
Last active March 23, 2020 14:45
AI Lab Specs
View ElaborateExample.js
// Provide TFJS Model and info
model: myModel,
objectDetection: true,
labels: ['dog', 'cat'],
threshold: 0.4,
max: 20,
IOU: 0.5
View App.js
// TensorFlow required
import * as tf from '@tensorflow/tfjs'
import { setWasmPath } from '@tensorflow/tfjs-backend-wasm'
// Default path without setWasmPath is /static/js/tfjs-backend-wasm.wasm
// We can now force a WASM backend and print it for proof!
tf.setBackend('wasm').then(console.log('The Backend is', tf.getBackend()))
GantMan / package.json
Created January 9, 2020 17:43
Copying the wasm file to public
View package.json
"scripts": {
"wasm": "cp node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm.wasm ./public",
"winwasm": "PowerShell -Command cp node_modules/@tensorflow/tfjs-backend-wasm/dist/tfjs-backend-wasm.wasm ./public -Force",
"start": "yarn wasm && react-scripts start",
"build": "yarn wasm && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
GantMan / config-overrides.js
Created January 6, 2020 21:33
Adding a WASM loader for react-app-rewired
View config-overrides.js
const path = require('path')
module.exports = function override(config, env) {
test: /\.wasm$/i,
type: 'javascript/auto',
use: [{ loader: 'file-loader' }]
return config
GantMan / dog-cat.js
Last active September 14, 2019 16:46
Dogs N Cats
View dog-cat.js
import * as DogsNCats from "dogs-n-cats"
// Creates a 1,000 dog and 1,000 cat images in memory
const DC = await DogsNCats.load()
// 4/5 Train/Test // 1600
DC.test.length // 400
GantMan / Tensorflow on Raspberry
Last active March 28, 2019 15:36
How I installed Tensorflow on the Raspberry Pi - Steps
View Tensorflow on Raspberry

Install pi, then camera, then edit the /boot/config.txt Add disable_camera_led=1 to the bottom of the file and rebooting.

Best to disable screensaver mode, as some follow-up commands may take hours

sudo apt-get install xscreensaver

Then disable screen saver in the “Display Mode” tab.

View use nsfwjs.js
// Gimme that image
const img = document.getElementById('questionable_img')
// Classify the image
const predictions = await model.classify(img)
// Share results
console.log('Predictions: ', predictions)