Home > Technology peripherals > AI > body text

How to implement AI image expansion function using PAI-DSW and SD WebUI

王林
Release: 2024-01-17 11:15:20
forward
528 people have browsed it

Tutorial Brief

In this tutorial, you will learn how to use Stable-Diffusion-WebUI to implement the AI ​​map expansion function in Alibaba Cloud Interactive Modeling (PAI-DSW).

With the continuous development of AIGC technology, AI image expansion has become an innovative gameplay. By giving the AI ​​a picture, the AI ​​is able to predict and supplement the image boundaries to generate larger-sized images. AI image enlargement can save useless photos and expand half-length photos into full-body photos, but sometimes overturns occur, and the resulting images make people laugh or cry.

This tutorial uses Stable Diffusion WebUI to implement the AI ​​image expansion function. The effect is shown below:

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

Based on this tutorial you can experience:

New users can receive free trial resources of the artificial intelligence platform PAI worth 10,000 yuan

Learn how to quickly create an interactive training and development environment on Alibaba Cloud.

Learn how to launch WebUI in DSW.

Learn how to implement AI image expansion function in DSW.

Use PAI-DSW to quickly start SD WebUI

1. Prepare environment and resources

1.1 Get the free trial rights of interactive modeling PAI-DSW

Go to the event page and receive the interactive modeling PAI-DSW product free trial resource package

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

  • For new users of interactive modeling PAI-DSW, Alibaba Cloud provides 5000CU*H free trial resources, which can be obtained directly on the event page (for trial rules, please refer to Alibaba Cloud Free Trial: https://free. aliyun.com/); or you can purchase the interactive modeling PAI-DSW resource package to participate in the event, purchase link: PAI-DSW 100CU*H resource package, price starts at 59 yuan; if you do not purchase the resource package, PAI-DSW will For billing, please refer to Alibaba Cloud product pricing for billing standards.

1.2 Create PAI-DSW instance

  1. Go to the artificial intelligence platform PAI console, link: https://pai.console.aliyun.com/
  2. Open artificial intelligence PAI and create a default workspace. See Provisioning and Creating a Default Workspace.
  3. In the artificial intelligence platform PAI console, select interactive modeling PAI-DSW, or click the link

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

4. Click to create an instance (as shown above)

5. Customize input instance name

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

6. Select the instance model, GPU category-ecs.gn6v-c8g1.2xlarge (supports resource package deduction), if there is no such model in stock, you can try changing the region;

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

7. Select the image, stable-diffusion-webui-develop:1.0.0-pytorch2.01-gpu-py310-cu117-ubuntu22.04

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

8. Click "Next"

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

9. Confirm [Resource Configuration] and [Mirror] as shown in the figure, click Create Instance;

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

10. Wait about 3-5 minutes, the instance status changes to "Running", and the instance creation is completed;

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

1.3 Open the tutorial file in DSW

  1. Click the instance you want to open Open under the Operation column to enter the PAI-DSW instance development environment.
  2. On the Launcher page of the Notebook tab, click Browse Gallery## under the Quick Start areaTool #, open the Gallery page

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

3. In the DSW Gallery page, search and find the

AI Image Expansion Artifact: Release Your Imagination tutorial, and click Open in DSW in the tutorial card.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

4. The folder "demos" appears on the right, click the "demos" folder, click the "stable_diffusion_inpaint" folder, click the "stable_diffusion_inpaint.ipynb" file, and open the prepared Notebook best practice tutorial. The specific steps are as follows As shown in the picture

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

5. Complete the above steps and successfully open the

AI image expansion tool: let your imagination run wild Notebook best practices.

1.4 Run tutorial file

    In the open tutorial file
  1. stable_diffusion_inpaint.ipynb file, you can directly see the tutorial text, and you can run each code snippet directly in the tutorial file. After successfully running a step command, run the next step command sequentially.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

2. This tutorial has a total of 3 running steps:

    Download stable-diffusion-webui open source library
  1. Download model
  2. Start WebUI
3. When step 3

Start WebUI is completed, click the URL link in the returned running details result to enter the WebUI page. You can then complete the AI ​​image enlargement on this page.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

2. Complete the deployment and start experiencing AI image expansion

In order to realize the ability of AI image expansion, the following configuration needs to be performed on the Stable Diffusion WebUI page.

2.1 Enter the drawing interface

Enter the graph generation interface,

Stable Diffusion model and VAE of the model can be kept as default.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

2.2 Basic configuration

Tushengtu configuration, complete image upload and Tushengtu parameter configuration. Please refer to the figure below for details.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

1.Zoom mode: Select fill.

2. Redraw amplitude: Select 1.0. — Generally speaking, the larger the redraw amplitude parameter, the lower the similarity between the generated image and the original image. However, when using controlnet inpaint to expand the image, it needs to be full.

3. Width and height: Fill in the size after expanding the image.

  • Please set the size according to the original image size and image enlargement requirements. Note that the proportions of the original image cannot remain the same when enlarging the image.
  • In this example, the width is set to 1024 and the height is 512. We look forward to seeing the result of horizontal extension of the image.

2.3 ControlNet configuration

Next, you need to configure ControlNet with the following parameters:

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

  • Select Enable, Upload independent control image and Pixel Perfect. The first two are to allow ControlNet to control the generation of images through images, and the latter are to improve the generation effect. Upload the same image as above here.
  • Controltype: Select partial redraw.
  • Preprocessor: Select inpaint_only.
  • Model: Select control_v11p_sd15_inpaint, which is the ControlNet expansion model of SD1.5.
  • ControlMode: It is more important to choose Controlnet.
  • Screen zoom mode: Select resize and fill.

2.4 Enter prompt to complete AI image expansion

According to personal preference, enter positive and negative prompts to complete AI image expansion. The following is an example for reference.

heart-shape balloons——Heart-shaped balloons

Christmas tree——Christmas tree

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

The theme of this event: After AI enlargement of the image, there is a tree in the image. After completing the AI ​​image expansion by the artificial intelligence platform PAI (PAI-DSW), please upload the works that match the theme of the event to the event page>> "Work with PAI, Play with AI Every Week" Issue 5: Use PAI-DSW to achieve AI image expansion function

3. Resource cleanup and follow-up

3.1 Cleanup

  • After the experiment is completed, you can go to the corresponding product console to stop or delete the instance (both operations are acceptable). Avoid the instance continuing to run, which will cause additional deductions after the free trial limit is exceeded.

基于 PAI-DSW 使用 SD WebUI 实现AI扩图功能

  • The instance will still be considered for use in the future>>Stop; the instance will no longer be used in the future>>Delete. Resource consumption will stop after successful stop.

3.2 Follow-up

During the trial validity period, you can continue to use DSW instances for model training and inference verification.

Original link: https://developer.aliyun.com/article/1417423?utm_content=g_1000388102

This article is original content of Alibaba Cloud and may not be reproduced without permission.

The above is the detailed content of How to implement AI image expansion function using PAI-DSW and SD WebUI. For more information, please follow other related articles on the PHP Chinese website!

source:sohu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template