Install NovelAI original backend (stable diffusion)

Install NovelAI original backend #

See this tutorial for details:  NovelAI original webpage UI + backend deployment tutorial

Hardware Requirements #

A Linux-based x86 device with an NVIDIA GPU with at least 11G of video memory.

It is recommended that the video memory is lower than 24G and do not try to use the official version front and back end.

Software Requirements #

  • NVIDIA CUDA Driver (CUDA Toolkit 11.6)
  • Docker 19+
  • nvidia-container-toolkit

Install Docker #

bash

curl -fsSL https://get.docker.com | bash

# 国内镜像

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

Driver related #

Install graphics driver

Use  nvidia-smi to view the status of the graphics card.

Use to  docker run --help | grep -i gpus confirm that nvidia-container-toolkit is installed successfully.

Run related #

Container Status #

Query the container ID docker ps

View container logs docker logs [Container ID]

"Application startup complete." appears, which means the program is ready

request API

Reference code, specifically refer to leak's front-end and back-end projects, and the sd-private\hydra-node-http\main.py

prompt In  masterpiece, best quality, the beginning corresponds to the original  Add Quality Tags option, it is not recommended to delete,  prompt just follow yourself directly later

uc Part corresponds to  Undesired Content , it is recommended to keep the default

sampler is the sampling method, optional plms/ddim/k_euler/k_euler_ancestral/k_heun/k_dpm_2/k_dpm_2_ancestral/k_lms

seed It is a seed, random an integer number, otherwise the same result will always be produced

n_samples represents how many pictures to generate

python

import requests
import json
import base64
import random

endpoint = "http://10.10.12.67/generate"
data = {
  "prompt": "masterpiece, best quality, brown red hair,blue eyes,twin tails,holding cat",
  "seed": random.randint(0,2**32),
  "n_samples": 1,
  "sampler": "ddim",
  "width": 512,
  "height": 768,
  "scale": 11,
  "steps": 28,
  "uc": "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
}


req = requests.post(endpoint, json=data).json()
output = req["output"]

for x in output:
  img = base64.b64decode(x)

  with open("output-" + str(output.index(x)) + ".png", "wb") as f:
    f.write(img)

Guess you like

Origin blog.csdn.net/weixin_63660670/article/details/130229425