Stable Diffusion : AUTOMATIC1111 - Developer Guide
Discover the ultimate developer guide for Stable Diffusion with AUTOMATIC1111. From installation and setup to performance optimization and custom script development, this guide walks you through everything you need to know to get the most out of AUTOMATIC1111 for Stable Diffusion.
Welcome to Stable Diffusion, your AI-powered image generation solution. As a developer, you can easily integrate AI-generated images into your projects using our simple API. Let's get started!
Prerequisites:
Before you begin, ensure you have the following prerequisites in place:
- Basic knowledge of AWS services (EC2 and CloudFormation).
- An active AWS account.
- Equipped with necessary vCPU quota for your selected instance type. Read how to increase AWS vCPU quota here: https://meetrix.io/articles/how-to-increase-aws-quota/
Launching the AMI
Step 1: Find and Select 'Stable Diffusion' AMI
- Log in to your AWS Management Console.
- Navigate to the "Stable-diffusion" in AWS Marketplace.
Step 2: Initial Setup & Configuration
- Click the "Continue to Subscribe" button.
- After subscribing, you will need to accept the terms and conditions. Click on "Accept Terms" to proceed.
- Please wait for a few minutes while the processing takes place. Once it's completed, click on "Continue to Configuration".
- Select the "CloudFormation Template for Stable Diffusion" as the fulfilment option and choose your preferred region on the "Configure this software" page. Afterward, click the "Continue to Launch" button.
- From the "Choose Action" dropdown menu in "Launch this software" page, select "Launch CloudFormation" and click "Launch" button.
Create CloudFormation Stack
Step1: Create stack
- Ensure the "Template is ready" radio button is selected under "Prepare template".
2. Click "Next".
Step2: Specify stack options
- Provide a unique "Stack name".
- Provide the "Admin Email" for SSL generation.
- For "DeploymentName", enter a name of your choice.
- Provide the domain name for "DomainName". (Stable-diffusion will automatically try to setup SSL based on provided domain name, if that domain hosted on Route53. Please make sure your turn domain name hosted on route53. If its unsuccessful then you have to setup SSL manually)
- Choose an instance type, "InstanceType" (Recommended: g4dn.xlarge).
- Select your preferred "keyName".
- Set "SSHLocation" as "0.0.0.0/0".
- Keep "SubnetCidrBlock" as "10.0.0.0/24".
- Keep "VpcCidrBlock" as "10.0.0.0/16".
- Click "Next".
Step3: Configure stack options
- Under "Stack failure options", select "Roll back all stack resources".
- click "Next".
Step4: Review
- Review and verify the details you've entered.
2. Tick the box that says, "I acknowledge that AWS CloudFormation might create IAM resources with custom names".
3. Click "Submit".
Afterward, you'll be directed to the CloudFormation stacks page.
You can easily locate the corresponding stack by searching for the stack name you entered in Step 2.
Please wait for 5-10 minutes until the stack has been successfully created. Afterward, you can click the "Refresh" button under the "Stacks" section.
Access Stable-diffusion Dashboard
Method1: Using public IP
Click the link located under the "DashboardUrlIp" section in the "Outputs" tab. This will direct you to the Stable-diffusion Dashboard.
Method2: Using Domain
- Copy the Public IP address indicated as "PublicIp" in the "Outputs" tab.
2. Go to AWS "Route 53" and navigate to "Hosted Zones".
3. Select the correct hosted zone and proceed.
4. Click on Create record button
5. Add Record name and then paste the copied "PublicIp" into the "value" textbox and click "Save".
6. Open a new tab and navigate to the "DashboardUrl" to access the Stable-diffusion dashboard.
(If you encounter a "502 Bad Gateway error", please wait for about 5 minutes before refreshing the page)
Access Stable-diffusion API
Go to https://<ip_address>/docs or https://<domain_name>/docs
You can find out the full API documentation here https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API
Generate SSL Manually
Stable-diffusion will automatically try to setup SSL based on provided domain name, if that domain hosted on Route53. If its unsuccessful then you have to setup SSL manually. Admin Email is acquiring for generate SSL certificates.
Step1: Point domain name into server IP
Follow steps 1 t0 5 in the "Method 2: Using Domain" section mentioned above, under the "Access Stable-diffusion Dashboard", to point domain name into the server's IP.
Step2: Log in to the server
- Copy the Public IP address indicated as "PublicIp" in the "Outputs" tab.
2. Open the terminal and go to the directory where your private key is located.
3. Paste the following command into your terminal and press Enter: ssh -i <your key name> ubuntu@<Public IP address>
.
3. Type "yes" and press Enter. This will log you into the server.
Step3: Generate SSL
Paste the following command into your terminal and press Enter:
sudo /root/certificate_generate_standalone.sh
Shutting Down
- Click the link labeled "Instance" in the "Resources" tab to access the EC2 instance, you will be directed to the Stable-diffusion instance in EC2.
2. Select the Stable-diffusion instance by marking the checkbox and click "Stop instance" from the "Instance state" dropdown. You can restart the instance at your convenience by selecting "Start instance".
Remove Stable-diffusion
Delete the stack that has been created in the AWS Management Console under 'CloudFormation Stacks' by clicking the 'Delete' button.
Upgrades
When there is an upgrade, we will update the product with a newer version. You can check the product version in AWS Marketplace. If a newer version is available, you can remove the previous version and launch the product again using the newer version. Remember to backup the necessary server data before removing.
Troubleshoot
- If you face the following error, please follow https://meetrix.io/articles/how-to-increase-aws-quota/ blog to increase vCPU quota.
2. If you face the following error (do not have sufficient <instance_type> capacity...) while creating the stack, try changing the region or try creating the stack at a later time.
3. If you face the below error, when you try to access the API dashboard, please wait 5-10 minutes and then try.
Conclusion
In conclusion, the Stable Diffusion Setup Guide gives you everything you need to easily start using this AI image generation tool. With its advanced features and easy-to-follow instructions, Stable Diffusion makes creating high-quality images simple. Whether you’re a beginner or an experienced creator, Stable Diffusion helps bring your creative ideas to life effortlessly. Get started today and experience just how easy AI-powered image creation can be!
Technical Support
Reach out to Meetrix Support (aws@meetrix.io) for assistance with Stable-diffusion issues.