{"id":5646695,"date":"2022-10-12T10:21:14","date_gmt":"2022-10-12T14:21:14","guid":{"rendered":"https:\/\/lightning.ai\/pages\/?p=5646695"},"modified":"2023-03-07T17:24:35","modified_gmt":"2023-03-07T22:24:35","slug":"deploy-diffusion-models","status":"publish","type":"post","link":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/","title":{"rendered":"How to Deploy Diffusion Models"},"content":{"rendered":"<h2>Diffusion Models in Production<\/h2>\n<h3><span style=\"color: #763ae0;\"><em>tl;dr<\/em><\/span> In this tutorial, you\u2019ll learn how to deploy diffusion models at scale and build a text-to-image generator<\/h3>\n<p>Today, we released <a href=\"https:\/\/lightning.ai\/muse\/view\/null\"><strong><span style=\"color: #7345e4;\">Muse<\/span><\/strong><\/a>: an entirely open-source text-to-image generator built on Stable Diffusion, and a blueprint for building intelligent cloud applications based on diffusion models. <a href=\"https:\/\/lightning.ai\/muse\/view\/null\"><span style=\"color: #7345e4;\"><strong>Give it a try!<\/strong><\/span><\/a><\/p>\n<p>If you\u2019re a part of the AI community, then chances are you\u2019ve probably seen the dizzying speed at which diffusion models (and their applications) are being developed. Diffusion models \u2014 a subcategory of deep generative models \u2014 are made up of forward and reverse diffusion stages to generate data similar to the data on which they\u2019re trained. At Lightning, we provide a way to deploy diffusion models at scale, which we cover below.<\/p>\n<p>A recent (and open-source) example of a diffusion model is Stability AI\u2019s <strong><span style=\"color: #773fe6;\"><a style=\"color: #773fe6;\" href=\"https:\/\/stability.ai\/blog\/stable-diffusion-public-release\">Stable Diffusion<\/a><\/span><\/strong>, a text-to-image model that produces high-fidelity images by using 10 GB of VRAM on consumer GPUs to generate a 512x512px image in just a few seconds.<\/p>\n<p>These models are groundbreaking, but deploying them continues to be a bottleneck. Below, we show you how we built a React UI as well as a model server with FastAPI in order to deploy these models easily and quickly with a Lightning App.<\/p>\n<p>In the following sections, we discuss the process of building our first version of Muse, the challenges we faced, and the steps we took to solve them.<\/p>\n<h2><\/h2>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2><a href=\"https:\/\/lightning.ai\/muse\/view\/null\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5646706\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23.png\" alt=\"\" width=\"3490\" height=\"2010\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23.png 3490w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-300x173.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-1024x590.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-1536x885.png 1536w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-2048x1180.png 2048w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-1920x1106.png 1920w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-600x346.png 600w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/image-23-600x346@2x.png 1200w\" sizes=\"(max-width: 3490px) 100vw, 3490px\" \/><\/a><\/h2>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Deploying Stable Diffusion with FastAPI and LightningApp<\/h2>\n<p><span class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-enable-hover\" data-token-index=\"0\" data-reactroot=\"\">We implemented a <code>StableDiffusionServe<\/code><\/span><span class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-enable-hover\" data-token-index=\"2\" data-reactroot=\"\">\u00a0class as a <\/span><span style=\"color: #773fe6;\"><strong><a class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-link-token notion-enable-hover\" style=\"color: #773fe6;\" href=\"https:\/\/lightning.ai\/lightning-docs\/core_api\/lightning_work\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-token-index=\"3\" data-reactroot=\"\"><span class=\"link-annotation-unknown-block-id--637920111\">Lightning Work<\/span><\/a><\/strong><\/span><span class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-enable-hover\" data-token-index=\"4\" data-reactroot=\"\">. <span class=\"mui_tooltip\"><span class=\"tooltip_wrap\"><img decoding=\"async\" width=\"12.5\" height=\"12.5\" alt=\"tooltip icon\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/themes\/lightning-wp\/assets\/images\/tooltip.svg\"><span class=\"tooltip_content\">Work is a building block for long-running jobs. Use it to download data or train and serve a model.<\/span><\/span><\/span> <\/span><\/p>\n<p><span class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-enable-hover\" data-token-index=\"4\" data-reactroot=\"\">This Work downloads the Stable Diffusion checkpoint, loads the model, and defines a REST endpoint that returns a base64 image based on the given prompt<\/span>:<\/p>\n<script src=\"https:\/\/gist.github.com\/381deedc44164d9c80780aab448029bc.js\"><\/script>\n<p>The first version of Muse was a simple web UI for a text to image generator that we implemented using React. One feature we added at the beginning of our iteration process was a toggle that swaps between images generated quickly, and images generated slightly slower but with the added benefit of additional quality. Because Stable Diffusion accepts <span class=\"discussion-id-829e0a8a-f886-4c2b-8416-c4462e7d8b96 notion-enable-hover\" data-token-index=\"0\" data-reactroot=\"\"><code>number of inference steps<\/code><\/span> as an argument, we use 50 steps for our higher-quality mode, and 25 for our faster option.<\/p>\n<p>Once we had completed our simple demo of this Stable Diffusion deployment, we integrated it into our Slack workspace in order to have some fun (we show you how to do this below).<\/p>\n<p>As members of our team started generating more and more images, however, we observed that the model server reached its limit with just 10 concurrent users. Lightning Apps are intended to be more than simple demos \u2014 instead, they offer a scalable and reusable way to deploy large models. We therefore experimented with several methods to scale the model serving such that it would handle a burst of hundreds of concurrent users.<\/p>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Autoscaling the Model Servers<\/h2>\n<p>One way to scale the concurrency is to run multiple model servers in parallel. We implemented a Load Balancer, again with FastAPI, which sends the request to the model servers in a <strong><span style=\"color: #773fe6;\"><a style=\"color: #773fe6;\" href=\"https:\/\/en.wikipedia.org\/wiki\/Round-robin_scheduling\">round-robin<\/a><\/span><\/strong> fashion.<\/p>\n<p>The goal here was to automatically scale the model servers based on the request traffic. We implemented an <code>autoscale<\/code> function that runs at a time interval (30 seconds) and checks the number of requests on the server. Then, based on the threshold value, it will add or remove a worker:<\/p>\n<script src=\"https:\/\/gist.github.com\/90a38608d8951038e08c470f4d07c31f.js\"><\/script>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Dynamic Batching<\/h2>\n<p>After implementing autoscaling, we noticed that our model was not processing client requests in parallel, which amounts to a waste of GPU resources. In order to increase throughput, aggregate requests, and process them on each of the model servers, we implemented dynamic batching in the load balancer. Implementing dynamic batching and more servers resulted in scaling Muse&#8217;s performance from being able to handle less than 5 to a burst of over 300 concurrent users.<\/p>\n<p>We ran performance tests on our server with and without batching with a different number of model servers.<\/p>\n<div id=\"attachment_5646700\" style=\"width: 1170px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5646700\" class=\"wp-image-5646700 size-full\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Muse-Batching.png\" alt=\"\" width=\"1160\" height=\"600\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Muse-Batching.png 1160w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Muse-Batching-300x155.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Muse-Batching-1024x530.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Muse-Batching-600x310.png 600w\" sizes=\"(max-width: 1160px) 100vw, 1160px\" \/><p id=\"caption-attachment-5646700\" class=\"wp-caption-text\">Muse performance based on batching<\/p><\/div>\n<p>The load balancer waits for a few seconds to aggregate client requests and sends them as a batch to the model server, thus processing multiple requests in parallel.<\/p>\n<p>To implement the dynamic batching, we put the requests in a queue with a unique id. This queue is consumed by a <span style=\"color: #773fe6;\"><strong><a style=\"color: #773fe6;\" href=\"https:\/\/docs.python.org\/3\/library\/asyncio-task.html#coroutines\">Python coroutine<\/a><\/strong><\/span> that waits to aggregate the requests. Once the batch is full or the wait timeout has been reached, it will send the aggregated requests to a model server and the response will be published in a dictionary with the unique id as a key.<\/p>\n<script src=\"https:\/\/gist.github.com\/c4f5b7ec2ba9fc48971bb5cdc6e1eb45.js\"><\/script>\n<p>After implementing autoscaling and dynamic batching, we were able process a significantly larger amount of requests in parallel and scale out based on the traffic.<\/p>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Turn your App into a Slackbot<\/h2>\n<p>In this section, we\u2019ll show you how to share your deployed diffusion model as a Slackbot. One of our Lightning Components is a <strong><span style=\"color: #773fe6;\"><a style=\"color: #773fe6;\" href=\"https:\/\/github.com\/Lightning-AI\/LAI-slack-command-bot-Component\">Slack Command Bot<\/a> <\/span><\/strong>that you can install in your workspace to send AI-generated art in a channel of your choice. Our Slack Command Bot Component provides an easy way to enable interactivity with Slack\u2019s slash commands.<\/p>\n<p>Once you\u2019ve install the Slackbot, simply type <code>\/muse &lt;PROMPT&gt;<\/code> and send the message in a channel where Muse Bot has been added. The bot will post an image generated with your prompt.<\/p>\n<div id=\"attachment_5646701\" style=\"width: 1506px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5646701\" class=\"size-full wp-image-5646701\" src=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo.png\" alt=\"\" width=\"1496\" height=\"674\" srcset=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo.png 1496w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo-300x135.png 300w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo-1024x461.png 1024w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo-600x270.png 600w, https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/MuseDemo-600x270@2x.png 1200w\" sizes=\"(max-width: 1496px) 100vw, 1496px\" \/><p id=\"caption-attachment-5646701\" class=\"wp-caption-text\"><a href=\"https:\/\/github.com\/Lightning-AI\/LAI-slack-command-bot-Component\">Try Muse in your Slack workspace!<\/a><\/p><\/div>\n<p>This component requires you to inherit the <code>SlackCommandBot<\/code> class and implement <code>handle_command(...)<\/code> method. For our purposes, we will implement the <code>handle_command<\/code> to post image generated using the prompt.<\/p>\n<p>We send the prompt to the Load balancer with a REST API and use the response base64 image for posting to Slack:<\/p>\n<script src=\"https:\/\/gist.github.com\/e86b52ac81d6a048b4a1eb07b15993eb.js\"><\/script>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Wrap-up<\/h2>\n<p>We scaled this diffusion model deployment from less than 5 users to 300 concurrent users with Autoscaling and Dynamic batching. We implemented this in pure Python and deployed it quickly and easily with a Lightning App. It manages cloud provisioning, GPU instance selection, disk allocation and other infrastructure challenges that get in the way of deploying diffusion models at scale.<\/p>\n<h2 style=\"text-align: center;\">\u00b7 \u00b7 \u00b7<\/h2>\n<h2>Why did we build this?<\/h2>\n<p>The internet\u2019s full of text-to-image generators (and now, even text-to-video!). So, you might be asking yourself, why did we spend time developing our own?<\/p>\n<p>Muse isn\u2019t just another image generator \u2014 we think of it like a blueprint. Not just for other image generators, but for all kinds of cloud applications powered by AI. We built Muse to show you what Lightning can do, and, even more importantly, what you can do with Lightning. Because Muse is open-source, you can use the code for inspiration on future projects just like this one. All you need to do is select &#8220;Clone &amp; Run&#8221; to open an instance of Muse on your own Lightning account (think of this like cloning a repo!). From there, you can adjust the code however you&#8217;d like.<\/p>\n<p>Normally, building distributed applications (apps that can run and store information on multiple machines) is hard. Lightning does the heavy lifting for you, so all you have to focus on is whatever you\u2019re trying to build. Lightning Apps (like Muse!) define a machine learning workflow that can run on your computer <em><strong>or<\/strong><\/em> <strong><span style=\"color: #783fe6;\"><a style=\"color: #783fe6;\" href=\"https:\/\/lightning.ai\/lightning-docs\/levels\/basic\/level_3.html\">the cloud<\/a><\/span><\/strong>, entirely at your discretion. It\u2019s as easy as adding a single flag to your code.<\/p>\n<p>They\u2019re powerful, too &#8211; you can have multiple Lightning Works (<span style=\"color: #773fe6;\"><strong><a style=\"color: #773fe6;\" href=\"https:\/\/lightning.ai\/lightning-docs\/core_api\/lightning_work\/\">one of the building blocks<\/a><\/strong><\/span> of a Lightning App) <span style=\"color: #773fe6;\"><strong><a style=\"color: #773fe6;\" href=\"https:\/\/lightning.ai\/lightning-docs\/workflows\/run_work_in_parallel.html\">run in parallel<\/a><\/strong><\/span>, so that even long-running workloads like model training or deployment can run a Work even while the rest of the Lightning App continues to execute.<\/p>\n<p>There you have it! Muse is all about inspiration, whether that\u2019s for art or distributed cloud applications. In our eyes, those are one and the same.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Diffusion Models in Production tl;dr In this tutorial, you\u2019ll learn how to deploy diffusion models at scale and build a text-to-image generator Today, we released Muse: an entirely open-source text-to-image generator built on Stable Diffusion, and a blueprint for building intelligent cloud applications based on diffusion models. Give it a try! If you\u2019re a part<a class=\"excerpt-read-more\" href=\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\" title=\"ReadHow to Deploy Diffusion Models\">&#8230; Read more &raquo;<\/a><\/p>\n","protected":false},"author":16,"featured_media":5646699,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[41],"tags":[96,115,112,97,113,114],"glossary":[],"acf":{"additional_authors":false,"hide_from_archive":false,"content_type":"Blog Post","custom_styles":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Deploy Diffusion Models - Lightning AI<\/title>\n<meta name=\"description\" content=\"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Deploy Diffusion Models - Lightning AI\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\" \/>\n<meta property=\"og:site_name\" content=\"Lightning AI\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-12T14:21:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-07T22:24:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1740\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"JP Hennessy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:site\" content=\"@LightningAI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JP Hennessy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\"},\"author\":{\"name\":\"JP Hennessy\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\"},\"headline\":\"How to Deploy Diffusion Models\",\"datePublished\":\"2022-10-12T14:21:14+00:00\",\"dateModified\":\"2023-03-07T22:24:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\"},\"wordCount\":1333,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png\",\"keywords\":[\"ai\",\"deploy\",\"diffusion models\",\"ml\",\"stability ai\",\"stable diffusion\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\",\"url\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\",\"name\":\"How to Deploy Diffusion Models - Lightning AI\",\"isPartOf\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png\",\"datePublished\":\"2022-10-12T14:21:14+00:00\",\"dateModified\":\"2023-03-07T22:24:35+00:00\",\"description\":\"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.\",\"breadcrumb\":{\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png\",\"width\":1740,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lightning.ai\/pages\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Deploy Diffusion Models\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lightning.ai\/pages\/#website\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"name\":\"Lightning AI\",\"description\":\"The platform for teams to build AI.\",\"publisher\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lightning.ai\/pages\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lightning.ai\/pages\/#organization\",\"name\":\"Lightning AI\",\"url\":\"https:\/\/lightning.ai\/pages\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"contentUrl\":\"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png\",\"width\":1744,\"height\":856,\"caption\":\"Lightning AI\"},\"image\":{\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/LightningAI\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6\",\"name\":\"JP Hennessy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g\",\"caption\":\"JP Hennessy\"},\"url\":\"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Deploy Diffusion Models - Lightning AI","description":"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/","og_locale":"en_US","og_type":"article","og_title":"How to Deploy Diffusion Models - Lightning AI","og_description":"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.","og_url":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/","og_site_name":"Lightning AI","article_published_time":"2022-10-12T14:21:14+00:00","article_modified_time":"2023-03-07T22:24:35+00:00","og_image":[{"width":1740,"height":900,"url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png","type":"image\/png"}],"author":"JP Hennessy","twitter_card":"summary_large_image","twitter_creator":"@LightningAI","twitter_site":"@LightningAI","twitter_misc":{"Written by":"JP Hennessy","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#article","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/"},"author":{"name":"JP Hennessy","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6"},"headline":"How to Deploy Diffusion Models","datePublished":"2022-10-12T14:21:14+00:00","dateModified":"2023-03-07T22:24:35+00:00","mainEntityOfPage":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/"},"wordCount":1333,"commentCount":0,"publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"image":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png","keywords":["ai","deploy","diffusion models","ml","stability ai","stable diffusion"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/","url":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/","name":"How to Deploy Diffusion Models - Lightning AI","isPartOf":{"@id":"https:\/\/lightning.ai\/pages\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage"},"image":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage"},"thumbnailUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png","datePublished":"2022-10-12T14:21:14+00:00","dateModified":"2023-03-07T22:24:35+00:00","description":"In this tutorial, we show you how to deploy diffusion models like Stable Diffusion in production as ready-to-use apps.","breadcrumb":{"@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#primaryimage","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2022\/10\/Deploy-Diffusion-Models.png","width":1740,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/lightning.ai\/pages\/community\/tutorial\/deploy-diffusion-models\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lightning.ai\/pages\/"},{"@type":"ListItem","position":2,"name":"How to Deploy Diffusion Models"}]},{"@type":"WebSite","@id":"https:\/\/lightning.ai\/pages\/#website","url":"https:\/\/lightning.ai\/pages\/","name":"Lightning AI","description":"The platform for teams to build AI.","publisher":{"@id":"https:\/\/lightning.ai\/pages\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lightning.ai\/pages\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lightning.ai\/pages\/#organization","name":"Lightning AI","url":"https:\/\/lightning.ai\/pages\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/","url":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","contentUrl":"https:\/\/lightningaidev.wpengine.com\/wp-content\/uploads\/2023\/02\/image-17.png","width":1744,"height":856,"caption":"Lightning AI"},"image":{"@id":"https:\/\/lightning.ai\/pages\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/LightningAI"]},{"@type":"Person","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/2518f4d5541f8e98016f6289169141a6","name":"JP Hennessy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lightning.ai\/pages\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28ade268218ae45f723b0b62499f527a?s=96&d=mm&r=g","caption":"JP Hennessy"},"url":"https:\/\/lightning.ai\/pages\/author\/jplightning-ai\/"}]}},"_links":{"self":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5646695"}],"collection":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/comments?post=5646695"}],"version-history":[{"count":0,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/posts\/5646695\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media\/5646699"}],"wp:attachment":[{"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/media?parent=5646695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/categories?post=5646695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/tags?post=5646695"},{"taxonomy":"glossary","embeddable":true,"href":"https:\/\/lightning.ai\/pages\/wp-json\/wp\/v2\/glossary?post=5646695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}