Quickstart

Installation

To install Diffusechain, use the following pip command:

pip install diffusechain

For more details and alternative installation options, refer to our comprehensive installation guide.

Environment Setup

Using DiffuseChain often involves integrating with various models and APIs. For this guide, we will demonstrate how to use DiffuseChain with Automatic1111's API.

Automatic1111

Automatic1111 Setup

First, ensure you have an instance of Automatic1111 running. If you haven't set it up yet, follow the Setup Guide to get started. Once your instance is running, make note of the base URL provided by Automatic1111.

Now, let's integrate Automatic1111 with DiffuseChain. In your Python script, import the Automatic1111 class from diffusechain:

from diffusechain import Automatic1111

Next, initialize the API instance with the base URL you obtained from Automatic1111:

api = Automatic1111(baseurl='http://your-automatic1111-url:port-number')
# api = Automatic1111(baseurl='http://localhost:7860')
# Alternatively, you can use the host and port directly, and specify whether to use HTTPS:
# api = Automatic1111(host='your-automatic1111-url', port=7860, use_https=False)

Generating Your First Image

Now that the environment is set up, let's generate an image using DiffuseChain with the Automatic1111 API. For this example, we'll create an image based on the prompt "Elon Musk" while avoiding the negative prompts "ugly" and "out of frame."

result = api.txt2img(prompt="Elon musk",
                    negative_prompt="ugly, out of frame",
                    seed=-1,
                    cfg_scale=7,
                    steps=30,
                    )

Displaying and Saving the Image

To access and visualize the generated image, use the image attribute of the result object:

result.image

To save the image to a file, you can use the save method:

result.image.save('name_of_image.png')

Congratulations! You've successfully generated and saved your first image using Diffusechain and the Automatic1111 API.

If you encounter any issues or have any questions, feel free to seek support from our community or open an issue on GitHub. Happy generating!

Last updated