Module: stable_diffusion_workflow
Inference workflow for Stable Diffusion pipelines.
This module contains the implementation of the Stable Diffusion Inference Workflow. The workflow is responsible for setting up the Stable Diffusion pipeline and performing inference on the input data.
Additional Installation
To use the Stable Diffusion pipeline, some additional packages need to be installed. You can install the required packages using the following command:
Example Usage
from infernet_ml.workflows.inference.stable_diffusion_workflow import (
StableDiffusionWorkflow,
SupportedPipelines,
)
def main():
# Initialize the Stable Diffusion Inference Workflow
workflow = StableDiffusionWorkflow(
pipeline=SupportedPipelines.STABLE_DIFFUSION,
model="stabilityai/stable-diffusion-2-1",
)
# Setup the workflow
workflow.setup()
# Perform inference on the input data
input_data = HFDiffusionInferenceInput(prompt="A photo of a cat")
output_data = workflow.run_model(input_data)
StableDiffusionWorkflow
Bases: BaseInferenceWorkflow
Inference workflow for Stable Diffusion pipelines.
Source code in src/infernet_ml/workflows/inference/stable_diffusion_workflow.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
__init__(pipeline, model=None, *args, **kwargs)
Initialize the Stable Diffusion Inference Workflow object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline |
SupportedPipelines
|
pipeline to be used for inference. Supported pipelines are "StableDiffusion" |
required |
model |
str
|
Stable Diffusion model to be used for inference. Defaults to "runwayml/stable-diffusion-v1-5" |
None
|
vae_type |
str
|
Type of VAE to be used for inference:
|
required |
torch_dtype |
str
|
Type of torch dtype to be used for inference. Defaults to "float32" |
required |
enable_xformers |
bool
|
Enable xformers memory efficient attention.
NOTE: requires |
required |
Source code in src/infernet_ml/workflows/inference/stable_diffusion_workflow.py
do_run_model(input_data)
Perform inference on the input data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_data |
dict
|
input data supported by the task to perform inference on |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, Any]
|
output data from the inference call |
Source code in src/infernet_ml/workflows/inference/stable_diffusion_workflow.py
do_setup()
Setup the inference client Returns: bool: True if setup is successful, False otherwise