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

Updated 2 months ago

text2image

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

Jael Gu 5bddf608ac Add more resources 16 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 1 year ago
file-icon README.md
3.8 KiB
download-icon
Add more resources 2 months ago
file-icon __init__.py
127 B
download-icon
Debug 1 year ago
file-icon an_orange_cat.png
448 KiB
download-icon
Debug 1 year ago
file-icon requirements.txt
17 B
download-icon
Add requirements 1 year ago
file-icon stable_diffusion.py
943 B
download-icon
Add requirements 1 year ago