Skip to content

Instantly share code, notes, and snippets.

View iaverypadberg's full-sized avatar

Isaac Padberg iaverypadberg

View GitHub Profile
@iaverypadberg
iaverypadberg / argsort.kt
Created September 6, 2022 20:39
Argsort in Kotlin
private fun argsort(needsSorting : Array<Int>){
val theRange = IntRange(0,needsSorting.size-1)
val idxs = theRange.toList().sortedBy { needsSorting[it] }
}
@iaverypadberg
iaverypadberg / scratch.kt
Created September 8, 2022 20:54
Kotlin Scratch File
import org.jetbrains.kotlinx.multik.api.toNDArray
import org.jetbrains.kotlinx.multik.ndarray.data.get
import org.jetbrains.kotlinx.multik.ndarray.data.slice
import org.jetbrains.kotlinx.multik.ndarray.operations.last
import org.jetbrains.kotlinx.multik.ndarray.operations.minus
import org.jetbrains.kotlinx.multik.ndarray.operations.plus
import org.jetbrains.kotlinx.multik.ndarray.operations.toList
// Filter out all items
val startList = listOf(Pair(1,.2),Pair(2,.4),Pair(3,.6),Pair(4,.3))
@iaverypadberg
iaverypadberg / background_dataset.md
Created September 29, 2022 19:46
Building a Background Dataset From Scratch

Building a background dataset from scratch

For object detection models with very few classes (<5) and no background images, most models will struggle with false positives. The model is only learning what the thing is that it needs to detect. This is only half the problem.

The other half is that the model needs to learn what not to detect. Heres where background images come in.

Aquire background images

The easiest way to get some background images is to take a video with a smart phone and chop it into individual frames.

@iaverypadberg
iaverypadberg / run_tflite_on_folder.py
Created November 8, 2022 13:35
A python script for running tflite inference on a folder of images
from sqlite3 import adapt
import numpy as np
from PIL import Image
import glob
import cv2
import numpy as np
import tflite_runtime.interpreter as tflite
@iaverypadberg
iaverypadberg / break_frames_2.sh
Created February 14, 2023 14:17
Use FFMPEG to break a viddeo in to 320x320 crops at 3fps
ffmpeg -i bg_3.mp4 -vb 30M -filter:v "crop=320:320:200:600, fps=3" frames/office_2_%04d.jpg