p-image-edit-lora

Image editing with custom LoRA weights from HuggingFace

Overview

p-image-edit-lora extends Pruna's p-image-edit model with support for custom LoRA (Low-Rank Adaptation) weights from HuggingFace. Load your own trained editing LoRAs to apply custom transformations, style transfers, and specialized edits to your images.

Rate Limit: 250 requests per minute

Category: Image Editing

Price: 0.01$ / image

Note: LoRAs used with this endpoint must be trained using p-image-edit-trainer. LoRAs trained with other trainers (like p-image-trainer) will not work.

Quickstart

Start with uploading an image

curl -X POST "https://api.pruna.ai/v1/files" \
  -H "apikey: YOUR_API_KEY" \
  -F "content=@/path/to/your/file.jpg"

Note: Use -F (form) with @ prefix to upload a file from your local filesystem. The file path should be absolute or relative to your current directory.

Response:

{
  "id": "fqadqq42xq",
  "name": "test.jpg",
  "content_type": "image/jpeg",
  "size": 185093,
  "etag": "\"14e9a51deaac6bee2dd8b5c52d7d0b5f\"",
  "checksums": {
    "sha256": "aa10d5d09bcee5cb5d854bd81899308b0cf0c0c50e29d4f00c2c06e51f0e2fe6"
  },
  "metadata": {
    "content_length": 185093,
    "width": 1344,
    "height": 768
  },
  "created_at": "2025-01-08T18:51:26.729Z",
  "expires_at": "2025-01-09T18:51:26.729Z",
  "urls": {
    "get": "https://api.pruna.ai/v1/files/fqadqq42xq"
  }
}

Image Edit with LoRA (Asynchronous)

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 my custom transformation to image 1",
      "images": ["https://api.pruna.ai/v1/files/fqadqq42xq"],
      "lora_weights": "huggingface.co/your-username/your-edit-lora",
      "lora_scale": 1.0
    }
  }'

Response:

{
  "id": "abc123xyz",
  "model": "p-image-edit-lora",
  "input": { ... },
  "get_url": "https://api.pruna.ai/v1/predictions/status/abc123xyz"
}

Image Edit with LoRA (Synchronous)

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' \
  -H 'Try-Sync: true' \
  -d '{
    "input": {
      "prompt": "Apply my custom transformation to image 1",
      "images": ["https://api.pruna.ai/v1/files/fqadqq42xq"],
      "lora_weights": "huggingface.co/your-username/your-edit-lora",
      "lora_scale": 1.0
    }
  }'

Using a Private HuggingFace LoRA

For private LoRA repositories, include your HuggingFace API token:

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 style to image 1",
      "images": ["https://api.pruna.ai/v1/files/fqadqq42xq"],
      "lora_weights": "huggingface.co/your-username/private-edit-lora",
      "hf_api_token": "hf_xxxxxxxxxxxxxxxxxxxx",
      "lora_scale": 1.2
    }
  }'

Parameters

Required Parameters

ParameterTypeDescription
promptstringText prompt describing the edit. Refer to images as "image 1", "image 2", etc.

Image Parameters

ParameterTypeDefaultDescription
imagesarray of stringsArray of image URLs. For editing tasks, provide the main image as the first image

LoRA Parameters

ParameterTypeDefaultDescription
lora_weightsstring-HuggingFace URL to LoRA weights. Format: huggingface.co/<owner>/<model-name>[/<lora-weights-file.safetensors>]
lora_scalenumber1How strongly to apply the LoRA. Range: -1 to 3
hf_api_tokenstring-HuggingFace API token for accessing private LoRAs

Generation Parameters

ParameterTypeDefaultDescription
turbobooleantrueEnable faster optimizations. Set to false for complex tasks requiring more precision
aspect_ratiostring"match_input_image"Output aspect ratio. Options: "match_input_image", "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"
seedintegerrandomRandom seed for reproducible generation
disable_safety_checkerbooleanfalseDisable safety checker for generated images