@@ -926,7 +926,98 @@ def apply_controlnet(self, image, control_net, preprocessor, union_type, resolut
926926 results ["result" ] = (p , n , image , para )
927927 return results
928928
929- class Inpaint :
929+ class DiffsynthControlNetApply :
930+ model_lib_path = os .path .join (os .path .dirname (os .path .dirname (__file__ )),"model_lib_any.json" )
931+ with open (model_lib_path , 'r' ) as json_file :
932+ modellist = json .load (json_file )
933+ list_model_patches_model = []
934+ for key , value in modellist .items ():
935+ if value [1 ] == "ModelPatch" :
936+ list_model_patches_model .append (key )
937+ list_full_model_patches_model = list (set (folder_paths .get_filename_list ("model_patches" ) + list_model_patches_model ))
938+ list_full_model_patches_model .sort ()
939+ @classmethod
940+ def INPUT_TYPES (s ):
941+ return {"required" : {
942+ "model" : ("MODEL" , {"tooltip" : "Mô hình diffusion" }),
943+ "vae" : ("VAE" , {"tooltip" : "Mô hình VAE" }),
944+ "image" : ("IMAGE" , {"tooltip" : "αΊ’nh ΔαΊ§u vΓ o cho ControlNet." }),
945+ "model_patch" : (none2list (s .list_full_model_patches_model ),{"tooltip" : "Chα»n model ControlNet, mα»t sα» model cΓ³ trong danh sΓ‘ch tαΊ£i xuα»ng tα»± Δα»ng." }),
946+ "preprocessor" : (preprocessor_list (),{"tooltip" : "Tiα»n xα» lΓ½ αΊ£nh cho ControlNet, cαΊ§n cΓ i ΔαΊ·t ControlNet Aux." }),
947+ "resolution" : ("INT" , {"default" : 1024 , "min" : 512 , "max" : 2048 , "step" : 1 , "tooltip" : "Δα» phΓ’n giαΊ£i cho preprocessor." }),
948+ "strength" : ("FLOAT" , {"default" : 1.0 , "min" : 0.0 , "max" : 10.0 , "step" : 0.01 , "tooltip" : "Mα»©c Δα» αΊ£nh hΖ°α»ng cα»§a ControlNet lΓͺn αΊ£nh sinh ra." }),
949+ },
950+ "optional" : {
951+ "mask" : ("MASK" , {"tooltip" : "Mask dΓΉng cho ControlNet inpaint" }),
952+ }
953+ }
954+
955+ RETURN_TYPES = ("MODEL" , "LATENT" ,)
956+ RETURN_NAMES = ("model" , "latent" ,)
957+ FUNCTION = "apply_controlnet"
958+
959+ CATEGORY = "π SDVN"
960+
961+ def apply_controlnet (self , model , vae , image , model_patch , preprocessor , resolution , strength , mask = None ):
962+ if preprocessor == "InvertImage" :
963+ image = ALL_NODE ["ImageInvert" ]().invert (image )[0 ]
964+ elif preprocessor != "None" :
965+ if "AIO_Preprocessor" in ALL_NODE :
966+ r = ALL_NODE ["AIO_Preprocessor" ]().execute (preprocessor , image , resolution )
967+ if "result" in r :
968+ image = r ["result" ][0 ]
969+ else :
970+ image = r [0 ]
971+ else :
972+ print (
973+ "You have not installed it yet Controlnet Aux (https://github.com/Fannovel16/comfyui_controlnet_aux)" )
974+ image = UpscaleImage ().upscale ("Maxsize" , resolution , resolution , 1 , "None" , image )[0 ]
975+ model_patch = ALL_NODE ["SDVN AnyDownload List" ]().any_download_list (model_patch )[0 ]
976+ model = ALL_NODE ["QwenImageDiffsynthControlnet" ]().diffsynth_controlnet ( model , model_patch , vae , image , strength , mask )[0 ]
977+ latent = ALL_NODE ["VAEEncode" ]().encode (vae , image )[0 ]
978+ results = ALL_NODE ["PreviewImage" ]().save_images (image )
979+ results ["result" ] = (model , latent )
980+ return results
981+
982+ class DiffsynthUnionLoraApply :
983+ @classmethod
984+ def INPUT_TYPES (s ):
985+ return {"required" : {
986+ "conditioning" : ("CONDITIONING" , {"tooltip" : "CΓ’u lα»nh Δα» chαΊ‘y reference image" }),
987+ "vae" : ("VAE" , {"tooltip" : "Mô hình VAE" }),
988+ "image" : ("IMAGE" , {"tooltip" : "αΊ’nh ΔαΊ§u vΓ o cho ControlNet." }),
989+ "preprocessor" : (preprocessor_list (),{"tooltip" : "Tiα»n xα» lΓ½ αΊ£nh cho ControlNet, cαΊ§n cΓ i ΔαΊ·t ControlNet Aux." }),
990+ "resolution" : ("INT" , {"default" : 1024 , "min" : 512 , "max" : 2048 , "step" : 1 , "tooltip" : "Δα» phΓ’n giαΊ£i cho preprocessor." }),
991+ },
992+ }
993+
994+ RETURN_TYPES = ("CONDITIONING" , "LATENT" ,)
995+ RETURN_NAMES = ("conditioning" , "latent" ,)
996+ FUNCTION = "apply_controlnet"
997+
998+ CATEGORY = "π SDVN"
999+
1000+ def apply_controlnet (self , conditioning , vae , image , preprocessor , resolution ):
1001+ if preprocessor == "InvertImage" :
1002+ image = ALL_NODE ["ImageInvert" ]().invert (image )[0 ]
1003+ elif preprocessor != "None" :
1004+ if "AIO_Preprocessor" in ALL_NODE :
1005+ r = ALL_NODE ["AIO_Preprocessor" ]().execute (preprocessor , image , resolution )
1006+ if "result" in r :
1007+ image = r ["result" ][0 ]
1008+ else :
1009+ image = r [0 ]
1010+ else :
1011+ print (
1012+ "You have not installed it yet Controlnet Aux (https://github.com/Fannovel16/comfyui_controlnet_aux)" )
1013+ image = UpscaleImage ().upscale ("Maxsize" , resolution , resolution , 1 , "None" , image )[0 ]
1014+ latent = ALL_NODE ["VAEEncode" ]().encode (vae , image )[0 ]
1015+ conditioning = ALL_NODE ["ReferenceLatent" ]().append (conditioning , latent )[0 ]
1016+ results = ALL_NODE ["PreviewImage" ]().save_images (image )
1017+ results ["result" ] = (conditioning , latent )
1018+ return results
1019+
1020+ class Inpaint :
9301021 @classmethod
9311022 def INPUT_TYPES (s ):
9321023 return {"required" : {"SetLatentNoiseMask" :("BOOLEAN" ,),
@@ -1605,6 +1696,8 @@ def any_download_list(s, Model):
16051696 "SDVN Load Image Ultimate" : LoadImageUltimate ,
16061697 "SDVN CLIP Text Encode" : CLIPTextEncode ,
16071698 "SDVN Controlnet Apply" : AutoControlNetApply ,
1699+ "SDVN DiffsynthControlNet Apply" : DiffsynthControlNetApply ,
1700+ "SDVN DiffsynthUnionLora Apply" : DiffsynthUnionLoraApply ,
16081701 "SDVN Inpaint" : Inpaint ,
16091702 "SDVN Apply Style Model" : ApplyStyleModel ,
16101703 "SDVN KSampler" : Easy_KSampler ,
@@ -1643,6 +1736,8 @@ def any_download_list(s, Model):
16431736 "SDVN CLIP Text Encode" : "π‘ CLIP Text Encode" ,
16441737 "SDVN KSampler" : "βοΈ KSampler" ,
16451738 "SDVN Controlnet Apply" : "ποΈ Controlnet Apply" ,
1739+ "SDVN DiffsynthControlNet Apply" : "ποΈ DiffsynthControlNet Apply" ,
1740+ "SDVN DiffsynthUnionLora Apply" : "ποΈ DiffsynthUnionLora Apply" ,
16461741 "SDVN Inpaint" : "π¨βπ¨ Inpaint" ,
16471742 "SDVN Apply Style Model" : "π Apply Style Model" ,
16481743 "SDVN Apply Kontext Reference" : "π Apply Kontext Reference" ,
0 commit comments