Skip to content

Instantly share code, notes, and snippets.

@rubenvarela
Created November 9, 2023 11:49
Show Gist options
  • Save rubenvarela/b842560876898411269015a35335ee63 to your computer and use it in GitHub Desktop.
Save rubenvarela/b842560876898411269015a35335ee63 to your computer and use it in GitHub Desktop.
stable diffusion test
torch
diffusers
transformers
pandas
from diffusers import DiffusionPipeline
import time
import pandas as pd
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("cpu")
# Recommended if your computer has < 64 GB of RAM
pipe.enable_attention_slicing()
prompt = "a photo of an astronaut riding a horse on mars"
out = []
for x in range(5):
start = time.time()
image = pipe(prompt).images[0]
out.append(time.time() - start)
image.save('test.png')
df = pd.DataFrame(out)
print(f"mean: {df.mean()[0]}")
print(f"variance: {df.var()[0]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment