Skip to main content

Overview

This guide walks you through fine-tuning an image generation model to create images in your custom style. You’ll learn how to:
  • Create an image generation fine-tune
  • Start the fine-tune run
  • Monitor training progress with sample outputs
  • Deploy the fine-tuned model
  • Run inference to generate images in your style
We’ll use one of the FLUX models, which are state-of-the-art for image generation:
  • base_model: black-forest-labs/FLUX.1-dev
  • script_type: image_generation
Your dataset should have two columns:
  • image_column – Training images showing your desired style
  • caption_column – Text descriptions of each image
For a quick minimal example, see the Image Generation Quick Start.

Prerequisites

  • Repository on Oxen with your training data committed, for example:
    • Namespace: Tutorials
    • Repository: CyberpunkArt
  • Dataset resource inside that repo, for example:
  • API key with access to the repo:
    • Exported as OXEN_API_KEY
  • Base URL for the Oxen API:
    • Cloud: https://hub.oxen.ai
    • Exported as OXEN_BASE_URL
Set these in your shell:

Data Requirements

For best results with image generation fine-tuning:
  • Quantity: 10-50 images minimum, 100-500 images ideal
  • Quality: High resolution (1024x1024 or higher), consistent style
  • Captions: Descriptive prompts that explain what makes your images unique
  • Consistency: Images should share common elements (style, subject matter, theme)
Example dataset structure in train_images.parquet:
See the Parameter Guide to understand training duration and the Data Requirements section for detailed guidelines.

Step 1 – Create an Image Generation Fine-Tune

Endpoint
  • POST /api/repos/{owner}/{repo}/fine_tunes
For this example, we’ll use:
  • resource: main/train_images.parquet
  • base_model: black-forest-labs/FLUX.1-dev
  • script_type: image_generation
Training parameters:
  • image_column: image (your image column name)
  • caption_column: caption (your caption column name)
  • steps: 2000 (standard training duration)
  • learning_rate: 0.0002 (default for image models)
  • lora_rank: 16 (balanced capacity)
  • sample_every: 200 (generate samples every 200 steps to monitor progress)
Example curl request:
The samples array allows you to specify test prompts that will be generated during training. This helps you monitor how well the model is learning your style.
The response will include a fine_tune object:
Capture the fine-tune ID for the next steps:

Step 2 – Start the Fine-Tune Run

Once you have the fine_tune.id, trigger the training run. Endpoint
  • POST /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}/actions/run
Example curl request:
The fine-tune will now begin training. This typically takes 1-2 hours for 2000 steps on a GPU.
For FLUX models, expect approximately 30-60 minutes per 1000 steps, depending on GPU availability and image complexity.

Step 3 – Monitor Fine-Tune Status and Sample Outputs

You can poll the fine-tune to check progress and view sample outputs generated during training. Endpoint
  • GET /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}
Example monitoring script (bash):

Understanding Training Progress

As training progresses, you’ll see:
  • Status updates: createdrunningcompleted
  • Current step: Progress counter (e.g., 400/2000)
  • Sample outputs: Generated images at steps 200, 400, 600, etc.
Review the sample outputs to see how well the model is learning your style. The images should progressively match your training style better as training continues.
If sample outputs aren’t matching your style by step 1000, consider adjusting learning_rate or training for more steps. See the Parameter Guide for tuning advice.

Step 4 – Deploy the Fine-Tuned Model

Once training completes, deploy your model to a GPU-backed inference endpoint. Endpoint
  • POST /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}/deploy
Example curl request:
The response will include deployment information with a model identifier you’ll use for inference:
Capture the model slug:
Deployment may take 2-5 minutes as the model is loaded onto a GPU instance. You can check deployment status by polling the fine-tune endpoint.

Step 5 – Generate Images with Your Fine-Tuned Model

Now you can generate images in your custom style using the inference API. Endpoint
  • POST /api/ai/images/generate
Example curl request (text-to-image):

Generate Multiple Images

You can generate multiple variations by setting num_images:

Inference Parameters

Use higher num_inference_steps (40-50) for final production images, and lower values (20-28) for quick iterations during testing.

Example Response


Complete Python Example

Here’s a complete Python script that ties everything together:

Troubleshooting

Ensure image paths in your parquet file are relative to your repository root, or use full URLs. Verify that all images are committed to your Oxen repository with oxen status.
Reduce batch_size to 1 (default). If still failing, try reducing lora_rank to 8. See the Batch Size guide for more memory optimization tips.
  • Train for more steps (3000-5000 instead of 2000)
  • Ensure captions clearly describe the unique aspects of your style
  • Increase dataset size (100+ images recommended)
  • Try adjusting learning_rate (see Learning Rate guide)
  • FLUX.1-dev takes ~1-2 hours for 2000 steps on GPU
  • Start with 1000 steps for quick testing
  • Consider using a faster model like Qwen/Qwen-Image for iteration
  • See supported models
  • Ensure training images are high resolution and consistent quality
  • Increase num_inference_steps to 40-50 during generation
  • Try different guidance_scale values (7.0-9.0)
  • Train for more steps to improve model quality

Next Steps


With these skills, you can now fine-tune image generation models for any visual style, brand identity, or artistic direction!