olegchomp / TDComfyUI

TouchDesigner interface for ComfyUI
134 stars 9 forks source link

black bg before output on local network #9

Closed keebOo closed 3 months ago

keebOo commented 7 months ago

Hi, I have on lan a linux server with graphic card, ubuntu server, comfyUI.

When utilizing Tox, the null in the output (output 0 TOP result) displays a black background until the image is generated. Therefore, I implemented an update within the script to mitigate this issue. This update prevents the return of the image and also inhibits empty img generation at start.

For testing purposes, try installing ComfyUI on a local PC. If you have a high-performance machine, increase the steps to observe the process, comparing the results with and without the black background between each new output.

(Note: I'm using a Mac M1 Pro, and the LAN machine is an Ubuntu server 22.04 with a 3070.)

inside callback script1: script2_callbacks1 (comment on img and before return at the end)


def onSetupParameters(scriptOp):
    #img = numpy.zeros((2, 2, 3), dtype = 'uint8')
    data = op('ImageBytes').text

    try:
        image = ast.literal_eval(data)
        s = struct.calcsize(">II")
        data = memoryview(image)
        if len(data) > s:
            event, format = struct.unpack_from(">II", data)            
            if event == 1 and format == 2:
                image = data[s:]
                img = cv2.imdecode(numpy.frombuffer(image, numpy.uint8), -1)
                img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
                img = cv2.flip(img, 0)
                scriptOp.copyNumpyArray(img)
    except:
        pass

    #scriptOp.copyNumpyArray(img)
    return`
olegchomp commented 7 months ago

@keebOo thank you! Can't remember why i've added this. Gonna fix this in next release.

olegchomp commented 3 months ago

Fixed in TDComfyUI-v.1.0.4