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

Function convert_super_res_pipeline

diffusers/scripts/convert_if.py:97–135  ·  view source on GitHub ↗
(tokenizer, text_encoder, feature_extractor, safety_checker, args, stage)

Source from the content-addressed store, hash-verified

95
96
97def convert_super_res_pipeline(tokenizer, text_encoder, feature_extractor, safety_checker, args, stage):
98 if stage == 2:
99 unet_checkpoint_path = args.unet_checkpoint_path_stage_2
100 sample_size = None
101 dump_path = args.dump_path_stage_2
102 elif stage == 3:
103 unet_checkpoint_path = args.unet_checkpoint_path_stage_3
104 sample_size = 1024
105 dump_path = args.dump_path_stage_3
106 else:
107 assert False
108
109 unet = get_super_res_unet(unet_checkpoint_path, verify_param_count=False, sample_size=sample_size)
110
111 image_noising_scheduler = DDPMScheduler(
112 beta_schedule="squaredcos_cap_v2",
113 )
114
115 scheduler = DDPMScheduler(
116 variance_type="learned_range",
117 beta_schedule="squaredcos_cap_v2",
118 prediction_type="epsilon",
119 thresholding=True,
120 dynamic_thresholding_ratio=0.95,
121 sample_max_value=1.0,
122 )
123
124 pipe = IFSuperResolutionPipeline(
125 tokenizer=tokenizer,
126 text_encoder=text_encoder,
127 unet=unet,
128 scheduler=scheduler,
129 image_noising_scheduler=image_noising_scheduler,
130 safety_checker=safety_checker,
131 feature_extractor=feature_extractor,
132 requires_safety_checker=True,
133 )
134
135 pipe.save_pretrained(dump_path)
136
137
138def get_stage_1_unet(unet_config, unet_checkpoint_path):

Callers 1

mainFunction · 0.85

Calls 4

DDPMSchedulerClass · 0.90
get_super_res_unetFunction · 0.85
save_pretrainedMethod · 0.45

Tested by

no test coverage detected