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​
- flux-lora-trainer-fast - Train custom LoRA models (asynchronous)
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 modeltrigger_word: Word to activate the LoRA model in promptsdataset_url: Direct URL to your training dataset. The dataset should be a ZIP archive containing JPEG imagestraining_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_KEYenvironment 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​
- Use high-quality training images
- Choose appropriate training steps (typically 1000-2000)
- Use meaningful trigger words
- Organize your dataset properly - ensure it's a ZIP archive with JPEG images
- Test the model after training