sd-webui-controlnet
sd-webui-controlnet copied to clipboard
api is slow and make webui error
my pc has two gpu, I use one to start webui with controlnet, when i use python to invoke controlnet/txt2img, generate is very slow and often webui process in cmd did not respond,must press the Enter key manually to make the process respond. 3070 is 4.5it/s,but api is 1it/s, system and gpu monitor show 3070 is working 100%. below is my code to invoke api.
import base64
import time
import requests
import cv2
from base64 import b64encode
def readImage(path):
img = cv2.imread(path)
img = cv2.resize(img, None, fx=.2, fy=.2)
retval, buffer = cv2.imencode('.jpg', img)
b64img = b64encode(buffer).decode("utf-8")
return b64img
b64img = readImage("./img/pexels-dominique-roellinger-2586353.jpg")
class controlnetRequest():
def __init__(self, prompt):
self.url = "http://127.0.0.1:3070/controlnet/txt2img"
self.body = {
"prompt": "1boy",
"negative_prompt": "EasyNegative, extra fingers,fewer fingers,",
"seed": -1,
"steps": 20,
"cfg_scale": 7,
"width": 512,
"height": 512,
"sampler_index": "DPM++ 2M Karras",
"controlnet_input_image": [b64img],
"controlnet_module": 'depth',
"controlnet_model": 'control_depth-fp16 [400750f6]',
"controlnet_guidance": 1.0,
}
def sendRequest(self):
r = requests.post(self.url, json=self.body)
return r.json()
js = controlnetRequest("walter white").sendRequest()
for s in js['images']:
imgdata = base64.b64decode(s)
filename = str(time.time()) + '.jpg'
file = open(str(time.time()) + '.jpg', 'wb')
file.write(imgdata)
file.close()
time.sleep(1)
after i use run api and get result, i can't use webui in edge browser again, webui in cmd show this error:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat1 in method wrapper_addmm)
I think the problem in #329 should be solved first. I also encountered make webui error, but I can't solve it because I don't understand it. controlnet_lowvram: bool = Body(True, title='Controlnet Low VRAM'), lowvram should default to Fasle, which is the solution to "api is slow" of #329.
fixed in https://github.com/Mikubill/sd-webui-controlnet/commit/9468e02b610f88577907df8c4cdcd76076f09960
After the update, the code that originally called the api cannot return the depth image, and the generated result is completely independent of the image depth,I tried to reinstall the extension, but it still didn't work
After the update, the code that originally called the api cannot return the depth image, and the generated result is completely independent of the image depth,I tried to reinstall the extension, but it still didn't work
Same for me. I reported it here: https://github.com/Mikubill/sd-webui-controlnet/issues/347 - Wasn't sure if this was a separate issue from the one reported her.
https://github.com/Mikubill/sd-webui-controlnet/issues/347#issuecomment-1444647723 it works.