Add missing metadata: library_name and pipeline_tag
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
@@ -1,3 +1,92 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
library_name: diffusers
|
4 |
+
pipeline_tag: text-to-image
|
5 |
+
---
|
6 |
+
|
7 |
+
# URAE: ~~Your Free FLUX Pro Ultra~~
|
8 |
+
|
9 |
+
<img src='teaser.jpg' width='100%' />
|
10 |
+
<br>
|
11 |
+
|
12 |
+
<a href="https://arxiv.org/abs/2503.16322"><img src="https://img.shields.io/badge/arXiv-2503.16322-A42C25.svg" alt="arXiv"></a>
|
13 |
+
<a href="https://huggingface.co/Huage001/URAE"><img src="https://img.shields.io/badge/🤗_HuggingFace-Model-ffbd45.svg" alt="HuggingFace"></a>
|
14 |
+
<a href="https://huggingface.co/spaces/Yuanshi/URAE"><img src="https://img.shields.io/badge/🤗_HuggingFace-Space-ffbd45.svg" alt="HuggingFace"></a>
|
15 |
+
<a href="https://huggingface.co/spaces/Yuanshi/URAE_dev"><img src="https://img.shields.io/badge/🤗_HuggingFace-Space-ffbd45.svg" alt="HuggingFace"></a>
|
16 |
+
|
17 |
+
> ***U*ltra-*R*esolution *A*daptation with *E*ase**
|
18 |
+
> <br>
|
19 |
+
> [Ruonan Yu*](https://scholar.google.com/citations?user=UHP95egAAAAJ&hl=en),
|
20 |
+
> [Songhua Liu*](http://121.37.94.87/),
|
21 |
+
> [Zhenxiong Tan](https://scholar.google.com/citations?user=HP9Be6UAAAAJ&hl=en),
|
22 |
+
> and
|
23 |
+
> [Xinchao Wang](https://sites.google.com/site/sitexinchaowang/)
|
24 |
+
> <br>
|
25 |
+
> [xML Lab](https://sites.google.com/view/xml-nus), National University of Singapore
|
26 |
+
> <br>
|
27 |
+
|
28 |
+
## 🪶Features
|
29 |
+
|
30 |
+
* **Easy-to-Use High-Quality and High-Resolution Generation😊**: Ultra-Resolution Adaptation with Ease, or URAE in short, generates high-resolution images with FLUX, with minimal code modifications.
|
31 |
+
* **Easy Training🚀**: URAE tames light-weight adapters with a handful of synthetic data from [FLUX1.1 Pro Ultra](https://blackforestlabs.ai/ultra-home/).
|
32 |
+
|
33 |
+
## 🔥News
|
34 |
+
|
35 |
+
**[2025/03/20]** We release models and codes for both training and inference of URAE.
|
36 |
+
|
37 |
+
## Introduction
|
38 |
+
|
39 |
+
Text-to-image diffusion models have achieved remarkable progress in recent years. However, training models for high-resolution image generation remains challenging, particularly when training data and computational resources are limited. In this paper, we explore this practical problem from two key perspectives: data and parameter efficiency, and propose a set of key guidelines for ultra-resolution adaptation termed *URAE*. For data efficiency, we theoretically and empirically demonstrate that synthetic data generated by some teacher models can significantly promote training convergence. For parameter efficiency, we find that tuning minor components of the weight matrices outperforms widely-used low-rank adapters when synthetic data are unavailable, offering substantial performance gains while maintaining efficiency. Additionally, for models leveraging guidance distillation, such as FLUX, we show that disabling classifier-free guidance, *i.e.*, setting the guidance scale to 1 during adaptation, is crucial for satisfactory performance. Extensive experiments validate that URAE achieves comparable 2K-generation performance to state-of-the-art closed-source models like FLUX1.1 [Pro] Ultra with only 3K samples and 2K iterations, while setting new benchmarks for 4K-resolution generation.
|
40 |
+
|
41 |
+
## Quick Start
|
42 |
+
|
43 |
+
* If you have not, install [PyTorch](https://pytorch.org/get-started/locally/), [diffusers](https://huggingface.co/docs/diffusers/index), [transformers](https://huggingface.co/docs/transformers/index), and [peft](https://huggingface.co/docs/peft/index).
|
44 |
+
|
45 |
+
* Clone this repo to your project directory:
|
46 |
+
|
47 |
+
``` bash
|
48 |
+
git clone https://github.com/Huage001/URAE.git
|
49 |
+
cd URAE
|
50 |
+
```
|
51 |
+
|
52 |
+
* **You only need minimal modifications!**
|
53 |
+
|
54 |
+
```diff
|
55 |
+
import torch
|
56 |
+
- from diffusers import FluxPipeline
|
57 |
+
+ from pipeline_flux import FluxPipeline
|
58 |
+
+ from transformer_flux import FluxTransformer2DModel
|
59 |
+
|
60 |
+
bfl_repo = "black-forest-labs/FLUX.1-dev"
|
61 |
+
+ transformer = FluxTransformer2DModel.from_pretrained(bfl_repo, subfolder="transformer", torch_dtype=torch.bfloat16)
|
62 |
+
- pipe = FluxPipeline.from_pretrained(bfl_repo, torch_dtype=torch.bfloat16)
|
63 |
+
+ pipe = FluxPipeline.from_pretrained(bfl_repo, transformer=transformer, torch_dtype=torch.bfloat16)
|
64 |
+
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
|
65 |
+
|
66 |
+
+ pipe.load_lora_weights("Huage001/URAE", weight_name="urae_2k_adapter.safetensors")
|
67 |
+
|
68 |
+
prompt = "An astronaut riding a green horse"
|
69 |
+
image = pipe(
|
70 |
+
prompt,
|
71 |
+
- height=1024,
|
72 |
+
- width=1024,
|
73 |
+
+ height=2048,
|
74 |
+
+ width=2048,
|
75 |
+
guidance_scale=3.5,
|
76 |
+
num_inference_steps=50,
|
77 |
+
max_sequence_length=512,
|
78 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
79 |
+
).images[0]
|
80 |
+
image.save("flux-urae.png")
|
81 |
+
```
|
82 |
+
⚠️ **FLUX requires at least 28GB of GPU memory to operate at a 2K resolution.** A 48GB GPU is recommended for the full functionalities of URAE, including both 2K and 4K. We are actively integrating model lightweighting strategies into URAE! If you have a good idea, feel free to submit a PR!
|
83 |
+
|
84 |
+
|
85 |
+
* Do not want to run the codes? No worry! Try the model on Huggingface Space!
|
86 |
+
|
87 |
+
* [URAE w. FLUX1.schnell](https://huggingface.co/spaces/Yuanshi/URAE) (Faster)
|
88 |
+
* [URAE w. FLUX1.dev](https://huggingface.co/spaces/Yuanshi/URAE_dev) (Higher Quality)
|
89 |
+
|
90 |
+
## Installation
|
91 |
+
|
92 |
+
* Clone this repo to your project directory:
|