Skip to content

Instantly share code, notes, and snippets.

View iaverypadberg's full-sized avatar

Isaac Padberg iaverypadberg

View GitHub Profile
@iaverypadberg
iaverypadberg / Playground.hs
Created April 20, 2021 20:41
Plutus Playground Smart Contract
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import Language.PlutusTx.Prelude
import Playground.Contract
-- | A 'Contract' that logs a message.
hello :: Contract BlockchainActions T.Text ()
hello = logInfo @String "Hello, world"
endpoints :: Contract BlockchainActions T.Text ()
/*
A function to change an ImageProxy to a bitmap
@param the image input
@return can be null or a bitmap
*/
fun preProcessImg(image : ImageProxy):Bitmap?{
val planes = image!!.planes
val yBuffer = planes[0].buffer
val uBuffer = planes[1].buffer
val vBuffer = planes[2].buffer
@iaverypadberg
iaverypadberg / format_xml.py
Created April 21, 2022 18:38
A python script for formatting lots of xml files in a directory.
import glob
import subprocess
# Replace this file directory with the location of the xml files
files = glob.glob('/home/isaac/Desktop/work_area/test2_xml/*.xml')
for xml_file in files:
bashCmd = ["xmllint","-format", "-o", "{}".format(xml_file), "{}".format(xml_file)]
process = subprocess.Popen(bashCmd, stdout=subprocess.PIPE)
@iaverypadberg
iaverypadberg / bash.sh
Last active April 26, 2022 14:43
Find a specific tags in an xml file with grep using regular exressions
# You can substitute out the tags for andy tags you like.
# The ".*" in the center of each tag specifies that any characters with any length can exist inside the tag
cat *.xml | grep -o -e "<name>.*<\/name>\|<filename>.*<\/filename>"
@iaverypadberg
iaverypadberg / check_labels.py
Created April 21, 2022 20:23
Check the integrity of labels after running the bash.sh script I wrote and piping it to a text file.
from re import T
labels = ["frodo","sam","legolas","gimli","karim benzema"]
# Open a text file to write the bad labels to
with open("bad_labels.txt","w") as bad:
# Open the text file with all of the data in it
with open("test2_xml/test.txt") as file:
@iaverypadberg
iaverypadberg / copy_xml_and_jpg.py
Created April 25, 2022 21:01
Copy corresponding xml and jpg files(predicated on labels)
from re import T
import os
import subprocess
from glob import glob
import xml.etree.ElementTree as ET
labels = [
"some",
"labels",
@iaverypadberg
iaverypadberg / remove_annotation_label.py
Last active April 26, 2022 13:50
Remove annotation label from an xml file
import xml.etree.ElementTree as ET
from glob import glob
labels = [
"labels",
"to",
"be",
"removed"]
files = glob('directory/with/xml/files/*.xml')
for file in files:
@iaverypadberg
iaverypadberg / ssd_mobilenet training on ubuntu 20.04-with gpu - conda & pip.MD
Last active May 10, 2022 15:47
ssd_mobilenet training on ubuntu 20.04-with gpu - conda & pip

Configuring a tensorflow environment to work with gpu's is really annoying. Thankfully, conda & pipmake it a lot less annoying.

Here are the core dependencies for getting this to work.

  • cudatoolkit=11.6.0
  • cudnn=8.2.1.32
  • tensorflow=2.7.0
  • tensorflow-gpu=2.7.0
  • tensorflow-io=0.25.0
  • python=3.9
@iaverypadberg
iaverypadberg / shrink_images.py
Created May 19, 2022 18:09
Changes the scales down the image size and the corresponding bounding box.
import random
from re import S
import xml.etree.ElementTree as ET
from glob import glob
import cv2
input_dir ='/home/isaac/Desktop/work_area/working_on/'
files = glob(input_dir+'*.png')
# For each file with a .png extension
@iaverypadberg
iaverypadberg / find_wrong_labels.py
Last active August 2, 2022 17:38
Find wrong labels in dataset
#from importlib.metadata import files
import xml.etree.ElementTree as ET
import glob
# Sort through a dataset's xml files and print out file names that contain labels which are invalid
valid_labels = ["frodo","baggins"]
# Loop through all xml files
files = glob.glob('/home/isaac/Desktop/work_area/working_on/*.xml')