Chaoses-Ib / ComfyScript

A Python frontend and library for ComfyUI
https://discord.gg/arqJbtEg7w
MIT License
432 stars 24 forks source link

ComfyScript unexpected behaviour with Fooocus Text #59

Open cihangoksu opened 5 months ago

cihangoksu commented 5 months ago

Hi all,

I've been trying to use the following workflow with comfyscript but somehow generated script fails to run: workflow: https://openart.ai/workflows/datou/fooocus-text/sl9YxQ1umL1N9aRHtldI

Even the following simple script follows cannot run successfully, and fails at FooocusStyles. ######################SCRIPT FAILING ################################### from comfy_script.runtime import load() from comfy_script.runtime.nodes import with Workflow():

_ = FooocusNegative('')

positive = FooocusPositive('a frozen brain is on fire, "LABEL"')
pipe = FooocusLoader('dreamshaperXL_lightningDPMSDE.safetensors', 'None', 0.5, 'joint', positive, '', '1024 x 1024', 1024, 1024, 1, None)
fooocus_styles = FooocusStyles('fooocus_styles')

###############################################################

image

Chaoses-Ib commented 5 months ago

I'll fix this later. A workaround is to run ComfyUI in a separate process, and then load('http://127.0.0.1:8188/').

cihangoksu commented 5 months ago

Tyu for quick reply :-) I basically opened a new terminal and run ComfyUI there, opened a browser with the workflow. Then in another terminal I ran the same script this time with load('http://127.0.0.1:8188/')

But I still get the same error. Did I somehow miss stg in the workaround you suggested actually?

Chaoses-Ib commented 5 months ago

Sorry, I misunderstood the problem. The real problem is FooocusStyles is an output type, and FooocusStyles_ is the actual node. So the fix should be changing FooocusStyles to FooocusStyles_ .

image

Looks like you got the code from the transpiler, which at the moment can't distinguish types/nodes with the same name (#30). I'll try to mitigate this problem in the future.

cihangoksu commented 5 months ago

Thank you very much for your help! I finally got it running, but only with the following required changes:

1) I had to force "run" function at Path/To/ComfyUI/custom_nodes/Fooocus_Nodes/py/prompt.py with the customized values (usually selected by UI) as try: values = [] if my_unique_id in prompt: if prompt[my_unique_id]["inputs"]["select_styles"]: values = prompt[my_unique_id]["inputs"]["select_styles"].split( ",") except: values = ["Fooocus V2","Fooocus Enhance","Fooocus Sharp","SAI Enhance","SAI Texture","SAI Digital Art"]

2) Somehow workflow ends up with an empty loras input for the "refresh_loras" function at Path/To/ComfyUI/custom_nodes/Fooocus_Nodes/py/modules/default_pipeline.py There I added a single line to fix this issue just before refreshing: if loras is None: loras = [] #cgoksu

Then it all worked fine, hurray! :-)

Chaoses-Ib commented 5 months ago

The first issue can be solved without the change by explicitly specifying the missing select_styles input:

FooocusStyles('fooocus_styles', select_styles='Fooocus V2,Fooocus Enhance,Fooocus Sharp,SAI Enhance,SAI Texture,SAI Digital Art')
# or: FooocusStyles('fooocus_styles', select_styles=','.join(["Fooocus V2","Fooocus Enhance","Fooocus Sharp","SAI Enhance","SAI Texture","SAI Digital Art"]))

The second one is a bug and now fixed. Thanks for your report.

cihangoksu commented 5 months ago

Tyuuu sounds much better indeed to add those as you suggested... Great to hear its now fixed! Keep up with the great work :-)