ComfyUI Extension: ComfyUI-Freepik

Authored by febogallo

Created

Updated

0 stars

Integrates Freepik's AI capabilities into ComfyUI workflows with features for photorealistic generation, upscaling, and background removal, plus smart caching and cost management. (Description by CC)

Custom Nodes (0)

    README

    ComfyUI-Freepik

    Professional Freepik AI integration for ComfyUI workflows

    License: MIT Python 3.9+ ComfyUI

    Bring Freepik's powerful AI capabilities directly into your ComfyUI workflows with seamless integration, smart caching, and pay-as-you-go pricing.

    ComfyUI-Freepik Banner

    ✨ Features

    • 🎨 Mystic AI - Photorealistic text-to-image generation
    • πŸ” Creative Upscaler - Magnific.ai powered prompt-guided enhancement (2x-16x)
    • 🎯 Precision Upscaler - High-fidelity upscaling without hallucinations
    • βœ‚οΈ Background Removal - Instant AI-powered background removal
    • πŸ’Ύ Smart Caching - Automatic result caching (30-day retention)
    • πŸ’° Cost Management - Real-time cost estimation before execution
    • πŸ”„ Async Processing - Non-blocking task management with progress tracking

    πŸš€ Quick Start

    Installation

    1. Clone or download into your ComfyUI custom nodes directory:
    cd ComfyUI/custom_nodes
    git clone https://github.com/yourusername/ComfyUI-Freepik.git
    cd ComfyUI-Freepik
    
    1. Install dependencies:
    pip install -r requirements.txt
    
    1. Get your API key:

    2. Restart ComfyUI and look for nodes under Freepik/ category

    First Generation

    1. Add Freepik Mystic node
    2. Enter your API key
    3. Write a prompt
    4. Connect to Preview Image or Save Image
    5. Queue prompt!

    πŸ“¦ Available Nodes

    🎨 Freepik Mystic (Text-to-Image)

    Generate photorealistic 2K images from text prompts.

    Features:

    • Multiple aspect ratios (16:9, 1:1, 9:16, 4:3, 21:9)
    • LoRA style support
    • Seed control for reproducibility
    • Cost: €0.10 per image

    Outputs:

    • square_1_1: 2048Γ—2048
    • widescreen_16_9: 2752Γ—1536
    • social_story_9_16: 1536Γ—2752

    πŸ” Freepik Upscaler Creative

    AI-powered upscaling with prompt guidance (Powered by Magnific.ai)

    Features:

    • Upscale factors: 2x, 4x, 8x, 16x
    • Prompt-guided enhancement
    • Creativity control (0.0-1.0)
    • Detail level control (0.0-1.0)
    • Cost: €0.10 - €1.60+ depending on output size

    Best for:

    • Architectural renders (creativity: 0.3-0.5)
    • Interior design (detail: 0.6-0.7)
    • Concept art enhancement

    🎯 Freepik Upscaler Precision

    High-fidelity upscaling without AI hallucinations

    Features:

    • Faithful to original content
    • Perfect for logos, UI, technical drawings
    • Denoise strength control
    • Sharpen control
    • Same cost structure as Creative

    βœ‚οΈ Freepik Remove Background

    Instant background removal with alpha mask output

    Features:

    • Returns image + alpha mask
    • Fast and reliable
    • Minimal cost

    πŸ’° Pricing & Cost Comparison

    Pay-As-You-Go (No Subscription Required)

    | Operation | Cost | |-----------|------| | Text-to-Image (2K) | €0.10 | | Upscale 2x | €0.10 | | Upscale 4x | €0.40 | | Upscale 8x | €1.60 | | Remove Background | Low/Free |

    vs Magnific AI Platform

    ComfyUI-Freepik is more cost-effective when:

    • βœ… You process < 90 upscales/month β†’ Save 33-89%
    • βœ… You need automation and complex workflows
    • βœ… Usage is variable month-to-month
    • βœ… You prefer pay-as-you-go with no monthly commitment

    Breakeven Analysis:

    | Monthly Volume | Magnific Subscription | API Pay-as-you-go | Savings | |----------------|----------------------|-------------------|---------| | 10 upscales | $39 | $4.32 | $34.68 (89%) | | 50 upscales | $39 | $21.60 | $17.40 (45%) | | 90 upscales | $39 | $38.88 | Breakeven | | 200 upscales | $39 | $86.40 | -$47.40 |

    For most users (< 90/month): ComfyUI-Freepik saves 33-89%

    πŸ“Š Read full cost analysis

    🎯 Example Workflows

    Basic Generation

    Freepik Mystic β†’ Preview Image
    

    Generation + Enhancement

    Freepik Mystic (2K, 16:9) β†’ 
    Freepik Upscaler Creative (4x) β†’ 
    Save Image
    
    Output: 2752Γ—1536 β†’ 11008Γ—6144
    

    Architectural Visualization Pipeline

    Freepik Mystic (architectural prompt) β†’ 
    Freepik Upscaler Precision (2x-4x) β†’ 
    Post-processing nodes β†’ 
    Final delivery
    

    Background Removal

    Load Image β†’ 
    Freepik Remove Background β†’ 
    Composite with new background
    

    πŸ—οΈ Architecture

    ComfyUI_Freepik/
    β”œβ”€β”€ __init__.py              # Node registration
    β”œβ”€β”€ requirements.txt         # Dependencies
    β”œβ”€β”€ api/
    β”‚   β”œβ”€β”€ client.py           # HTTP client with retry logic
    β”‚   └── tasks.py            # Async task manager
    β”œβ”€β”€ nodes/
    β”‚   β”œβ”€β”€ generation/
    β”‚   β”‚   └── mystic_node.py  # Text-to-image
    β”‚   β”œβ”€β”€ editing/
    β”‚   β”‚   └── upscaler_nodes.py # Upscalers
    β”‚   └── utilities/
    β”‚       └── remove_bg_node.py # Background removal
    └── utils/
        β”œβ”€β”€ cache.py            # Caching system
        └── image_utils.py      # Image conversions
    

    πŸ”§ Technical Highlights

    • Smart Caching: MD5-based parameter matching with automatic cleanup
    • Async Processing: Non-blocking execution with configurable intervals
    • Error Recovery: Exponential backoff retry strategy (3 retries)
    • Multi-format Support: JSON + multipart/form-data requests
    • Progress Tracking: Real-time status updates during processing
    • Cost Transparency: Estimation before execution

    πŸ“‹ Requirements

    • Python 3.9+
    • ComfyUI (latest version recommended)
    • Internet connection
    • Freepik API key

    Python Dependencies:

    • requests
    • Pillow
    • torch

    🎨 Parameter Reference

    Magnific Creative Upscaler Equivalence

    | Freepik Platform | ComfyUI Node | Value Mapping | |-----------------|--------------|---------------| | Creativity (0-10) | creativity | 0.0-1.0 (divide by 10) | | HDR (0-10) | detail_level | 0.0-1.0 (divide by 10) | | Scale Factor | upscale_factor | "2x", "4x", "8x", "16x" | | Prompt | prompt | Direct equivalent |

    Recommended for Architecture:

    • Creativity: 0.3-0.5
    • Detail Level: 0.6-0.7
    • Prompt: "enhance architectural details, photorealistic render, natural lighting"

    πŸ“– Full parameter reference

    πŸ› οΈ Advanced Usage

    Batch Processing

    # Process multiple images automatically
    for image in image_list:
        mystic_node.generate(
            api_key=api_key,
            prompt=prompt,
            aspect_ratio="widescreen_16_9"
        )
    

    Custom Workflows

    Integrate with other ComfyUI nodes for complex pipelines:

    • Pre-processing with ControlNet
    • Post-processing with color correction
    • Automated client delivery systems

    Cost Optimization

    • Enable caching to avoid redundant API calls
    • Batch similar operations
    • Use appropriate resolution for your needs

    ⚠️ Limitations

    API Restrictions

    • Mystic outputs fixed ~2K resolution (aspect ratio determines dimensions)
    • Some Magnific parameters not available (Resemblance, Fractality, Engine)
    • Rate limits apply (check Freepik API documentation)

    vs Magnific.ai Platform

    • ❌ No Resemblance slider
    • ❌ No Fractality slider
    • ❌ No Engine selection
    • βœ… But: Full workflow automation
    • βœ… And: Pay-as-you-go pricing

    πŸ—ΊοΈ Roadmap

    Phase 2 (Future)

    • [ ] Video Generation nodes (Kling v2.5, PixVerse V5)
    • [ ] Image Relighting
    • [ ] Style Transfer
    • [ ] Image-to-Prompt utility
    • [ ] LoRA Training nodes
    • [ ] Batch processing manager
    • [ ] Credit tracker dashboard

    Improvements

    • [ ] Remove debug prints
    • [ ] Add architectural preset system
    • [ ] Optimize cache management
    • [ ] Progress bars in UI
    • [ ] Better error messages

    πŸ“š Documentation

    🀝 Contributing

    Contributions are welcome! Please feel free to submit a Pull Request.

    πŸ“„ License

    MIT License - see LICENSE file for details

    πŸ™ Credits

    Developer: Felipe @ Pixelflakes
    Built for: Architectural visualization workflows
    Powered by: Freepik API + Magnific.ai technology

    Special thanks to:

    • ComfyUI community
    • Freepik API team
    • Magnific.ai for upscaling technology

    πŸ”— Links

    πŸ“ž Support

    • Issues: GitHub Issues
    • API Docs: https://docs.freepik.com
    • Freepik Support: https://support.freepik.com

    Made with ❀️ for the ComfyUI community

    If you find this useful, please ⭐ star the repository!