Skip to content

Instantly share code, notes, and snippets.

View JACKHAHA363's full-sized avatar
🦄
Researching

Yuchen Lu JACKHAHA363

🦄
Researching
View GitHub Profile
@JACKHAHA363
JACKHAHA363 / extract_imagenet.sh
Created February 3, 2021 21:41
extract imagenet
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
@JACKHAHA363
JACKHAHA363 / render_img.py
Created October 28, 2019 20:28
Plot probability with original image for demo
import cv2
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
def _rounding(ratio, max_val):
""" Return a rounded valud from 0 to max_val - 1 """
val = int(ratio * max_val)
return min(max_val - 1, val)
@JACKHAHA363
JACKHAHA363 / config_dict.py
Last active February 22, 2019 06:23
A principled way to have config dictionary that can be saved/restored, support pre-defined type and default values, and support cmd parsing
import yaml
import argparse
class _ConfigDict(dict):
""" A subclass of dict that supports required args
"""
# Change this to customize it
fields = []
@classmethod