MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / decoder

Function decoder

diffusers/scripts/convert_kakao_brain_unclip_to_diffusers.py:966–998  ·  view source on GitHub ↗
(*, args, checkpoint_map_location)

Source from the content-addressed store, hash-verified

964
965
966def decoder(*, args, checkpoint_map_location):
967 print("loading decoder")
968
969 decoder_checkpoint = torch.load(args.decoder_checkpoint_path, map_location=checkpoint_map_location)
970 decoder_checkpoint = decoder_checkpoint["state_dict"]
971
972 decoder_model = decoder_model_from_original_config()
973
974 decoder_diffusers_checkpoint = decoder_original_checkpoint_to_diffusers_checkpoint(
975 decoder_model, decoder_checkpoint
976 )
977
978 # text proj interlude
979
980 # The original decoder implementation includes a set of parameters that are used
981 # for creating the `encoder_hidden_states` which are what the U-net is conditioned
982 # on. The diffusers conditional unet directly takes the encoder_hidden_states. We pull
983 # the parameters into the UnCLIPTextProjModel class
984 text_proj_model = text_proj_from_original_config()
985
986 text_proj_checkpoint = text_proj_original_checkpoint_to_diffusers_checkpoint(decoder_checkpoint)
987
988 load_checkpoint_to_model(text_proj_checkpoint, text_proj_model, strict=True)
989
990 # done text proj interlude
991
992 del decoder_checkpoint
993
994 load_checkpoint_to_model(decoder_diffusers_checkpoint, decoder_model, strict=True)
995
996 print("done loading decoder")
997
998 return decoder_model, text_proj_model
999
1000
1001def super_res_unet(*, args, checkpoint_map_location):

Tested by

no test coverage detected