Skip to content

Instantly share code, notes, and snippets.

View Franklin-Yao's full-sized avatar
🏠
Working from home

Felix Yao Franklin-Yao

🏠
Working from home
  • LA
View GitHub Profile
@Franklin-Yao
Franklin-Yao / download_yfcc100m.py
Last active June 21, 2022 09:22
yfcc100m downloader
# pip install parlai
# download hash file from https://drive.google.com/file/d/1u_u6MPx1i3AVuw0CkjyAC8udvcid3vX_/view?usp=sharing
from parlai.core.build_data import download_multiprocess
image_path = '/mnt/data/dataset/yfcc'
with open(f'/home/franklin/fewshot/dataset/yfcc-100m/yfcc100m_hash') as f:
data= f.readlines()
print(f'number of images: {len(data)}')
#data = data[:1000]
n_img = len(data)
@Franklin-Yao
Franklin-Yao / Visual Studio.tmTheme
Last active September 20, 2020 21:52
sublime theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Visual Studio</string>
@Franklin-Yao
Franklin-Yao / t1.py
Created July 7, 2020 22:54
pytorch1.7 mix precision training
# NEW
scaler = torch.cuda.amp.GradScaler()
for epoch in range(self.n_epochs):
for i, (X_batch, y_batch) in enumerate(batches):
X_batch = X_batch.cuda()
y_batch = y_batch.cuda()
optimizer.zero_grad()
# NEW
@Franklin-Yao
Franklin-Yao / baseline.py
Last active June 7, 2020 18:44
Lightning and 16-bit precision, range test
Check my git repo styleMix
import torch.nn as nn
from utils import Model_type, euclidean_dist
from torch.nn import functional as F
import torch
from pytorch_lightning.core.lightning import LightningModule
import numpy as np
from collections import OrderedDict
from time import time
from utils import count_acc
from time import time
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.manifold import TSNE
def get_data():
digits = datasets.load_digits(n_class=10)
@Franklin-Yao
Franklin-Yao / hdf5.py
Created February 23, 2020 16:45
save and read images with hdf5
import os.path as osp
dataset_dir = '/home/frankllin/Downloads/DomainNet'
split_dir = osp.join(dataset_dir, 'splits_mini')
image_size = 84
from PIL import Image
import h5py
import numpy as np
from tqdm import tqdm
def store_many_hdf5(h5file, images, labels):
@Franklin-Yao
Franklin-Yao / 0_reuse_code.js
Created October 28, 2016 08:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console