This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)}') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tokenizer = BertTokenizer.from_pretrained("bert-base-cased", | |
num_labels=num_labels, | |
do_lower_case=args.do_lower_case) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |