Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
razzant authored Mar 28, 2023
1 parent 2b63d51 commit 8a0f814
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Kandinsky 2.1 was trained on a large-scale image-text dataset LAION HighRes and

### 1. text2image

```
```python
from kandinsky2 import get_kandinsky2
model = get_kandinsky2('cuda', task_type='text2img', model_version='2.1', use_flash_attention=False)
images = model.generate_text2img('''red cat, 4k photo''', num_steps=100,
Expand All @@ -44,6 +44,40 @@ images = model.generate_text2img('''red cat, 4k photo''', num_steps=100,
sampler='p_sampler', prior_cf_scale=4,
prior_steps="5",)
```

### 2. image fuse

```python
from kandinsky2 import get_kandinsky2
from PIL import Image
model = get_kandinsky2('cuda', task_type='text2img', model_version='2.1', use_flash_attention=False)
images_texts = ['red cat', Image.open('img1.jpg'), Image.open('img2.jpg'), 'a man']; weights = [0.25, 0.25, 0.25, 0.25]
images = model.mix_images(images_texts, weights, num_steps=150,
batch_size=1, guidance_scale=5,
h=768, w=768,
sampler='p_sampler', prior_cf_scale=4,
prior_steps="5", negative_decoder_prompt='')
```

### 3. image fuse

```python
from kandinsky2 import get_kandinsky2
from PIL import Image
import numpy as np

model = get_kandinsky2('cuda', task_type='inpainting', model_version='2.1', use_flash_attention=False)
init_image = Image.open('img.jpg')
mask = np.ones((768, 768), dtype=np.float32)
mask[:550] = 0
images = model.generate_inpainting('man 4k photo', init_image, mask,
num_steps=150,
batch_size=1, guidance_scale=5,
h=768, w=768,
sampler='p_sampler', prior_cf_scale=4,
prior_steps="5")
```

# Kandinsky 2.0

[![Framework: PyTorch](https://img.shields.io/badge/Framework-PyTorch-orange.svg)](https://pytorch.org/) [![Huggingface space](https://img.shields.io/badge/🤗-Huggingface-yello.svg)](https://huggingface.co/sberbank-ai/Kandinsky_2.0)
Expand Down

0 comments on commit 8a0f814

Please sign in to comment.