Chaoses-Ib / ComfyScript

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

grab workflow from image #49

Closed ghostsquad closed 5 months ago

ghostsquad commented 5 months ago

is there a way to grab/load the ComfyScript from an existing image?

Chaoses-Ib commented 5 months ago

Yes. Actually I have a widget for this. Unfortunately, there is a bug in the old versions of VS Code Notebook and one cannot drag files into it. It's fixed in the preview version and I'm using it. A stable version should be released now. I'll upload the code later. Though it still can't show syntax highlights properly in VS Code.

image

image

ghostsquad commented 5 months ago

cool thanks!

Chaoses-Ib commented 5 months ago

It's now uploaded. ComfyScript / ComfyUI / Stable Diffusion web UI images and workflow JSON are supported.

Docs: https://github.com/Chaoses-Ib/ComfyScript/blob/main/docs/UI/Solara.md

ghostsquad commented 5 months ago

love it! thanks

ghostsquad commented 5 months ago

mm... tried using it, got this:

Set state = <ResultState.RUNNING: 4> for key '2' (previous value was <ResultState.STARTING: 2>) (2804838762640)
No render phase triggered, already rendering
'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
Traceback (most recent call last):
  File "e:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\solara\hooks\use_thread.py", line 84, in runner
    value = f()
            ^^^
  File "e:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\solara\components\file_drop.py", line 75, in handle_file
    on_file(wired_files[0])
  File "E:\custom_nodes\ComfyScript\src\comfy_script\ui\solara\metadata.py", line 20, in on_file
    image = Image.open(bin)
            ^^^^^^^^^^^^^^^
  File "e:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\PIL\Image.py", line 3274, in open
    filename = os.path.realpath(os.fspath(fp))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen ntpath>", line 675, in realpath
  File "<frozen ntpath>", line 542, in normpath
  File "<frozen os>", line 826, in fsdecode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
Set state = <ResultState.ERROR: 5> for key '2' (previous value was <ResultState.RUNNING: 4>) (2804838612816)
Render phase: 2 'main' of _AppLayoutEmbed(children = ...)

Dragging that same image to the UI works fine.

Chaoses-Ib commented 5 months ago

Fixed. Forgot to test images after adding support for JSON.

ghostsquad commented 5 months ago

awesome! just tried it, and it works wonderfully. 🙌