This article shows you how to deploy the Stable Diffusion V1.5 model and launch a WebUI application to use and debug the model.
Prerequisites
An OSS Bucket has been created. For more information, see Create a bucket in the console.
1. Access model details
Go to the Model Gallery page.
Log in to the PAI console.
In the upper-left corner, select a region.
In the left-side navigation pane, click Workspaces and then click the name of your workspace.
In the left-side navigation pane, choose Quick Start > Model Gallery.
On the Model Gallery page, search for and click the Stable_Diffusion_V1.5 model card.
2. Deploy and test the model
On the model details page, click Deploy in the upper-right corner. In the Deploy panel, select a deployment resource, such as
ecs.gn6e-c12g1.3xlarge. Use the default values for the other parameters.Click Deploy. In the Billing Notification dialog box, click OK.
The page is automatically redirected to the Service details page. In the Basic Information section, you can view the deployment status of the model service. When the Status changes to Running, the model service is successfully deployed.
In the upper-right corner of the service details page, click View Web App to launch the WebUI.
On the WebUI, test the model.
On the text-to-image tab, in the prompt area, enter the following text:
The eagle is flying in the sky, in the distance is the vast snow, and under the snow mountain is a grassland. Then, click Generate to view the inference result. Select the text-to-image tab and enter an English prompt, such asThe eagle is flying in the sky, in the distance is the vast snow, and under the snow mountain is a grassland, in the positive prompt text box. Set the sampling method to Euler a, sampling steps to 20, width and height to 512, CFG Scale to 7, and random seed to -1. Then, click the Generate button. The generated image is displayed in the output area on the right.
3. Fine-tune the model
Fine-tune the Stable Diffusion V1.5 model to customize its output for your specific use case.
Return to the model details page and click Fine-tune in the upper-right corner.
In the Train panel, expand the configuration sections to view or modify the following key configurations. Use the default values for the other parameters. For more information about the parameter configurations, see Model deployment and training.
Configuration
Description
Dataset Configuration
PAI provides a default dataset for this tutorial. Alternatively, prepare your own dataset as follows:
Prepare training data based on the training data format on the model details page. Refer to the sample dataset. The following is the directory structure of the training dataset:
|——img1.jpg |——img2.jpg |——... |——metadata.jsonlThe
metadata.jsonlfile is in the JSON Lines format. Thefile_namefield indicates the image file name, and thetextfield contains the text corresponding to the image. The following is a sample of themetadata.jsonlfile:{"file_name": "img1.jpg", "text": "cat"} {"file_name": "img2.jpg", "text": "penguin"} {"file_name": "img3.jpg", "text": "dragon"}Upload the training data to an OSS Bucket. For more information, see Upload files.
Update the training dataset. For more information, see Model deployment and training.
Hyperparameter configuration
Use the default value
standardfor the training_method parameter. Keep the default values for other parameters.Output Configuration
Set Model output path to an OSS Bucket path. For more information about how to create an OSS Bucket, see Quick start.
Click Train.
The page is automatically redirected to the Task details page.
After a training task runs successfully, you can click the Deploy button in the upper-right corner of the task details page to deploy the model. The model deployment process is the same as deploying a model directly. For more information, see II. Directly deploy and debug a model.