Skip to content

Instantly share code, notes, and snippets.

View GantMan's full-sized avatar
🤖
Being a Machine Learning beast

Gant Laborde GantMan

🤖
Being a Machine Learning beast
View GitHub Profile
@GantMan
GantMan / code.py
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
GantMan / bundlate.sh
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 ./index.android.bundle
# 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
GantMan / custom.html
Created June 3, 2020 21:09
teachable custom certificate code
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
<style>
.cert, .cert * {
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
@GantMan
GantMan / ElaborateExample.js
Last active March 23, 2020 14:45
AI Lab Specs
<AILabPhoto
// Provide TFJS Model and info
modelInfo={{
model: myModel,
objectDetection: true,
labels: ['dog', 'cat'],
threshold: 0.4,
max: 20,
IOU: 0.5
}}
// 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
setWasmPath('/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
GantMan / package.json
Created January 9, 2020 17:43
Copying the wasm file to public
"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
GantMan / config-overrides.js
Created January 6, 2020 21:33
Adding a WASM loader for react-app-rewired
const path = require('path')
module.exports = function override(config, env) {
config.module.rules.push({
test: /\.wasm$/i,
type: 'javascript/auto',
use: [{ loader: 'file-loader' }]
})
return config
@GantMan
GantMan / dog-cat.js
Last active September 14, 2019 16:46
Dogs N Cats
// https://www.cs.toronto.edu/~kriz/cifar.html
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
DC.training.length // 1600
DC.test.length // 400
@GantMan
GantMan / Tensorflow on Raspberry Pi.md
Last active March 28, 2019 15:36
How I installed Tensorflow on the Raspberry Pi - Steps

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
xscreensaver

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

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