|
| 1 | +# PhotoDoodle Pipeline |
| 2 | + |
| 3 | +The PhotoDoodle pipeline is designed for image generation with conditional image input. It uses a combination of text and image conditioning to generate high-quality images. |
| 4 | + |
| 5 | +## Model Architecture |
| 6 | + |
| 7 | +The pipeline uses the following components: |
| 8 | + |
| 9 | +1. **Transformer**: A FluxTransformer2DModel for denoising image latents |
| 10 | +2. **VAE**: An AutoencoderKL for encoding/decoding images |
| 11 | +3. **Text Encoders**: |
| 12 | + - CLIP text encoder for initial text embedding |
| 13 | + - T5 encoder for additional text understanding |
| 14 | +4. **Scheduler**: FlowMatchEulerDiscreteScheduler for the diffusion process |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +```python |
| 19 | +from diffusers import PhotoDoodlePipeline |
| 20 | +import torch |
| 21 | + |
| 22 | +pipeline = PhotoDoodlePipeline.from_pretrained("black-forest-labs/FLUX.1-dev") |
| 23 | +pipeline = pipeline.to("cuda") |
| 24 | +# Load initial model weights |
| 25 | +pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle", weight_name="pretrain.safetensors") |
| 26 | +pipeline.fuse_lora() |
| 27 | +pipeline.unload_lora_weights() |
| 28 | + |
| 29 | +pipeline.load_lora_weights("nicolaus-huang/PhotoDoodle",weight_name="sksmagiceffects.safetensors") |
| 30 | + |
| 31 | +# Generate image with text prompt and condition image |
| 32 | +prompt = "add a halo and wings for the cat by sksmagiceffects" |
| 33 | +condition_image = load_image("path/to/condition.jpg") # PIL Image |
| 34 | +output = pipeline( |
| 35 | + prompt=prompt, |
| 36 | + condition_image=condition_image, |
| 37 | + num_inference_steps=28, |
| 38 | + guidance_scale=3.5 |
| 39 | +) |
| 40 | + |
| 41 | +# Save the generated image |
| 42 | +output.images[0].save("generated_image.png") |
| 43 | +``` |
| 44 | + |
| 45 | +## Parameters |
| 46 | + |
| 47 | +- `prompt`: Text prompt for image generation |
| 48 | +- `prompt_2`: Optional secondary prompt for T5 encoder |
| 49 | +- `condition_image`: Input image for conditioning |
| 50 | +- `height`: Output image height (default: 512) |
| 51 | +- `width`: Output image width (default: 512) |
| 52 | +- `num_inference_steps`: Number of denoising steps (default: 28) |
| 53 | +- `guidance_scale`: Classifier-free guidance scale (default: 3.5) |
| 54 | +- `num_images_per_prompt`: Number of images to generate per prompt |
| 55 | +- `generator`: Random number generator for reproducibility |
| 56 | +- `output_type`: Output format ("pil", "latent", or "pt") |
| 57 | + |
| 58 | +## Features |
| 59 | + |
| 60 | +- Dual text encoder architecture (CLIP + T5) |
| 61 | +- Image conditioning support |
| 62 | +- Position encoding for better spatial understanding |
| 63 | +- Support for LoRA fine-tuning |
| 64 | +- VAE slicing and tiling for memory efficiency |
| 65 | +- Progress bar during generation |
| 66 | +- Callback support for step-by-step monitoring |
0 commit comments