Skip to content

Instantly share code, notes, and snippets.

View shaystrong's full-sized avatar

Shay Strong shaystrong

  • Helsinki, Finland
  • 08:40 (UTC +03:00)
View GitHub Profile
@shaystrong
shaystrong / cleanup
Created May 8, 2019 05:20
cleanup images & xml label pairs for object detectors
def cleanupPairs(pathh):
import glob
for i in glob.glob(pathh+'JPEGImages/'+'*png'):
filename_split = os.path.splitext(i)
filename_zero, fileext = filename_split
basename = os.path.basename(filename_zero)
if not os.path.isfile(pathh+'Annotations/'+basename+'.xml'):
os.system('rm '+i)
for i in glob.glob(pathh+'Annotations/'+'*xml'):
filename_split = os.path.splitext(i)
@shaystrong
shaystrong / silly_lib.py
Created March 26, 2020 18:15
silly madlibs with NLTK tokenizer
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.tokenize.treebank import TreebankWordDetokenizer
import argparse
#python sillylib.py --input bed button kill be black open clothes also
# inspired by https://towardsdatascience.com/a-i-plays-mad-libs-and-the-results-are-terrifying-78fa44e7f04e
parser = argparse.ArgumentParser()
parser.add_argument('--input',nargs='+',default=['bed','button','kill','be','black','open','clothes','even'])
parser.add_argument('--person',default='AI')