Spaces:
Running
on
Zero
Running
on
Zero
| title: PuLID based FLUX FaceID | |
| emoji: ๐ค | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: gradio | |
| sdk_version: 5.35.0 | |
| app_file: app.py | |
| pinned: false | |
| license: apache-2.0 | |
| ## PuLID for FLUX: Portrait-Guided Image Generation | |
| This code implements **PuLID (Pure and Lightning ID customization)** for FLUX.1-dev, an advanced image generation system that allows users to create personalized images using ID (identity) images as guidance. The system combines the power of FLUX diffusion models with identity preservation capabilities. | |
| ### Key Features | |
| **1. Identity-Guided Generation** | |
| - Upload an ID image (portrait photo) to guide the generation process | |
| - Control identity strength with adjustable ID weight (0.0-3.0) | |
| - Preserve facial features while applying various artistic styles | |
| **2. Advanced Configuration Options** | |
| - **Resolution Control**: Adjustable width (256-1536px) and height (256-1536px) | |
| - **Generation Steps**: 1-20 steps for quality vs speed tradeoff | |
| - **Guidance Scale**: Fine-tune adherence to prompts (1.0-10.0) | |
| - **Seed Control**: Reproducible results with manual seed input | |
| **3. True CFG (Classifier-Free Guidance)** | |
| - Fake CFG mode (scale=1): Faster generation with basic guidance | |
| - True CFG mode (scale>1): Enhanced quality with negative prompt support | |
| - Configurable timestep for CFG activation | |
| **4. Technical Architecture** | |
| - Built on FLUX.1-dev diffusion model | |
| - Utilizes T5 text encoder for prompt understanding | |
| - CLIP model for image-text alignment | |
| - Autoencoder for latent space operations | |
| - GPU acceleration with CUDA support | |
| ### How It Works | |
| 1. **Text Prompt Input**: Describe the desired image style (e.g., "portrait, pixar") | |
| 2. **ID Image Upload**: Provide a reference portrait for identity guidance | |
| 3. **Parameter Tuning**: Adjust generation settings for optimal results | |
| 4. **Image Generation**: The model creates an image matching the prompt while preserving the identity | |
| ### Example Use Cases | |
| - Transform portraits into different artistic styles (ice sculpture, pixar animation) | |
| - Create personalized avatars maintaining facial identity | |
| - Generate creative variations of portraits with text prompts | |
| - Produce consistent character designs across different scenarios | |
| The system leverages Gradio for an intuitive web interface, making advanced AI image generation accessible to users without technical expertise. | |
| --- | |
| ## PuLID for FLUX: ์ธ๋ฌผ ๊ธฐ๋ฐ ์ด๋ฏธ์ง ์์ฑ ์์คํ | |
| ์ด ์ฝ๋๋ FLUX.1-dev๋ฅผ ์ํ **PuLID (Pure and Lightning ID customization)** ์์คํ ์ ๊ตฌํํ ๊ฒ์ผ๋ก, ID(์ ์) ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ด๋๋ก ์ฌ์ฉํ์ฌ ๊ฐ์ธํ๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์๋ ๊ณ ๊ธ ์ด๋ฏธ์ง ์์ฑ ์์คํ ์ ๋๋ค. FLUX ํ์ฐ ๋ชจ๋ธ์ ๊ฐ๋ ฅํ ์ฑ๋ฅ๊ณผ ์ ์ ๋ณด์กด ๊ธฐ๋ฅ์ ๊ฒฐํฉํ์์ต๋๋ค. | |
| ### ์ฃผ์ ๊ธฐ๋ฅ | |
| **1. ์ ์ ๊ธฐ๋ฐ ์ด๋ฏธ์ง ์์ฑ** | |
| - ID ์ด๋ฏธ์ง(์ธ๋ฌผ ์ฌ์ง)๋ฅผ ์ ๋ก๋ํ์ฌ ์์ฑ ๊ณผ์ ๊ฐ์ด๋ | |
| - ์กฐ์ ๊ฐ๋ฅํ ID ๊ฐ์ค์น(0.0-3.0)๋ก ์ ์ ๊ฐ๋ ์ ์ด | |
| - ๋ค์ํ ์์ ์ ์คํ์ผ์ ์ ์ฉํ๋ฉด์๋ ์ผ๊ตด ํน์ง ๋ณด์กด | |
| **2. ๊ณ ๊ธ ์ค์ ์ต์ ** | |
| - **ํด์๋ ์ ์ด**: ๋๋น(256-1536px)์ ๋์ด(256-1536px) ์กฐ์ ๊ฐ๋ฅ | |
| - **์์ฑ ๋จ๊ณ**: ํ์ง ๋ ์๋ ๊ท ํ์ ์ํ 1-20๋จ๊ณ ์ค์ | |
| - **๊ฐ์ด๋์ค ์ค์ผ์ผ**: ํ๋กฌํํธ ์ค์๋ ๋ฏธ์ธ ์กฐ์ (1.0-10.0) | |
| - **์๋ ์ ์ด**: ์๋ ์๋ ์ ๋ ฅ์ผ๋ก ์ฌํ ๊ฐ๋ฅํ ๊ฒฐ๊ณผ ์์ฑ | |
| **3. True CFG (Classifier-Free Guidance)** | |
| - Fake CFG ๋ชจ๋(scale=1): ๊ธฐ๋ณธ ๊ฐ์ด๋์ค๋ก ๋น ๋ฅธ ์์ฑ | |
| - True CFG ๋ชจ๋(scale>1): ๋ถ์ ํ๋กฌํํธ ์ง์์ผ๋ก ํฅ์๋ ํ์ง | |
| - CFG ํ์ฑํ ์์ ์ค์ ๊ฐ๋ฅ | |
| **4. ๊ธฐ์ ์ ๊ตฌ์กฐ** | |
| - FLUX.1-dev ํ์ฐ ๋ชจ๋ธ ๊ธฐ๋ฐ | |
| - T5 ํ ์คํธ ์ธ์ฝ๋๋ก ํ๋กฌํํธ ์ดํด | |
| - CLIP ๋ชจ๋ธ๋ก ์ด๋ฏธ์ง-ํ ์คํธ ์ ๋ ฌ | |
| - ์ ์ฌ ๊ณต๊ฐ ์์ ์ ์ํ ์คํ ์ธ์ฝ๋ | |
| - CUDA ์ง์ GPU ๊ฐ์ | |
| ### ์๋ ๋ฐฉ์ | |
| 1. **ํ ์คํธ ํ๋กฌํํธ ์ ๋ ฅ**: ์ํ๋ ์ด๋ฏธ์ง ์คํ์ผ ์ค๋ช (์: "portrait, pixar") | |
| 2. **ID ์ด๋ฏธ์ง ์ ๋ก๋**: ์ ์ ๊ฐ์ด๋๋ฅผ ์ํ ์ฐธ์กฐ ์ธ๋ฌผ ์ฌ์ง ์ ๊ณต | |
| 3. **๋งค๊ฐ๋ณ์ ์กฐ์ **: ์ต์ ์ ๊ฒฐ๊ณผ๋ฅผ ์ํ ์์ฑ ์ค์ ์กฐ์ | |
| 4. **์ด๋ฏธ์ง ์์ฑ**: ๋ชจ๋ธ์ด ์ ์์ ๋ณด์กดํ๋ฉด์ ํ๋กฌํํธ์ ๋ง๋ ์ด๋ฏธ์ง ์์ฑ | |
| ### ํ์ฉ ์์ | |
| - ์ธ๋ฌผ ์ฌ์ง์ ๋ค์ํ ์์ ์คํ์ผ๋ก ๋ณํ (์ผ์ ์กฐ๊ฐ, ํฝ์ฌ ์ ๋๋ฉ์ด์ ) | |
| - ์ผ๊ตด ์ ์์ ์ ์งํ ๊ฐ์ธํ๋ ์๋ฐํ ์์ฑ | |
| - ํ ์คํธ ํ๋กฌํํธ๋ก ์ธ๋ฌผ์ ์ฐฝ์์ ์ธ ๋ณํ ์์ฑ | |
| - ๋ค์ํ ์๋๋ฆฌ์ค์์ ์ผ๊ด๋ ์บ๋ฆญํฐ ๋์์ธ ์ ์ | |
| ์ด ์์คํ ์ Gradio๋ฅผ ํ์ฉํ ์ง๊ด์ ์ธ ์น ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ์ฌ, ๊ธฐ์ ์ ์ ๋ฌธ ์ง์์ด ์๋ ์ฌ์ฉ์๋ ๊ณ ๊ธ AI ์ด๋ฏธ์ง ์์ฑ ๊ธฐ๋ฅ์ ์ฝ๊ฒ ์ด์ฉํ ์ ์์ต๋๋ค. |