AIGC (Artificial Intelligence Generated Content) refers to content generated by artificial intelligence. The 'text-to-image' technology uses AI to create images. Stable Diffusion is a diffusion model that generates images from text. It extracts latent variables from text using the CLIP model and generates images using the UNet model. The image quality is optimized through gradual diffusion and processing. This article guides you on how to quickly deploy the Stable Diffusion text-to-image model based on Function Compute and implement AI painting.
“ Prerequisites for Deployment
Before deploying Stable Diffusion, ensure you have activated the Function Compute service. Refer to the Function Compute documentation for details on activation.
“ Creating and Deploying the Stable Diffusion Application
1. Log in to the Function Compute console and click on 'Applications' in the left navigation bar.
2. If you are a first-time user or have no applications, you will automatically enter the application creation page. Otherwise, click 'Create Application'.
3. Choose to create an application from a template and select the 'AI Digital Painting stable-diffusion' template. Click 'Create Immediately'.
4. Configure the following settings:
- Deployment Type: Select 'Direct Deployment'.
- Role Name: If you are a first-time user, click 'Authorize' to configure role permissions (e.g., AliyunFCServerlessDevsRole).
- Region: Choose a region for deployment. If deployment fails, try switching to another region.
- Drawing Type: Select a drawing type (e.g., SD1.5, Anime Style, Realistic Style, or Lightweight Version).
5. Acknowledge the cost implications and click 'Agree and Continue Deployment'.
6. Wait for the deployment to complete (approximately 1-2 minutes).
“ Accessing the Stable Diffusion WebUI
1. Check the image acceleration readiness status of the GPU function 'sd'. Function Compute provides image acceleration to optimize the startup of large AI/GPU images.
2. In the application details page, click on the environment name (e.g., 'default environment').
3. Select the 'Environment Details' tab and click on the 'sd' function in the 'Resource Information' area.
4. In the 'Function Configuration' tab, under 'Environment Information', wait for the 'Image Acceleration Readiness Status' to become 'Available'.
5. Return to the application details page and click on the access domain in the 'Operation' column of the target environment. This will take you to the Stable Diffusion WebUI.
“ Generating Images with Text Prompts
Once in the Stable Diffusion WebUI, navigate to the 'Text to Image' tab. Enter your text prompt in the input box and click the 'Generate' button. The image will gradually become clearer, and a progress bar will show the generation progress and estimated remaining time.
“ Cost Considerations and Free Tier Usage
Deploying and using Stable Diffusion will incur costs for GPU resources, vCPU resources, memory resources, disk resources, public network traffic, and function calls. New users can claim a trial package, but it may not cover public network traffic and disk usage. If you generate 100 images, each requiring 5 MB of public network traffic and taking 5 seconds, the costs can be estimated as follows:
- Public Network Traffic: 0.50 yuan/GB * 500MB = 0.25 yuan
- Disk Usage: (Exceeding 512 MB) 0.00000175 yuan/GB*second * 5000 GB*seconds = 0.008 yuan
With a Function Compute configuration of GPU 16 GB, vCPU 8 cores, and memory 32 GB, the free trial can support approximately 1041 minutes of Stable Diffusion WebUI usage. Each image generation (assuming 5 seconds) can generate up to 12500 images. Remember to close the WebUI when not in use to conserve resources.
“ Deleting Resources
If you no longer need to use the Stable Diffusion application, delete the resources to avoid incurring further costs. Go to the Function Compute console, click on 'Applications', and delete the target application. Confirm the deletion and associated resources.
“ FAQ
Refer to the Function Compute documentation for troubleshooting common issues such as application startup failures, process freezes during image generation, inability to install plugins online, accessing the Stable Diffusion API, cost details, and alternative customization options.
We use cookies that are essential for our site to work. To improve our site, we would like to use additional cookies to help us understand how visitors use it, measure traffic to our site from social media platforms and to personalise your experience. Some of the cookies that we use are provided by third parties. To accept all cookies click ‘Accept’. To reject all optional cookies click ‘Reject’.
Comment(0)