Skip to content

Instantly share code, notes, and snippets.

View moodoki's full-sized avatar

TeckYian Lim moodoki

View GitHub Profile
@moodoki
moodoki / toolchain-arm-cortexa9_neon-linux-gnueabihf.cmake
Created October 20, 2014 06:23
CMake toolchain file for building OpenSceneGraph with a cross compiler toolchain
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSROOT /path/to/rootfs)
#debian dependencies required for building:
# libpthread-stubs0-dev_0.3-2_armel.deb
# libx11-6_1.3.3-4+squeeze1_armel.deb
# libx11-dev_1.3.3-4+squeeze1_armel.deb
# libxau-dev_1.0.6-1_armel.deb
# libxcb1_1.6-1+squeeze1_armel.deb
@moodoki
moodoki / exportgraph.py
Last active February 14, 2023 05:58
Freeze and export Tensorflow graph from checkpoint files
import os, argparse
import tensorflow as tf
from tensorflow.python.framework import graph_util
dir = os.path.dirname(os.path.realpath(__file__))
def freeze_graph(model_folder, output_nodes='y_hat',
output_filename='frozen-graph.pb',
rename_outputs=None):
@moodoki
moodoki / download_dataset.sh
Created November 27, 2017 22:25
Beethoven Piano Sonatas found on archive.org
#!/usr/bin/env bash
if [ "$#" -ne 1 ]; then
echo "Usage download_dataset <path_to_save>"
exit 1
fi
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
TEMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
echo $SCRIPT_PATH
@moodoki
moodoki / html_snippet.html
Last active February 21, 2021 09:31
Automatically resizing iframe youtube embed
<div>
<div style="position:relative;padding-top:56.25%">
<iframe src="<youtube-embed-url-here" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
</div>
</div>
@moodoki
moodoki / high-dimensional-data-visualization.ipynb
Last active June 30, 2021 06:11
High Dimensional Data Visualization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moodoki
moodoki / SecurityCam.py
Last active March 23, 2023 07:00
Streamlit AI Security Camera
import streamlit as st
import cv2
import tflite_runtime.interpreter as tflite
import numpy as np
import threading
from zipfile import ZipFile
BOX_COLOR = (0, 255, 255) #Yellow
TF_LITE_MODEL = './lite-model_ssd_mobilenet_v1_1_metadata_2.tflite'
CLASSES_OF_INTEREST = ['person', 'car', 'cat', 'dog']
@moodoki
moodoki / barebones_camera_thread.py
Created September 19, 2021 05:25
Barebones Camera Thread
import threading
import numpy as np
import cv2
class CameraThread(threading.Thread):
def __init__(self, name='CameraThread'):
super().__init__(name=name, daemon=True)
self.stop_event = False
self.open_camera()
self.setup_inference_engine()
@moodoki
moodoki / stremlit_thread_gist.py
Created September 19, 2021 06:39
Streamlit function cache threading
import streamlit as st
#CameraThread is a sub-class of threading.Thread
@st.cache(allow_output_mutation=True)
def get_or_create_camera_thread():
for th in threading.enumerate():
if th.name == 'CameraThread':
th.stop()
th.join()
cw = CameraThread(name='CameraThread')
@moodoki
moodoki / RemapedKeys.terminal
Created May 8, 2022 03:11
Fix macOS's Home, End and F1-4 keys
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGjCwwTVSRudWxs0w0ODxAREldO
U1doaXRlXE5TQ29sb3JTcGFjZVYkY2xhc3NNMCAwLjg5OTk5OTk4ABADgALSFBUWF1ok
Y2xhc3NuYW1lWCRjbGFzc2VzV05TQ29sb3KiFhhYTlNPYmplY3QIERokKTI3SUxRU1dd
@moodoki
moodoki / download.sh
Last active July 6, 2023 09:58
Segment Anything SA-1B Dataset Download script
#!/bin/bash
count=0
if [ $# -ne 2 ]; then
>&2 echo "Usage: $0 <input_file> <output_dir>"
>&2 echo "This script downloads all the tar files listed in the text file from https://ai.facebook.com/datasets/segment-anything-downloads/"
>&2 echo "To use this, accept the terms there, download the text file and run this script with it"
exit 1
fi