Skip to content
Developer Portal

p-image-trainer

Train custom LoRAs for text-to-image generation

p-image-trainer allows you to train custom LoRA (Low-Rank Adaptation) weights for use with the p-image-lora model. Train personalized styles, subjects, characters, or concepts using your own images.

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

Rate Limit: 5 requests per minute

Category: LoRA Training

Price: $1.80 / 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-lora, not with other models.
  1. Prepare training data - Create a ZIP file with at least 10 images and optional caption files
  2. Upload ZIP to accessible URL - Host your training data somewhere accessible (e.g., cloud storage)
  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-lora - Generate images using your trained LoRA

Create a ZIP archive with your training images:

training_data.zip
├── image1.jpg
├── image1.txt # Optional: caption for image1.jpg
├── image2.png
├── image2.txt # Optional: caption for image2.png
├── image3.jpg
└── ...

Use at least 10 images for good results. Caption files should match image names (e.g., photo.txt for photo.jpg).

Terminal window
curl -X POST 'https://api.pruna.ai/v1/predictions' \
-H 'Content-Type: application/json' \
-H 'apikey: YOUR_API_KEY' \
-H 'Model: p-image-trainer' \
-d '{
"input": {
"image_data": "https://your-storage.com/training_data.zip",
"steps": 1000,
"training_type": "balanced"
}
}'

Response:

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

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

Terminal window
curl -X GET 'https://api.pruna.ai/v1/predictions/status/training123xyz' \
-H 'apikey: YOUR_API_KEY'

When complete:

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

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

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

Extract and upload the .safetensors file to HuggingFace:

Terminal window
unzip lora_output.zip
# Upload lora.safetensors to huggingface.co/your-username/my-lora
Terminal window
curl -X POST 'https://api.pruna.ai/v1/predictions' \
-H 'Content-Type: application/json' \
-H 'apikey: YOUR_API_KEY' \
-H 'Model: p-image-lora' \
-d '{
"input": {
"prompt": "A portrait in my custom style",
"lora_weights": "huggingface.co/your-username/my-lora"
}
}'
ParameterTypeDescription
image_datastring (URI)URL to a ZIP archive with training images. Use at least 10 images. Can include text files for captions (e.g., photo.txt for photo.jpg)
ParameterTypeDefaultDescription
stepsinteger1000Number of training steps. Range: 100-5000, in increments of 100. More steps = longer training, potentially better results
learning_ratenumber0.0001Learning rate for training. Range: 0.00001-0.01. Lower = slower but more stable
training_typestring"balanced"Type of training: "content" (subjects/characters), "style" (artistic styles), "balanced" (both)
default_captionstring-Default caption for images without .txt files. If not provided and captions are missing, training will fail
TypeUse Case
contentSpecific subjects, characters, objects, people
styleArtistic styles, color palettes, aesthetic treatments
balancedGeneral-purpose, mixed content and style
StepsUse CaseExpected Time
100-500Quick tests, simple stylesMinutes
500-1000Standard training10-30 minutes
1000-2000High quality, complex30-60 minutes
2000-5000Maximum quality1-2+ hours