CoolFace
Apppublic

DurtyDhiana/ComfyUI-Style-IPAdapterGenerator

sourceHugging Facemitupdated 1y agoView on Hugging Face
1likes
App README

๐ŸŽจ ComfyUI-Style IPAdapter Generator

A Hugging Face Space that replicates core ComfyUI + IPAdapter functionality using Gradio. Generate images using text prompts and reference images with advanced AI models.

โœจ Features

  • โ€”Text-to-Image Generation: Create images from detailed text descriptions
  • โ€”IPAdapter Integration: Use reference images to guide generation (faces, styles, compositions)
  • โ€”Multiple Models: Support for Stable Diffusion 1.5 and SDXL
  • โ€”Advanced Controls: Fine-tune generation with guidance scale, steps, and resolution
  • โ€”Face Enhancement: Optional CodeFormer/GFPGAN integration for face improvement
  • โ€”LoRA Support: Apply custom style models for unique aesthetics
  • โ€”Side-by-Side Comparison: View reference and generated images together
  • โ€”Memory Optimized: Works on both CPU and GPU with automatic fallbacks

๐Ÿš€ Quick Start

Local Installation

  1. 1.Clone and Setup:
bash
   git clone <your-repo-url>
   cd comfyui-ipAdapter-space
   pip install -r requirements.txt
  1. 1.Run the Application:
bash
   python app.py
  1. 1.Access the Interface: Open your browser to http://localhost:7860

Hugging Face Space Deployment

  1. 1.Create a new Space on Hugging Face
  2. 2.Upload files: app.py, requirements.txt, README.md
  3. 3.Select hardware: CPU (free) or GPU (paid) based on your needs
  4. 4.Deploy: The space will automatically build and launch

๐Ÿ“– Usage Guide

Basic Workflow

  1. 1.Select Model: Choose between Stable Diffusion 1.5 or SDXL
  2. 2.Enter Prompt: Describe the image you want to generate
  3. 3.Upload Reference: Provide a reference image (face, style, or composition guide)
  4. 4.Adjust Settings: Fine-tune generation parameters
  5. 5.Generate: Click the generate button and wait for results

Parameters Explained

Core Settings
  • โ€”Text Prompt: Detailed description of desired image
  • โ€”Reference Image: Guide image for IPAdapter (faces work best)
  • โ€”Model: Base diffusion model (SD 1.5 for speed, SDXL for quality)
Generation Controls
  • โ€”Guidance Scale (1-20): How closely to follow the prompt (7.5 recommended)
  • โ€”IPAdapter Scale (0-2): Strength of reference image influence (1.0 recommended)
  • โ€”Resolution: Output image dimensions (512x512 for speed, higher for quality)
  • โ€”Inference Steps (10-50): Quality vs speed tradeoff (20 recommended)
  • โ€”Seed: For reproducible results (0 for random)
Enhancement Options
  • โ€”Face Enhancement: Improve facial details in generated images
  • โ€”CodeFormer vs GFPGAN: Different face enhancement algorithms
  • โ€”LoRA Path: Local path to custom style models
  • โ€”LoRA Scale: Strength of style model application

Best Practices

For Face Generation
  • โ€”Use clear, well-lit reference photos
  • โ€”Keep IPAdapter scale between 0.8-1.2
  • โ€”Enable face enhancement for better results
  • โ€”Use descriptive prompts: "professional headshot, studio lighting"
For Style Transfer
  • โ€”Use artistic references (paintings, illustrations)
  • โ€”Adjust IPAdapter scale based on desired style strength
  • โ€”Experiment with different guidance scales
  • โ€”Consider using LoRA models for consistent styles
Performance Optimization
  • โ€”Use 512x512 resolution for faster generation
  • โ€”Reduce inference steps to 15-20 for speed
  • โ€”Enable face enhancement only when needed
  • โ€”Use CPU mode if GPU memory is limited

๐Ÿ› ๏ธ Technical Details

Architecture

  • โ€”Frontend: Gradio web interface
  • โ€”Backend: Hugging Face Diffusers + IPAdapter
  • โ€”Models: Stable Diffusion 1.5/XL with IPAdapter weights
  • โ€”Enhancement: CodeFormer/GFPGAN for face improvement
  • โ€”Styling: LoRA support for custom aesthetics

Memory Management

  • โ€”Automatic model loading/unloading
  • โ€”GPU memory optimization with xformers
  • โ€”CPU fallback for limited hardware
  • โ€”Efficient attention mechanisms

Supported Formats

  • โ€”Input Images: JPG, PNG, WebP
  • โ€”Output: PNG format
  • โ€”LoRA Models: .safetensors, .ckpt files

๐Ÿ”ง Configuration

Environment Variables

bash
# Optional: Set device preference
CUDA_VISIBLE_DEVICES=0

# Optional: Set cache directory
HF_HOME=/path/to/cache

Hardware Requirements

Minimum (CPU)
  • โ€”8GB RAM
  • โ€”10GB storage
  • โ€”Generation time: 2-5 minutes
Recommended (GPU)
  • โ€”NVIDIA GPU with 6GB+ VRAM
  • โ€”16GB RAM
  • โ€”20GB storage
  • โ€”Generation time: 10-30 seconds

๐Ÿ“ Example Prompts

Portrait Generation

"A professional headshot photo of a person, studio lighting, high quality, detailed facial features"

Artistic Styles

"An oil painting portrait in the style of Renaissance masters, dramatic lighting, classical composition"

Fantasy/Sci-Fi

"A cyberpunk character with neon lighting, futuristic elements, digital art style"

Anime/Illustration

"An anime-style character portrait, vibrant colors, detailed eyes, manga illustration"

๐Ÿ› Troubleshooting

Common Issues

Model Loading Errors

  • โ€”Check internet connection for model downloads
  • โ€”Ensure sufficient disk space (20GB+)
  • โ€”Try switching to CPU mode if GPU memory insufficient

Generation Failures

  • โ€”Verify reference image is valid (JPG/PNG)
  • โ€”Check prompt length (keep under 200 characters)
  • โ€”Reduce resolution if memory errors occur

Slow Performance

  • โ€”Use smaller resolutions (512x512)
  • โ€”Reduce inference steps
  • โ€”Disable face enhancement
  • โ€”Switch to CPU mode if GPU is overloaded

Face Enhancement Issues

  • โ€”Ensure face is clearly visible in reference
  • โ€”Try different enhancement algorithms
  • โ€”Adjust IPAdapter scale for better face preservation

๐Ÿค Contributing

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Make your changes
  4. 4.Test thoroughly
  5. 5.Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License. See LICENSE file for details.

๐Ÿ™ Acknowledgments

  • โ€”Hugging Face for the Diffusers library and model hosting
  • โ€”IPAdapter team for the reference image integration
  • โ€”ComfyUI for inspiration and workflow concepts
  • โ€”Gradio team for the excellent web interface framework

๐Ÿ“ž Support

  • โ€”Issues: Report bugs via GitHub Issues
  • โ€”Discussions: Join the community discussions
  • โ€”Documentation: Check the Hugging Face Spaces documentation

Note: This is an educational project replicating ComfyUI functionality. For production use, consider the original ComfyUI or commercial alternatives.