RioShiina commited on
Commit
3088c88
·
verified ·
1 Parent(s): 7eb9d75

feat: Add FLUX.3 Prompt Upsampler integration & update requirements

Browse files
README.md CHANGED
@@ -154,6 +154,7 @@ models:
154
  - black-forest-labs/FLUX.1-Krea-dev
155
  - black-forest-labs/FLUX.1-schnell
156
  - black-forest-labs/flux-3-image-klein
 
157
  - Boogu/Boogu-Image-0.1-Turbo
158
  - Boogu/Boogu-Image-0.1-Base
159
  - Boogu/Boogu-Image-0.1-Edit
 
154
  - black-forest-labs/FLUX.1-Krea-dev
155
  - black-forest-labs/FLUX.1-schnell
156
  - black-forest-labs/flux-3-image-klein
157
+ - black-forest-labs/flux-3-image-klein-pup
158
  - Boogu/Boogu-Image-0.1-Turbo
159
  - Boogu/Boogu-Image-0.1-Base
160
  - Boogu/Boogu-Image-0.1-Edit
chain_injectors/flux3_prompt_upsampler_injector.py ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FLUX.3 Prompt Upsampler Chain Injector.
2
+
3
+ This injector integrates the FLUX.3 prompt upsampler model into the generation workflow:
4
+ - Uses qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors (type: flux3).
5
+ - Uses PrimitiveStringMultiline for system prompt and input prompt.
6
+ - Expands user prompt into detailed generative captions using TextGenerate.
7
+ - Supports reasoning mode (thinking=True) via native ComfyUI TextGenerate reasoning separation.
8
+ - Supports single or multi-reference image inputs: multiple reference images are stitched
9
+ into a structured grid layout via ComfyUI native ImageStitch nodes and scaled via ImageScaleToTotalPixels,
10
+ then connected to the TextGenerate 'image' input.
11
+ - Connects enhanced prompt directly to downstream CLIPTextEncode positive prompt.
12
+ """
13
+
14
+ try:
15
+ from utils.app_utils import ensure_file_downloaded
16
+ except ImportError:
17
+ ensure_file_downloaded = None
18
+
19
+ SYSTEM_PROMPTS = {
20
+ "t2i": (
21
+ "You are the prompt upsampler of a text-to-image model. Expand the user's short request into ONE detailed, self-contained caption: the exact text the image model receives. Output only the caption, with no greetings, explanations, refusals, questions, Markdown, headings, JSON, coordinates, ids or angle-bracket tokens, and no quotes around it. If the input is not clearly an image request, caption a visualization of its concept. The request may begin with a \"TARGET CANVAS: W:H\" line: compose for that canvas (wide spreads content sideways, tall stacks it) and never mention the ratio or the canvas.\n\n"
22
+ "Fidelity and planning: keep every explicit subject, attribute, count, spatial constraint, style cue and piece of wording; never contradict, substitute, drop or narrow the request, and keep an abstract concept abstract. Decide everything left open as ONE concrete, consistent plan; never offer alternatives or hedge. Never re-express a stated constraint through another mechanism; add camera optics (depth of field, bokeh, blur) only when asked for or implied. Without a stated style, plan an actual photograph and open with the medium convention (\"Full-color outdoor photograph, ...\", \"Full-color indoor photograph, ...\", \"Studio photograph, ...\", \"Close-up photograph, ...\"); keep \"Photorealistic\" for renders, and turn \"photorealistic\" or \"realistic\" requests for photos into the photograph convention. Give a photograph a few ordinary, non-ideal specifics drawn from the scene's own objects instead of the stock-photo ideal. Do not invent names, brands, logos or celebrities; keep user-named ones. A long request keeps its content but not its wording: drop appraisal and sales vocabulary, turn moods into observable physical facts, and add only new concrete content with positions. Time of day is lighting, not rendered text.\n\n"
23
+ "Caption format: one continuous prose block in the generative voice, never \"this image shows\", \"we can see\" or \"is visible\". Lead with medium and style, then scene, lighting and camera, then the subjects with concrete colors, materials and state. Every person in focus gets an observable profile: ethnicity, gender, age range, skin tone (\"fair skin\", \"brown skin\"), hair and clothing. Make the layout reconstructable from words: frame-relative positions (frame-left, frame-right, upper, lower, foreground, midground, background), sentence-initial anchors (\"On the left, ...\", \"In the background, ...\"), relations (holds, faces, behind) and a consistent order; describe up to about ten instances one by one, beyond that give the exact count and arrangement. Out-of-focus or distant planes are shapes, colors and silhouettes, never identities or readable text, and the background takes about a sixth of the caption. Be definite: no hedging adverbs, no quality or emotion judgments, no closing sentence about mood; state negations as what is present. Rendered text: transcribe every wording verbatim inside double quotes in its original language and script, keep the line breaks of multi-line text, and give its typography, color and placement; author concrete, domain-correct wording when the request needs text it does not supply, and name canonical structures (calendar, keyboard, periodic table) exactly with their full layout. All prose is English; only quoted text keeps its language. Typical length is 100 to 350 words, more for complex scenes.\n\n"
24
+ "Output only the caption."
25
+ ),
26
+ "i2i": (
27
+ "You are the prompt upsampler of an image-editing model. You see the reference image(s), attached in order (the first image, the second image, ...), and the user's short request. Expand it into ONE detailed, self-contained instruction: the caption the editing model receives together with the same images. Output only the instruction as one continuous English prose block, with no greetings, explanations, Markdown, JSON, coordinates, ids or angle-bracket tokens. Read a vague or conversational request as the most plausible edit of the supplied images.\n\n"
28
+ "Pick the voice by task shape. When one reference stays and gets bounded changes, write an imperative editing instruction on it (\"Remove the ...\", \"Change the ... to ...\", \"Zoom in on ...\"); a whole-image transformation opens with its scope (\"Convert the entire image into ...\", \"Apply a ... filter over the entire scene\", \"Horizontally flip the entire image so that ...\", \"Shift the camera viewpoint to ...\", then where the major elements should now be). When the references are drawn into a newly composed frame (combining subjects, a new scene, a garment, object or style donor), write a generation request (\"Create a photograph of ...\", \"Create an anime-style illustration of ...\", \"Generate a new image featuring ...\") that says what to take from each image, by ordinal, and what is newly generated.\n\n"
29
+ "Keep every explicit edit, constraint, count, position, style cue and piece of wording, and decide what is left open as one concrete plan. Ground everything in what is actually visible: identify each referent unambiguously by its real appearance, never mention content that is not there, and use every image the user attached. State every end state concretely (which color, how large, which pose, which material) and give new content enough appearance to be generated. Cover the knock-on effects of the change (shadows, reflections, occlusion, perspective, scale, lighting) and say what fills a removed region. A zoom-in names what stays in frame and which neighbors are cropped out; an outpainting continues the scene in the same medium. Describe the change, not the whole scene, and close an editing instruction with one compact clause naming what stays unchanged; transferred people keep their identity, face and accessories unless asked otherwise. Transcribe on-image text verbatim in its original language inside double quotes, with line breaks as \\n, and match the original font, size and color when replacing it. Name recognizable public figures, brands and landmarks you can see. Directions are frame-relative; use no evaluative or quality words. Typical length is 50 to 150 words.\n\n"
30
+ "Output only the instruction."
31
+ ),
32
+ "t2i_bbox": (
33
+ "You are the prompt upsampler of a text-to-image model. Plan the full image the user's short request implies and output ONE structured caption on a single line: the global caption paragraph, one space, then ONE JSON array, the element table that places every cited element with a bounding box in the image to be generated. Output nothing else (no Markdown fences, commentary or refusals); visualize the concept of a non-image input. The request may begin with a \"TARGET CANVAS: W:H\" line: compose for that canvas and never mention it. Boxes live on a 0-1000 grid stretched onto the canvas: an element of physical width-to-height ratio a gets an x-span of about y-span x a x H/W.\n\n"
34
+ "Planning: keep every explicit subject, attribute, count, spatial constraint, style cue and piece of wording, and decide everything left open as ONE concrete composition that the caption and the table both describe. Without a stated style plan an actual photograph and open with the medium convention (\"Full-color outdoor photograph, ...\", \"Studio photograph, ...\"); add camera optics only when asked for; do not invent names, brands, logos or celebrities; drop appraisal and sales vocabulary.\n\nThe table: one row per distinct object, person, animal, building or salient region the caption mentions and one per coherent text block; no rows for style, lighting or atmosphere. Structured layouts (tables, grids, calendars, keyboards, charts, maps, posters, pages) decompose into their regions, each row carrying that region's complete verbatim content; more than about ten interchangeable items become one collection row giving the exact count and arrangement, while items whose positions matter keep a row each. Row keys, in order: \"id\", \"bbox\", \"desc\". id: the bare class noun plus an index numbered left to right, then top to bottom, from 1 (person_1, dog_2); a text block is its two-letter language code plus _Text_ plus an index (En_Text_1); one entity is one row and ids are unique. bbox: [y_min, x_min, y_max, x_max] as integers from 0 to 1000, top-left origin, clamped at the borders, with plausible relative sizes and a small margin around text. desc: one self-contained paragraph in the generative voice that opens with the element's identity (never \"the X\"): shape, material, colors, state and markings, but no position. People in focus get the richest desc: ethnicity, gender, age range, skin tone, build, hair, face, each garment, accessories, pose and expression. A text row carries its complete wording verbatim in double quotes, with line breaks as \\n, plus its typography.\n\nThe global caption: one flowing paragraph in the generative voice (medium first, then scene, lighting, camera and frame-relative layout; no quality judgments) that names each table element at identity level at its first mention and cites it with its id in its own angle brackets: \"a wicker table <table_1> holding a tiered stand <stand_1>\". Cite every table id and no other; appearance detail and text content live in the descs; no coordinates. Text-dense documents are laid out region by region with every visible text transcribed verbatim at a readable size (cut content rather than shrink type), and a grid quotes every visible cell. All prose is English; only quoted text keeps its language.\n\nOutput only the caption and the table."
35
+ ),
36
+ "i2i_bbox": (
37
+ "You are the annotation system an image-editing model was trained on. You see the source image(s), attached in order as ref_image_0, ref_image_1, ..., and the user's editing instruction; the edited target image does not exist yet. Determine the edit precisely, imagine the target consistently with the source, and write the record its annotator would have written, on one line: the instruction paragraph, one space, then ONE JSON array. Output nothing else.\n\nThe paragraph: English, instruction voice (\"Change the ...\", \"Remove the ...\", or \"Create a photograph of ...\" when the references are drawn into a new frame), never observer phrasing and never a comparison with the target. Cite every involved object, person or text block at its first mention with its table id in its own angle brackets (\"remove the delivery van <van_1>\"), every table id exactly once and no other id; cite a reference image by its token when content is taken from it (\"the cup <cup_1> from <ref_image_1>\"). End states (new color, new text in quotes, pose, degree) live in the paragraph, static appearance in the descs; no coordinates. An editing instruction closes with one compact clause that everything else stays identical to the source.\n\nThe table, rows {\"id\", \"from\", \"src_bbox\", \"tgt_bbox\", \"desc\"}: one row per edited, removed, added, moved or anchoring item, plus the scene or background when it is itself changed or preserved; no rows for untouched scenery. id: a lowercase class noun plus an index (person_1, cup_2) numbered left to right, then top to bottom; text blocks are En_Text_1 and so on; ids are unique. from: \"ref_image_N\" for an item visible in reference N, \"target\" for newly created content. src_bbox is the item's box in its from-image and null for target rows; tgt_bbox is its box in the imagined result and null for removed items; moved or resized items carry both; new items are sized like similar objects in the frame. Boxes are [y_min, x_min, y_max, x_max] integers from 0 to 1000, top-left origin, tight around objects, with 5 to 15 units of margin around text. A row may also carry src_bbox_1stage and tgt_bbox_1stage, a first-pass estimate of the same boxes. desc: one English paragraph of the item's static appearance in its from-image (for target rows, its decided appearance), opening with its identity; people get the richest descs (ethnicity, gender, age range, skin tone, hair, face, garments, accessories, pose, expression); text rows quote their text verbatim.\n\nState only decided facts: visible in the source, demanded by the instruction, or a concrete default needed to realize it. Settle whether the edit targets one instance, all of a class or several; land every magnitude on a concrete value; include visible knock-on effects; added objects are new objects at real-world size; a zoom-in names the neighbors it excludes; an outpainting keeps the source whole and continues it in the same medium. Everything the instruction does not involve stays identical to the source.\n\nOutput only the paragraph and the table."
38
+ )
39
+ }
40
+
41
+ DEFAULT_FLUX3_SYSTEM_PROMPT = SYSTEM_PROMPTS["t2i"]
42
+
43
+
44
+ def create_node(assembler, class_type, title):
45
+ """Create a workflow node dictionary with fallback template generation."""
46
+ try:
47
+ node = assembler._get_node_template(class_type)
48
+ except Exception:
49
+ node = {
50
+ "inputs": {},
51
+ "class_type": class_type,
52
+ "_meta": {"title": title}
53
+ }
54
+ if "_meta" not in node:
55
+ node["_meta"] = {}
56
+ node['_meta']['title'] = title
57
+ return node
58
+
59
+
60
+ def inject(assembler, chain_definition, chain_items):
61
+ """Inject FLUX.3 prompt upsampler nodes into the target generation workflow."""
62
+ if not chain_items:
63
+ return
64
+
65
+ is_enabled = False
66
+ thinking_enabled = False
67
+ bbox_mode = False
68
+ max_length = 3584
69
+ custom_system_prompt = None
70
+
71
+ for item in chain_items:
72
+ if isinstance(item, dict):
73
+ if item.get("enable", False) or item.get("enabled", False) or item.get("value", False):
74
+ is_enabled = True
75
+ if item.get("thinking", False) in (True, "true", "on", "yes", "1", 1):
76
+ thinking_enabled = True
77
+ if item.get("bbox_mode", False) in (True, "true", "on", "yes", "1", 1):
78
+ bbox_mode = True
79
+ if "max_length" in item and item["max_length"]:
80
+ try:
81
+ max_length = int(item["max_length"])
82
+ except (ValueError, TypeError):
83
+ pass
84
+ if "system_prompt" in item and item["system_prompt"]:
85
+ custom_system_prompt = str(item["system_prompt"])
86
+ elif item is True or str(item).lower() in ("on", "true", "yes", "1"):
87
+ is_enabled = True
88
+ break
89
+
90
+ if not is_enabled:
91
+ return
92
+
93
+ target_node_name = chain_definition.get('target_node', 'pos_prompt')
94
+ target_node_id = assembler.node_map.get(target_node_name)
95
+
96
+ if not target_node_id or target_node_id not in assembler.workflow:
97
+ for node_id, node in assembler.workflow.items():
98
+ if isinstance(node, dict) and node.get('class_type') == 'CLIPTextEncode':
99
+ title = node.get('_meta', {}).get('title', '').lower()
100
+ if 'pos' in title or 'positive' in title:
101
+ target_node_id = node_id
102
+ break
103
+
104
+ if not target_node_id or target_node_id not in assembler.workflow:
105
+ for node_id, node in assembler.workflow.items():
106
+ if isinstance(node, dict) and node.get('class_type') in ('CLIPTextEncode', 'TextEncodeQwenImage21', 'TextEncodeMingImageEdit'):
107
+ target_node_id = node_id
108
+ break
109
+
110
+ if not target_node_id or target_node_id not in assembler.workflow:
111
+ print(f"Warning: Target node '{target_node_name}' not found for FLUX.3 Prompt Upsampler. Skipping.")
112
+ return
113
+
114
+ target_node = assembler.workflow[target_node_id]
115
+ original_prompt = target_node.get('inputs', {}).get('text')
116
+ if original_prompt is None:
117
+ original_prompt = target_node.get('inputs', {}).get('prompt', '')
118
+
119
+ # 1. Collect image connections for multi-image reference support
120
+ load_image_nodes = [
121
+ node_id for node_id, node in assembler.workflow.items()
122
+ if isinstance(node, dict) and node.get('class_type') == 'LoadImage'
123
+ ]
124
+ has_load_image = len(load_image_nodes) > 0
125
+ target_image_conn = None
126
+
127
+ # Auto-select official BFL system prompt template:
128
+ # If loadimage is detected: i2i / i2i_bbox; otherwise t2i / t2i_bbox
129
+ if custom_system_prompt:
130
+ system_prompt = custom_system_prompt
131
+ else:
132
+ if has_load_image:
133
+ template_key = "i2i_bbox" if bbox_mode else "i2i"
134
+ else:
135
+ template_key = "t2i_bbox" if bbox_mode else "t2i"
136
+ system_prompt = SYSTEM_PROMPTS.get(template_key, DEFAULT_FLUX3_SYSTEM_PROMPT)
137
+
138
+ if has_load_image:
139
+ indexed_slots = []
140
+ target_inputs = target_node.get('inputs', {})
141
+ for slot_key, slot_val in target_inputs.items():
142
+ if slot_key.startswith('images.image_') and isinstance(slot_val, (list, tuple)):
143
+ try:
144
+ idx = int(slot_key.split('_')[-1])
145
+ except Exception:
146
+ idx = 999
147
+ indexed_slots.append((idx, slot_val))
148
+
149
+ indexed_slots.sort(key=lambda x: x[0])
150
+ ref_image_conns = [s[1] for s in indexed_slots]
151
+
152
+ if not ref_image_conns:
153
+ for lid in load_image_nodes:
154
+ scaled_conn = None
155
+ for nid, node in assembler.workflow.items():
156
+ if isinstance(node, dict) and node.get('class_type') == 'ImageScaleToTotalPixels':
157
+ img_input = node.get('inputs', {}).get('image')
158
+ if isinstance(img_input, (list, tuple)) and str(img_input[0]) == str(lid):
159
+ scaled_conn = [nid, 0]
160
+ break
161
+ if scaled_conn:
162
+ ref_image_conns.append(scaled_conn)
163
+ else:
164
+ scale_id = assembler._get_unique_id()
165
+ scale_node = create_node(assembler, "ImageScaleToTotalPixels", "Scale Input Image")
166
+ scale_node['inputs'] = {
167
+ "upscale_method": "nearest-exact",
168
+ "megapixels": 1,
169
+ "resolution_steps": 1,
170
+ "image": [lid, 0]
171
+ }
172
+ assembler.workflow[scale_id] = scale_node
173
+ ref_image_conns.append([scale_id, 0])
174
+
175
+ if len(ref_image_conns) == 1:
176
+ target_image_conn = ref_image_conns[0]
177
+ elif len(ref_image_conns) >= 2:
178
+ num_cols = 2 if len(ref_image_conns) <= 4 else 3
179
+ rows = []
180
+ for i in range(0, len(ref_image_conns), num_cols):
181
+ rows.append(ref_image_conns[i:i + num_cols])
182
+
183
+ stitched_rows = []
184
+ for r_idx, row_imgs in enumerate(rows):
185
+ if len(row_imgs) == 1:
186
+ stitched_rows.append(row_imgs[0])
187
+ else:
188
+ curr_stitch = row_imgs[0]
189
+ for c_idx in range(1, len(row_imgs)):
190
+ st_id = assembler._get_unique_id()
191
+ st_node = create_node(assembler, "ImageStitch", f"Stitch Images (Row {r_idx+1}-{c_idx})")
192
+ st_node['inputs'] = {
193
+ "direction": "right",
194
+ "match_image_size": True,
195
+ "spacing_width": 0,
196
+ "spacing_color": "white",
197
+ "image1": curr_stitch,
198
+ "image2": row_imgs[c_idx]
199
+ }
200
+ assembler.workflow[st_id] = st_node
201
+ curr_stitch = [st_id, 0]
202
+ stitched_rows.append(curr_stitch)
203
+
204
+ if len(stitched_rows) == 1:
205
+ final_stitched = stitched_rows[0]
206
+ else:
207
+ curr_vertical = stitched_rows[0]
208
+ for r_idx in range(1, len(stitched_rows)):
209
+ st_id = assembler._get_unique_id()
210
+ st_node = create_node(assembler, "ImageStitch", f"Stitch Images (Vertical {r_idx})")
211
+ st_node['inputs'] = {
212
+ "direction": "down",
213
+ "match_image_size": True,
214
+ "spacing_width": 0,
215
+ "spacing_color": "white",
216
+ "image1": curr_vertical,
217
+ "image2": stitched_rows[r_idx]
218
+ }
219
+ assembler.workflow[st_id] = st_node
220
+ curr_vertical = [st_id, 0]
221
+ final_stitched = curr_vertical
222
+
223
+ final_scale_id = assembler._get_unique_id()
224
+ final_scale_node = create_node(assembler, "ImageScaleToTotalPixels", "Scale Stitched Image")
225
+ final_scale_node['inputs'] = {
226
+ "upscale_method": "nearest-exact",
227
+ "megapixels": 1,
228
+ "resolution_steps": 1,
229
+ "image": final_stitched
230
+ }
231
+ assembler.workflow[final_scale_id] = final_scale_node
232
+ target_image_conn = [final_scale_id, 0]
233
+
234
+ # 2. Ensure model is downloaded
235
+ clip_model_name = "qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors"
236
+ if ensure_file_downloaded:
237
+ try:
238
+ ensure_file_downloaded(clip_model_name)
239
+ except Exception as e:
240
+ print(f"Warning: Failed to ensure '{clip_model_name}' downloaded: {e}")
241
+
242
+ # 3. Create CLIPLoader node (type: flux3)
243
+ clip_node_id = assembler._get_unique_id()
244
+ clip_node = create_node(assembler, "CLIPLoader", "Load CLIP")
245
+ clip_node['inputs'] = {
246
+ "clip_name": clip_model_name,
247
+ "type": "flux3",
248
+ "device": "default"
249
+ }
250
+ assembler.workflow[clip_node_id] = clip_node
251
+
252
+ # 4. Create PrimitiveStringMultiline node for System Prompt
253
+ system_prompt_node_id = assembler._get_unique_id()
254
+ system_prompt_node = create_node(assembler, "PrimitiveStringMultiline", "Text (System prompt)")
255
+ system_prompt_node['inputs'] = {
256
+ "value": system_prompt
257
+ }
258
+ assembler.workflow[system_prompt_node_id] = system_prompt_node
259
+
260
+ # 5. Create PrimitiveStringMultiline node for User Prompt
261
+ if isinstance(original_prompt, (list, tuple)):
262
+ prompt_conn = original_prompt
263
+ else:
264
+ prompt_node_id = assembler._get_unique_id()
265
+ prompt_node = create_node(assembler, "PrimitiveStringMultiline", "Text (Multiline)")
266
+ prompt_node['inputs'] = {
267
+ "value": original_prompt if isinstance(original_prompt, str) else ""
268
+ }
269
+ assembler.workflow[prompt_node_id] = prompt_node
270
+ prompt_conn = [prompt_node_id, 0]
271
+
272
+ # 6. Create TextGenerate node
273
+ text_gen_node_id = assembler._get_unique_id()
274
+ text_gen_node = create_node(assembler, "TextGenerate", "Generate Text")
275
+ text_gen_inputs = {
276
+ "prompt": prompt_conn,
277
+ "max_length": max_length,
278
+ "sampling_mode": "on",
279
+ "sampling_mode.temperature": 1.0,
280
+ "sampling_mode.top_k": 1,
281
+ "sampling_mode.top_p": 0.95,
282
+ "sampling_mode.min_p": 0.0,
283
+ "sampling_mode.repetition_penalty": 1.05,
284
+ "sampling_mode.seed": 0,
285
+ "sampling_mode.presence_penalty": 1.5,
286
+ "thinking": thinking_enabled,
287
+ "use_default_template": True,
288
+ "mtp": "auto",
289
+ "clip": [clip_node_id, 0],
290
+ "system_prompt": [system_prompt_node_id, 0]
291
+ }
292
+ if target_image_conn is not None:
293
+ text_gen_inputs["image"] = target_image_conn
294
+
295
+ text_gen_node['inputs'] = text_gen_inputs
296
+ assembler.workflow[text_gen_node_id] = text_gen_node
297
+
298
+ # 7. Connect TextGenerate output to positive prompt node
299
+ if 'text' in target_node.get('inputs', {}):
300
+ target_node['inputs']['text'] = [text_gen_node_id, 0]
301
+ else:
302
+ target_node['inputs']['prompt'] = [text_gen_node_id, 0]
303
+
304
+ print(f"[Injector] FLUX.3 Prompt Upsampler applied successfully (clip='{clip_model_name}', thinking={thinking_enabled}, images={has_load_image}).")
core/pipelines/pipeline_input_processor.py CHANGED
@@ -430,6 +430,20 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
430
  item["system_prompt"] = str(sys_p)
431
  active_ming_image_prompt_enhancer.append(item)
432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  return {
434
  "active_loras_for_gpu": active_loras_for_gpu,
435
  "active_loras_for_meta": active_loras_for_meta,
@@ -449,5 +463,6 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
449
  "active_conditioning": active_conditioning,
450
  "active_qwen_image_2_1_prompt_enhancer": active_qwen_image_2_1_prompt_enhancer,
451
  "active_ming_image_prompt_enhancer": active_ming_image_prompt_enhancer,
 
452
  "temp_files_to_clean": temp_files_to_clean
453
  }
 
430
  item["system_prompt"] = str(sys_p)
431
  active_ming_image_prompt_enhancer.append(item)
432
 
433
+ flux3_pe_enable = ui_inputs.get('flux3_prompt_upsampler_enable', False)
434
+ active_flux3_prompt_upsampler = []
435
+ if 'flux3_prompt_upsampler' in enabled_chains and flux3_pe_enable:
436
+ item = {
437
+ "enable": True,
438
+ "thinking": bool(ui_inputs.get('flux3_prompt_upsampler_thinking', False)),
439
+ "bbox_mode": bool(ui_inputs.get('flux3_prompt_upsampler_bbox_mode', False)),
440
+ "max_length": int(ui_inputs.get('flux3_prompt_upsampler_max_length', 3584))
441
+ }
442
+ sys_p = ui_inputs.get('flux3_prompt_upsampler_system_prompt')
443
+ if sys_p:
444
+ item["system_prompt"] = str(sys_p)
445
+ active_flux3_prompt_upsampler.append(item)
446
+
447
  return {
448
  "active_loras_for_gpu": active_loras_for_gpu,
449
  "active_loras_for_meta": active_loras_for_meta,
 
463
  "active_conditioning": active_conditioning,
464
  "active_qwen_image_2_1_prompt_enhancer": active_qwen_image_2_1_prompt_enhancer,
465
  "active_ming_image_prompt_enhancer": active_ming_image_prompt_enhancer,
466
+ "active_flux3_prompt_upsampler": active_flux3_prompt_upsampler,
467
  "temp_files_to_clean": temp_files_to_clean
468
  }
core/pipelines/sd_image_pipeline.py CHANGED
@@ -121,6 +121,7 @@ class SdImagePipeline(BasePipeline):
121
  active_conditioning = processed["active_conditioning"]
122
  active_qwen_image_2_1_prompt_enhancer = processed.get("active_qwen_image_2_1_prompt_enhancer", [])
123
  active_ming_image_prompt_enhancer = processed.get("active_ming_image_prompt_enhancer", [])
 
124
 
125
  loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""
126
 
@@ -180,6 +181,7 @@ class SdImagePipeline(BasePipeline):
180
  "reference_image_chain": active_reference_images,
181
  "qwen_image_2_1_prompt_enhancer_chain": active_qwen_image_2_1_prompt_enhancer,
182
  "ming_image_prompt_enhancer_chain": active_ming_image_prompt_enhancer,
 
183
  "vae_chain": [ui_inputs.get('vae_name')] if (ui_inputs.get('vae_name') and 'vae' in enabled_chains) else [],
184
  "hidream_o1_smoothing_chain": hidream_o1_smoothing_data,
185
  "pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],
 
121
  active_conditioning = processed["active_conditioning"]
122
  active_qwen_image_2_1_prompt_enhancer = processed.get("active_qwen_image_2_1_prompt_enhancer", [])
123
  active_ming_image_prompt_enhancer = processed.get("active_ming_image_prompt_enhancer", [])
124
+ active_flux3_prompt_upsampler = processed.get("active_flux3_prompt_upsampler", [])
125
 
126
  loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""
127
 
 
181
  "reference_image_chain": active_reference_images,
182
  "qwen_image_2_1_prompt_enhancer_chain": active_qwen_image_2_1_prompt_enhancer,
183
  "ming_image_prompt_enhancer_chain": active_ming_image_prompt_enhancer,
184
+ "flux3_prompt_upsampler_chain": active_flux3_prompt_upsampler,
185
  "vae_chain": [ui_inputs.get('vae_name')] if (ui_inputs.get('vae_name') and 'vae' in enabled_chains) else [],
186
  "hidream_o1_smoothing_chain": hidream_o1_smoothing_data,
187
  "pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],
core/pipelines/workflow_recipes/_partials/conditioning/flux3.yaml CHANGED
@@ -78,6 +78,10 @@ dynamic_reference_latent_chains:
78
  ksampler_node: "ksampler"
79
  vae_node: "vae_loader"
80
 
 
 
 
 
81
  dynamic_pid_chains:
82
  pid_chain:
83
  ksampler_node: "ksampler"
 
78
  ksampler_node: "ksampler"
79
  vae_node: "vae_loader"
80
 
81
+ dynamic_flux3_prompt_upsampler_chains:
82
+ flux3_prompt_upsampler_chain:
83
+ target_node: "pos_prompt"
84
+
85
  dynamic_pid_chains:
86
  pid_chain:
87
  ksampler_node: "ksampler"
mcp_tools/common.py CHANGED
@@ -628,6 +628,22 @@ def _execute_imagegen_pipeline(task_id: str, params: dict):
628
  ui_inputs["ming_image_prompt_enhancer_max_length"] = int(item.get("max_length", 4096))
629
  if "system_prompt" in item:
630
  ui_inputs["ming_image_prompt_enhancer_system_prompt"] = str(item["system_prompt"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  elif itype == "krea2_identity_edit":
632
  img = _parse_image_param(item.get("image"))
633
  if img:
@@ -757,6 +773,22 @@ def _execute_imagegen_pipeline(task_id: str, params: dict):
757
  else:
758
  ui_inputs["ming_image_prompt_enhancer_enable"] = False
759
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
760
  _TASKS_DB[task_id]["progress"] = 50
761
 
762
  # Execute Pipeline
 
628
  ui_inputs["ming_image_prompt_enhancer_max_length"] = int(item.get("max_length", 4096))
629
  if "system_prompt" in item:
630
  ui_inputs["ming_image_prompt_enhancer_system_prompt"] = str(item["system_prompt"])
631
+ elif itype == "flux3_prompt_upsampler":
632
+ is_enabled = item.get("enable", item.get("enabled", True))
633
+ if isinstance(is_enabled, str):
634
+ is_enabled = is_enabled.upper() in ("ON", "TRUE", "1")
635
+ ui_inputs["flux3_prompt_upsampler_enable"] = bool(is_enabled)
636
+ is_thinking = item.get("thinking", False)
637
+ if isinstance(is_thinking, str):
638
+ is_thinking = is_thinking.upper() in ("ON", "TRUE", "1")
639
+ ui_inputs["flux3_prompt_upsampler_thinking"] = bool(is_thinking)
640
+ is_bbox_mode = item.get("bbox_mode", False)
641
+ if isinstance(is_bbox_mode, str):
642
+ is_bbox_mode = is_bbox_mode.upper() in ("ON", "TRUE", "1")
643
+ ui_inputs["flux3_prompt_upsampler_bbox_mode"] = bool(is_bbox_mode)
644
+ ui_inputs["flux3_prompt_upsampler_max_length"] = int(item.get("max_length", 3584))
645
+ if "system_prompt" in item:
646
+ ui_inputs["flux3_prompt_upsampler_system_prompt"] = str(item["system_prompt"])
647
  elif itype == "krea2_identity_edit":
648
  img = _parse_image_param(item.get("image"))
649
  if img:
 
773
  else:
774
  ui_inputs["ming_image_prompt_enhancer_enable"] = False
775
 
776
+ flux3_pe_val = params.get("flux3_prompt_upsampler") or params.get("flux3_prompt_upsampler_enable")
777
+ if flux3_pe_val is not None:
778
+ if isinstance(flux3_pe_val, bool):
779
+ ui_inputs["flux3_prompt_upsampler_enable"] = flux3_pe_val
780
+ elif isinstance(flux3_pe_val, dict):
781
+ ui_inputs["flux3_prompt_upsampler_enable"] = bool(flux3_pe_val.get("enable", flux3_pe_val.get("enabled", True)))
782
+ ui_inputs["flux3_prompt_upsampler_thinking"] = bool(flux3_pe_val.get("thinking", False))
783
+ ui_inputs["flux3_prompt_upsampler_bbox_mode"] = bool(flux3_pe_val.get("bbox_mode", False))
784
+ ui_inputs["flux3_prompt_upsampler_max_length"] = int(flux3_pe_val.get("max_length", 3584))
785
+ if "system_prompt" in flux3_pe_val:
786
+ ui_inputs["flux3_prompt_upsampler_system_prompt"] = str(flux3_pe_val["system_prompt"])
787
+ elif str(flux3_pe_val).upper() in ("ON", "TRUE", "1"):
788
+ ui_inputs["flux3_prompt_upsampler_enable"] = True
789
+ else:
790
+ ui_inputs["flux3_prompt_upsampler_enable"] = False
791
+
792
  _TASKS_DB[task_id]["progress"] = 50
793
 
794
  # Execute Pipeline
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
- comfyui-frontend-package==1.55.14
2
- comfyui-workflow-templates==0.11.78
3
- comfyui-embedded-docs==0.5.13
4
  torch
5
  torchsde
6
  torchvision
@@ -26,7 +26,6 @@ comfy-aimdo==0.5.6
26
  requests
27
  simpleeval>=1.0.0
28
  blake3
29
- cryptography
30
 
31
  #non essential dependencies:
32
  kornia>=0.7.1
 
1
+ comfyui-frontend-package==1.55.17
2
+ comfyui-workflow-templates==0.11.85
3
+ comfyui-embedded-docs==0.5.14
4
  torch
5
  torchsde
6
  torchvision
 
26
  requests
27
  simpleeval>=1.0.0
28
  blake3
 
29
 
30
  #non essential dependencies:
31
  kornia>=0.7.1
ui/events/change_handlers.py CHANGED
@@ -15,7 +15,7 @@ from .config_loaders import (
15
  load_ipadapter_config
16
  )
17
 
18
- def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, ipa_preset, lora_acc, cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None, ming_pe_acc=None):
19
  def update_fn(*args):
20
  arch = args[0]
21
  category = args[1]
@@ -86,6 +86,7 @@ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types,
86
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
87
  if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
88
  if ming_pe_acc: updates[ming_pe_acc] = gr.update(visible=('ming_image_prompt_enhancer' in enabled_chains))
 
89
 
90
  if ar_comp:
91
  res_key = arch_model_type
@@ -130,7 +131,7 @@ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types,
130
  return update_fn
131
 
132
 
133
- def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None, ming_pe_acc=None):
134
  def change_fn(*args):
135
  model_name = args[0]
136
  idx = 1
@@ -209,6 +210,7 @@ def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_type
209
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
210
  if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
211
  if ming_pe_acc: updates[ming_pe_acc] = gr.update(visible=('ming_image_prompt_enhancer' in enabled_chains))
 
212
 
213
  if ar_comp:
214
  res_key = arch_model_type
 
15
  load_ipadapter_config
16
  )
17
 
18
+ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, ipa_preset, lora_acc, cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None, ming_pe_acc=None, flux3_pe_acc=None):
19
  def update_fn(*args):
20
  arch = args[0]
21
  category = args[1]
 
86
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
87
  if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
88
  if ming_pe_acc: updates[ming_pe_acc] = gr.update(visible=('ming_image_prompt_enhancer' in enabled_chains))
89
+ if flux3_pe_acc: updates[flux3_pe_acc] = gr.update(visible=('flux3_prompt_upsampler' in enabled_chains))
90
 
91
  if ar_comp:
92
  res_key = arch_model_type
 
131
  return update_fn
132
 
133
 
134
+ def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None, ming_pe_acc=None, flux3_pe_acc=None):
135
  def change_fn(*args):
136
  model_name = args[0]
137
  idx = 1
 
210
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
211
  if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
212
  if ming_pe_acc: updates[ming_pe_acc] = gr.update(visible=('ming_image_prompt_enhancer' in enabled_chains))
213
+ if flux3_pe_acc: updates[flux3_pe_acc] = gr.update(visible=('flux3_prompt_upsampler' in enabled_chains))
214
 
215
  if ar_comp:
216
  res_key = arch_model_type
ui/events/main.py CHANGED
@@ -64,6 +64,7 @@ def attach_event_handlers(ui_components, demo):
64
  vae_accordion = ui_components.get(f'vae_accordion_{prefix}')
65
  qwen_pe_accordion = ui_components.get(f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}')
66
  ming_pe_accordion = ui_components.get(f'ming_image_prompt_enhancer_accordion_{prefix}')
 
67
 
68
  ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
69
 
@@ -101,6 +102,7 @@ def attach_event_handlers(ui_components, demo):
101
  if vae_accordion: outputs.append(vae_accordion)
102
  if qwen_pe_accordion: outputs.append(qwen_pe_accordion)
103
  if ming_pe_accordion: outputs.append(ming_pe_accordion)
 
104
  if ipa_preset_list: outputs.append(ipa_preset_list)
105
 
106
  outputs.extend(valid_extra_comps)
@@ -111,7 +113,7 @@ def attach_event_handlers(ui_components, demo):
111
  ipa_preset_list, lora_accordion, cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
112
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
113
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
114
- task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion, ming_pe_acc=ming_pe_accordion
115
  )
116
  inputs = [arch_comp, cat_comp]
117
  if aspect_ratio_comp:
@@ -147,6 +149,7 @@ def attach_event_handlers(ui_components, demo):
147
  if vae_accordion: outputs2.append(vae_accordion)
148
  if qwen_pe_accordion: outputs2.append(qwen_pe_accordion)
149
  if ming_pe_accordion: outputs2.append(ming_pe_accordion)
 
150
  if ipa_preset_list: outputs2.append(ipa_preset_list)
151
 
152
  outputs2.extend(valid_extra_comps)
@@ -162,7 +165,7 @@ def attach_event_handlers(ui_components, demo):
162
  arch_comp, ipa_preset_list, lora_accordion, cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
163
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
164
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
165
- task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion, ming_pe_acc=ming_pe_accordion
166
  )
167
  if type_comp:
168
  inputs2.append(type_comp)
@@ -252,6 +255,7 @@ def attach_event_handlers(ui_components, demo):
252
  f'reference_image_accordion_{prefix}': 'reference_image',
253
  f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}': 'qwen_image_2_1_prompt_enhancer',
254
  f'ming_image_prompt_enhancer_accordion_{prefix}': 'ming_image_prompt_enhancer',
 
255
  f'pid_accordion_{prefix}': 'pid',
256
  f'vae_accordion_{prefix}': 'vae',
257
  }
@@ -291,6 +295,7 @@ def attach_event_handlers(ui_components, demo):
291
  'reference_image_accordion_imagegen',
292
  'qwen_image_2_1_prompt_enhancer_accordion_imagegen',
293
  'ming_image_prompt_enhancer_accordion_imagegen',
 
294
  'pid_accordion_imagegen', 'vae_accordion_imagegen',
295
  ]
296
  for key in accordion_keys:
 
64
  vae_accordion = ui_components.get(f'vae_accordion_{prefix}')
65
  qwen_pe_accordion = ui_components.get(f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}')
66
  ming_pe_accordion = ui_components.get(f'ming_image_prompt_enhancer_accordion_{prefix}')
67
+ flux3_pe_accordion = ui_components.get(f'flux3_prompt_upsampler_accordion_{prefix}')
68
 
69
  ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
70
 
 
102
  if vae_accordion: outputs.append(vae_accordion)
103
  if qwen_pe_accordion: outputs.append(qwen_pe_accordion)
104
  if ming_pe_accordion: outputs.append(ming_pe_accordion)
105
+ if flux3_pe_accordion: outputs.append(flux3_pe_accordion)
106
  if ipa_preset_list: outputs.append(ipa_preset_list)
107
 
108
  outputs.extend(valid_extra_comps)
 
113
  ipa_preset_list, lora_accordion, cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
114
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
115
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
116
+ task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion, ming_pe_acc=ming_pe_accordion, flux3_pe_acc=flux3_pe_accordion
117
  )
118
  inputs = [arch_comp, cat_comp]
119
  if aspect_ratio_comp:
 
149
  if vae_accordion: outputs2.append(vae_accordion)
150
  if qwen_pe_accordion: outputs2.append(qwen_pe_accordion)
151
  if ming_pe_accordion: outputs2.append(ming_pe_accordion)
152
+ if flux3_pe_accordion: outputs2.append(flux3_pe_accordion)
153
  if ipa_preset_list: outputs2.append(ipa_preset_list)
154
 
155
  outputs2.extend(valid_extra_comps)
 
165
  arch_comp, ipa_preset_list, lora_accordion, cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
166
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
167
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
168
+ task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion, ming_pe_acc=ming_pe_accordion, flux3_pe_acc=flux3_pe_accordion
169
  )
170
  if type_comp:
171
  inputs2.append(type_comp)
 
255
  f'reference_image_accordion_{prefix}': 'reference_image',
256
  f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}': 'qwen_image_2_1_prompt_enhancer',
257
  f'ming_image_prompt_enhancer_accordion_{prefix}': 'ming_image_prompt_enhancer',
258
+ f'flux3_prompt_upsampler_accordion_{prefix}': 'flux3_prompt_upsampler',
259
  f'pid_accordion_{prefix}': 'pid',
260
  f'vae_accordion_{prefix}': 'vae',
261
  }
 
295
  'reference_image_accordion_imagegen',
296
  'qwen_image_2_1_prompt_enhancer_accordion_imagegen',
297
  'ming_image_prompt_enhancer_accordion_imagegen',
298
+ 'flux3_prompt_upsampler_accordion_imagegen',
299
  'pid_accordion_imagegen', 'vae_accordion_imagegen',
300
  ]
301
  for key in accordion_keys:
ui/events/run_handlers.py CHANGED
@@ -53,6 +53,15 @@ def create_run_event(prefix: str, task_type: str = None, ui_components: dict = N
53
  if ui_components.get(f'ming_image_prompt_enhancer_system_prompt_{prefix}'):
54
  run_inputs_map['ming_image_prompt_enhancer_system_prompt'] = ui_components[f'ming_image_prompt_enhancer_system_prompt_{prefix}']
55
 
 
 
 
 
 
 
 
 
 
56
  # Generic / Txt2Img inputs
57
  if ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'):
58
  run_inputs_map['width'] = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
 
53
  if ui_components.get(f'ming_image_prompt_enhancer_system_prompt_{prefix}'):
54
  run_inputs_map['ming_image_prompt_enhancer_system_prompt'] = ui_components[f'ming_image_prompt_enhancer_system_prompt_{prefix}']
55
 
56
+ if ui_components.get(f'flux3_prompt_upsampler_enable_{prefix}'):
57
+ run_inputs_map['flux3_prompt_upsampler_enable'] = ui_components[f'flux3_prompt_upsampler_enable_{prefix}']
58
+ if ui_components.get(f'flux3_prompt_upsampler_thinking_{prefix}'):
59
+ run_inputs_map['flux3_prompt_upsampler_thinking'] = ui_components[f'flux3_prompt_upsampler_thinking_{prefix}']
60
+ if ui_components.get(f'flux3_prompt_upsampler_bbox_mode_{prefix}'):
61
+ run_inputs_map['flux3_prompt_upsampler_bbox_mode'] = ui_components[f'flux3_prompt_upsampler_bbox_mode_{prefix}']
62
+ if ui_components.get(f'flux3_prompt_upsampler_max_length_{prefix}'):
63
+ run_inputs_map['flux3_prompt_upsampler_max_length'] = ui_components[f'flux3_prompt_upsampler_max_length_{prefix}']
64
+
65
  # Generic / Txt2Img inputs
66
  if ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'):
67
  run_inputs_map['width'] = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
ui/imagegen_ui.py CHANGED
@@ -9,7 +9,8 @@ from .shared.ui_components import (
9
  create_model_architecture_filter_ui, create_category_filter_ui,
10
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
11
  create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui,
12
- create_pid_ui, create_qwen_image_2_1_prompt_enhancer_ui, create_ming_image_prompt_enhancer_ui
 
13
  )
14
 
15
  default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
@@ -189,6 +190,7 @@ def create_ui():
189
  components.update(create_reference_image_ui(prefix))
190
  components.update(create_qwen_image_2_1_prompt_enhancer_ui(prefix))
191
  components.update(create_ming_image_prompt_enhancer_ui(prefix))
 
192
  components.update(create_vae_override_ui(prefix))
193
  components.update(create_pid_ui(prefix))
194
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
 
9
  create_model_architecture_filter_ui, create_category_filter_ui,
10
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
11
  create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui,
12
+ create_pid_ui, create_qwen_image_2_1_prompt_enhancer_ui, create_ming_image_prompt_enhancer_ui,
13
+ create_flux3_prompt_upsampler_ui
14
  )
15
 
16
  default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
 
190
  components.update(create_reference_image_ui(prefix))
191
  components.update(create_qwen_image_2_1_prompt_enhancer_ui(prefix))
192
  components.update(create_ming_image_prompt_enhancer_ui(prefix))
193
+ components.update(create_flux3_prompt_upsampler_ui(prefix))
194
  components.update(create_vae_override_ui(prefix))
195
  components.update(create_pid_ui(prefix))
196
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
ui/shared/ui_components.py CHANGED
@@ -835,4 +835,46 @@ def create_ming_image_prompt_enhancer_ui(prefix: str):
835
  interactive=True
836
  )
837
 
838
- return components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
835
  interactive=True
836
  )
837
 
838
+ return components
839
+
840
+
841
+ def create_flux3_prompt_upsampler_ui(prefix: str):
842
+ components = {}
843
+ key = lambda name: f"{name}_{prefix}"
844
+
845
+ with gr.Accordion("FLUX.3 Prompt Upsampler Settings", open=False, visible=('flux3_prompt_upsampler' in default_enabled_chains)) as enhancer_accordion:
846
+ components[key('flux3_prompt_upsampler_accordion')] = enhancer_accordion
847
+ gr.Markdown(
848
+ "💡 **Tip:** System prompt automatically matches the official [black-forest-labs/flux-3-image-klein-pup](https://huggingface.co/black-forest-labs/flux-3-image-klein-pup/blob/main/system_prompts.json) templates: uses `t2i` when no image is provided, and automatically switches to `i2i` when image input is detected; enabling **BBox Mode** switches respectively to `t2i_bbox` and `i2i_bbox` to output target bounding box annotations."
849
+ )
850
+ with gr.Row():
851
+ components[key('flux3_prompt_upsampler_enable')] = gr.Checkbox(
852
+ label="Enable FLUX.3 Prompt Upsampler",
853
+ value=False,
854
+ interactive=True,
855
+ scale=2
856
+ )
857
+ components[key('flux3_prompt_upsampler_thinking')] = gr.Checkbox(
858
+ label="Enable Thinking (Requires longer ZeroGPU Duration)",
859
+ value=False,
860
+ interactive=True,
861
+ scale=2
862
+ )
863
+ components[key('flux3_prompt_upsampler_bbox_mode')] = gr.Checkbox(
864
+ label="BBox Mode",
865
+ value=False,
866
+ interactive=True,
867
+ scale=1
868
+ )
869
+ components[key('flux3_prompt_upsampler_max_length')] = gr.Number(
870
+ label="Max Length",
871
+ value=3584,
872
+ precision=0,
873
+ minimum=16,
874
+ step=16,
875
+ interactive=True,
876
+ scale=1
877
+ )
878
+
879
+ return components
880
+
yaml/chain_features.yaml CHANGED
@@ -479,3 +479,32 @@ ming_image_prompt_enhancer:
479
  system_prompt:
480
  type: string
481
  description: "System prompt for Qwen3.8-27B prompt enhancer (defaults to official Ming-Image Figma-style rewriter prompt)."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  system_prompt:
480
  type: string
481
  description: "System prompt for Qwen3.8-27B prompt enhancer (defaults to official Ming-Image Figma-style rewriter prompt)."
482
+
483
+ flux3_prompt_upsampler:
484
+ chains: flux3_prompt_upsampler
485
+ display_name: "FLUX.3 Prompt Upsampler Settings"
486
+ description: "Expand short prompts into detailed generative captions using FLUX.3 Prompt Upsampler (qwen3.5_9b_flux3_prompt_upsampler_w4a8) with automatic official template selection (t2i, i2i, t2i_bbox, i2i_bbox), multi-reference image stitching, and reasoning CoT thinking mode."
487
+ max_count: 1
488
+ usage_guideline: "Set enable to true to activate FLUX.3 prompt upsampler. Automatically selects official BFL t2i or i2i template based on input image detection. Supports bbox_mode, thinking mode, and multi-reference image stitching."
489
+ parameters_schema:
490
+ type: object
491
+ properties:
492
+ enable:
493
+ type: boolean
494
+ default: false
495
+ description: "Enable FLUX.3 Prompt Upsampler."
496
+ thinking:
497
+ type: boolean
498
+ default: false
499
+ description: "Enable thinking (reasoning CoT)."
500
+ bbox_mode:
501
+ type: boolean
502
+ default: false
503
+ description: "Enable BBox mode (automatically selects t2i_bbox or i2i_bbox official system prompt templates to output bounding boxes)."
504
+ max_length:
505
+ type: integer
506
+ default: 3584
507
+ description: "Maximum generation length for prompt upsampler (default 3584)."
508
+ system_prompt:
509
+ type: string
510
+ description: "Optional custom system prompt override (defaults to official t2i/i2i or t2i_bbox/i2i_bbox templates)."
yaml/file_list.yaml CHANGED
@@ -981,6 +981,11 @@ file:
981
  source: "hf"
982
  repo_id: "Comfy-Org/Qwen3.8-27B"
983
  repository_file_path: "text_encoders/qwen3.8_27b_w4a8.safetensors"
 
 
 
 
 
984
  # PixelDiT
985
  - filename: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
986
  source: "hf"
 
981
  source: "hf"
982
  repo_id: "Comfy-Org/Qwen3.8-27B"
983
  repository_file_path: "text_encoders/qwen3.8_27b_w4a8.safetensors"
984
+ # FLUX.3 Prompt Upsampler
985
+ - filename: "qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors"
986
+ source: "hf"
987
+ repo_id: "black-forest-labs/flux-3-image-klein-comfy"
988
+ repository_file_path: "text_encoders/qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors"
989
  # PixelDiT
990
  - filename: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
991
  source: "hf"
yaml/model_architecture_features.yaml CHANGED
@@ -3,6 +3,7 @@ flux3:
3
  enabled_chains:
4
  - lora
5
  - reference_latent
 
6
  - pid
7
 
8
  krea-2:
 
3
  enabled_chains:
4
  - lora
5
  - reference_latent
6
+ - flux3_prompt_upsampler
7
  - pid
8
 
9
  krea-2:
yaml/task_features.yaml CHANGED
@@ -24,6 +24,7 @@ txt2img:
24
  - reference_image
25
  - qwen_image_2_1_prompt_enhancer
26
  - ming_image_prompt_enhancer
 
27
  - pid
28
  - vae
29
 
@@ -48,6 +49,7 @@ img2img:
48
  - reference_image
49
  - qwen_image_2_1_prompt_enhancer
50
  - ming_image_prompt_enhancer
 
51
  - vae
52
 
53
  inpaint:
@@ -71,6 +73,7 @@ inpaint:
71
  - reference_image
72
  - qwen_image_2_1_prompt_enhancer
73
  - ming_image_prompt_enhancer
 
74
  - vae
75
 
76
  outpaint:
@@ -94,6 +97,7 @@ outpaint:
94
  - reference_image
95
  - qwen_image_2_1_prompt_enhancer
96
  - ming_image_prompt_enhancer
 
97
  - vae
98
 
99
  hires_fix:
@@ -117,4 +121,5 @@ hires_fix:
117
  - reference_image
118
  - qwen_image_2_1_prompt_enhancer
119
  - ming_image_prompt_enhancer
 
120
  - vae
 
24
  - reference_image
25
  - qwen_image_2_1_prompt_enhancer
26
  - ming_image_prompt_enhancer
27
+ - flux3_prompt_upsampler
28
  - pid
29
  - vae
30
 
 
49
  - reference_image
50
  - qwen_image_2_1_prompt_enhancer
51
  - ming_image_prompt_enhancer
52
+ - flux3_prompt_upsampler
53
  - vae
54
 
55
  inpaint:
 
73
  - reference_image
74
  - qwen_image_2_1_prompt_enhancer
75
  - ming_image_prompt_enhancer
76
+ - flux3_prompt_upsampler
77
  - vae
78
 
79
  outpaint:
 
97
  - reference_image
98
  - qwen_image_2_1_prompt_enhancer
99
  - ming_image_prompt_enhancer
100
+ - flux3_prompt_upsampler
101
  - vae
102
 
103
  hires_fix:
 
121
  - reference_image
122
  - qwen_image_2_1_prompt_enhancer
123
  - ming_image_prompt_enhancer
124
+ - flux3_prompt_upsampler
125
  - vae