@@ -123,7 +123,7 @@ static WorkflowGenerator()
123123 #region Positive Prompt
124124 AddStep ( g =>
125125 {
126- g . FinalPrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . Prompt ) , g . FinalClip , g . UserInput . Get ( T2IParamTypes . Model ) ) ;
126+ g . FinalPrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . Prompt ) , g . FinalClip , g . UserInput . Get ( T2IParamTypes . Model ) , true ) ;
127127 } , - 8 ) ;
128128 #endregion
129129 #region ReVision/UnCLIP
@@ -225,7 +225,7 @@ static WorkflowGenerator()
225225 #region Negative Prompt
226226 AddStep ( g =>
227227 {
228- g . FinalNegativePrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . NegativePrompt ) , g . FinalClip , g . UserInput . Get ( T2IParamTypes . Model ) ) ;
228+ g . FinalNegativePrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . NegativePrompt ) , g . FinalClip , g . UserInput . Get ( T2IParamTypes . Model ) , false ) ;
229229 } , - 7 ) ;
230230 #endregion
231231 #region ControlNet
@@ -434,8 +434,8 @@ bool getBestFor(string phrase)
434434 {
435435 g . FinalVae = new ( ) { "20" , 2 } ;
436436 }
437- prompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . Prompt ) , new JArray ( ) { "20" , 1 } , refineModel ) ;
438- negPrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . NegativePrompt ) , new JArray ( ) { "20" , 1 } , refineModel ) ;
437+ prompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . Prompt ) , new JArray ( ) { "20" , 1 } , refineModel , true ) ;
438+ negPrompt = g . CreateConditioning ( g . UserInput . Get ( T2IParamTypes . NegativePrompt ) , new JArray ( ) { "20" , 1 } , refineModel , false ) ;
439439 }
440440 if ( ComfyUIBackendExtension . FeaturesSupported . Contains ( "aitemplate" ) && g . UserInput . Get ( ComfyUIBackendExtension . AITemplateParam ) )
441441 {
@@ -695,11 +695,14 @@ public JObject Generate()
695695 }
696696
697697 /// <summary>Creates a "CLIPTextEncode" or equivalent node for the given input.</summary>
698- public JArray CreateConditioningDirect ( string prompt , JArray clip , T2IModel model )
698+ public JArray CreateConditioningDirect ( string prompt , JArray clip , T2IModel model , bool isPositive )
699699 {
700700 string node ;
701701 if ( model is not null && model . ModelClass is not null && model . ModelClass . ID == "stable-diffusion-xl-v1-base" )
702702 {
703+ double mult = isPositive ? 1.5 : 0.8 ;
704+ int width = UserInput . Get ( T2IParamTypes . Width , 1024 ) ;
705+ int height = UserInput . GetImageHeight ( ) ;
703706 node = CreateNode ( "CLIPTextEncodeSDXL" , ( _ , n ) =>
704707 {
705708 n [ "inputs" ] = new JObject ( )
@@ -709,10 +712,10 @@ public JArray CreateConditioningDirect(string prompt, JArray clip, T2IModel mode
709712 [ "text_l" ] = prompt ,
710713 [ "crop_w" ] = 0 ,
711714 [ "crop_h" ] = 0 ,
712- [ "width" ] = UserInput . Get ( T2IParamTypes . Width , 1024 ) ,
713- [ "height" ] = UserInput . GetImageHeight ( ) ,
714- [ "target_width" ] = UserInput . Get ( T2IParamTypes . Width , 1024 ) ,
715- [ "target_height" ] = UserInput . GetImageHeight ( )
715+ [ "width" ] = ( int ) ( width * mult ) ,
716+ [ "height" ] = ( int ) ( height * mult ) ,
717+ [ "target_width" ] = width ,
718+ [ "target_height" ] = height
716719 } ;
717720 } ) ;
718721 }
@@ -733,10 +736,10 @@ public JArray CreateConditioningDirect(string prompt, JArray clip, T2IModel mode
733736 public record struct RegionHelper ( JArray PartCond , JArray Mask ) ;
734737
735738 /// <summary>Creates a "CLIPTextEncode" or equivalent node for the given input, applying prompt-given conditioning modifiers as relevant.</summary>
736- public JArray CreateConditioning ( string prompt , JArray clip , T2IModel model )
739+ public JArray CreateConditioning ( string prompt , JArray clip , T2IModel model , bool isPositive )
737740 {
738741 PromptRegion regionalizer = new ( prompt ) ;
739- JArray globalCond = CreateConditioningDirect ( regionalizer . GlobalPrompt , clip , model ) ;
742+ JArray globalCond = CreateConditioningDirect ( regionalizer . GlobalPrompt , clip , model , isPositive ) ;
740743 if ( regionalizer . Parts . IsEmpty ( ) )
741744 {
742745 return globalCond ;
@@ -746,7 +749,7 @@ public JArray CreateConditioning(string prompt, JArray clip, T2IModel model)
746749 JArray lastMergedMask = null ;
747750 foreach ( PromptRegion . Part part in regionalizer . Parts )
748751 {
749- JArray partCond = CreateConditioningDirect ( part . Prompt , clip , model ) ;
752+ JArray partCond = CreateConditioningDirect ( part . Prompt , clip , model , isPositive ) ;
750753 string regionNode = CreateNode ( "SwarmSquareMaskFromPercent" , ( _ , n ) =>
751754 {
752755 n [ "inputs" ] = new JObject ( )
@@ -797,7 +800,7 @@ public JArray CreateConditioning(string prompt, JArray clip, T2IModel model)
797800 } ;
798801 } ) ;
799802 string backgroundPrompt = string . IsNullOrWhiteSpace ( regionalizer . BackgroundPrompt ) ? regionalizer . GlobalPrompt : regionalizer . BackgroundPrompt ;
800- JArray backgroundCond = CreateConditioningDirect ( backgroundPrompt , clip , model ) ;
803+ JArray backgroundCond = CreateConditioningDirect ( backgroundPrompt , clip , model , isPositive ) ;
801804 string mainConditioning = CreateNode ( "ConditioningSetMask" , ( _ , n ) =>
802805 {
803806 n [ "inputs" ] = new JObject ( )
0 commit comments