Skip to content

Instantly share code, notes, and snippets.

View sayakpaul's full-sized avatar
:octocat:
Learn, unlearn and relearn.

Sayak Paul sayakpaul

:octocat:
Learn, unlearn and relearn.
View GitHub Profile
"""
Examples:
(1) python benchmark_distilled_sd.py --pipeline_id CompVis/stable-diffusion-v1-4
(2) python benchmark_distilled_sd.py --pipeline_id CompVis/stable-diffusion-v1-4 --vae_path sayakpaul/taesd-diffusers
(3) python benchmark_distilled_sd.py --pipeline_id nota-ai/bk-sdm-small
(4) python benchmark_distilled_sd.py --pipeline_id nota-ai/bk-sdm-small --vae_path sayakpaul/taesd-diffusers
"""
import argparse
import time
"""
Examples:
(1) python benchmark_controlnet_sdxl.py --controlnet_id diffusers/controlnet-depth-sdxl-1.0
(2) python benchmark_controlnet_sdxl.py --controlnet_id diffusers/controlnet-depth-sdxl-1.0-small
(3) python benchmark_controlnet_sdxl.py --controlnet_id diffusers/controlnet-depth-sdxl-1.0-mid
"""
import argparse
import time
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# To run the script, first install `diffusers` like so:
# pip install git+https://github.com/huggingface/diffusers@temp/lora-debug
# Then grab the LoRA file:
# wget https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/vividWatercolors_10.safetensors
import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
@sayakpaul
sayakpaul / rand_augment_tfrecords.py
Last active April 30, 2023 07:03
Example of incorporating RandAugment in a tf.data pipeline for image classification.
from imgaug import augmenters as iaa
import imgaug as ia
ia.seed(4)
import tensorflow as tf
tf.random.set_seed(666)
aug = iaa.RandAugment(n=2, m=9)
BATCH_SIZE = 224
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Adapted from https://github.com/borisdayma/dalle-mini/blob/main/tools/train/train.py
import random
from dataclasses import dataclass, field
from functools import partial
import jax
import jax.numpy as jnp
import numpy as np
from datasets import Dataset, load_dataset