Giter Site home page Giter Site logo

feffy380 / comfyui-prediction Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redhottensors/comfyui-prediction

0.0 0.0 0.0 374 KB

Fully customizable Classifer Free Guidance for ComfyUI

License: GNU General Public License v3.0

Python 100.00%

comfyui-prediction's Introduction

ComfyUI-Prediction

Fully customizable Classifier Free Guidance for ComfyUI.

Custom Prediction

Copyright 2024 by @RedHotTensors and released by Project RedRocket.

Installation

Clone this repo into ComfyUI/custom_nodes or use ComfyUI-Manager.

(Optional) If you want beautiful teal PREDICTION edges like the example apply patches/colorPalette.js.patch to ComfyUI/web/extensions/core/colorPalette.js.

Usage

All custom nodes are provided under Add Node > sampling > prediction. An example workflow is in examples/custom_prediction.json.

Follow these steps for fully custom prediction:

  1. You will need to use the sampling > prediction > Sample Predictions node as your sampler.
  2. The sampler input comes from sampling > custom_sampling > samplers. Generally you'll use KSamplerSelect.
  3. The sigmas input comes from sampling > custom_sampling > schedulers. If you don't know what sigmas you are using, try BasicScheduler. (NOTE: These nodes are not in the "sigmas" menu.)
  4. You'll need one or more prompts. Chain conditioning > CLIP Text Encode (Prompt) to sampling > prediction > Conditioned Prediction to get started.
  5. After your prediction chain, connect the result to the noise_prediction input of your Sample Predictions node.

Predictors

Primitive Nodes

All other predictions can be implemented in terms of these nodes. However, it may get a little messy.

Conditioned Prediction - Evaluate your chosen model with a prompt (conditioning). You need to pick a unique conditioning name like "positive", "negative", or "empty". (The names are arbitrary and you can choose any name, but the names may evenutally interact with ControlNet if/when it's implemented.)

Combine Predictions - Operates on two predictions. Supports add (+), subtract (-), multiply (*), divide (/), vector projection (proj), vector rejection (oproj), min, and max.
prediction_A <operation> prediction_B

Scale Prediction - Linearly scales a prediction.
prediction * scale

Convinence Nodes

Scaled Guidance Prediction - Combines a baseline prediction with a scaled guidance prediction, similar to CFG.
baseline + guidance * scale

Avoid and Erase Prediction - Re-aligns a desirable (positive) prediction called guidance away from an undesirable (negative) prediction called avoid_and_erase, and erases some of the negative prediction as well.
guidance - (guidance proj avoid_and_erase) * avoid_scale - avoid_and_erase * erase_scale

Prebuilt Nodes

CFG Prediction - Vanilla Classifer Free Guidance (CFG) with a postive prompt and a negative/empty prompt.
(positive - negative) * cfg_scale + negative

Perp-Neg Prediction - Implements https://arxiv.org/abs/2304.04968. This is also implemented less flexibly in vanilla ComfyUI under _for_testing > Perp-Neg.
pos_ind = positive - empty; neg_ind = negative - empty
(pos_ind - (pos_ind proj neg_ind) * neg_scale) * cfg_scale + empty

Limitations

ControlNet is not supported at this time.

Regional prompting may work but is totally untested.

Any other advanced features affecting conditioning are not likely to work.

License

The license is the same as ComfyUI, GPL 3.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.