(
key=1,
img2img_strength=1.0,
specify_num_samples=True,
stage2strength=None,
)
| 324 | |
| 325 | |
| 326 | def init_sampling( |
| 327 | key=1, |
| 328 | img2img_strength=1.0, |
| 329 | specify_num_samples=True, |
| 330 | stage2strength=None, |
| 331 | ): |
| 332 | num_rows, num_cols = 1, 1 |
| 333 | if specify_num_samples: |
| 334 | num_cols = st.number_input( |
| 335 | f"num cols #{key}", value=2, min_value=1, max_value=10 |
| 336 | ) |
| 337 | |
| 338 | steps = st.sidebar.number_input( |
| 339 | f"steps #{key}", value=40, min_value=1, max_value=1000 |
| 340 | ) |
| 341 | sampler = st.sidebar.selectbox( |
| 342 | f"Sampler #{key}", |
| 343 | [ |
| 344 | "EulerEDMSampler", |
| 345 | "HeunEDMSampler", |
| 346 | "EulerAncestralSampler", |
| 347 | "DPMPP2SAncestralSampler", |
| 348 | "DPMPP2MSampler", |
| 349 | "LinearMultistepSampler", |
| 350 | ], |
| 351 | 0, |
| 352 | ) |
| 353 | discretization = st.sidebar.selectbox( |
| 354 | f"Discretization #{key}", |
| 355 | [ |
| 356 | "LegacyDDPMDiscretization", |
| 357 | "EDMDiscretization", |
| 358 | ], |
| 359 | ) |
| 360 | |
| 361 | discretization_config = get_discretization(discretization, key=key) |
| 362 | |
| 363 | guider_config = get_guider(key=key) |
| 364 | |
| 365 | sampler = get_sampler(sampler, steps, discretization_config, guider_config, key=key) |
| 366 | if img2img_strength < 1.0: |
| 367 | st.warning( |
| 368 | f"Wrapping {sampler.__class__.__name__} with Img2ImgDiscretizationWrapper" |
| 369 | ) |
| 370 | sampler.discretization = Img2ImgDiscretizationWrapper( |
| 371 | sampler.discretization, strength=img2img_strength |
| 372 | ) |
| 373 | if stage2strength is not None: |
| 374 | sampler.discretization = Txt2NoisyDiscretizationWrapper( |
| 375 | sampler.discretization, strength=stage2strength, original_steps=steps |
| 376 | ) |
| 377 | return sampler, num_rows, num_cols |
| 378 | |
| 379 | |
| 380 | def get_discretization(discretization, key=1): |
no test coverage detected