Views
No views yet
The Flux.1-Krea-Merged-Dev repository contains merged parameters combining two advanced image generation models: black-forest-labs/FLUX.1-dev and black-forest-labs/FLUX.1-Krea-dev. This merged model integrates the capabilities of the rectified flow transformer FLUX.1-dev, known for competitive prompt following and high-quality outputs, with FLUX.1-Krea-dev, a guidance distilled model emphasizing aesthetics and photorealism. The result is a unified model that balances quality, aesthetic control, and efficiency for text-to-image generation tasks. The repository includes instructions for loading, merging, and using the fused parameters via the Diffusers library, enabling users to generate images from text prompts through the FluxPipeline with enhanced performance and visual quality. This merge facilitates leveraging strengths from both base models in a single, accessible implementation for research and creative workflows.
| FLUX.1-dev (28 steps) | FLUX.1-Krea-dev (28 steps) | Flux.1-Krea-Merged-Dev (28 steps) |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
prompt : a tiny astronaut hatching from an egg on the moon
| FLUX.1-dev (28 steps) | FLUX.1-Krea-dev (28 steps) | Flux.1-Krea-Merged-Dev (28 steps) |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
prompt : cute anime illustration of a colorful sushi platter featuring nigiri, maki rolls, sashimi, and wasabi on a wooden tray with decorative two chopsticks.
1%%capture
2!pip install git+https://github.com/huggingface/transformers.git
3!pip install git+https://github.com/huggingface/diffusers.git
4!pip install git+https://github.com/huggingface/peft.git
5!pip install git+https://github.com/huggingface/accelerate.git
6!pip install safetensors huggingface_hub hf_xetfrom huggingface_hub import notebook_login, HfApi
notebook_login()1from diffusers import FluxTransformer2DModel
2from huggingface_hub import snapshot_download
3from accelerate import init_empty_weights
4from diffusers.models.model_loading_utils import load_model_dict_into_meta
5import safetensors.torch
6import glob
7import torch
8
9# Initialize model with empty weights
10with init_empty_weights():
11 config = FluxTransformer2DModel.load_config("black-forest-labs/FLUX.1-dev", subfolder="transformer")
12 model = FluxTransformer2DModel.from_config(config)
13
14# Download checkpoints
15dev_ckpt = snapshot_download(repo_id="black-forest-labs/FLUX.1-dev", allow_patterns="transformer/*")
16krea_ckpt = snapshot_download(repo_id="black-forest-labs/FLUX.1-Krea-dev", allow_patterns="transformer/*")
17
18# Get sorted shard paths
19dev_shards = sorted(glob.glob(f"{dev_ckpt}/transformer/*.safetensors"))
20krea_shards = sorted(glob.glob(f"{krea_ckpt}/transformer/*.safetensors"))
21
22# Initialize dictionaries for merged and guidance weights
23merged_state_dict = {}
24guidance_state_dict = {}
25
26# Merge shards
27for dev_shard, krea_shard in zip(dev_shards, krea_shards):
28 state_dict_dev = safetensors.torch.load_file(dev_shard)
29 state_dict_krea = safetensors.torch.load_file(krea_shard)
30
31 # Process keys from dev model
32 for k in list(state_dict_dev.keys()):
33 if "guidance" in k:
34 # Keep guidance weights from dev model
35 guidance_state_dict[k] = state_dict_dev.pop(k)
36 else:
37 # Average non-guidance weights if key exists in krea
38 if k in state_dict_krea:
39 merged_state_dict[k] = (state_dict_dev.pop(k) + state_dict_krea.pop(k)) / 2
40 else:
41 raise ValueError(f"Key {k} missing in krea shard.")
42
43 # Check for residual keys in krea (e.g., extra guidance keys)
44 for k in list(state_dict_krea.keys()):
45 if "guidance" in k:
46 # Skip extra guidance keys in krea
47 state_dict_krea.pop(k)
48 else:
49 raise ValueError(f"Unexpected non-guidance key in krea shard: {k}")
50
51 # Verify no unexpected residue
52 if len(state_dict_dev) > 0:
53 raise ValueError(f"Residue in dev shard: {list(state_dict_dev.keys())}")
54 if len(state_dict_krea) > 0:
55 raise ValueError(f"Residue in krea shard: {list(state_dict_krea.keys())}")
56
57# Combine merged and guidance state dictionaries
58merged_state_dict.update(guidance_state_dict)
59
60# Load merged state dictionary into model
61load_model_dict_into_meta(model, merged_state_dict)
62
63# Convert to bfloat16 and save
64model.to(torch.bfloat16).save_pretrained("merged/transformer")1api = HfApi()
2repo_id = "prithivMLmods/Flux.1-Krea-Merged-Dev"
3
4api.upload_folder(
5 folder_path="merged/",
6 path_in_repo=".",
7 repo_id=repo_id,
8 repo_type="model",
9 revision="main"
10)1from diffusers import FluxPipeline
2import torch
3
4pipeline = FluxPipeline.from_pretrained(
5 "prithivMLmods/Flux.1-Krea-Merged-Dev", torch_dtype=torch.bfloat16
6).to("cuda")
7image = pipeline(
8 prompt="a tiny astronaut hatching from an egg on the moon",
9 guidance_scale=3.5,
10 num_inference_steps=28,
11 height=1024,
12 width=1024,
13 max_sequence_length=512,
14 generator=torch.manual_seed(0),
15).images[0]
16image.save("img0.png")COMPARATOR : FLUX.1-Dev(Realism) and FLUX.1-Krea-Merged-Dev (Flux.1-Dev + Flux.1-Krea-Dev)
1%%capture
2!pip install git+https://github.com/huggingface/transformers.git
3!pip install git+https://github.com/huggingface/diffusers.git
4!pip install git+https://github.com/huggingface/peft.git
5!pip install git+https://github.com/huggingface/accelerate.git
6!pip install safetensors huggingface_hub hf_xetfrom huggingface_hub import notebook_login, HfApi
notebook_login()1import spaces
2import gradio as gr
3import torch
4from PIL import Image
5from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL
6import random
7import uuid
8from typing import Tuple, Union, List, Optional, Any, Dict
9import numpy as np
10import time
11import zipfile
12from transformers import CLIPTextModel, CLIPTokenizer, T5EncoderModel, T5TokenizerFast
13
14# Description for the app
15DESCRIPTION = """## flux comparator hpc/."""
16
17# Helper functions
18def save_image(img):
19 unique_name = str(uuid.uuid4()) + ".png"
20 img.save(unique_name)
21 return unique_name
22
23def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
24 if randomize_seed:
25 seed = random.randint(0, MAX_SEED)
26 return seed
27
28MAX_SEED = np.iinfo(np.int32).max
29MAX_IMAGE_SIZE = 2048
30
31# Load pipelines for both models
32# Flux.1-dev-realism
33base_model_dev = "black-forest-labs/FLUX.1-dev"
34pipe_dev = DiffusionPipeline.from_pretrained(base_model_dev, torch_dtype=torch.bfloat16)
35lora_repo = "strangerzonehf/Flux-Super-Realism-LoRA"
36trigger_word = "Super Realism"
37pipe_dev.load_lora_weights(lora_repo)
38pipe_dev.to("cuda")
39
40# Flux.1-krea
41dtype = torch.bfloat16
42device = "cuda" if torch.cuda.is_available() else "cpu"
43taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
44good_vae = AutoencoderKL.from_pretrained("prithivMLmods/Flux.1-Krea-Merged-Dev", subfolder="vae", torch_dtype=dtype).to(device)
45pipe_krea = DiffusionPipeline.from_pretrained("prithivMLmods/Flux.1-Krea-Merged-Dev", torch_dtype=dtype, vae=taef1).to(device)
46
47# Define the flux_pipe_call_that_returns_an_iterable_of_images for flux.1-krea
48@torch.inference_mode()
49def flux_pipe_call_that_returns_an_iterable_of_images(
50 self,
51 prompt: Union[str, List[str]] = None,
52 prompt_2: Optional[Union[str, List[str]]] = None,
53 height: Optional[int] = None,
54 width: Optional[int] = None,
55 num_inference_steps: int = 28,
56 timesteps: List[int] = None,
57 guidance_scale: float = 3.5,
58 num_images_per_prompt: Optional[int] = 1,
59 generator: Optional[Union[torch.Generator, List[torch.Generator]]] = None,
60 latents: Optional[torch.FloatTensor] = None,
61 prompt_embeds: Optional[torch.FloatTensor] = None,
62 pooled_prompt_embeds: Optional[torch.FloatTensor] = None,
63 output_type: Optional[str] = "pil",
64 return_dict: bool = True,
65 joint_attention_kwargs: Optional[Dict[str, Any]] = None,
66 max_sequence_length: int = 512,
67 good_vae: Optional[Any] = None,
68):
69 height = height or self.default_sample_size * self.vae_scale_factor
70 width = width or self.default_sample_size * self.vae_scale_factor
71
72 self.check_inputs(
73 prompt,
74 prompt_2,
75 height,
76 width,
77 prompt_embeds=prompt_embeds,
78 pooled_prompt_embeds=pooled_prompt_embeds,
79 max_sequence_length=max_sequence_length,
80 )
81
82 self._guidance_scale = guidance_scale
83 self._joint_attention_kwargs = joint_attention_kwargs
84 self._interrupt = False
85
86 batch_size = 1 if isinstance(prompt, str) else len(prompt)
87 device = self._execution_device
88
89 lora_scale = joint_attention_kwargs.get("scale", None) if joint_attention_kwargs is not None else None
90 prompt_embeds, pooled_prompt_embeds, text_ids = self.encode_prompt(
91 prompt=prompt,
92 prompt_2=prompt_2,
93 prompt_embeds=prompt_embeds,
94 pooled_prompt_embeds=pooled_prompt_embeds,
95 device=device,
96 num_images_per_prompt=num_images_per_prompt,
97 max_sequence_length=max_sequence_length,
98 lora_scale=lora_scale,
99 )
100
101 num_channels_latents = self.transformer.config.in_channels // 4
102 latents, latent_image_ids = self.prepare_latents(
103 batch_size * num_images_per_prompt,
104 num_channels_latents,
105 height,
106 width,
107 prompt_embeds.dtype,
108 device,
109 generator,
110 latents,
111 )
112
113 sigmas = np.linspace(1.0, 1 / num_inference_steps, num_inference_steps)
114 image_seq_len = latents.shape[1]
115 mu = calculate_shift(
116 image_seq_len,
117 self.scheduler.config.base_image_seq_len,
118 self.scheduler.config.max_image_seq_len,
119 self.scheduler.config.base_shift,
120 self.scheduler.config.max_shift,
121 )
122 timesteps, num_inference_steps = retrieve_timesteps(
123 self.scheduler,
124 num_inference_steps,
125 device,
126 timesteps,
127 sigmas,
128 mu=mu,
129 )
130 self._num_timesteps = len(timesteps)
131
132 guidance = torch.full([1], guidance_scale, device=device, dtype=torch.float32).expand(latents.shape[0]) if self.transformer.config.guidance_embeds else None
133
134 for i, t in enumerate(timesteps):
135 if self.interrupt:
136 continue
137
138 timestep = t.expand(latents.shape[0]).to(latents.dtype)
139
140 noise_pred = self.transformer(
141 hidden_states=latents,
142 timestep=timestep / 1000,
143 guidance=guidance,
144 pooled_projections=pooled_prompt_embeds,
145 encoder_hidden_states=prompt_embeds,
146 txt_ids=text_ids,
147 img_ids=latent_image_ids,
148 joint_attention_kwargs=self.joint_attention_kwargs,
149 return_dict=False,
150 )[0]
151
152 latents_for_image = self._unpack_latents(latents, height, width, self.vae_scale_factor)
153 latents_for_image = (latents_for_image / self.vae.config.scaling_factor) + self.vae.config.shift_factor
154 image = self.vae.decode(latents_for_image, return_dict=False)[0]
155 yield self.image_processor.postprocess(image, output_type=output_type)[0]
156
157 latents = self.scheduler.step(noise_pred, t, latents, return_dict=False)[0]
158 torch.cuda.empty_cache()
159
160 latents = self._unpack_latents(latents, height, width, self.vae_scale_factor)
161 latents = (latents / good_vae.config.scaling_factor) + good_vae.config.shift_factor
162 image = good_vae.decode(latents, return_dict=False)[0]
163 self.maybe_free_model_hooks()
164 torch.cuda.empty_cache()
165 yield self.image_processor.postprocess(image, output_type=output_type)[0]
166
167pipe_krea.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe_krea)
168
169# Helper functions for flux.1-krea
170def calculate_shift(
171 image_seq_len,
172 base_seq_len: int = 256,
173 max_seq_len: int = 4096,
174 base_shift: float = 0.5,
175 max_shift: float = 1.16,
176):
177 m = (max_shift - base_shift) / (max_seq_len - base_seq_len)
178 b = base_shift - m * base_seq_len
179 mu = image_seq_len * m + b
180 return mu
181
182def retrieve_timesteps(
183 scheduler,
184 num_inference_steps: Optional[int] = None,
185 device: Optional[Union[str, torch.device]] = None,
186 timesteps: Optional[List[int]] = None,
187 sigmas: Optional[List[float]] = None,
188 **kwargs,
189):
190 if timesteps is not None and sigmas is not None:
191 raise ValueError("Only one of `timesteps` or `sigmas` can be passed.")
192 if timesteps is not None:
193 scheduler.set_timesteps(timesteps=timesteps, device=device, **kwargs)
194 timesteps = scheduler.timesteps
195 num_inference_steps = len(timesteps)
196 elif sigmas is not None:
197 scheduler.set_timesteps(sigmas=sigmas, device=device, **kwargs)
198 timesteps = scheduler.timesteps
199 num_inference_steps = len(timesteps)
200 else:
201 scheduler.set_timesteps(num_inference_steps, device=device, **kwargs)
202 timesteps = scheduler.timesteps
203 return timesteps, num_inference_steps
204
205# Styles for flux.1-dev-realism
206style_list = [
207 {"name": "3840 x 2160", "prompt": "hyper-realistic 8K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic", "negative_prompt": ""},
208 {"name": "2560 x 1440", "prompt": "hyper-realistic 4K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic", "negative_prompt": ""},
209 {"name": "HD+", "prompt": "hyper-realistic 2K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic", "negative_prompt": ""},
210 {"name": "Style Zero", "prompt": "{prompt}", "negative_prompt": ""},
211]
212
213styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
214DEFAULT_STYLE_NAME = "3840 x 2160"
215STYLE_NAMES = list(styles.keys())
216
217def apply_style(style_name: str, positive: str) -> Tuple[str, str]:
218 p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
219 return p.replace("{prompt}", positive), n
220
221# Generation function for flux.1-dev-realism
222@spaces.GPU
223def generate_dev(
224 prompt: str,
225 negative_prompt: str = "",
226 use_negative_prompt: bool = False,
227 seed: int = 0,
228 width: int = 1024,
229 height: int = 1024,
230 guidance_scale: float = 3,
231 randomize_seed: bool = False,
232 style_name: str = DEFAULT_STYLE_NAME,
233 num_inference_steps: int = 30,
234 num_images: int = 1,
235 zip_images: bool = False,
236 progress=gr.Progress(track_tqdm=True),
237):
238 positive_prompt, style_negative_prompt = apply_style(style_name, prompt)
239
240 if use_negative_prompt:
241 final_negative_prompt = style_negative_prompt + " " + negative_prompt
242 else:
243 final_negative_prompt = style_negative_prompt
244
245 final_negative_prompt = final_negative_prompt.strip()
246
247 if trigger_word:
248 positive_prompt = f"{trigger_word} {positive_prompt}"
249
250 seed = int(randomize_seed_fn(seed, randomize_seed))
251 generator = torch.Generator(device="cuda").manual_seed(seed)
252
253 start_time = time.time()
254
255 images = pipe_dev(
256 prompt=positive_prompt,
257 negative_prompt=final_negative_prompt if final_negative_prompt else None,
258 width=width,
259 height=height,
260 guidance_scale=guidance_scale,
261 num_inference_steps=num_inference_steps,
262 num_images_per_prompt=num_images,
263 generator=generator,
264 output_type="pil",
265 ).images
266
267 end_time = time.time()
268 duration = end_time - start_time
269
270 image_paths = [save_image(img) for img in images]
271
272 zip_path = None
273 if zip_images:
274 zip_name = str(uuid.uuid4()) + ".zip"
275 with zipfile.ZipFile(zip_name, 'w') as zipf:
276 for i, img_path in enumerate(image_paths):
277 zipf.write(img_path, arcname=f"Img_{i}.png")
278 zip_path = zip_name
279
280 return image_paths, seed, f"{duration:.2f}", zip_path
281
282# Generation function for flux.1-krea
283@spaces.GPU
284def generate_krea(
285 prompt: str,
286 seed: int = 0,
287 width: int = 1024,
288 height: int = 1024,
289 guidance_scale: float = 4.5,
290 randomize_seed: bool = False,
291 num_inference_steps: int = 28,
292 num_images: int = 1,
293 zip_images: bool = False,
294 progress=gr.Progress(track_tqdm=True),
295):
296 if randomize_seed:
297 seed = random.randint(0, MAX_SEED)
298 generator = torch.Generator().manual_seed(seed)
299
300 start_time = time.time()
301
302 images = []
303 for _ in range(num_images):
304 final_img = list(pipe_krea.flux_pipe_call_that_returns_an_iterable_of_images(
305 prompt=prompt,
306 guidance_scale=guidance_scale,
307 num_inference_steps=num_inference_steps,
308 width=width,
309 height=height,
310 generator=generator,
311 output_type="pil",
312 good_vae=good_vae,
313 ))[-1] # Take the final image only
314 images.append(final_img)
315
316 end_time = time.time()
317 duration = end_time - start_time
318
319 image_paths = [save_image(img) for img in images]
320
321 zip_path = None
322 if zip_images:
323 zip_name = str(uuid.uuid4()) + ".zip"
324 with zipfile.ZipFile(zip_name, 'w') as zipf:
325 for i, img_path in enumerate(image_paths):
326 zipf.write(img_path, arcname=f"Img_{i}.png")
327 zip_path = zip_name
328
329 return image_paths, seed, f"{duration:.2f}", zip_path
330
331# Main generation function to handle model choice
332@spaces.GPU
333def generate(
334 model_choice: str,
335 prompt: str,
336 negative_prompt: str = "",
337 use_negative_prompt: bool = False,
338 seed: int = 0,
339 width: int = 1024,
340 height: int = 1024,
341 guidance_scale: float = 3,
342 randomize_seed: bool = False,
343 style_name: str = DEFAULT_STYLE_NAME,
344 num_inference_steps: int = 30,
345 num_images: int = 1,
346 zip_images: bool = False,
347 progress=gr.Progress(track_tqdm=True),
348):
349 if model_choice == "flux.1-dev-realism":
350 return generate_dev(
351 prompt=prompt,
352 negative_prompt=negative_prompt,
353 use_negative_prompt=use_negative_prompt,
354 seed=seed,
355 width=width,
356 height=height,
357 guidance_scale=guidance_scale,
358 randomize_seed=randomize_seed,
359 style_name=style_name,
360 num_inference_steps=num_inference_steps,
361 num_images=num_images,
362 zip_images=zip_images,
363 progress=progress,
364 )
365 elif model_choice == "flux.1-krea-merged-dev":
366 return generate_krea(
367 prompt=prompt,
368 seed=seed,
369 width=width,
370 height=height,
371 guidance_scale=guidance_scale,
372 randomize_seed=randomize_seed,
373 num_inference_steps=num_inference_steps,
374 num_images=num_images,
375 zip_images=zip_images,
376 progress=progress,
377 )
378 else:
379 raise ValueError("Invalid model choice")
380
381# Examples (tailored for flux.1-dev-realism)
382examples = [
383 "An attractive young woman with blue eyes lying face down on the bed, in the style of animated gifs, light white and light amber, jagged edges, the snapshot aesthetic, timeless beauty, goosepunk, sunrays shine upon it --no freckles --chaos 65 --ar 1:2 --profile yruxpc2 --stylize 750 --v 6.1",
384 "Headshot of handsome young man, wearing dark gray sweater with buttons and big shawl collar, brown hair and short beard, serious look on his face, black background, soft studio lighting, portrait photography --ar 85:128 --v 6.0 --style",
385 "Purple Dreamy, a medium-angle shot of a young woman with long brown hair, wearing a pair of eye-level glasses, stands in front of a backdrop of purple and white lights.",
386 "High-resolution photograph, woman, UHD, photorealistic, shot on a Sony A7III --chaos 20 --ar 1:2 --style raw --stylize 250"
387]
388
389css = '''
390.gradio-container {
391 max-width: 590px !important;
392 margin: 0 auto !important;
393}
394h1 {
395 text-align: center;
396}
397footer {
398 visibility: hidden;
399}
400'''
401
402# Gradio interface
403with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
404 gr.Markdown(DESCRIPTION)
405 with gr.Row():
406 prompt = gr.Text(
407 label="Prompt",
408 show_label=False,
409 max_lines=1,
410 placeholder="Enter your prompt",
411 container=False,
412 )
413 run_button = gr.Button("Run", scale=0, variant="primary")
414 result = gr.Gallery(label="Result", columns=1, show_label=False, preview=True)
415
416 with gr.Row():
417 # Model choice radio button above additional options
418 model_choice = gr.Radio(
419 choices=["flux.1-krea-merged-dev", "flux.1-dev-realism"],
420 label="Select Model",
421 value="flux.1-krea-merged-dev"
422 )
423
424 with gr.Accordion("Additional Options", open=False):
425 style_selection = gr.Dropdown(
426 label="Quality Style (for flux.1-dev-realism only)",
427 choices=STYLE_NAMES,
428 value=DEFAULT_STYLE_NAME,
429 interactive=True,
430 )
431 use_negative_prompt = gr.Checkbox(label="Use negative prompt (for flux.1-dev-realism only)", value=False)
432 negative_prompt = gr.Text(
433 label="Negative prompt",
434 max_lines=1,
435 placeholder="Enter a negative prompt",
436 visible=False,
437 )
438 seed = gr.Slider(
439 label="Seed",
440 minimum=0,
441 maximum=MAX_SEED,
442 step=1,
443 value=0,
444 )
445 randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
446 with gr.Row():
447 width = gr.Slider(
448 label="Width",
449 minimum=512,
450 maximum=2048,
451 step=64,
452 value=1024,
453 )
454 height = gr.Slider(
455 label="Height",
456 minimum=512,
457 maximum=2048,
458 step=64,
459 value=1024,
460 )
461 guidance_scale = gr.Slider(
462 label="Guidance Scale",
463 minimum=0.1,
464 maximum=20.0,
465 step=0.1,
466 value=3.5,
467 )
468 num_inference_steps = gr.Slider(
469 label="Number of inference steps",
470 minimum=1,
471 maximum=40,
472 step=1,
473 value=28,
474 )
475 num_images = gr.Slider(
476 label="Number of images",
477 minimum=1,
478 maximum=5,
479 step=1,
480 value=1,
481 )
482 zip_images = gr.Checkbox(label="Zip generated images", value=False)
483
484 gr.Markdown("### Output Information")
485 seed_display = gr.Textbox(label="Seed used", interactive=False)
486 generation_time = gr.Textbox(label="Generation time (seconds)", interactive=False)
487 zip_file = gr.File(label="Download ZIP")
488
489 gr.Examples(
490 examples=examples,
491 inputs=prompt,
492 outputs=[result, seed_display, generation_time, zip_file],
493 fn=generate,
494 cache_examples=False,
495 )
496
497 use_negative_prompt.change(
498 fn=lambda x: gr.update(visible=x),
499 inputs=use_negative_prompt,
500 outputs=negative_prompt,
501 api_name=False,
502 )
503
504 gr.on(
505 triggers=[
506 prompt.submit,
507 run_button.click,
508 ],
509 fn=generate,
510 inputs=[
511 model_choice,
512 prompt,
513 negative_prompt,
514 use_negative_prompt,
515 seed,
516 width,
517 height,
518 guidance_scale,
519 randomize_seed,
520 style_selection,
521 num_inference_steps,
522 num_images,
523 zip_images,
524 ],
525 outputs=[result, seed_display, generation_time, zip_file],
526 api_name="run",
527 )
528
529if __name__ == "__main__":
530 demo.queue(max_size=30).launch(mcp_server=True, ssr_mode=False, show_error=True)@hardware-accelerator : H200Flux is a suite of state-of-the-art text-to-image generation models based on diffusion transformers, developed by Black Forest Labs. The models are designed for high-quality generative image tasks, including text-to-image, inpainting, outpainting, and advanced structure or depth-controlled workflows. Flux is available through the Hugging Face diffusers library.