Giter Club home page Giter Club logo

latent_activation's Introduction

Latent Activation

This set of nodes will apply various activation functions directly to latent tensors. Have fun and experiment with different non-linear transformations of the latent space!

Activation Functions

The following activation functions are included in this pack:

  • ReLU:

    ReLU(x) = max(0, x)

  • Sigmoid:

    Sigmoid(x) = 1 / (1 + e-x)

  • Tanh:

    Tanh(x) = (ex - e-x) / (ex + e-x)

  • Leaky ReLU:

    Leaky ReLU(x) = max(0.01x, x)

  • ELU:

    ELU(x) = x if x > 0, else ELU(x) = α (ex - 1)

  • Softplus:

    Softplus(x) = log(1 + ex)

  • Swish:

    Swish(x) = x * Sigmoid(x)

  • GELU:

    GELU(x) = 0.5x(1 + tanh(√(2/π) (x + 0.044715x3)))

  • SELU:

    SELU(x) = λ x if x > 0, else SELU(x) = λ α (ex - 1)

    where λ ≈ 1.0507 and α ≈ 1.67326.

  • Mish:

    Mish(x) = x * tanh(Softplus(x))

  • PReLU:

    PReLU(x) = x if x > 0, else PReLU(x) = ax

Installation

  1. Clone or download this repository to your ComfyUI/custom_nodes directory.

Usage

  1. In your ComfyUI workflow, add one of the activation nodes (e.g., ReLU Activation) after a node that outputs a latent tensor (such as KSampler or LoadLatent).
  2. Connect the output of the activation node to a VAEDecode node to generate an image from the transformed latent.
  3. Adjust the following parameters to control the effect of the activation:
    • Strength: Determines the intensity of the activation function (how much of the transformed latent is mixed with the original).
    • Add to Original: If enabled, the activated latent will be added to the original latent. If disabled, the original latent will be replaced.
    • Normalize: If enabled, the transformed latent will be normalized to have zero mean and unit variance.
    • Clamp: If enabled, the values of the transformed latent will be clamped within a specified range (Clamp Min and Clamp Max).
    • Composite: If enabled, the activated latent will be composited (blended) with the upscaled original latent.
    • Blend Amount: Controls the blending ratio during compositing (0.0 to 1.0).
    • Additional Parameters: Certain activation functions have additional parameters (e.g., alpha for ELU, beta and threshold for Softplus, negative_slope for Leaky ReLU, etc.).

Contributing

Contributions are welcome! Feel free to submit issues, fork the repository, and create pull requests.

License

This project is licensed under the MIT License.

latent_activation's People

Contributors

bennarum avatar

Watchers

Rahul Y Gupta avatar  avatar

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.