Labsco
CLOUDWERX-DEV logo

DiffuGen

ā˜… 17

from CLOUDWERX-DEV

Generate images from text using Flux and Stable Diffusion models.

šŸ”„šŸ”„šŸ”„āœ“ VerifiedFreeAdvanced setup

DiffuGen - Advanced Local Image Generator with MCP Integration

DiffuGen Logo

Your AI art studio embedded directly in code. Generate, iterate, and perfect visual concepts through this powerful MCP server for Cursor, Windsurf, and other compatible IDEs, utilizing cutting-edge Flux and Stable Diffusion models without disrupting your development process.

⭐ New: Now includes OpenAPI server support and OpenWebUI OpenAPI Tools (OWUI Version 0.60.0 Required) integration for seamless image generation and display in chat interfaces! The OpenAPI is seperate from the MCP server and allowss for initigrations into your own projects!

šŸ“ƒ Table of Contents

šŸš€ Introduction

DiffuGen is a powerful MCP-based image generation system that brings cutting-edge AI models directly into your development workflow. It seamlessly integrates both Flux models (Flux Schnell, Flux Dev) and Stable Diffusion variants (SDXL, SD3, SD1.5) into a unified interface, allowing you to leverage the unique strengths of each model family without switching tools. With comprehensive parameter control and multi-GPU support, DiffuGen scales from rapid concept sketches on modest hardware to production-quality visuals on high-performance systems.

Built on top of the highly optimized stable-diffusion.cpp implementation, DiffuGen offers exceptional performance even on modest hardware while maintaining high-quality output.

🧠 Understanding MCP and DiffuGen

What is MCP?

MCP (Model Context Protocol) is a protocol that enables LLMs (Large Language Models) to access custom tools and services. In simple terms, an MCP client (like Cursor, Windsurf, Roo Code, or Cline) can make requests to MCP servers to access tools that they provide.

DiffuGen as an MCP Server

DiffuGen functions as an MCP server that provides text-to-image generation capabilities. It implements the MCP protocol to allow compatible IDEs to send generation requests and receive generated images.

The server exposes two main tools:

  1. generate_stable_diffusion_image: Generate with Stable Diffusion models
  2. generate_flux_image: Generate with Flux models

Technical Architecture

DiffuGen consists of several key components:

  • setup-diffugen.sh: The complete install utility and model downloader and manager
  • diffugen.py: The core Python script that implements the MCP server functionality and defines the generation tools
  • diffugen.sh: A shell script launcher that sets up the environment and launches the Python server
  • diffugen.json: Template configuration file for MCP integration with various IDEs (to be copied into IDE's MCP configuration)
  • stable-diffusion.cpp: The optimized C++ implementation of Stable Diffusion used for actual image generation

The system works by:

  1. Receiving prompt and parameter data from an MCP client
  2. Processing the request through the Python server
  3. Calling the stable-diffusion.cpp binary with appropriate parameters
  4. Saving the generated image to a configured output directory
  5. Returning the path and metadata of the generated image to the client

About stable-diffusion.cpp

stable-diffusion.cpp is a highly optimized C++ implementation of the Stable Diffusion algorithm. Compared to the Python reference implementation, it offers:

  • Significantly faster inference speed (up to 3-4x faster)
  • Lower memory usage (works on GPUs with as little as 4GB VRAM)
  • Optimized CUDA kernels for NVIDIA GPUs
  • Support for various sampling methods and model formats
  • Support for model quantization for better performance
  • No Python dependencies for the core generation process

This allows DiffuGen to provide high-quality image generation with exceptional performance, even on modest hardware setups.

✨ Features

  • Multiple Model Support: Generate images using various models including Flux Schnell, Flux Dev, SDXL, SD3, and SD1.5
  • MCP Integration: Seamlessly integrates with IDEs that support MCP (Cursor, Windsurf, Roo Code, Cline, etc.)
  • OpenAPI Server: Additional REST API interface for direct HTTP access to image generation capabilities
  • Cross-Platform: Works on Linux, macOS, and Windows (via native or WSL)
  • Parameter Control: Fine-tune your generations with controls for:
    • Image dimensions (width/height)
    • Sampling steps
    • CFG scale
    • Seed values
    • Negative prompts (for SD models only, Flux does not support negative prompts.)
    • Sampling methods
  • CUDA Acceleration: Utilizes GPU acceleration for faster image generation
  • Natural Language Interface: Generate images using simple natural language commands
  • Smart Error Recovery: Robust error handling with operation-aware recovery procedures
  • User-Friendly Setup: Interactive setup script with improved interrupt handling
  • Resource Tracking: Session-aware resource management for efficient cleanup
  • Customizable Interface: Support for custom ANSI art logos and visual enhancements

🌟 Contributing

Contributions to DiffuGen are welcome! To contribute:

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

Please ensure your code follows the project's coding standards and includes appropriate tests.

šŸ“„ License

This project is licensed under the Apache License - see the LICENSE file for details.

  • All models are licensed under their respective distribution and are not in any way licensed or provided by CLOUDWERX.DEV
  • HuggingFace.co is used to download models and is not affiliated in any way with CLOUDWERX.DEV

šŸ™ Acknowledgments

šŸ“¬ Contact

                   ______   __   ___   ___         _______              
                  |   _  \ |__|.'  _|.'  _|.--.--.|   _   |.-----.-----.
                  |.  |   \|  ||   _||   _||  |  ||.  |___||  -__|     |
                  |.  |    \__||__|  |__|  |_____||.  |   ||_____|__|__|
                  |:  1    /                      |:  1   |             
                  |::.. . /                       |::.. . |             
                  `------'                        `-------'             

Made with ā¤ļø by CLOUDWERX LAB