back to the blog

How to generate Images from Text using the Dreambooth API?

Written on . Posted in Stable Diffusion API.
How to generate Images from Text using the Dreambooth API?

Hey there! Are you ready to add a little extra pizazz to your projects? The DreamBooth API from Stable Diffusion API is here to help! This user-friendly API makes generating images from text a breeze, giving you the power to create unique and eye-catching images with ease. 

 

In this blog, we'll see how the DreamBooth API can help you create images that perfectly match your style and vision. Whether you're a seasoned designer or just looking for a new tool to play with, this blog is for you. 

 

Getting started with the Dreambooth API

Setting up account

The first step is to sign up and create an account to get the API key so that you can make the API calls. You can subscribe to a plan and get more out of this API service. Once you sign up you will see your dashboard and it looks like the below


 

stable diffusion

Click the ‘View’ button to see your API key. Once you get the API key, you can use any programming language to make API calls. In this tutorial, we will use python language to make the calls. We can use the requests module or the http.client method to make the API calls. 

 

Making the API calls

To make the API calls we use the requests module. The code to make an API call using the requests module is as follows

 

import requests
url ="https://stablediffusionapi.com/api/v3/dreambooth"
payload = {"key":"Your API key","model_id":"midjourney","prompt":"actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera","negative_prompt":"painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime", "width":"512","height":"512","samples":"1","num_inference_steps":"30","safety_checker":"no","enhance_prompt":"yes","guidance_scale":7.5
}
headers = {}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

 

In the above code, we first imported the requests module and created a variable for the URL of the dreambooth endpoint. In the next step, we created a payload that has all the parameters that the endpoint needs to generate the 

image. Then we created a request response to interact with the API endpoint. The output of the above code is as follows:

 

Output

We can see the link for the generated image. The image generated is shown below

stable diffusion api

This is how we generate an image using the dreambooth API. In the next section, we will take a look at the different parameters that this API uses.

 

Parameters for the Dreambooth API

 

The following parameters are available for this API

 

{
"key": Your API key
"model_id": The public model you want to use or your trained model
"prompt": The sentence you want to give to generate an image
"negative_prompt": This removes the unnecessary things you want to be removed from the image
"Width": The width of the image
"height": The height of the image
"samples": Number of images you want to generate
"num_inference_steps": Number of steps for inference(Minimum:1, Maximum:50)
"safety_checker": This is an NSFW filter.
"enhance_prompt": This enhances the prompt.
"seed": A random seed number of your Image
"guidance_scale": scale for classifier-free guidance
"webhook": A webhook to call the generated image
"track_id": A tracking id for your API call
}

 

Advantages of using the Dreambooth API for text-to-image generation

Versatility: With different models available for image generation, the API can be tailored to meet a wide range of needs.

High quality: The API uses state-of-the-art models and techniques to generate high-quality images that are optimized for a variety of use cases.

Cost-effective: The API offers a cost-effective alternative to building and maintaining an in-house image generation system.

 

Conclusion

In conclusion, the Dreambooth API is a powerful tool for anyone looking to generate high-quality images. With its versatility, ease of use, and cost-effectiveness, it offers a compelling alternative to building and maintaining an in-house image generation system. The addition of the DreamBooth API makes it an especially attractive option for businesses and organizations looking to create photorealistic images for a wide range of applications. 

 Start exploring today with ModelsLab: Sign up today!

If you're looking for a fast and easy way to generate high-quality images, consider giving the Stable Diffusion API a try. You'll be impressed by the results and the time and resources you'll save. So, take action now and sign up to experience the power of the Stable Diffusion API for yourself.