Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to add auto-transpile to create a python script for running? #43

Closed
gaoming714 opened this issue Jun 13, 2024 · 2 comments
Labels
enhancement New feature or request transpiler

Comments

@gaoming714
Copy link

gaoming714 commented Jun 13, 2024

I know python -m comfy_script.transpile workflow.json can create script

    model, clip, vae = CheckpointLoaderSimple('realisticVisionV60B1_v51HyperVAE.safetensors')
    conditioning = CLIPTextEncode('beautiful scenery nature glass bottle landscape, , purple galaxy bottle,', clip)
    conditioning2 = CLIPTextEncode('text, watermark', clip)
    latent = EmptyLatentImage(512, 512, 1)
    latent = KSampler(model, 156680208700286, 20, 8, 'euler', 'normal', conditioning, conditioning2, latent, 1)    
    image = VAEDecode(latent, vae)
    SaveImage(image, 'ComfyUI')

then I will add these codes to make it run

from comfy_script.runtime import *
load()
from comfy_script.runtime.nodes import *
with Workflow():

Is it possible to make a auto-transpile to convert workflow into a script.py , so I can convert it and then run without editting any code?

@Chaoses-Ib
Copy link
Owner

Chaoses-Ib commented Jun 13, 2024

It's now added. Example:

> python -m comfy_script.transpile tests\transpile\default.json --runtime
from comfy_script.runtime import *
load()
from comfy_script.runtime.nodes import *

with Workflow():
    model, clip, vae = CheckpointLoaderSimple('v1-5-pruned-emaonly.ckpt')
    conditioning = CLIPTextEncode('beautiful scenery nature glass bottle landscape, , purple galaxy bottle,', clip)
    conditioning2 = CLIPTextEncode('text, watermark', clip)
    latent = EmptyLatentImage(512, 512, 1)
    latent = KSampler(model, 156680208700286, 20, 8, 'euler', 'normal', conditioning, conditioning2, latent, 1)
    image = VAEDecode(latent, vae)
    SaveImage(image, 'ComfyUI')

Save the code to script.py:

> python -m comfy_script.transpile tests\transpile\default.json --runtime > script.py

@gaoming714
Copy link
Author

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request transpiler
Projects
None yet
Development

No branches or pull requests

2 participants