Skip to content

Instantly share code, notes, and snippets.

View ZackAkil's full-sized avatar

Zack Akil ZackAkil

View GitHub Profile
@ZackAkil
ZackAkil / Code.gs
Created April 1, 2018 15:22
Code resources for generating a google form for labelling data.
function getSpreadsheetData(sheetName) {
// Return an list of objects (one for each row) containing the sheets data.
var arrayOfArrays = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName || 'Sheet1').getDataRange().getValues();
var headers = arrayOfArrays.shift();
return arrayOfArrays.map(function (row) {
return row.reduce(function (memo, value, index) {
if (value) {
memo[headers[index]] = value;
}
@ZackAkil
ZackAkil / main.py
Created October 24, 2018 09:22
Cloud Function python code to collect model feedback and save in DataStore
import json
import datetime
from flask import Response
# inport datastore client library
from google.cloud import datastore
# create new connection to datastore (will default connect to the one in the same project)
client = datastore.Client()
@ZackAkil
ZackAkil / list images for automl object detection.sh
Created May 24, 2019 10:53
Shell script that takes a folder on images stored on Google Cloud Storage and generates the CSV file needed to create a unlabeled dataset for AutoML Object Detection
for f in $(gsutil ls gs://YOUR_BUCKET/YOUR_IMAGES_FOLDER/);
do echo UNASSIGNED,$f,,,,,,,,,;
done >> labels.csv;
arr[0]="TRAIN"
arr[1]="TRAIN"
arr[2]="TRAIN"
arr[3]="TRAIN"
arr[4]="TRAIN"
arr[5]="TRAIN"
arr[6]="TRAIN"
arr[7]="VALIDATION"
arr[8]="TEST"
const drive_url_col = 2
const ouput_text_col = 3
function myFunction(e) {
var row_added = e.range.getRow()
Logger.log(row_added)
var drive_url = SpreadsheetApp.getActiveSheet().getRange(row_added, drive_url_col).getValue();
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu("🔮 Predictions for cell")
.addItem('😃/😡 Sentiment', 'predict_on_row')
.addToUi();
}
const output_column_number = 2
@ZackAkil
ZackAkil / unity_object_bounding_box.cs
Last active August 10, 2020 20:18
How to produce the perfect (tight) bounding box for a game object in Unity relative to a specific camera.
private Rect Get_object_bounding_box(GameObject game_object, Camera cam)
{
// This is a relativly intense way as it is looking at each mesh point to calculate the bounding box.
// but it produces perfect bounding boxes so yolo.
// get the mesh points
Vector3[] vertices = game_object.GetComponent<MeshFilter>().mesh.vertices;
// apply the world transforms (position, rotation, scale) to the mesh points and then get their 2D position
// relative to the camera
@ZackAkil
ZackAkil / unity_save_camera_image.cs
Last active May 28, 2024 09:28
Unity code to save camera view to PNG image.
void Save_camera_image(Camera cam, string path){
// set render target to target texture
var currentRT = RenderTexture.active;
RenderTexture.active = cam.targetTexture;
// Make a new texture and read the active Render Texture into it.
Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height);
image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
image.Apply();
/*
Mathify prototype code
Author - Zack Akil, 24 Nov 2015
*/
function generateAddition(num){
ran = Math.floor((Math.random() * (num-1)) + 1);
ran2 = num - ran;
return [ran,ran2];
@ZackAkil
ZackAkil / edge-tpu-compiler.ipynb
Created September 25, 2020 12:52
How to compile a tensorflow lite model to run on edge TPU all inside of a Colab notebook.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.