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-Syncheader. - 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.
Workflow
Section titled “Workflow”- Prepare training data - Create a ZIP file with at least 10 images and optional caption files
- Upload ZIP to accessible URL - Host your training data somewhere accessible (e.g., cloud storage)
- Start training - Submit async request (takes minutes to hours)
- Poll for completion - Check status until training succeeds
- Download output - Get the ZIP file within 30 minutes
- Upload to HuggingFace - Store the .safetensors file for permanent access
- Use with p-image-lora - Generate images using your trained LoRA
Quickstart
Section titled “Quickstart”Prepare Training Data
Section titled “Prepare Training Data”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).
Start Training (Async Only)
Section titled “Start Training (Async Only)”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"}Poll for Completion
Section titled “Poll for Completion”Training takes minutes to hours depending on steps. Poll periodically:
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"}Download Output Immediately
Section titled “Download Output Immediately”The output URL expires in ~30 minutes. Download the ZIP file immediately:
curl -o lora_output.zip "https://api.pruna.ai/v1/predictions/delivery/xezq/abc123.../lora_weights.zip"Upload to HuggingFace
Section titled “Upload to HuggingFace”Extract and upload the .safetensors file to HuggingFace:
unzip lora_output.zip# Upload lora.safetensors to huggingface.co/your-username/my-loraUse with p-image-lora
Section titled “Use with p-image-lora”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" } }'Parameters
Section titled “Parameters”Required Parameters
Section titled “Required Parameters”| Parameter | Type | Description |
|---|---|---|
| image_data | string (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) |
Optional Parameters
Section titled “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 |
| training_type | string | "balanced" | Type of training: "content" (subjects/characters), "style" (artistic styles), "balanced" (both) |
| default_caption | string | - | Default caption for images without .txt files. If not provided and captions are missing, training will fail |
Training Type Options
Section titled “Training Type Options”| Type | Use Case |
|---|---|
| content | Specific subjects, characters, objects, people |
| style | Artistic styles, color palettes, aesthetic treatments |
| balanced | General-purpose, mixed content and style |
Steps Guidelines
Section titled “Steps Guidelines”| Steps | Use Case | Expected Time |
|---|---|---|
| 100-500 | Quick tests, simple styles | Minutes |
| 500-1000 | Standard training | 10-30 minutes |
| 1000-2000 | High quality, complex | 30-60 minutes |
| 2000-5000 | Maximum quality | 1-2+ hours |