# Image generation using Stable Diffusion
A text2image operator generates image given a text prompt.
This operator is implemented with [Huggingface Diffusers](https://github.com/huggingface/diffusers).
## Code example
```python
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](https://huggingface.co/models?library=diffusers&sort=downloads)
***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.