kontext Training

Differences between Kontext training and conventional LoRA training:

Comparison

Training Principle

Number of Training Images

Applicable Scenarios

Generalization Ability

LoRA

Traditional low-rank adaptation training, mainly learning visual features

Generally requires 50-100 images or more

Style transfer, character/object feature learning

Strong generalization ability with similar visual features

Kontext LoRA

Context-based training method, focusing on semantic associations

Usually 20-50 pairs can achieve good results

Creative scenarios requiring precise semantic control, image modification, and partial transfer

Strong generalization ability in similar semantic scenarios

Basic Concepts and Architecture

- Difference from Flux Dev:

Flux Dev is Text to Image (prompt → target image), Kontext is image conversion (prompt + original image → target image).

- Application Scenarios: Image editing, style conversion, content modification, etc.

Flux LoRA

Kontext LoRA

Dataset Preparation

Image Screening

● Kontext training dataset images must be in pairs: each group includes one original image, one result image, and annotations.

● Number of image sets: 20-50 groups recommended, maximum upload limit: 100 groups.

● Image selection: Multiple types of original images, watermarked images need watermark removal.

Example: For conversion to ink style, original images can include realistic style, line art style, people, objects, and landscapes to increase generalization.

Image Annotation

● Annotation language: English annotations are recommended to avoid translation errors.

● Default annotation: Can be filled in when no annotation is available. Not needed if all groups are annotated.

● Annotation Content:

Correct annotations: Describe the difference between the original and the result images with simple descriptions.

Correct examples: Convert image to ink style; Transform into fisheye lens; Turn character into a cat.

Incorrect annotations: Like regular image model training annotations, which describe the image content.

Incorrect example: A slim young Asian woman with long black hair, wearing a pink tank top and blue denim shorts, standing on a green railing by the river with a bridge in the background.

Dataset Upload

Dataset Upload

● Dataset naming format: "filename_start.png", "filename_end.png", "filename.txt".

● If not named in a fixed format, manual matching of images and re-annotation is required.

Image Upload

● Upload all images and fill each group in order. If the original and result images don't match correctly, manually move the images to the corresponding groups.

Parameter Setting

Training Steps

● Training steps optimization: The model needs to show proper effects across all images, maintaining better generalization. This requires more dataset images and increased steps.

For limited specific use, choose fewer dataset images and reduce steps.

● Recommended steps: Default is 1,500 steps, for a dataset of 20-50 groups, 2,000-5,000 steps are recommended.

Learning Rate

● For a dataset of 20-50 groups, the default learning rate should be fine. If there are more image groups and steps, and you want the model to be effective consistently, increase the learning rate.

Default Annotation

● If all or any image groups lack annotations, the default annotation will be used to avoid missing annotations.

● Example 1:

Change the photo of green stalks with yellow bananas to black and white line drawings.

● Example 2:

Change the woman in the picture into a cat, keeping the background the same, the clothing and decorations the same.

Model Testing

Model Saving

● After training completion, only one model is produced. Click to save the model.

Testing Method

● We recommend testing via a workflow.

SeaArt AI | Kontext

● Test Parameter Settings:

Please select the LoRA name: Select the saved model.

Please enter the model strength: Generally, use the default value 1.

Please enter the width: The output image's width.

Please enter the height: The output image's height.

Please select an image: Select the image to be modified.

Please enter text: The prompt, a short sentence similar to or identical to the annotation content.

Last updated