Skip to content

Instantly share code, notes, and snippets.

@wfng92
Last active October 24, 2022 07:30
Show Gist options
  • Save wfng92/f5a4e8f6faf9a622513e3cc222fb49bd to your computer and use it in GitHub Desktop.
Save wfng92/f5a4e8f6faf9a622513e3cc222fb49bd to your computer and use it in GitHub Desktop.
from ldm.generate import Generate
# model configuration
gr = Generate(
'stable-diffusion-1.4',
embedding_path='./models/embeddings.pt' # modify the embedding path
)
# model loading
gr.load_model()
# variable initialization
text = "a photo of *"
# inference returns a list of tuple
results = gr.prompt2image(
prompt = text,
outdir = "./outputs/",
iterations=1,
steps=50
)
# save the image in outputs folder
for row in results:
im = row[0]
seed = row[1]
im.save(f'./outputs/image-{seed}.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment