Guest User

fix Diffusion CG

a guest
Aug 9th, 2025
54
0
14 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | Source Code | 0 0
  1. from functools import wraps
  2. from typing import Union
  3.  
  4. import execution
  5.  
  6. from .normalization import Normalization
  7. from .recenter import Recenter, RecenterXL, disable_recenter
  8.  
  9. NODE_CLASS_MAPPINGS = {
  10.     "Normalization": Normalization,
  11.     "Recenter": Recenter,
  12.     "Recenter XL": RecenterXL,
  13. }
  14.  
  15. NODE_DISPLAY_NAME_MAPPINGS = {
  16.     "Normalization": "Normalization",
  17.     "Recenter": "Recenter",
  18.     "Recenter XL": "RecenterXL",
  19. }
  20.  
  21.  
  22. def find_node(prompt: dict) -> bool:
  23.     """Find any ReCenter Node"""
  24.  
  25.     for node in prompt.values():
  26.         if node.get("class_type", None) in ("Recenter", "Recenter XL"):
  27.             return True
  28.  
  29.     return False
  30.  
  31.  
  32. original_validate = execution.validate_prompt
  33.  
  34.  
  35. @wraps(original_validate)
  36. async def hijack_validate(prompt_id: int, prompt: dict, partial_execution_list: Union[list[str], None]) -> bool:
  37.     if not find_node(prompt):
  38.         disable_recenter()
  39.     return await original_validate(prompt_id, prompt, partial_execution_list)
  40.  
  41.  
  42. execution.validate_prompt = hijack_validate
  43.  
Advertisement
Add Comment
Please, Sign In to add comment