Skip to content

Invoking dream directly through Python #117

@veprogames

Description

@veprogames

I don't know if it's possible or not, but what if dream could be directly invoked in python? It would have the form of

def dream(prompt, **config) -> PIL.Image[]

where the config kwargs take the same name as in the dream console. config.init_img or config.I would be of instance PIL.Image.

example:

images = dream("A tasty burger", s=100, S=42, C=10, n=4)
new_images = dream("A tasty burger with fries", I=images[0], f=0.6, n=4)
final_image = new_images[0]
final_image.save("out.png")

This can help developers who are interested in automating stuff or using Stable Diffusion as part of another project.
From quickly looking over the code, my guess is that T2I.prompt_to_image() needs to be called, which leads me to the guess that:

the module dream_api contains the following functions:

def load_model() # do the things that are done when starting scripts/dream.py until the dream cli is ready
def dream(prompt, **config) -> PIL.Image[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions