o Ô>õg©ã@s~ddlZddlZddlZddlZddlZddlZdd„ZGdd„dƒZGdd„dej j ƒZ Gdd „d ƒZ ee d œZ dd iZdS) éNc CsR||}||}|t ||¡ ¡t |¡d|}||} |||| } | S)Né)ÚtorchÚmulÚsumÚnorm) ÚxÚnoise_pred_posÚnoise_pred_negÚnoise_pred_nocondÚ neg_scaleÚ cond_scaleÚposÚnegÚperpÚperp_negÚ cfg_result©rúD/home/comdoleger1/zen-flux-style-shape/comfy_extras/nodes_perpneg.pyrs &rc@s0eZdZedd„ƒZdZdZdZdZdd„Z d S) ÚPerpNegc Csddddddddd œfd œiS) NÚrequired©ÚMODEL©Ú CONDITIONINGÚFLOATçð?ççY@ç{®Gáz„?©ÚdefaultÚminÚmaxÚstep)ÚmodelÚempty_conditioningr r©ÚsrrrÚ INPUT_TYPESsþzPerpNeg.INPUT_TYPESrÚpatchÚ _for_testingTcs2| ¡}tj |¡‰‡‡fdd„}| |¡|fS)Nc s‚|d}|d}|d}|d}|d}|d}|d}tj |jˆ||jd¡}tj ||g|||¡\} |t|||| ˆ|ƒ} | S) Nr$Ú cond_denoisedÚuncond_denoisedr ÚinputÚsigmaÚ model_optionsÚnegative)ÚcomfyÚsamplersÚencode_model_condsÚ extra_condsÚdeviceÚcalc_cond_batchr) Úargsr$rr r rr.r/Znocond_processedr r©r ZnocondrrÚ cfg_function#sz#PerpNeg.patch..cfg_function)Úcloner1Úsampler_helpersÚ convert_condÚset_model_sampler_cfg_function)Úselfr$r%r Úmr9rr8rr)s   z PerpNeg.patchN) Ú__name__Ú __module__Ú __qualname__Ú classmethodr(Ú RETURN_TYPESÚFUNCTIONÚCATEGORYÚ DEPRECATEDr)rrrrrs  rc@s*eZdZdd„Zdd„Zidfdd„ZdS)ÚGuider_PerpNegcCs&t |ddi¡}| |||dœ¡dS)NÚ prompt_typer0)ÚpositiveÚempty_negative_promptr0)Ú node_helpersÚconditioning_set_valuesÚinner_set_conds)r>rJr0rKrrrÚ set_conds8szGuider_PerpNeg.set_condscCs||_||_dS©N)Úcfgr )r>rQr rrrÚset_cfg<s zGuider_PerpNeg.set_cfgNc Csž|j dd¡}|j dd¡}|j dd¡}tj |j|||g|||¡\}} } t||| | |j|jƒ} | dg¡D]} | |||j| |||||| dœ } | | ƒ} q7| S)NrJr0rKÚsampler_post_cfg_function) ÚdenoisedÚcondÚuncondr$r,r+r.r/r-Ú empty_condZempty_cond_denoised) ÚcondsÚgetr1r2r6Ú inner_modelrr rQ)r>rÚtimestepr/ÚseedZ positive_condÚ negative_condrWrr Znoise_pred_emptyrÚfnr7rrrÚ predict_noise@s*ÿô zGuider_PerpNeg.predict_noise)r@rArBrOrRr_rrrrrH7srHc@s,eZdZedd„ƒZdZdZdZdd„ZdS) Ú PerpNegGuiderc Cs4ddddddddddd d œfdd ddd d œfd œiS)Nrrrrg @rrgš™™™™™¹?r)r r!r"r#Úroundrr)r$rJr0r%rQr rr&rrrr(csûÿzPerpNegGuider.INPUT_TYPES)ÚGUIDERÚ get_guiderr*cCs(t|ƒ}| |||¡| ||¡|fSrP)rHrOrR)r>r$rJr0r%rQr Úguiderrrrrcts zPerpNegGuider.get_guiderN) r@rArBrCr(rDrErFrcrrrrr`bs   r`)rr`z&Perp-Neg (DEPRECATED by PerpNegGuider))rZcomfy.model_managementr1Úcomfy.sampler_helpersÚcomfy.samplersÚ comfy.utilsrLrrr2Ú CFGGuiderrHr`ÚNODE_CLASS_MAPPINGSÚNODE_DISPLAY_NAME_MAPPINGSrrrrÚs %+þÿ