File size: 1,167 Bytes
ace4b52
9ec9de7
ace4b52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc6739b
9ec9de7
fc6739b
 
 
 
 
 
 
ace4b52
 
 
 
 
9ec9de7
ace4b52
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Gemini Prompt Expander

A custom ModularPipelineBlocks that uses Google's Gemini API to expand short prompts into detailed, vivid image generation prompts.

## Requirement

Install the Google Generative AI package:
```bash
pip install google-generativeai
```

## Setup

Get your Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey) and set it as an environment variable:
```bash
export GOOGLE_API_KEY="your-api-key-here"
```

## Usage
```python
from diffusers.modular_pipelines import ModularPipelineBlocks

gemini_block = ModularPipelineBlocks.from_pretrained(
    "diffusers-internal-dev/gemini-prompt-expander",
    trust_remote_code=True,
)
gemini = gemini_block.init_pipeline()
output = gemini(prompt="a dog sitting by the river, watching the sunset")
print(f"{output.values['prompt']=}")
```

## Use in Mellon

This block includes a `mellon_pipeline_config.json` for use with [Mellon](https://github.com/cubiq/Mellon):

1. Drag a **Dynamic Block Node** from the ModularDiffusers section
2. Enter `diffusers-internal-dev/gemini-prompt-expander` as the repo_id
3. The node will transform to show the prompt input and expanded prompt output