How to run a fine-tuned image generation SDXL model?

Fine-tuning the SDXL model for your use case is complicated. Deploying the finetuned SDXL model is even more complex. So, we created this step by step guide on how to run SDXL model.

Running a fine-tuned SDXL Model

Fine-tuning a model like SDXL (Stable Diffusion XL) for image generation has become increasingly popular for creating specialized and unique image outputs. In this blog, we will explore what SDXL fine-tuning entails, why it’s essential, and how you can easily fine-tune and deploy an SDXL model using the MonsterAPI platform.

What is SDXL Finetuning?

SDXL fine-tuning refers to the process of adjusting a pre-trained Stable Diffusion model to generate images that align more closely with a specific style, subject, or set of requirements. This process involves training the model on a custom dataset so it can better capture the desired visual nuances, whether that's a specific art style, brand identity, or any other visual element. MonsterAPI simplifies this process by providing a straightforward interface and tools that allow you to fine-tune SDXL models with minimal effort.

Why You Need to Finetune SDXL?

Out-of-the-box SDXL models are versatile and can generate a wide range of images, but they might not always produce results that perfectly align with your specific needs.

Fine-tuning allows you to adapt the model to better suit your particular use case, whether that's for commercial branding, personalized art, or even research applications. By fine-tuning SDXL, you gain more control over the output, ensuring that the generated images are more relevant and accurate to your specific domain.

How to Finetune SDXL on MonsterAPI?

MonsterAPI offers a user-friendly platform to fine-tune SDXL models. Here's a step-by-step guide to get you started:

  1. Sign Up and Credits: Sign up for your MonsterAPI account and claim 2,500 free credits. If you're already logged in, make sure you have at least 1,000 credits available to start a fine-tuning job.
  2. Access the Fine-Tuning Portal: After logging in, navigate to the "Fine-Tuning" portal from the left-side menu.
  3. Create a New Fine-Tuning Job: Click on "Create New Finetuning Job" and select "Finetune SDXL Model." You'll be prompted to choose a base model (like SDXL Base 1.0, Stable Diffusion 2, etc.).
  4. Dataset Selection: You can either upload a custom dataset as a zip file, provide an S3 presigned URL, or manually access a dataset through AWS credentials.
  5. Hyperparameter Configuration: Adjust hyperparameters like learning rate, steps, and resolution. These settings can be modified based on your specific requirements.
  6. Launch the Job: Once everything is configured, submit the job. The platform provides real-time tracking of the fine-tuning process, allowing you to monitor the progress and review the logs.

How to Run a Finetuned SDXL Model on MonsterAPI?

Deploying your fine-tuned SDXL model on MonsterAPI is as simple as the fine-tuning process:

  1. Access Deployment Section: Go to the deployment section on the MonsterAPI platform.
  2. Click to Deploy: Choose the "SDXL Dreambooth" option from the deployment choices.
  3. Finalize Deployment: Provide the paths for your base model and LoRA model (if applicable), and if your model is private or gated, enter your Hugging Face API key. Once deployed, you’ll receive a link to a Gradio-based user interface where you can interact with your model.

How to Run a Finetuned SDXL Model from an API?

To deploy SDXL Dreambooth, you can also use our API to run 

After fine-tuning your model, you can monitor the status and logs through the status link or directly on the fine-tuning page.

To deploy your fine-tuned SDXL model via API, use the following code snippet:

import requests

url = "https://api.monsterapi.ai/v1/deploy/sdxl-dreambooth"

payload = {
    "deployment_name": "optimistic_einstein",
    "basemodel_path": "stabilityai/stable-diffusion-xl-base-1.0",
    "hf_token": "YOUR_HF_TOKEN" # with read-write permissions.

}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Bearer YOUR_API_KEY"
}
response = requests.post(url, json=payload, headers=headers)

print(response.text)

Replace "YOUR_API_KEY" with your actual API key. You can also adjust the hf_token to point to the URL of your fine-tuned model. This provides a flexible way to deploy and test your image generation model programmatically.

Conclusion

Fine-tuning and deploying an SDXL model on MonsterAPI is a powerful way to customise your image generation tasks to fit your specific needs. With easy-to-follow steps and a user-friendly interface, MonsterAPI makes the complex process of fine-tuning accessible to everyone, from beginners to advanced users.

Whether you're working on art, design, or any visual project, fine-tuning SDXL on MonsterAPI can help you achieve more precise and meaningful results.

For more detailed guidance, visit the Documentation​.