Skip to content

Instantly share code, notes, and snippets.

import time
import numpy as np
import torch
import torchvision
from torchvision import transforms, models
import tqdm
import random
import furiosa.runtime.session
preprocess = transforms.Compose(
import time
import numpy as np
import onnx
import torch
import torchvision
from torchvision import transforms
import tqdm
import furiosa.runtime.session
from furiosa.quantizer.frontend.onnx import post_training_quantize
embed="elon"
echo "Embedding $embed"
export MODEL_NAME="CompVis/stable-diffusion-v1-4"
export INSTANCE_DIR='/media/auro/NLP/diffusers/diffusers/examples/dreambooth/images/'$embed
export OUTPUT_DIR=$embed'_saved_model'
export CLASS_DIR='path_to_'$embed'_class_images'
"title","heading","content","tokens"
"Chapter_1","0"," It seems like everyone I know has a different opinion about their dishwasher.
Some seem to think that theirs is a Godsend and a lifesaver; others think it's a total waste
of time, hot water and electricity. Truth is, everybody's right! Within their limitations,
dishwashers can provide virtually sterile dishes, if that's what you need.
Poorly used and poorly maintained, they can be a huge, inefficient pain in the neck.","73"
@aurotripathy
aurotripathy / tokenizer-flavors.py
Last active October 10, 2022 18:46
showing the differences between the WordPiece and BPE tokenizer
from transformers import BertTokenizer, RobertaTokenizer, GPT2Tokenizer
text = "The quick brown fox was hospilatized while jumping over the dog"
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
print(f'WordPiece tokens:{tokenizer.tokenize(text)}')
@aurotripathy
aurotripathy / tokenizer-one-liner.py
Last active October 9, 2022 19:58
tokenizer one liner
tokenizer = BertTokenizer.from_pretrained("bert-base-cased",
num_labels=num_labels,
do_lower_case=args.do_lower_case)
@aurotripathy
aurotripathy / scrape-HF-for-model-download-data.py
Created April 25, 2022 19:58
scrape HuggingFace for model download data
import requests
from bs4 import BeautifulSoup
import os
import datetime
model_names = ['bert-base-uncased',
'bert-large-uncased',
'bert-base-cased',
'bert-large-cased',
'distilbert-base-cased-distilled-squad',
def add_gauss_noise(point, sigma):
noise_x = torch.tensor(np.random.normal(0, sigma, point.shape[0]),
dtype=torch.float32)
noise_y = torch.tensor(np.random.normal(0, sigma, point.shape[0]),
dtype=torch.float32)
point = point + torch.cat([noise_x, noise_y]).reshape(point.shape)
return point
import torch
import torchvision.models as models
from torchinfo import summary
import argparse
from pudb import set_trace
def round_to_higher(n, m):
# find the near 7-multiple to n
if (n/m - n //m) > 0:
out = (n//m) * m + m
import math
import json
import pytest
from pathlib import Path
import numpy as np
import torch
from torch.nn import functional
from pprint import pprint
from pudb import set_trace