$ show MeiGen-AI/PosterCraft
PosterCraft is an application for generating high-quality aesthetic posters from text prompts using a fine-tuned FLUX.1 model. The system consists of three main components: a prompt enhancement module (QwenRecapAgent) that rewrites user prompts for better detail, an image generation module (PosterGenerator) that uses a custom FLUX transformer to create posters, and a Gradio web interface for interactive use. The application supports CPU offloading for low-memory GPUs and demonstrates modular design with clear separation between prompt processing and image generation. Key entry points include inference.py (command-line generation), inference_offload.py (memory-efficient generation), and demo_gradio.py (web UI).
The LLM identified 2 files worth highlighting for reuse:
The QwenRecapAgent class provides a robust, reusable prompt enhancement wrapper for large language models. It handles model loading, device management, and gracefully falls back to the original prompt on failure. The component is isolated (only depends on the LLM and tokenizer) and can be extracted for any text refinement task with minimal changes.
The PosterGenerator class demonstrates effective CPU offloading patterns for Hugging Face diffusers pipelines. It conditionally enables model CPU offload for the FLUX pipeline when GPU memory is constrained and implements similar offloading for the Qwen prompt model during inference. This pattern is reusable across any Hugging Face pipeline to reduce GPU memory usage with minimal code changes.