Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,131 +1,10 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
[**Haofan Wang**](https://haofanwang.github.io/)<sup>*</sup> · [Matteo Spinelli](https://github.com/cubiq) · [**Qixun Wang**](https://github.com/wangqixun) · [**Xu Bai**](https://huggingface.co/baymin0220) · [**Zekui Qin**](https://github.com/ZekuiQin) · [**Anthony Chen**](https://antonioo-c.github.io/)
|
5 |
-
|
6 |
-
InstantX Team
|
7 |
-
|
8 |
-
<sup>*</sup>corresponding authors
|
9 |
-
|
10 |
-
<a href='[https://instantid.github.io/](https://instantstyle.github.io/)'><img src='https://img.shields.io/badge/Project-Page-green'></a>
|
11 |
-
<a href='https://arxiv.org/abs/2404.02733'><img src='https://img.shields.io/badge/Technique-Report-red'></a>
|
12 |
-
[](https://github.com/InstantStyle/InstantStyle)
|
13 |
-
|
14 |
-
</div>
|
15 |
-
|
16 |
-
InstantStyle is a general framework that employs two straightforward yet potent techniques for achieving an effective disentanglement of style and content from reference images.
|
17 |
-
|
18 |
-
<img src='assets/pipe.png'>
|
19 |
-
|
20 |
-
## Principle
|
21 |
-
|
22 |
-
Separating Content from Image. Benefit from the good characterization of CLIP global features, after subtracting the content text fea- tures from the image features, the style and content can be explicitly decoupled. Although simple, this strategy is quite effective in mitigating content leakage.
|
23 |
-
<p align="center">
|
24 |
-
<img src="assets/subtraction.png">
|
25 |
-
</p>
|
26 |
-
|
27 |
-
Injecting into Style Blocks Only. Empirically, each layer of a deep network captures different semantic information the key observation in our work is that there exists two specific attention layers handling style. Specifically, we find up blocks.0.attentions.1 and down blocks.2.attentions.1 capture style (color, material, atmosphere) and spatial layout (structure, composition) respectively.
|
28 |
-
<p align="center">
|
29 |
-
<img src="assets/tree.png">
|
30 |
-
</p>
|
31 |
-
|
32 |
-
## Release
|
33 |
-
- [2024/04/03] 🔥 We release the [technical report](https://arxiv.org/abs/2404.02733).
|
34 |
-
|
35 |
-
## Download
|
36 |
-
Follow [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter?tab=readme-ov-file#download-models) to download pre-trained checkpoints.
|
37 |
-
|
38 |
-
## Demos
|
39 |
-
|
40 |
-
### Stylized Synthesis
|
41 |
-
|
42 |
-
<p align="center">
|
43 |
-
<img src="assets/example1.png">
|
44 |
-
<img src="assets/example2.png">
|
45 |
-
</p>
|
46 |
-
|
47 |
-
### Image-based Stylized Synthesis
|
48 |
-
|
49 |
-
<p align="center">
|
50 |
-
<img src="assets/example3.png">
|
51 |
-
</p>
|
52 |
-
|
53 |
-
### Comparison with Previous Works
|
54 |
-
|
55 |
-
<p align="center">
|
56 |
-
<img src="assets/comparison.png">
|
57 |
-
</p>
|
58 |
-
|
59 |
-
## Usage
|
60 |
-
|
61 |
-
Our method is fully compatible with [IP-Adapter](https://github.com/tencent-ailab/IP-Adapter). But for feature subtraction, it only works with IP-Adapter using global embeddings.
|
62 |
-
|
63 |
-
```python
|
64 |
-
import torch
|
65 |
-
from diffusers import StableDiffusionXLPipeline
|
66 |
-
from PIL import Image
|
67 |
-
|
68 |
-
from ip_adapter import IPAdapterXL
|
69 |
-
|
70 |
-
base_model_path = "stabilityai/stable-diffusion-xl-base-1.0"
|
71 |
-
image_encoder_path = "sdxl_models/image_encoder"
|
72 |
-
ip_ckpt = "sdxl_models/ip-adapter_sdxl.bin"
|
73 |
-
device = "cuda"
|
74 |
-
|
75 |
-
# load SDXL pipeline
|
76 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
77 |
-
base_model_path,
|
78 |
-
torch_dtype=torch.float16,
|
79 |
-
add_watermarker=False,
|
80 |
-
)
|
81 |
-
|
82 |
-
# load ip-adapter
|
83 |
-
# target_blocks=["blocks"] for original IP-Adapter
|
84 |
-
# target_blocks=["up_blocks.0.attentions.1"] for style blocks only
|
85 |
-
# target_blocks = ["up_blocks.0.attentions.1", "down_blocks.2.attentions.1"] # for style+layout blocks
|
86 |
-
ip_model = IPAdapterXL(pipe, image_encoder_path, ip_ckpt, device, target_blocks=["up_blocks.0.attentions.1"])
|
87 |
-
|
88 |
-
image = "./assets/0.jpg"
|
89 |
-
image = Image.open(image)
|
90 |
-
image.resize((512, 512))
|
91 |
-
|
92 |
-
# generate image variations with only image prompt
|
93 |
-
images = ip_model.generate(pil_image=image,
|
94 |
-
prompt="a cat, masterpiece, best quality, high quality",
|
95 |
-
negative_prompt= "text, watermark, lowres, low quality, worst quality, deformed, glitch, low contrast, noisy, saturation, blurry",
|
96 |
-
scale=1.0,
|
97 |
-
guidance_scale=5,
|
98 |
-
num_samples=1,
|
99 |
-
num_inference_steps=30,
|
100 |
-
seed=42,
|
101 |
-
#neg_content_prompt="a rabbit",
|
102 |
-
#neg_content_scale=0.5,
|
103 |
-
)
|
104 |
-
|
105 |
-
images[0].save("result.png")
|
106 |
-
```
|
107 |
-
|
108 |
-
We will support diffusers API soon.
|
109 |
-
|
110 |
-
## TODO
|
111 |
-
- Support in diffusers API.
|
112 |
-
- Support InstantID.
|
113 |
-
|
114 |
-
## Sponsor Us
|
115 |
-
If you find this project useful, you can buy us a coffee via Github Sponsor! We support [Paypal](https://ko-fi.com/instantx) and [WeChat Pay](https://tinyurl.com/instantx-pay).
|
116 |
-
|
117 |
-
## Cite
|
118 |
-
If you find InstantStyle useful for your research and applications, please cite us using this BibTeX:
|
119 |
-
|
120 |
-
```bibtex
|
121 |
-
@misc{wang2024instantstyle,
|
122 |
-
title={InstantStyle: Free Lunch towards Style-Preserving in Text-to-Image Generation},
|
123 |
-
author={Haofan Wang and Qixun Wang and Xu Bai and Zekui Qin and Anthony Chen},
|
124 |
-
year={2024},
|
125 |
-
eprint={2404.02733},
|
126 |
-
archivePrefix={arXiv},
|
127 |
-
primaryClass={cs.CV}
|
128 |
-
}
|
129 |
-
```
|
130 |
-
|
131 |
-
For any question, please feel free to contact us via [email protected].
|
|
|
1 |
+
title: SDXS-512-0.9 GPU Demo -1 Steps
|
2 |
+
emoji: ⚡
|
3 |
+
colorFrom: yellow
|
4 |
+
colorTo: gray
|
5 |
+
sdk: gradio
|
6 |
+
sdk_version: 4.23.0
|
7 |
+
app_file: app.py
|
8 |
+
pinned: false
|
9 |
+
short_description: SDXS 1024 will Release this is based on SDXS-512-0.9
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|