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
base_model:black-forest-labs/FLUX.1-devscript_type:image_generation
image_column– Training images showing your desired stylecaption_column– Text descriptions of each image
Prerequisites
- Repository on Oxen with your training data committed, for example:
- Namespace:
Tutorials - Repository:
CyberpunkArt
- Namespace:
- Dataset resource inside that repo, for example:
main/train_images.parquet- Each row contains an image path and descriptive caption
- Example: view sample dataset structure
- API key with access to the repo:
- Exported as
OXEN_API_KEY
- Exported as
- Base URL for the Oxen API:
- Cloud:
https://hub.oxen.ai - Exported as
OXEN_BASE_URL
- Cloud:
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)
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
EndpointPOST /api/repos/{owner}/{repo}/fine_tunes
resource:main/train_images.parquetbase_model:black-forest-labs/FLUX.1-devscript_type:image_generation
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)
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.fine_tune object:
Step 2 – Start the Fine-Tune Run
Once you have thefine_tune.id, trigger the training run.
Endpoint
POST /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}/actions/run
curl request:
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. EndpointGET /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}
Understanding Training Progress
As training progresses, you’ll see:- Status updates:
created→running→completed - Current step: Progress counter (e.g., 400/2000)
- Sample outputs: Generated images at steps 200, 400, 600, etc.
Step 4 – Deploy the Fine-Tuned Model
Once training completes, deploy your model to a GPU-backed inference endpoint. EndpointPOST /api/repos/{owner}/{repo}/fine_tunes/{fine_tune_id}/deploy
curl request:
Step 5 – Generate Images with Your Fine-Tuned Model
Now you can generate images in your custom style using the inference API. EndpointPOST /api/ai/images/generate
curl request (text-to-image):
Generate Multiple Images
You can generate multiple variations by settingnum_images:
Inference Parameters
Example Response
Complete Python Example
Here’s a complete Python script that ties everything together:Troubleshooting
Images not loading during training
Images not loading during training
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.Out of memory errors
Out of memory errors
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.Sample outputs don't match my style
Sample outputs don't match my style
- 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)
Training taking too long
Training taking too long
- 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-Imagefor iteration - See supported models
Generated images have artifacts or low quality
Generated images have artifacts or low quality
- Ensure training images are high resolution and consistent quality
- Increase
num_inference_stepsto 40-50 during generation - Try different
guidance_scalevalues (7.0-9.0) - Train for more steps to improve model quality
Next Steps
- Advanced Parameters: See the Image Generation API Reference for all available parameters
- Parameter Tuning: Learn about LoRA configuration and learning rate optimization
- More Examples: Check out the Quick Start guide for simplified examples
- Other Modalities: Explore Image Editing or Video Generation
With these skills, you can now fine-tune image generation models for any visual style, brand identity, or artistic direction!