Introduction
While text-to-image generation has reached remarkable levels of fidelity, the task of controlled image editing remains a significant challenge. Users often require precise modifications—such as replacing a specific object or altering a localized attribute—without affecting the rest of the scene. Current approaches typically rely on manual masking or complex attention-map manipulations, both of which are labor-intensive and prone to error. Furthermore, diffusion models are highly sensitive to hyperparameters like Classifier-Free Guidance (CFG) scales, which dictate the balance between text adherence and image preservation. Finding the optimal settings usually involves exhaustive manual trial and error.
The BayesGenie Framework
To address these challenges, we present BayesGenie, a training-free, model-agnostic framework designed to automate the optimization of image editing parameters. BayesGenie treats controlled editing as a black-box optimization problem, leveraging the reasoning capabilities of Large Language Models (LLMs) and the efficiency of Bayesian Optimization (BO).
The framework operates through a recursive four-stage loop:
- LLM as Promptist: A high-level LLM (e.g., GPT-4) expands a simple user request into a detailed, context-aware prompt. This prompt ensures the edit remains consistent with the original scene's style and lighting.
- Image Generation: The expanded prompt and the source image are processed by an off-the-shelf diffusion model (such as InstructPix2Pix or UltraEdit).
- LLM as Evaluator: A multimodal LLM assesses the generated output, providing a numerical score (0-100) based on instruction following, preservation of original content, and the quality of the modification.
- Bayesian Optimization: Using the scores as feedback, a Gaussian Process models the relationship between the CFG parameters and the output quality. An "Expected Improvement" acquisition function then selects the most promising parameters for the next iteration.
Key Insights
The success of BayesGenie rests on two primary observations. First, the "Smoothness" Hypothesis: the authors posit that the parameter space of diffusion models is sufficiently smooth, allowing Bayesian Optimization to converge more effectively than random or grid searches. Second, the use of LLMs as Nuanced Judges overcomes the limitations of traditional metrics like CLIP, which often struggle to evaluate fine-grained, localized changes.
Experimental Results
The framework was evaluated on a dataset of over 500 images encompassing three core operations: adding, removing, and modifying objects. BayesGenie was compared against established baselines, including DALLE-3, InstructPix2Pix, UltraEdit, and MagicBrush.
Quantitative and Qualitative Performance
BayesGenie consistently outperformed base models in both CLIP and GPT-4o consistency scores. In a human preference study involving 500 votes, BayesGenie was overwhelmingly preferred, securing 391 votes, compared to 66 for DALLE-3 and 43 for the baseline InstructPix2Pix.
Efficiency and Cost
Despite the iterative nature of the process, BayesGenie remains practical for consumer use. On a single RTX 4080 GPU, the system generates a high-quality 512x512 edited image in approximately 2.5 minutes. The associated API costs are estimated at $0.176 per image, making it a cost-effective solution for high-precision tasks.
Limitations and Future Work
The primary trade-off in the BayesGenie framework is latency; the iterative optimization loop is inherently slower than single-pass inference. Additionally, the framework's performance is bounded by the capabilities of the underlying diffusion model. Future research will explore optimizing a broader range of hyperparameters and extending the framework to more diverse architectural backends.
Conclusion
BayesGenie demonstrates that combining LLM-based reasoning with Bayesian Optimization can significantly enhance the precision of image editing without the need for manual masking or model fine-tuning. By automating the search for optimal hyperparameters, it provides a robust "meta-framework" for the next generation of creative AI tools.
Summary updated