Skip to main content

LoRA Training Guide 🧠

Overview​

This guide will help you understand and use LoRA (Low-Rank Adaptation) training with our models. LoRA allows you to fine-tune models for specific styles or subjects while maintaining efficiency.

Available Models​

Basic Usage​

The training process is asynchronous, so you'll need to use predict_async_task and poll for results. Here's a complete example:

import os

try:
import flymyai
except ModuleNotFoundError:
os.system('pip install flymyai')
import flymyai

payload = {
"lora_name": "random-lora",
"trigger_word": "random",
"dataset_url": "", # Direct URL to a ZIP archive with JPEG photos
"training_steps": 1000,
}

fma_client = flymyai.client(apikey=os.getenv("FLYMYAI_API_KEY", ""))

prediction_task = fma_client.predict_async_task(
model="flymyai/flux-lora-trainer-fast",
payload=payload,
)
print(f'Got prediction task: {prediction_task}')

while True:
try:
# Get result
result = fma_client.prediction_task_result(prediction_task)
break
except:
continue

print(f"Prediction completed: {result.inference_responses}")
print(result.inference_responses[0].output_data['model'][0]['data'])
print(result.inference_responses[0].output_data['config'][0]['data'])

Parameters​

  • lora_name: Name for your LoRA model
  • trigger_word: Word to activate the LoRA model in prompts
  • dataset_url: Direct URL to your training dataset. The dataset should be a ZIP archive containing JPEG images
  • training_steps: Number of training steps (typically 1000-2000)

Important Notes​

  • The training process is asynchronous and may take several minutes to complete
  • Make sure your FLYMYAI_API_KEY environment variable is set
  • The dataset should be a ZIP archive containing JPEG images for training
  • You'll need to poll for results using prediction_task_result() until the training completes

Best Practices​

  1. Use high-quality training images
  2. Choose appropriate training steps (typically 1000-2000)
  3. Use meaningful trigger words
  4. Organize your dataset properly - ensure it's a ZIP archive with JPEG images
  5. Test the model after training