Skip to content

generativelabs/runpod-worker-a1111

Repository files navigation

A1111 Stable Diffusion | RunPod Serverless Worker

This is the source code for a RunPod Serverless worker that uses the Automatic1111 Stable Diffusion API for inference.

Important

A1111 1.9.0 API format has changed dramatically and is not backwards compatible. You will need to ensure that you check out the 2.5.0 release of this worker if you require backwards compatibility, and also ensure that you are using A1111 1.8.0 and not version 1.9.0.

Model

The model(s) for inference will be loaded from a RunPod Network Volume.

Extensions

This worker includes the following A1111 extensions:

  1. ControlNet
  2. ReActor
  3. ADetailer

Testing

  1. Local Testing
  2. RunPod Testing

Installing, Building and Deploying the Serverless Worker

  1. Install Automatic1111 Web UI on your Network Volume
  2. Building the Docker image
  3. Deploying on RunPod Serveless
  4. Frequently Asked Questions

RunPod API Endpoint

You can send requests to your RunPod API Endpoint using the /run or /runsync endpoints.

Requests sent to the /run endpoint will be handled asynchronously, and are non-blocking operations. Your first response status will always be IN_QUEUE. You need to send subsequent requests to the /status endpoint to get further status updates, and eventually the COMPLETED status will be returned if your request is successful.

Requests sent to the /runsync endpoint will be handled synchronously and are blocking operations. If they are processed by a worker within 90 seconds, the result will be returned in the response, but if the processing time exceeds 90 seconds, you will need to handle the response and request status updates from the /status endpoint until you receive the COMPLETED status which indicates that your request was successful.

RunPod API Examples

A1111 APIs

Helper APIs

Optional Webhook Callbacks

You can optionally Enable a Webhook.

Endpoint Status Codes

Status Description
IN_QUEUE Request is in the queue waiting to be picked up by a worker. You can call the /status endpoint to check for status updates.
IN_PROGRESS Request is currently being processed by a worker. You can call the /status endpoint to check for status updates.
FAILED The request failed, most likely due to encountering an error.
CANCELLED The request was cancelled. This usually happens when you call the /cancel endpoint to cancel the request.
TIMED_OUT The request timed out. This usually happens when your handler throws some kind of exception that does return a valid response.
COMPLETED The request completed successfully and the output is available in the output field of the response.

Serverless Handler

The serverless handler (rp_handler.py) is a Python script that handles the API requests to your Endpoint using the runpod Python library. It defines a function handler(event) that takes an API request (event), runs the inference using the model(s) from your Network Volume with the input, and returns the output in the JSON response.

Acknowledgements

Additional Resources

Community and Contributing

Pull requests and issues on GitHub are welcome. Bug fixes and new features are encouraged.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published