add flux.1-kontext-dev

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-06-26 17:09:53 -04:00
parent d6a8d2b173
commit 1147f9ec56
7 changed files with 40 additions and 31 deletions
+9 -2
View File
@@ -3,11 +3,18 @@
## Update for 2025-06-26
- **Models**
- [Models Wiki page](https://vladmandic.github.io/sdnext-docs/Models/) is updated will all new models
- [nVidia Cosmos-Predict2 T2I](https://research.nvidia.com/labs/dir/cosmos-predict2/) *2B and 14B*
- new foundational model from Nvidia in two variants: small 2B and large 14B
- Cosmos-Predict2 T2I is a new foundational model from Nvidia in two variants: small 2B and large 14B
- available via *networks -> models -> reference*
- *note*: 14B variant is a very large model at 36GB
- *note*: this is a gated model, you need to [accept terms](https://huggingface.co/nvidia/Cosmos-Predict2-2B-Text2Image) and set your [huggingface token](https://vladmandic.github.io/sdnext-docs/Gated/)
- [Chroma](https://huggingface.co/lodestones/Chroma)
- [Black Forest Labs FLUX.1 Kontext I2I](https://bfl.ai/announcements/flux-1-kontext-dev) *Dev* variant
- FLUX.1-Kontext is a 12B model billion parameter capable of editing images based on text instructions
- requirements are similar to regular FLUX.1 although 2x slower
- available via *networks -> models -> reference*
- *note*: this is a gated model, you need to [accept terms](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev) and set your [huggingface token](https://vladmandic.github.io/sdnext-docs/Gated/)
- [lodestones Chroma](https://huggingface.co/lodestones/Chroma)
- Chroma is a 8.9B parameter model based on *FLUX.1-schnell* and fully Apache 2.0 licensed
- available via *networks -> models -> reference*
- *note*: model is still in training so future updates will trigger re-download
+4 -18
View File
@@ -158,24 +158,10 @@
"skip": true,
"extras": "sampler: Default, cfg_scale: 3.5"
},
"Black Forest Labs FLUX.1 Dev qint8": {
"path": "Disty0/FLUX.1-dev-qint8",
"preview": "black-forest-labs--FLUX.1-dev.jpg",
"desc": "FLUX.1 models are based on a hybrid architecture of multimodal and parallel diffusion transformer blocks, scaled to 12B parameters and builing on flow matching",
"skip": true,
"extras": "sampler: Default, cfg_scale: 3.5"
},
"Black Forest Labs FLUX.1 Dev qint4": {
"path": "Disty0/FLUX.1-dev-qint4",
"preview": "black-forest-labs--FLUX.1-dev.jpg",
"desc": "FLUX.1 models are based on a hybrid architecture of multimodal and parallel diffusion transformer blocks, scaled to 12B parameters and builing on flow matching",
"skip": true,
"extras": "sampler: Default, cfg_scale: 3.5"
},
"Black Forest Labs FLUX.1 Dev nf4": {
"path": "sayakpaul/flux.1-dev-nf4",
"preview": "black-forest-labs--FLUX.1-dev.jpg",
"desc": "FLUX.1 models are based on a hybrid architecture of multimodal and parallel diffusion transformer blocks, scaled to 12B parameters and builing on flow matching",
"Black Forest Labs FLUX.1 Kontext Dev": {
"path": "black-forest-labs/FLUX.1-Kontext-dev",
"preview": "black-forest-labs--FLUX.1-Kontext-dev.jpg",
"desc": "FLUX.1 Kontext [dev] is a 12 billion parameter rectified flow transformer capable of editing images based on text instructions.",
"skip": true,
"extras": "sampler: Default, cfg_scale: 3.5"
},
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

+7
View File
@@ -317,6 +317,13 @@ def load_flux(checkpoint_info, diffusers_load_config): # triggered by opts.sd_ch
cls = diffusers.FluxControlPipeline
elif 'Depth' in repo_id:
cls = diffusers.FluxControlPipeline
elif 'Kontext' in repo_id:
cls = diffusers.FluxKontextPipeline
from diffusers import pipelines
pipelines.auto_pipeline.AUTO_TEXT2IMAGE_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline
pipelines.auto_pipeline.AUTO_IMAGE2IMAGE_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline
pipelines.auto_pipeline.AUTO_INPAINT_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline
else:
cls = diffusers.FluxPipeline
shared.log.debug(f'Load model: type=FLUX cls={cls.__name__} preloaded={list(kwargs)} revision={diffusers_load_config.get("revision", None)}')
+11 -7
View File
@@ -48,17 +48,21 @@ def task_specific_kwargs(p, model):
'image': p.init_images,
'strength': p.denoising_strength,
}
if model.__class__.__name__ == 'FluxImg2ImgPipeline': # needs explicit width/height
if model.__class__.__name__ == 'FluxImg2ImgPipeline' or model.__class__.__name__ == 'FluxKontextPipeline': # needs explicit width/height
if torch.is_tensor(p.init_images[0]):
p.width = p.init_images[0].shape[-1] * 16
p.height = p.init_images[0].shape[-2] * 16
p.width, p.height = p.init_images[0].shape[-1] * 16, p.init_images[0].shape[-2] * 16
else:
p.width = 8 * math.ceil(p.init_images[0].width / 8)
p.height = 8 * math.ceil(p.init_images[0].height / 8)
p.width, p.height = 8 * math.ceil(p.init_images[0].width / 8), 8 * math.ceil(p.init_images[0].height / 8)
if model.__class__.__name__ == 'FluxKontextPipeline':
aspect_ratio = p.width / p.height
vae_scale_factor = 16
max_area = max(p.width, p.height)**2
p.width, p.height = round((max_area * aspect_ratio) ** 0.5), round((max_area / aspect_ratio) ** 0.5)
p.width, p.height = p.width // vae_scale_factor * vae_scale_factor, p.height // vae_scale_factor * vae_scale_factor
task_args['max_area'] = max_area
task_args['width'], task_args['height'] = p.width, p.height
if model.__class__.__name__ == 'OmniGenPipeline':
p.width = 16 * math.ceil(p.init_images[0].width / 16)
p.height = 16 * math.ceil(p.init_images[0].height / 16)
p.width, p.height = 16 * math.ceil(p.init_images[0].width / 16), 16 * math.ceil(p.init_images[0].height / 16)
task_args = {
'width': p.width,
'height': p.height,
+1 -3
View File
@@ -466,9 +466,7 @@ def calculate_base_steps(p, use_denoise_start, use_refiner_start):
cls = shared.sd_model.__class__.__name__
if cls in sd_models.i2i_pipes:
steps = p.steps
elif 'Flex' in cls:
steps = p.steps
elif 'HiDreamImageEditingPipeline' in cls:
elif 'Flex' in cls or 'HiDreamImageEditingPipeline' in cls or 'Kontext' in cls:
steps = p.steps
elif use_denoise_start and (shared.sd_model_type == 'sdxl'):
steps = p.steps // (1 - p.refiner_start)
+8 -1
View File
@@ -37,7 +37,14 @@ def create_ui():
model = modelstats.analyze()
desc = f"Model: {model.name}<br>Type: {model.type}<br>Class: {model.cls}<br>Size: {model.size} bytes<br>Modified: {model.mtime}<br>"
meta = model.meta
components = [(m.name, m.cls, m.device, m.dtype, m.params, m.modules, str(m.config)) for m in model.modules]
components = []
for m in model.modules:
try:
component = (m.name, m.cls, str(m.device), str(m.dtype), m.params, m.modules, str(m.config))
components.append(component)
except Exception:
component = (m.name, m.cls, str(m.device), str(m.dtype), m.params, m.modules, '')
components.append(component)
return [desc, components, meta]
with gr.Row():