back to the blog

How to generate Images from Images using the Dreambooth API?

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

Welcome to the world of the image-to-image generation! Stable Diffusion API offers a cutting-edge API service called DreamBooth API, which allows you to generate custom images using existing images as a starting point. With DreamBooth API, you can take your image creation game to the next level and create eye-catching designs that truly stand out.

 

In this blog, we'll explore the capabilities of the DreamBooth API and how it can be used for image-to-image generation. You'll see how easy it is to generate unique images using the different models available. Whether you're a professional designer or just someone looking to add a personal touch to your projects, this API has something for everyone. This powerful API offers endless possibilities for image creation, so grab your creativity and let's get started!

 

Getting started with the Dreambooth API

Setting up Account

The first step is creating an account and getting the API key. Sign up here and get the API key. Your dashboard will look something like the one below

stable diffusion api

You can see the ‘View’ button, click it to see the API key. Once you get the API key, you can make the API calls to the endpoint to generate images. You can do this using multiple programming languages. In this tutorial, we will use the Python requests module to generate the images. 

 

Making the API calls

The code to use the requests module is shown below. 

 

import requests
url ="https://stablediffusionapi.com/api/v3/dreambooth/img2img"
payload = {"key": "Your API key","model_id": "your_model_id","prompt": "a cat sitting on a bench","negative_prompt": null,"init_image": "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png","width": "512","height": "512","samples": "1","num_inference_steps": "30","safety_checker": "no","enhance_prompt": "yes","guidance_scale": 7.5,"strength": 0.7,"seed": null,"webhook": null,"track_id": null
}

headers = {}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

 

In the above code, we first imported the requests module and gave the endpoint URL to make send the input parameters. In the next step, we created a payload that has all the parameters for the input. After this, we created a response request to call the API and printed the result. The output of the above code looks like this

 

Output

You can see the URL of the generated image. Click that to see the generated image. The input image we gave is this

stable diffusion

The output image that we got is shown below

image to image

We replaced the dog in the image with a cat. This is how this endpoint works. Next, we will see the different parameters that this endpoint uses.

 

Parameters for the Dreambooth API img2img Endpoint

 

The following parameters are available for this endpoint

 

{
 "key": Your API key,
 "model_id": The model id on which you want to train
 "prompt": a sentence that tells the model to generate the image
 "negative_prompt": sentence to exclude things you don’t want in the output image
 "init_image": Initial image which needs to be changed
 "width": Width of the Image
 "height": Height of the Image
 "samples": Number of images to be generated
 "num_inference_steps": Number of steps for Inference
 "safety_checker": NSFW filter
 "enhance_prompt": Boolean value. This enhances the prompt if set to ‘yes’
 "guidance_scale": Scale for classifier-free guidance
 "strength": Prompt Strength when using the init image
 "seed": A random seed for the image generation
 "webhook": A webhook to call the generated image
 "track_id": A tracking id that tracks the API calls
}

 

Advantages of using the Dreambooth API img2img Endpoint

The main advantages of using this API are

  • Customization: The DreamBooth API allows you to generate custom images using existing images as a starting point, giving you the power to create designs that perfectly match your style and vision.
  • Efficiency: With this API, you can create high-quality images in a matter of seconds, saving you time and effort compared to traditional image creation methods.
  • Versatility: The DreamBooth API offers different models for image generation, allowing you to choose the best model for your specific needs and ensuring that you get the best possible results.

Conclusion

In conclusion, the DreamBooth API from Stable Diffusion API is a powerful tool for anyone looking to generate custom images. Whether you're a seasoned professional or just starting out, the DreamBooth API has something to offer. 

 

So why not give it a try? Sign up for the DreamBooth API today and experience the power of image-to-image generation for yourself. You'll be amazed at the results you can achieve with this cutting-edge technology. So go ahead, unleash your creativity, and bring your image ideas to life!