MCPcopy Create free account
hub / github.com/MeiGen-AI/PosterCraft / __init__

Method __init__

inference_offload.py:106–137  ·  view source on GitHub ↗
(self, 
                 pipeline_path="black-forest-labs/FLUX.1-dev",
                 custom_transformer_path=None,
                 qwen_model_path=None,
                 device="cuda:0")

Source from the content-addressed store, hash-verified

104
105class PosterGenerator:
106 def __init__(self,
107 pipeline_path="black-forest-labs/FLUX.1-dev",
108 custom_transformer_path=None,
109 qwen_model_path=None,
110 device="cuda:0"):
111
112 self.device = torch.device(device) if isinstance(device, str) else device
113
114 # Load Qwen model for prompt rewriting
115 if qwen_model_path and os.path.exists(qwen_model_path):
116 print(f"Loading Qwen model from: {qwen_model_path}")
117 self.qwen_agent = QwenRecapAgent(qwen_model_path, device=self.device)
118 else:
119 self.qwen_agent = None
120
121 # Load Flux pipeline
122 print(f"Loading Flux pipeline from: {pipeline_path}")
123 self.pipeline = FluxPipeline.from_pretrained(pipeline_path, torch_dtype=torch.bfloat16)
124
125 # Load custom transformer if provided
126 if custom_transformer_path:
127 print(f"Loading custom transformer from: {custom_transformer_path}")
128 self.pipeline.transformer = FluxTransformer2DModel.from_pretrained(
129 custom_transformer_path,
130 torch_dtype=torch.bfloat16
131 )
132
133 if self.device.type != 'cpu':
134 print("Enabling model CPU offload for FLUX pipeline.")
135 self.pipeline.enable_model_cpu_offload()
136 else:
137 self.pipeline.to(self.device)
138
139 def generate(self,
140 prompt,

Callers

nothing calls this directly

Calls 1

QwenRecapAgentClass · 0.70

Tested by

no test coverage detected