Complete Guide to ComfyUI FLUX.1 Kontext: AI Image Editing and Prompt Tutorial
FLUX.1 Kontext is a generative model suite designed for text and image-driven editing. Unlike traditional text-to-image (T2I) models, Kontext supports context-based image processing, capable of understanding both image and text content to achieve more precise image editing capabilities.
Currently, Black Forest Labs has only released the API version, with the open-source version yet to be released. We will update this article with relevant tutorials once the open-source version is available. Currently, FLUX.1 Kontext can be used in ComfyUI through API nodes.
FLUX.1 Kontext Model Features
- Continuous Image Editing: Maintains consistency across multiple editing steps
- Precise Object Modification: Accurately modifies specific objects in images
- Character Consistency Editing: Maintains character features across multiple editing steps
- Style Preservation and Transfer: Can both maintain original style and perform style transfer
- Image Text Editing: Directly edits text content in images
- Composition Control: Precise control over image composition, camera angles, and poses
- Fast Inference: Efficient image generation and editing speed
Using FLUX.1 Kontext in ComfyUI via API
FLUX.1 Kontext is currently provided in ComfyUI as API nodes. We will continue to update this tutorial after the open-source version is released. Please visit the ComfyUI Wiki for related articles written in the official ComfyUI documentation.
FLUX.1 Kontext API Node Official Tutorial
- Please update your ComfyUI Portable or Desktop to the latest version.
- In the menu bar, select Workflow -> Browse Templates -> Image API category to find FLUX.1 Kontext related templates.
Using API nodes requires you to log in and ensure sufficient balance in your account. Please refer to ComfyUI API Nodes Overview to learn about the credit system.
Since the corresponding nodes are very simple to use, basically just find the Flux.1 Kontext [pro] Image
or Flux.1 Kontext [pro] Image
node in the API Node and use the Load Image
and Save Image
nodes.
- Load the image to be edited in the
Load Image
node - Modify necessary parameters in the
Flux.1 Kontext Pro Image
orFlux.1 Kontext Max Image
node:prompt
Enter the prompt for the image you want to editaspect_ratio
Set the aspect ratio of the original image, ratio must be between 1:4 and 4:1prompt_upsampling
Set whether to use prompt upsampling. If enabled, it will automatically modify the prompt to get richer results, but the results are not reproducible
- Click the
Run
button or use the shortcutCtrl(cmd) + Enter
to execute the image editing. - After waiting for the API to return results, you can view the edited image in the
Save Image
node, and the corresponding image will also be saved to theComfyUI/output/
directory.
ComfyUI Flux.1 Kontext Native Workflow
[To be updated]
Complete Guide to FLUX.1 Kontext Prompts
FLUX.1 Kontext Prompt Basics
Important Note: FLUX.1 Kontext has a maximum prompt limit of 512 tokens, please plan your prompt length accordingly.
Please write prompts in English Kontextâs core advantage lies in understanding image context - you only need to specify what you want to change, without needing to describe the entire scene in detail. This makes image editing simpler and more intuitive.
FLUX.1 Kontext Basic Object Modification
Kontext excels at direct object modification, such as changing colors or replacing objects.
Basic Modification Examples:
Modification Type | Prompt Example | Effect Description |
---|---|---|
Color Change | âChange the car color to redâ | Only changes car color, keeps rest |
Object Replacement | âChange the flowers to yellowâ | Changes flower color |
Simple Addition | âAdd an apple on the tableâ | Adds new object to existing scene |
Prompt Precision Level Comparison
Different levels of detail in prompts will produce different editing effects. Hereâs a comparison of three precision levels:
Level Comparison Table
Precision Level | Characteristics | Advantages | Disadvantages | Use Cases |
---|---|---|---|---|
Simple Edit | Concise and direct | Quick and easy | May change style | Quick idea testing |
Controlled Edit | Add preservation | More stable | Slightly longer | Need to preserve |
Complex Transform | Detailed all | Precise control | Longer prompts | Multiple changes |
Specific Example Comparison
Scenario: Changing night scene to daytime
Precision Level | Prompt | Expected Effect |
---|---|---|
Simple Edit | âChange to daytimeâ | Time changes, style may change |
Controlled Edit | âChange to daytime while maintaining the same style of the paintingâ | Time changes, style preserved |
Complex Transform | âChange the setting to a day time, add a lot of people walking the sidewalk while maintaining the same style of the paintingâ | Multiple changes, precise |
Complete Style Conversion Guide
Style Conversion Principles Table
Principle | Description | Good Example | Avoid Example |
---|---|---|---|
Specify Style | Use specific names | âTransform to Bauhaus art style" | "Make it artisticâ |
Reference Movements | Mention specific | â1960s pop art poster style" | "Modern art styleâ |
Describe Features | Detail elements | âVisible brushstrokes, thick paint texture" | "Make it look betterâ |
Preserve Elements | Specify retention | âWhile maintaining the original composition and placementâ | No preservation |
Style Conversion Prompt Comparison
Converting photo to painting style
Effect Type | Prompt | Result Quality |
---|---|---|
â Basic (may lose detail) | âMake it a sketchâ | Style change, detail loss |
â Improved (preserves) | âConvert to pencil sketch with natural graphite lines, cross-hatching, and visible paper textureâ | Style + details |
â Best (full control) | âConvert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture while maintaining all background details and featuresâ | Perfect balance |
Common Style Conversion Prompt Templates
Style Type | Recommended Prompt Template |
---|---|
Oil Painting | âTransform to oil painting with visible brushstrokes, thick paint texture, and rich color depthâ |
Watercolor | âConvert to watercolor painting with transparent colors, paper texture, and natural paint flow effectsâ |
Pencil Sketch | âConvert to pencil sketch with natural graphite lines, cross-hatching, and visible paper textureâ |
Anime Style | âTransform to anime style with clear lines, vibrant colors, and typical anime character featuresâ |
Claymation | âRestyle to Claymation style with 3D sculpted texture and soft lighting effectsâ |
FLUX.1 Kontext Character Consistency Editing Framework
Character Consistency Three-Step Method
Step | Purpose | Example | Importance |
---|---|---|---|
1. Establish Reference | Define identity | âThe woman with short black hairâ | âââââ |
2. Specify Change | State changes | âNow in a tropical beach settingâ | ââââ |
3. Retention Mark | Specify features | âWhile maintaining the same facial features and expressionâ | âââââ |
Character Description Word Comparison
Description Method | Effect | Example | Recommendation |
---|---|---|---|
â Pronoun Reference | Confusing | âSheâ, âHeâ, âThis personâ | Not recommended |
â Specific Description | Clear identity | âThe woman with short black hairâ | Strongly recommended |
â Feature Marking | Precise identification | âThe man with glassesâ, âThe girl in red coatâ | Recommended |
Sequential Editing Example Sequence
Character: Young Woman
Edit Step | Prompt | Goal |
---|---|---|
Step 1 | âSheâs now taking a selfie in a street in Freiburg, itâs a lovely day outâ | Change environment and activity |
Step 2 | âRemove the thing from her faceâ | Remove specific item |
Step 3 | âItâs now snowing, everything is covered in snowâ | Change weather environment |
Text Editing Special Techniques
Text Editing Syntax Rules
Edit Type | Syntax Format | Example |
---|---|---|
Replace Text | âReplace â[original text]â with â[new text]â" | "Replace âjoyâ with âBFLââ |
Modify Style | âReplace â[original text]â with â[new text]â while maintaining [style requirements]" | "Replace âSALEâ with âOPENâ while maintaining the same font style and colorâ |
Add Text | âAdd text â[content]â at [position]" | "Add text âWELCOMEâ on the signâ |
Text Editing Best Practices Comparison
Practice | Effect | Example |
---|---|---|
â Use quotes | Precise text identification | âReplace âOPENâ with âCLOSEDââ |
â No quotes | May cause errors | âChange OPEN to CLOSEDâ |
â Specify style | Maintain visual effect | âWhile maintaining the same font style and colorâ |
â No specification | May change overall design | Only specify text content |
FLUX.1 Kontext Troubleshooting Reference
Common Problems and Solutions
Problem Type | Problem Manifestation | Error Example | Correct Solution |
---|---|---|---|
Character Identity Change | Excessive facial feature changes | âTransform the person into a Viking" | "Transform the man into a viking warrior while preserving his exact facial features, eye color, and facial expressionâ |
Composition Shift | Subject position or scale changes | âPut him on a beach" | "Change the background to a beach while keeping the person in the exact same position, scale, and poseâ |
Style Detail Loss | Loss of important details during style conversion | âMake it a sketch" | "Convert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture while preserving all scene detailsâ |
Unexpected Element Change | Unwanted modifications | âChange to daytime" | "Change to daytime while everything else should stay black and white and maintain the original styleâ |
Verb Choice Impact on Results
Verb Type | Meaning Strength | Applicable Scenarios | Example |
---|---|---|---|
âTransformâ | Complete change | When style is completely changed | âTransform to oil painting style" |
"Changeâ | Partial modification | When modifying specific elements | âChange the clothing color" |
"Replaceâ | Direct replacement | When replacing objects or text | âReplace the background with forest" |
"Addâ | Add element | When adding elements | âAdd a small bird" |
"Removeâ | Remove element | When removing unwanted content | âRemove the cars from backgroundâ |
FLUX.1 Kontext Advanced Prompt Combination Techniques
Multi-Edit Prompt Structure
Template Format: [Main Modification] + [Preservation Requirements] + [Detail Description]
Actual Example:
Edit Requirements | Prompt Organized by Template |
---|---|
Change Background + Keep Person | âChange the background to a forest scene while keeping the person in exactly the same position and pose, maintaining the original lightingâ |
Style Conversion + Keep Composition | âTransform to watercolor painting style while maintaining the original composition and all object positions, using soft color transitionsâ |
Multi-Object Modification | âChange the car to red and the sky to sunset colors while keeping the road and buildings in their original appearanceâ |
Prompt Priority Guide
Priority | Content Type | Example |
---|---|---|
Highest | Keep Character Identity | âWhile maintaining the exact same facial featuresâ |
High | Main Modification Target | âChange the background to beachâ |
Medium | Style and Texture | âUsing watercolor painting styleâ |
Low | Detail Supplement | âAdd soft lighting effectsâ |
FLUX.1 Kontext Prompt Checklist
Before using prompts, please check the following points:
Basic Check Items
- Is the content to be modified specified clearly?
- Is the element that needs to be kept unchanged described?
- Is the prompt length within the 512 token limit?
- Is a specific rather than vague description used?
Advanced Check Items
- Is a specific description used instead of pronouns when editing characters?
- Is a specific feature described when converting styles?
- Is quotation marks used when editing text?
- Is the appropriate verb (transform/change/replace) selected?
Through this comprehensive prompt guide, you can better master the use of FLUX.1 Kontext to achieve more precise image editing effects.
FLUX.1 Kontext Prompt Best Practices Summary
- Specific and Clear: Precise language brings better results. Use accurate color names, detailed descriptions, and clear action verbs to avoid vague terms.
- Start Simple: Before adding complexity, start with core changes. First test basic edits, then build on successful results.
- Intended Preservation: Clearly state what should remain unchanged. Use phrases like âwhile maintaining the same [facial features/composition/lighting]â to protect important elements.
- Iterate When Necessary: Complex transformations often require multiple steps. Decompose drastic changes into sequential edits for better control.
- Directly Name the Subject: Use âThe woman with short black hairâ or âThe red carâ instead of âSheâ, âItâ, or âThisâ etc.
- Text Use Quotes: Quote the exact text you want to change: âReplace âjoyâ with âBFLââ is better than general text descriptions.
- Explicit Composition Control: When changing background or settings, specify âKeep accurate camera angle, position, and compositionâ to prevent unnecessary repositioning.
- Carefully Select Verbs: âTransformâ may imply a complete change, while âChange clothingâ or âReplace backgroundâ allows you to better control the actual changes.
Remember: Itâs always beneficial to make content more explicit when the number of instructions for each edit is not too complex.