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
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.
"""
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
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
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
@sayakpaul
sayakpaul / benchmark_onnx.py
Last active March 16, 2023 02:45
Scripts to benchmark OpenVINO and ONNX versions of Stable Diffusion on an AWS m6i.4xlarge instance.
import timeit
from optimum.onnxruntime import ORTStableDiffusionPipeline
from diffusers import StableDiffusionPipeline
import numpy as np
model_id = "runwayml/stable-diffusion-v1-5"
onnx_model_id = "sayakpaul/onnx-stable-diffusion-v1-5"
prompt = "a photo of an astronaut riding a horse on mars"

To run

export MODEL_NAME="CompVis/stable-diffusion-v1-4"
export DATASET_NAME="lambdalabs/pokemon-blip-captions"

accelerate launch --mixed_precision="fp16"  train_text_to_image.py   \
	--pretrained_model_name_or_path=$MODEL_NAME --dataset_name=$DATASET_NAME \