MCPcopy
hub / github.com/Stability-AI/generative-models / apply_refiner

Function apply_refiner

scripts/demo/sampling.py:210–249  ·  view source on GitHub ↗
(
    input,
    state,
    sampler,
    num_samples,
    prompt,
    negative_prompt,
    filter=None,
    finish_denoising=False,
)

Source from the content-addressed store, hash-verified

208
209
210def apply_refiner(
211 input,
212 state,
213 sampler,
214 num_samples,
215 prompt,
216 negative_prompt,
217 filter=None,
218 finish_denoising=False,
219):
220 init_dict = {
221 "orig_width": input.shape[3] * 8,
222 "orig_height": input.shape[2] * 8,
223 "target_width": input.shape[3] * 8,
224 "target_height": input.shape[2] * 8,
225 }
226
227 value_dict = init_dict
228 value_dict["prompt"] = prompt
229 value_dict["negative_prompt"] = negative_prompt
230
231 value_dict["crop_coords_top"] = 0
232 value_dict["crop_coords_left"] = 0
233
234 value_dict["aesthetic_score"] = 6.0
235 value_dict["negative_aesthetic_score"] = 2.5
236
237 st.warning(f"refiner input shape: {input.shape}")
238 samples = do_img2img(
239 input,
240 state["model"],
241 sampler,
242 value_dict,
243 num_samples,
244 skip_encode=True,
245 filter=filter,
246 add_noise=not finish_denoising,
247 )
248
249 return samples
250
251
252if __name__ == "__main__":

Callers 1

sampling.pyFile · 0.85

Calls 1

do_img2imgFunction · 0.70

Tested by

no test coverage detected