Skip to content

Instantly share code, notes, and snippets.

@varunshenoy
Created June 21, 2023 01:24
Show Gist options
  • Save varunshenoy/0146a65de2d4db3bad95c2e0e43a66a3 to your computer and use it in GitHub Desktop.
Save varunshenoy/0146a65de2d4db3bad95c2e0e43a66a3 to your computer and use it in GitHub Desktop.
This is an example of an Opendream serverless extension using Modal. Combined with Opendream, an extension using Modal allows you to run functions on GPUs while accessing Opendream through consumer hardware. See: https://modal.com/docs/guide/trigger-deployed-functions
@opendream.define_op
def superresolution(image_layer: ImageLayer, model_ckpt: str = "runwayml/stable-diffusion-v1-5", batch_size = 1, seed = 42, selected = 0, num_steps = 20, **kwargs):
import modal
# Use ControlNet + Tile preprocessor
f = modal.Function.lookup("diffuseqr", "ControlNet.run_inference")
image = f.call(Layer.pil_to_b64(image_layer.get_image()))[0]
image = Layer.b64_to_pil(image)
return ImageLayer(image=image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment