Skip to content

Instantly share code, notes, and snippets.

Avatar

David Bau davidbau

View GitHub Profile
@davidbau
davidbau / simpleganpaint.ipynb
Last active Oct 31, 2019
A simplified GAN Paint, running in a colab notebook, in 20 lines of code
View simpleganpaint.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidbau
davidbau / explorefeaturebyclick.ipynb
Created Oct 20, 2019
ExploreFeatureByClick.ipynb
View explorefeaturebyclick.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View seeing_images.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidbau
davidbau / fooling.html
Created Feb 14, 2019
an example vue HTML file that displays images and metadata
View fooling.html
<!DOCTYPE html>
<html>
<!-- an example vue HTML file that displays images and metadata -->
<head>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"
integrity="sha256-CMMTrj5gGwOAXBeFi7kNokqowkzbeL8ydAJy39ewjkQ="
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.js"
integrity="sha256-qwbDmNVLiCqkqRBpF46q5bjYH11j5cd+K+Y6D3/ja28="
crossorigin="anonymous"></script>
View featurefolder.py
import os
import torch.utils.data as data
from torchvision.datasets.folder import default_loader, is_image_file
from PIL import Image
def grayscale_loader(path):
with open(path, 'rb') as f:
return Image.open(f).convert('L')
class FeatureFolder(data.Dataset):
@davidbau
davidbau / autoimport.py
Created Aug 26, 2018
Used to eval python expressions containing arbitrary fully-qualified package names, automatically importing packages as needed.
View autoimport.py
from collections import defaultdict
from importlib import import_module
def autoimport_eval(term):
'''
Used to eval any expression containing fully-qualified names, such as
'torchvision.models.alexnet(pretrained=True)' with automatic import of
global module names.
'''
@davidbau
davidbau / download_mp.py
Last active Feb 21, 2018
Script for downloading and formatting miniplaces in pytorch ImageFolder format
View download_mp.py
#!/usr/bin/env python2.7
# Script to create simple flat pytorch ImageFolder folder hierarchy
# of training and validation images for miniplaces. Each category
# name is just a folder name (numbered in alphabetical order as in
# the original miniplaces), and both train and val images are places
# directly inside a single level of folders with the flat cateogry names.
import shutil, os, tarfile
@davidbau
davidbau / npycat
Last active Jul 30, 2020
npycat: cat utility and swiss army knife for npy and npz files
View npycat
#!/usr/bin/env python
"""
npycat: cat utility and swiss army knife for npy and npz files
"""
import numpy, argparse
def main():
parser = argparse.ArgumentParser(
description="""\
@davidbau
davidbau / .block
Last active Mar 25, 2017
3D Scatter Plot Using three.js
View .block
license: mit
@davidbau
davidbau / googlesender.py
Last active Apr 15, 2019
Python 2 script for generating a JavaScript/jQuery function for submitting to a Google Form
View googlesender.py
# Google form submit-maker.
#
# Usage: python googlesender.py https://docs.google.com/forms/d/e/1.../viewform
#
# Point this python file at a live Google forms URL, and it will generate
# code for a Javascript function that submits to that form cross-domain.
#
# Notes:
# - The form should be created with "short answer text" questions.
# - The viewform URL to scrape is the link shared when the form is sent.
You can’t perform that action at this time.