--- language: - en - zh license: other license_name: flux-1-dev-non-commercial-license license_link: LICENSE.md extra_gated_prompt: >- By clicking "Agree", you agree to the [FluxDev Non-Commercial License Agreement](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev/blob/main/LICENSE.md) and acknowledge the [Acceptable Use Policy](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev/blob/main/POLICY.md). tags: - image-generation - flux - diffusion-single-file pipeline_tag: image-to-image library_name: diffusers --- ![FLUX.1 [dev] Grid](./teaser.png) `FLUX.1 Kontext [dev]` is a 12 billion parameter rectified flow transformer capable of editing images based on text instructions. For more information, please read our [blog post](https://bfl.ai/announcements/flux-1-kontext-dev) and our [technical report](https://arxiv.org/abs/2506.15742). You can find information about the `[pro]` version in [here](https://bfl.ai/models/flux-kontext). # Key Features 1. Change existing images based on an edit instruction. 2. Have character, style and object reference without any finetuning. 3. Robust consistency allows users to refine an image through multiple successive edits with minimal visual drift. 4. Trained using guidance distillation, making `FLUX.1 Kontext [dev]` more efficient. 5. Open weights to drive new scientific research, and empower artists to develop innovative workflows. 6. Generated outputs can be used for personal, scientific, and commercial purposes, as described in the [FLUX.1 \[dev\] Non-Commercial License](https://github.com/black-forest-labs/flux/blob/main/model_licenses/LICENSE-FLUX1-dev). # Usage We provide a reference implementation of `FLUX.1 Kontext [dev]`, as well as sampling code, in a dedicated [github repository](https://github.com/black-forest-labs/flux). Developers and creatives looking to build on top of `FLUX.1 Kontext [dev]` are encouraged to use this as a starting point. `FLUX.1 Kontext [dev]` is also available in both [ComfyUI](https://github.com/comfyanonymous/ComfyUI) and [Diffusers](https://github.com/huggingface/diffusers). ## API Endpoints The FLUX.1 Kontext models are also available via API from the following sources - bfl.ai: https://docs.bfl.ai/ - DataCrunch: https://datacrunch.io/managed-endpoints/flux-kontext - fal: https://fal.ai/flux-kontext - Replicate: https://replicate.com/blog/flux-kontext - https://replicate.com/black-forest-labs/flux-kontext-dev - https://replicate.com/black-forest-labs/flux-kontext-pro - https://replicate.com/black-forest-labs/flux-kontext-max - Runware: https://runware.ai/blog/introducing-flux1-kontext-instruction-based-image-editing-with-ai?utm_source=bfl - TogetherAI: https://www.together.ai/models/flux-1-kontext-dev ### Using with diffusers 🧨 ```shell # Install diffusers from the main branch until future stable release pip install git+https://github.com/huggingface/diffusers.git ``` Image editing: ```py import torch from diffusers import FluxKontextPipeline from diffusers.utils import load_image pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16) pipe.to("cuda") input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe( image=input_image, prompt="Add a hat to the cat", guidance_scale=2.5 ).images[0] ``` Flux Kontext comes with an integrity checker, which should be run after the image generation step. To run the safety checker, install the official repository from [black-forest-labs/flux](https://github.com/black-forest-labs/flux) and add the following code: ```python import torch import numpy as np from flux.content_filters import PixtralContentFilter integrity_checker = PixtralContentFilter(torch.device("cuda")) image_ = np.array(image) / 255.0 image_ = 2 * image_ - 1 image_ = torch.from_numpy(image_).to("cuda", dtype=torch.float32).unsqueeze(0).permute(0, 3, 1, 2) if integrity_checker.test_image(image_): raise ValueError("Your image has been flagged. Choose another prompt/image or try again.") ``` For VRAM saving measures and speed ups check out the [diffusers docs](https://huggingface.co/docs/diffusers/en/index) --- # Risks Black Forest Labs is committed to the responsible development of generative AI technology. Prior to releasing FLUX.1 Kontext, we evaluated and mitigated a number of risks in our models and services, including the generation of unlawful content. We implemented a series of pre-release mitigations to help prevent misuse by third parties, with additional post-release mitigations to help address residual risks: 1. **Pre-training mitigation**. We filtered pre-training data for multiple categories of “not safe for work” (NSFW) content to help prevent a user generating unlawful content in response to text prompts or uploaded images. 2. **Post-training mitigation.** We have partnered with the Internet Watch Foundation, an independent nonprofit organization dedicated to preventing online abuse, to filter known child sexual abuse material (CSAM) from post-training data. Subsequently, we undertook multiple rounds of targeted fine-tuning to provide additional mitigation against potential abuse. By inhibiting certain behaviors and concepts in the trained model, these techniques can help to prevent a user generating synthetic CSAM or nonconsensual intimate imagery (NCII) from a text prompt, or transforming an uploaded image into synthetic CSAM or NCII. 3. **Pre-release evaluation.** Throughout this process, we conducted multiple internal and external third-party evaluations of model checkpoints to identify further opportunities for improvement. The third-party evaluations—which included 21 checkpoints of FLUX.1 Kontext [pro] and [dev]—focused on eliciting CSAM and NCII through adversarial testing with text-only prompts, as well as uploaded images with text prompts. Next, we conducted a final third-party evaluation of the proposed release checkpoints, focused on text-to-image and image-to-image CSAM and NCII generation. The final FLUX.1 Kontext [pro] (as offered through the FLUX API only) and FLUX.1 Kontext [dev] (released as an open-weight model) checkpoints demonstrated very high resilience against violative inputs, and FLUX.1 Kontext [dev] demonstrated higher resilience than other similar open-weight models across these risk categories. Based on these findings, we approved the release of the FLUX.1 Kontext [pro] model via API, and the release of the FLUX.1 Kontext [dev] model as openly-available weights under a non-commercial license to support third-party research and development. 4. **Inference filters.** We are applying multiple filters to intercept text prompts, uploaded images, and output images on the FLUX API for FLUX.1 Kontext [pro]. Filters for CSAM and NCII are provided by Hive, a third-party provider, and cannot be adjusted or removed by developers. We provide filters for other categories of potentially harmful content, including gore, which can be adjusted by developers based on their specific risk profile. Additionally, the repository for the open FLUX.1 Kontext [dev] model includes filters for illegal or infringing content. Filters or manual review must be used with the model under the terms of the FLUX.1 [dev] Non-Commercial License. We may approach known deployers of the FLUX.1 Kontext [dev] model at random to verify that filters or manual review processes are in place. 5. **Content provenance.** The FLUX API applies cryptographically-signed metadata to output content to indicate that images were produced with our model. Our API implements the Coalition for Content Provenance and Authenticity (C2PA) standard for metadata. 6. **Policies.** Access to our API and use of our models are governed by our Developer Terms of Service, Usage Policy, and FLUX.1 [dev] Non-Commercial License, which prohibit the generation of unlawful content or the use of generated content for unlawful, defamatory, or abusive purposes. Developers and users must consent to these conditions to access the FLUX Kontext models. 7. **Monitoring.** We are monitoring for patterns of violative use after release, and may ban developers who we detect intentionally and repeatedly violate our policies via the FLUX API. Additionally, we provide a dedicated email address (safety@blackforestlabs.ai) to solicit feedback from the community. We maintain a reporting relationship with organizations such as the Internet Watch Foundation and the National Center for Missing and Exploited Children, and we welcome ongoing engagement with authorities, developers, and researchers to share intelligence about emerging risks and develop effective mitigations. # License This model falls under the [FLUX.1 \[dev\] Non-Commercial License](https://github.com/black-forest-labs/flux/blob/main/model_licenses/LICENSE-FLUX1-dev). # Citation ```bib @misc{labs2025flux1kontextflowmatching, title={FLUX.1 Kontext: Flow Matching for In-Context Image Generation and Editing in Latent Space}, Add commentMore actions author={Black Forest Labs and Stephen Batifol and Andreas Blattmann and Frederic Boesel and Saksham Consul and Cyril Diagne and Tim Dockhorn and Jack English and Zion English and Patrick Esser and Sumith Kulal and Kyle Lacey and Yam Levi and Cheng Li and Dominik Lorenz and Jonas Müller and Dustin Podell and Robin Rombach and Harry Saini and Axel Sauer and Luke Smith}, year={2025}, eprint={2506.15742}, archivePrefix={arXiv}, primaryClass={cs.GR}, url={https://arxiv.org/abs/2506.15742}, } ``` --- 语言: - 英文 - zh 许可证:其他 license_name:flux-1-dev-non-commercial-license license_link:LICENSE.md extra_gated_prompt: >- 点击“同意”,即表示您同意 [FluxDev 非商业许可证 协议](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev/blob/main/LICENSE.md) 并确认 [可接受的使用 Policy](https://huggingface.co/black-forest-labs/FLUX.1-Kontext-dev/blob/main/POLICY.md) 的 标签: - 图像生成 -通量 - 扩散单文件 pipeline_tag:图像到图像 library_name: 扩散器 ---![FLUX.1 [开发] 网格](./teaser.png)'FLUX.1 Kontext [dev]' 是一个 120 亿参数的整流转换器,能够根据文本指令编辑图像。 有关更多信息,请阅读我们的 [博客文章](https://bfl.ai/announcements/flux-1-kontext-dev) 和我们的 [技术报告](https://arxiv.org/abs/2506.15742)。您可以在 [here](https://bfl.ai/models/flux-kontext) 中找到有关 '[pro]' 版本的信息。# 主要特点 1. 根据编辑指令更改现有图像。 2. 具有字符、样式和对象参考,无需任何微调。 3. 强大的一致性允许用户通过多次连续编辑来优化图像,同时将视觉漂移降至最低。 4. 使用指导蒸馏进行训练,使“FLUX.1 Kontext [dev]”更高效。 5. 打开砝码以推动新的科学研究,并赋予艺术家开发创新工作流程的能力。 6. 生成的输出可用于个人、科学和商业目的,如 [FLUX.1 \[dev\] 非商业许可证](https://github.com/black-forest-labs/flux/blob/main/model_licenses/LICENSE-FLUX1-dev)中所述。# 用途 我们在专用的 [github 存储库](https://github.com/black-forest-labs/flux) 中提供了 'FLUX.1 Kontext [dev]' 的参考实现以及采样代码。 我们鼓励希望在“FLUX.1 Kontext [dev]”之上构建的开发人员和创意人员以此为起点。“FLUX.1 Kontext [dev]”也可用于 [ComfyUI](https://github.com/comfyanonymous/ComfyUI) 和 [Diffusers](https://github.com/huggingface/diffusers)。## API 端点 FLUX.1 Kontext 模型也可以通过 API 从以下来源获得 - bfl.ai: https://docs.bfl.ai/ - DataCrunch:https://datacrunch.io/managed-endpoints/flux-kontext - FAL:https://fal.ai/flux-kontext - 复制:https://replicate.com/blog/flux-kontext - https://replicate.com/black-forest-labs/flux-kontext-dev - https://replicate.com/black-forest-labs/flux-kontext-pro - https://replicate.com/black-forest-labs/flux-kontext-max - Runware:https://runware.ai/blog/introducing-flux1-kontext-instruction-based-image-editing-with-ai?utm_source=bfl - TogetherAI: https://www.together.ai/models/flux-1-kontext-dev### 与扩散器🧨一起使用 ''' shell # 从 main 分支安装 diffusers 直到将来的稳定版本 pip 安装 git+https://github.com/huggingface/diffusers.git '''图像编辑: '''py Import Torch (导入火炬) from diffusers import FluxKontextPipeline from diffusers.utils import load_imagepipe = FluxKontextPipeline.from_pretrained(“black-forest-labs/FLUX.1-Kontext-dev”, torch_dtype=torch.bfloat16) pipe.to(“cuda”)input_image = load_image(“https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png”)image = pipe( image=input_image、 prompt=“给猫加顶帽子”, guidance_scale=2.5 ).images[0] '''Flux Kontext 带有一个完整性检查器,它应该在图像生成步骤之后运行。要运行安全检查器,请从 [black-forest-labs/flux](https://github.com/black-forest-labs/flux) 安装官方仓库并添加以下代码:'''python Import Torch (导入火炬) 将 numpy 导入为 NP from flux.content_filters import PixtralContentFilterintegrity_checker = PixtralContentFilter(torch.device(“cuda”)) image_ = np.array(图像) / 255.0 image_ = 2 * image_ - 1 image_ = torch.from_numpy(image_).to(“cuda”, dtype=torch.float32).unsqueeze(0).permute(0, 3, 1, 2) 如果 integrity_checker.test_image(image_): raise ValueError(“您的图片已被标记。选择其他提示/图像或重试。 '''有关 VRAM 节省措施和加速方法,请查看 [diffusers 文档](https://huggingface.co/docs/diffusers/en/index) ---# 风险 Black Forest Labs 致力于负责任地开发生成式 AI 技术。在发布 FLUX.1 Kontext 之前,我们评估并缓解了我们的模型和服务中的许多风险,包括生成非法内容。我们实施了一系列发布前缓解措施,以帮助防止第三方滥用,并实施了额外的发布后缓解措施,以帮助解决剩余风险: 1. **训练前缓解**。我们筛选了多类“工作不安全”(NSFW) 内容的训练前数据,以帮助防止用户生成非法内容以响应文本提示或上传的图像。 2. **培训后缓解。我们与 Internet Watch Foundation(一家致力于防止在线虐待的独立非营利组织)合作,从培训后数据中筛选出已知的儿童性虐待材料 (CSAM)。随后,我们进行了多轮有针对性的微调,以进一步缓解潜在的滥用行为。通过抑制训练模型中的某些行为和概念,这些技术可以帮助防止用户从文本提示生成合成 CSAM 或未经同意的私密图像 (NCII),或将上传的图像转换为合成 CSAM 或 NCII。 3. **发布前评估。在整个过程中,我们对模型检查点进行了多次内部和外部第三方评估,以确定进一步的改进机会。第三方评估包括 FLUX.1 Kontext [pro] 和 [dev] 的 21 个检查点,重点是通过使用纯文本提示的对抗性测试以及带有文本提示的上传图像来引出 CSAM 和 NCII。接下来,我们对提议的发布检查点进行了最终的第三方评估,重点是文本到图像和图像到图像的 CSAM 和 NCII 生成。最终的 FLUX.1 Kontext [pro](仅通过 FLUX API 提供)和 FLUX.1 Kontext [dev](作为开放权重模型发布)检查点对违规输入表现出非常高的弹性,而 FLUX.1 Kontext [dev] 在这些风险类别中表现出比其他类似的开放权重模型更高的弹性。 基于这些发现,我们批准通过 API 发布 FLUX.1 Kontext [pro] 模型,并在非商业许可下将 FLUX.1 Kontext [dev] 模型作为公开可用的权重发布,以支持第三方研究和开发。 4. **推理过滤器。我们正在应用多个过滤器来拦截文本提示、上传的图像和输出图像,以拦截 FLUX API for FLUX.1 Kontext [pro] 上的图像。CSAM 和 NCII 的筛选器由第三方提供商 Hive 提供,开发人员无法调整或删除。我们为其他类别的潜在有害内容(包括血腥内容)提供了过滤器,开发人员可以根据其特定的风险状况进行调整。此外,开放式 FLUX.1 Kontext [dev] 模型的存储库包括非法或侵权内容的过滤器。滤镜或人工审核必须根据 FLUX.1 [dev] 非商业许可证的条款与模型一起使用。我们可能会随机联系 FLUX.1 Kontext [dev] 模型的已知部署者,以验证过滤器或手动审查流程是否到位。 5. **内容来源。** FLUX API 将加密签名的元数据应用于输出内容,以指示图像是使用我们的模型生成的。我们的 API 实施了元数据的内容来源和真实性联盟 (C2PA) 标准。 6. 访问我们的 API 和使用我们的模型受我们的开发人员服务条款、使用政策和 FLUX.1 [dev] 非商业许可的约束,这些条款禁止生成非法内容或将生成的内容用于非法、诽谤或滥用目的。开发人员和用户必须同意这些条件才能访问 FLUX Kontext 模型。 7. **监控。我们正在监控发布后的违规使用模式,并且可能会通过 FLUX API 禁止我们检测到故意和反复违反我们政策的开发人员。此外,我们还提供了一个专用的电子邮件地址 (safety@blackforestlabs.ai) 来征求社区的反馈。我们与 Internet Watch Foundation 和 National Center for Missing and Exploited Children 等组织保持报告关系,我们欢迎与当局、开发人员和研究人员持续合作,以共享有关新出现的风险的情报并制定有效的缓解措施。 # 许可证 此模型属于 [FLUX.1 \[dev\] 非商业许可证](https://github.com/black-forest-labs/flux/blob/main/model_licenses/LICENSE-FLUX1-dev)。 # 引用'''围兜 @misc{labs2025flux1kontextflowmatching, title={FLUX.1 Kontext: 用于潜在空间中上下文图像生成和编辑的流匹配}, 添加 commentMore 作 author={黑森林实验室和斯蒂芬·巴蒂福尔、安德烈亚斯·布拉特曼和弗雷德里克·博塞尔和萨克沙姆领事、西里尔·迪亚涅和蒂姆·多克霍恩和杰克·英吉利和锡安·英吉利和帕特里克·埃塞尔和苏米特·库拉尔和凯尔·莱西和亚姆·李成、李成和多米尼克·洛伦茨、乔纳斯·穆勒和达斯汀·波德尔和罗宾·罗姆巴赫、哈里·塞尼和阿克塞尔·绍尔和卢克·史密斯}, year={2025}, eprint={2506.15742}, archivePrefix={arXiv} 中,则 primaryClass={cs.GR}、 url={https://arxiv.org/abs/2506.15742}、 } ```