logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

3.8 KiB

Image generation using Stable Diffusion

A text2image operator generates image given a text prompt. This operator is implemented with Huggingface Diffusers.

Code example

from towhee import pipe, ops

pipe = (
    pipe.input('prompt')
        .map('prompt', 'image', ops.text2image.stable_diffusion())
        .output('image')
)

image = pipe('an orange cat')
image.save('an_orange_cat.png')


Factory Constructor

Create the operator via the following factory method:

text2image.stable_diffusion(model_id='stabilityai/stable-diffusion-2-1', device=None)

Parameters:

model_id: str

The model id in string, defaults to 'stabilityai/stable-diffusion-2-1'.

Supported model names: pretrained diffuser models

device: str

The device to running model on, defaults to None. If None, it will automatically use cuda if gpu is available.


Interface

The operator takes a text prompt in string as input. It loads pretrained diffuser model and generates an image.

__call__(txt)

Parameters:

prompt: str

​ The text in string.

Returns:

PIL.Image

​ The generated image.


More Resources

3.8 KiB

Image generation using Stable Diffusion

A text2image operator generates image given a text prompt. This operator is implemented with Huggingface Diffusers.

Code example

from towhee import pipe, ops

pipe = (
    pipe.input('prompt')
        .map('prompt', 'image', ops.text2image.stable_diffusion())
        .output('image')
)

image = pipe('an orange cat')
image.save('an_orange_cat.png')


Factory Constructor

Create the operator via the following factory method:

text2image.stable_diffusion(model_id='stabilityai/stable-diffusion-2-1', device=None)

Parameters:

model_id: str

The model id in string, defaults to 'stabilityai/stable-diffusion-2-1'.

Supported model names: pretrained diffuser models

device: str

The device to running model on, defaults to None. If None, it will automatically use cuda if gpu is available.


Interface

The operator takes a text prompt in string as input. It loads pretrained diffuser model and generates an image.

__call__(txt)

Parameters:

prompt: str

​ The text in string.

Returns:

PIL.Image

​ The generated image.


More Resources