Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Refactor and Optimize Codebase for latest ComfyUI #237

Open
wants to merge 158 commits into
base: main
Choose a base branch
from

Conversation

toxicwind
Copy link

@toxicwind toxicwind commented Nov 5, 2023

This pull request aims to enhance the codebase by improving code organization, readability, and maintainability. The changes made are as follows:

  1. Code Organization and Style:

    • Sorted imported modules alphabetically.
    • Added type hints for function parameters and return values.
    • Removed unnecessary imports for code cleanliness.
    • Formatted the code according to PEP 8 style guidelines.
  2. Refactored Functions:

    • Refactored functions like adjust_tensor_shape, expand, and bounded_modulo for improved efficiency and readability.
  3. calc_cond Function:

    • Simplified and improved readability using dictionary comprehension.
    • Enhanced the code for determining 'orig_len' and selecting conditions.
  4. catenate_conds and subscript_cond Functions:

    • Simplified and made more concise for better readability.
  5. pad_cond Function:

    • Modified to use F.pad for efficient tensor padding.
  6. CFGDenoiser Class:

    • Introduced methods like prepare_inputs, prepare_cond, apply_model, and post_process for modularity and readability.
    • Eliminated redundant code segments for conciseness and clarity.
  7. CFGNoisePredictor Class:

    • Refactored the apply_model method for readability and modularity.
    • Introduced helper methods for efficient condition preparation.
    • Made the txt2img_image_conditioning method static for better organization.
  8. SDKSampler Class:

    • Introduced the set_model_wrap method to set the model_wrap attribute for improved organization.
    • Modified the constructor to use the set_model_wrap method.

These changes aim to improve code quality and make it more readable and maintainable while preserving the original functionality of the code. The code remains functionally intact, but the enhancements result in a cleaner, more organized, and better-documented codebase.

jags111 and others added 30 commits April 6, 2024 00:29
Add Github Action for Publishing to Comfy Registry
Add pyproject.toml for Custom Node Registry
"both" was missing
Show latent upscaler when "both" is selected
omfy.sampler's 'convert cond' has been removed so line 127 changes
changes in line 131 check same
 module 'comfy.sample' has no attribute 'get_additional_models'
…LucianoCirino#203)

This fixes cases where the widget is not a plain object, but a class instance with `value` getters/setters.
* bugfix: in case of XY_Capsule, prompt needs to be encoded by the analysed LoRA's clip

* bugfix: when processing LoRAs you need to reload the LoRA every index on the y scale (not only the first one) to maintain the LoRA-patched clip.

* add align your step schedulers via monkey patching

---------

Co-authored-by: larsupb <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.