---
title: "p-image-edit-trainer"
description: "Train custom LoRAs for image editing"
url: "https://docs.api.pruna.ai/guides/models/p-image-edit-trainer"
image: "https://docs.api.pruna.ai/_og/d/c_Ocean.takumi,title_p-image-edit-trainer,description_Train+custom+LoRAs+for+image+editing,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiM3YzNhZWQifX19,p_Ii9ndWlkZXMvbW9kZWxzL3AtaW1hZ2UtZWRpdC10cmFpbmVyIg,s_P5ipGUp61dEG_zaB.png"
---

# p-image-edit-trainer

Train custom LoRAs for image editing transformations

## [Overview](#overview)

p-image-edit-trainer allows you to train custom LoRA (Low-Rank Adaptation) weights for use with the `p-image-edit-lora` model. Train personalized image transformations, style transfers, and custom editing behaviors using pairs of before/after images.

**This is NOT an inference model.** It does not edit images. Instead, it outputs a ZIP file containing trained LoRA weights (.safetensors).

**Rate Limit:** 5 requests per minute

**Category:** LoRA Training

**Price:** $4.00 / 1000 steps

**Important Notes:**

-   **Async only** - Training takes minutes to hours. Do not use `Try-Sync` header.
-   **Download within 30 minutes** - The output URL expires approximately 30 minutes after training completes. Download immediately and upload to HuggingFace for permanent storage.
-   Trained LoRAs only work with `p-image-edit-lora`, not with other models.

## [Workflow](#workflow)

1.  **Prepare image pairs** - Create a ZIP file with before/after image pairs using `_start`/`_end` naming
2.  **Upload ZIP to accessible URL** - Host your training data somewhere accessible
3.  **Start training** - Submit async request (takes minutes to hours)
4.  **Poll for completion** - Check status until training succeeds
5.  **Download output** - Get the ZIP file within 30 minutes
6.  **Upload to HuggingFace** - Store the .safetensors file for permanent access
7.  **Use with p-image-edit-lora** - Edit images using your trained LoRA

## [Quickstart](#quickstart)

### [Prepare Training Data (Image Pairs)](#prepare-training-data-image-pairs)

Create a ZIP archive with before/after image pairs. Images must follow the `_start`/`_end` naming convention:

```text
training_data.zip
├── photo_start.jpg       # Before image
├── photo_end.jpg         # After image (transformed)
├── photo.txt             # Optional: caption describing the transformation
├── landscape_start.png   # Another before image
├── landscape_end.png     # Corresponding after image
├── landscape.txt         # Optional: caption
└── ...
```

**Naming Convention:**

-   Before image: `<ROOT>_start.<EXT>`
-   After image: `<ROOT>_end.<EXT>`
-   Caption (optional): `<ROOT>.txt`

**Multiple Reference Images (Optional):** For complex transformations, you can include multiple "before" references:

```text
example_start.jpg      # Primary before image
example_start2.jpg     # Additional reference
example_start3.jpg     # Additional reference
example_end.jpg        # After image
example.txt            # Caption
```

### [Start Training (Async Only)](#start-training-async-only)

```bash
curl -X POST 'https://api.pruna.ai/v1/predictions' \
  -H 'Content-Type: application/json' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Model: p-image-edit-trainer' \
  -d '{
    "input": {
      "image_data": "https://your-storage.com/edit_pairs.zip",
      "steps": 1000,
      "default_caption": "apply the trained transformation"
    }
  }'
```

Response:

```text
{
  "id": "training456xyz",
  "model": "p-image-edit-trainer",
  "input": { ... },
  "get_url": "https://api.pruna.ai/v1/predictions/status/training456xyz"
}
```

### [Poll for Completion](#poll-for-completion)

Training takes minutes to hours depending on steps. Poll periodically:

```bash
curl -X GET 'https://api.pruna.ai/v1/predictions/status/training456xyz' \
  -H 'apikey: YOUR_API_KEY'
```

When complete:

```text
{
  "status": "succeeded",
  "output": "https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../lora_weights.zip"
}
```

### [Download Output Immediately](#download-output-immediately)

The output URL expires in ~30 minutes. Download the ZIP file immediately:

```bash
curl -o lora_output.zip "https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../lora_weights.zip"
```

### [Upload to HuggingFace](#upload-to-huggingface)

Extract and upload the .safetensors file to HuggingFace:

```bash
unzip lora_output.zip
# Upload lora.safetensors to huggingface.co/your-username/my-edit-lora
```

### [Use with p-image-edit-lora](#use-with-p-image-edit-lora)

```bash
curl -X POST 'https://api.pruna.ai/v1/predictions' \
  -H 'Content-Type: application/json' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Model: p-image-edit-lora' \
  -d '{
    "input": {
      "prompt": "Apply the trained transformation to image 1",
      "images": ["https://example.com/input.jpg"],
      "lora_weights": "huggingface.co/your-username/my-edit-lora"
    }
  }'
```

### [Parameters](#parameters)

#### [Required Parameters](#required-parameters)

| Parameter  | Type         | Description                                                                      |
| :--------- | :----------- | :------------------------------------------------------------------------------- |
| image_data | string (URI) | URL to a ZIP archive with image pairs. Images must be named ROOT_start.EXT and ROOT_end.EXT. Can include multiple references (ROOT_start2.EXT, etc.) and text files for captions (ROOT.txt) |

#### [Optional Parameters](#optional-parameters)

| Parameter       | Type    | Default | Description                                                                      |
| :-------------- | :------ | :------ | :------------------------------------------------------------------------------- |
| steps           | integer | 1000    | Number of training steps. Range: 100-5000, in increments of 100. More steps = longer training, potentially better results |
| learning_rate   | number  | 0.0001  | Learning rate for training. Range: 0.00001-0.01. Lower = slower but more stable  |
| default_caption | string  | -       | Default caption for image pairs without .txt files. If not provided and captions are missing, training fails |

#### [Steps Guidelines](#steps-guidelines)

| Steps     | Use Case                         | Expected Time |
| :-------- | :------------------------------- | :------------ |
| 100-500   | Quick tests, simple transforms   | Minutes       |
| 500-1000  | Standard training                | 10-30 minutes |
| 1000-2000 | High quality, complex transforms | 30-60 minutes |
| 2000-5000 | Maximum quality                  | 1-2+ hours    |

#### [Example Use Cases](#example-use-cases)

| Transformation Type | Training Data Example                                 |
| :------------------ | :---------------------------------------------------- |
| Style transfer      | Photos paired with artistic renditions                |
| Day-to-night        | Daytime scenes paired with nighttime versions         |
| Season changes      | Summer scenes paired with winter versions             |
| Enhancement filters | Original images paired with enhanced versions         |
| Custom effects      | Before/after pairs showing your custom transformation |