Image Generator Python client
The ImageGenClient
class specializes in supporting image generation in your application, and guiding what options are available to modify your outputs. It will return a list of all images using the ImageGeneration
type. It allows you to use Stable Diffusion XL for text to image and image to image use cases, and set parameters and prompts either with weighted prompts with the prompt
field or human-readable descriptions using prompt_2
.
This guide will walk you through a text to image example, and then we will use the resulting image to demonstrate the image to image use case.
Requirements
- First, create an OctoAI API token.
- Then, complete Python SDK Installation & Setup..
- If you use the
OCTOAI_TOKEN
envvar for your token, you can instantiate the image_gen client withclient = OctoAI().image_gen
- If you use the
Simple Text to Image Generation Example
After running this simple prompt, you should hopefully have an output somewhat similar to the image below:
A good start and in our next example, we’ll use more features to help guide our outputs.
Text to Image Generation Example
One of the simplest ways to customize your outputs is a style_preset
, negative_prompt
, loras
, and through image generation model selection.
Much more realistic! Now that we have our cinematic poodle, let’s go ahead and use this image as part of an image-to-image workflow.
Image to Image Generation Example
Image to Image Generation lets you use a base image, in our case the above pretty_poodle.jpeg
to shape the feel of your outputs image. In our case, we’d expect some focal point in the center, and a blurred, bright background, but otherwise our output can look anywhere from completely different or quite similar depending on our prompt. In this case, let’s go for a complete different style of outputs and stray from the usual theme of poodles to a corgi in the rain.