File size: 2,255 Bytes
d00d50c 5d96bd0 1c703ea 5d96bd0 1c703ea d00d50c 1c703ea d00d50c |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
---
license: apache-2.0
tags:
- text-to-image
- kandinsky
inference: false
---
# Kandinsky 3.0 IP Adapter
## Usage
```python
pip install git+https://github.com/ai-forever/kandinsky3-diffusers.git
```
### Image variations
```python
from diffusers.models.attention_processor import Kandi3AttnProcessorIpAdapter, Kandi3AttnProcessor
from diffusers.pipelines.kandinsky3.kandinsky3_pipeline_ip_adapter import KandinskyV3PipelineIpAdapter
from PIL import Image
import torch
pipe = KandinskyV3PipelineIpAdapter.from_pretrained('ai-forever/kandinsky3_ip_adapter', torch_dtype=torch.float16, low_cpu_mem_usage=False, device_map=None)
pipe = pipe.to('cuda')
img = Image.open('path_to_img.jpg')
out_img = pipe('4k caption', img=[img], weights=[1], negative_prompt='', height=1024, width=1024, guidance_scale=7.5, num_inference_steps=50, cut_context=1)[0][0]
```
### Image + Image mixing
```python
from diffusers.models.attention_processor import Kandi3AttnProcessorIpAdapter, Kandi3AttnProcessor
from diffusers.pipelines.kandinsky3.kandinsky3_pipeline_ip_adapter import KandinskyV3PipelineIpAdapter
from PIL import Image
import torch
pipe = KandinskyV3PipelineIpAdapter.from_pretrained('ai-forever/kandinsky3_ip_adapter', torch_dtype=torch.float16, low_cpu_mem_usage=False, device_map=None)
pipe = pipe.to('cuda')
img1 = Image.open('path_to_img1.jpg')
img2 = Image.open('path_to_img2.jpg')
out_img = pipe('4k photo', img=[img1, img2], weights=[0.5, 0.5], negative_prompt='', height=1024, width=1024, guidance_scale=7.5, num_inference_steps=50, cut_context=1)[0][0]
```
### Text + Image mixing
```python
from diffusers.models.attention_processor import Kandi3AttnProcessorIpAdapter, Kandi3AttnProcessor
from diffusers.pipelines.kandinsky3.kandinsky3_pipeline_ip_adapter import KandinskyV3PipelineIpAdapter
from PIL import Image
import torch
pipe = KandinskyV3PipelineIpAdapter.from_pretrained('ai-forever/kandinsky3_ip_adapter', torch_dtype=torch.float16, low_cpu_mem_usage=False, device_map=None)
pipe = pipe.to('cuda')
img = Image.open('path_to_img.jpg')
caption = 'cat, 4k photo'
out_img = pipe(caption, img=[img], weights=[1], negative_prompt='', height=1024, width=1024, guidance_scale=7.5, num_inference_steps=50, cut_context=1, img_weight=0.5)[0][0]
``` |