Skip to content

Instantly share code, notes, and snippets.

View BIGBALLON's full-sized avatar
🎯
Focusing

WILL LEE BIGBALLON

🎯
Focusing
View GitHub Profile
@BIGBALLON
BIGBALLON / extract_ILSVRC.sh
Created May 13, 2018 20:09
script for ImageNet data extract.
#!/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/
@BIGBALLON
BIGBALLON / radar.ipynb
Created January 13, 2024 18:52 — forked from donglixp/radar.ipynb
Radar figure in BEiT-3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BIGBALLON
BIGBALLON / color_log.py
Last active October 19, 2023 10:50
colorlog for color logger.
import colorlog
import logging
# 创建日志记录器
logger = colorlog.getLogger(__name__)
# 设置日志级别和格式
logger.setLevel(logging.DEBUG)
formatter = colorlog.ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(log_color)s%(asctime)s | %(blue)s%(message)s",
@BIGBALLON
BIGBALLON / imagenet21k_ids_with_classnames.csv
Created June 20, 2023 07:51
Imagenet21k label with classnames
We can't make this file beautiful and searchable because it's too large.
n00004475,organism, being
n00005787,benthos
n00006024,heterotroph
n00006484,cell
n00007846,person, individual, someone, somebody, mortal, soul
n00015388,animal, animate_being, beast, brute, creature, fauna
n00017222,plant, flora, plant_life
n00021265,food, nutrient
n00021939,artifact, artefact
n00120010,hop
@BIGBALLON
BIGBALLON / AS.py
Created January 4, 2023 08:30
Anomaly Simulation
"""
# Anomaly Simulation for MVTecAD
# Download describable textures dataset
wget https://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz
# Download MVTec anomaly detection dataset
wget https://www.mydrive.ch/shares/38536/3830184030e49fe74747669442f0f282/download/420938113-1629952094/mvtec_anomaly_detection.tar.xz
"""
import os
import random
@BIGBALLON
BIGBALLON / EMAE_crop.py
Last active November 4, 2022 10:48
for EMAE figures
import math
import os
import random
from itertools import product
import numpy as np
from imgaug import augmenters as iaa
from PIL import Image
IMG_SIZE = 600
from PIL import Image, ImageOps
def padding(img, expected_size):
desired_size = expected_size
delta_width = desired_size - img.size[0]
delta_height = desired_size - img.size[1]
pad_width = delta_width // 2
pad_height = delta_height // 2
padding = (pad_width, pad_height, delta_width - pad_width, delta_height - pad_height)
@BIGBALLON
BIGBALLON / conv.py
Created March 26, 2021 13:13
ddp->single
import torch
checkpoint = torch.load("resnet18.pth.tar")
state_dict = checkpoint["state_dict"]
from collections import OrderedDict
new_state_dict = OrderedDict()
for k, v in state_dict.items():
name = k[7:] # remove 'module.' of dataparallel
import numpy as np
def voc_ap(rec, prec):
# correct AP calculation
# first append sentinel values at the end
mrec = np.concatenate(([0.], rec, [1.])) #[0. 0.0666, 0.1333, 0.4 , 0.4666, 1.]
mpre = np.concatenate(([0.], prec, [0.])) #[0. 1., 0.6666, 0.4285, 0.3043, 0.]
for i in range(mpre.size - 1, 0, -1):
mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i]) #[1. 1. 0.6666 0.4285 0.3043 0. ]
@BIGBALLON
BIGBALLON / .vimrc
Created March 26, 2021 10:53
vim configuration
" BASIC SETTING
set number
set noswapfile
set autoindent
set cindent
set mouse=a
set encoding=utf-8
set cursorcolumn
set cursorline