https://github.com/christian-byrne/python-interpreter-node

Embed scripts into workflows. Alter the node's input/outputs with python. Debug live. ComfyUI OS

https://github.com/christian-byrne/python-interpreter-node

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary

Keywords

comfyui comfyui-nodes
Last synced: 6 months ago · JSON representation

Repository

Embed scripts into workflows. Alter the node's input/outputs with python. Debug live. ComfyUI OS

Basic Info
  • Host: GitHub
  • Owner: christian-byrne
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 35.7 MB
Statistics
  • Stars: 65
  • Watchers: 3
  • Forks: 11
  • Open Issues: 5
  • Releases: 0
Topics
comfyui comfyui-nodes
Created almost 2 years ago · Last pushed 11 months ago
Metadata Files
Readme

README.md

Python Interpreter ComfyUI Node 🐍

demo video

[!TIP] To install via manager, you must first open the ComfyUI Manager settings and set the channel setting to dev:

  See Picture of Specified Setting ![channel setting in comfyui manager](https://github.com/christian-byrne/python-interpreter-node/blob/demo-files/wiki/comfyui-manager-setting.png?raw=true)

Description

  • Write Python code that executes when the workflow is queued
  • The stdout/err (e.g., prints, error tracebacks) are displayed in the node.
  • The input values can be accessed by their UI name.
  • The output values are the same as the input values, changes made to input values in the code are reflected in the output values.

Requirements

  • python 3.10+

Installation

  1. cd into ComfyUI/custom_nodes directory
  2. git clone this repository

To install via ComfyUI Manager, set the channels setting to dev and search for Python Interpreter in the manager.

Usage

  • The variables in the UI (e.g., image1, number1, text1, etc.) can be accessed directly in the code by the same name python print(image1.shape) print(number1 * random.randint(0, 99))
  • The output values share the same names as the input values. Changes you make to these variables will be reflected in the output values.
  • The code will work as expected in almost all cases except for i. re-assignment and ii. passing the variables as arguments to external functions.

    1. To re-assign a variable, you must use its to() method, regardless of the variable's type ```python # Instead of number1 = float(number1): number1.to(float(number1))

    # Instead of image1 = 0.5 * (image1 + image2): image1.to(0.5 * (image1 + image2))

    # Instead of mask1 = 1 - mask1: mask1.to(1 - mask1)

    # Instead of text1 = text1.replace("bad", ""): text1.to(text1.replace("bad", ""))

    # In-place operators (+=, ++, /=, etc.) will work normally number1++ text1 += " is good" 2. To pass the variables as arguments to functions, just pass the `.data` attribute of the variable instead (regardless of the variable's type) python # Instead of pilimg = ToPILImage()(image1): pilimg = ToPILImage()(image1.data)

    # Instead of random.sample[number1, number2]: random.sample([number1.data, number2.data])

    # Not necessary for built-in functions print(image1) # works print(len(text1)) # works ```

  • Refer to the Images, Latents, and Masks section of comfydocs.org for info regarding types.

  • Try to avoid re-assigning the input/output variables to objects of a different type. You may lose access to some instance methods. If it must be done (e.g., to get an ouput of a novel type), just do it at the end of the code, and use your own variables in the meantime.

Examples

Get Complementary Colors from Image -> Interpolate into a Prompt

  Expand Image ![demo picture - complementary color palette](https://github.com/christian-byrne/python-interpreter-node/blob/demo-files/wiki/demos/pictures/new-example-complementary-colors.png?raw=true)

Paste Input Text on Image

  Expand Image ![demo picture = caption composite](https://github.com/christian-byrne/python-interpreter-node/blob/demo-files/wiki/demos/pictures/new-example-caption-draw.png?raw=true)

Snippets


Disclaimer: Do not put this on a server that is accessible to the public. This node can run any Python code provided by a user, including malicious code.

Owner

  • Name: Christian Byrne
  • Login: christian-byrne
  • Kind: user
  • Location: San Francisco
  • Company: Comfy-Org

GitHub Events

Total
  • Issues event: 9
  • Watch event: 23
  • Issue comment event: 14
  • Push event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 3
  • Create event: 1
Last Year
  • Issues event: 9
  • Watch event: 23
  • Issue comment event: 14
  • Push event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 3
  • Create event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 67
  • Total Committers: 2
  • Avg Commits per committer: 33.5
  • Development Distribution Score (DDS): 0.015
Past Year
  • Commits: 20
  • Committers: 2
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.05
Top Committers
Name Email Commits
christian-byrne a****m@g****m 66
IOMisaka z****a@q****m 1
Committer Domains (Top 20 + Academic)
qq.com: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 11
  • Total pull requests: 8
  • Average time to close issues: 15 days
  • Average time to close pull requests: about 2 hours
  • Total issue authors: 10
  • Total pull request authors: 3
  • Average comments per issue: 1.18
  • Average comments per pull request: 0.25
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 8
  • Pull requests: 7
  • Average time to close issues: 1 day
  • Average time to close pull requests: about 3 hours
  • Issue authors: 7
  • Pull request authors: 3
  • Average comments per issue: 1.13
  • Average comments per pull request: 0.29
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • christian-byrne (2)
  • sraney (1)
  • kullervo-wanona (1)
  • SencneS (1)
  • ShagaONhan (1)
  • cardenluo (1)
  • ClayShoaf (1)
  • geroldmeisinger (1)
  • robpridham-bbc (1)
  • drmbt (1)
Pull Request Authors
  • christian-byrne (8)
  • IOMisaka (2)
  • robinjhuang (2)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

pyproject.toml pypi
  • Pillow >=10.3.0
requirements.txt pypi
  • Pillow >=10.3.0