(p: processing.StableDiffusionProcessing, output)
| 468 | |
| 469 | |
| 470 | def process_decode(p: processing.StableDiffusionProcessing, output): |
| 471 | shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model, exclude=['vae']) |
| 472 | if output is not None: |
| 473 | if hasattr(output, 'bytes') and output.bytes is not None: |
| 474 | log.debug(f'Generated: bytes={len(output.bytes)}') |
| 475 | return output |
| 476 | audio = getattr(output, 'audio', None) |
| 477 | if not hasattr(output, 'images') and hasattr(output, 'frames'): |
| 478 | log.debug(f'Generated: frames={len(output.frames[0])}') |
| 479 | output.images = output.frames[0] |
| 480 | if output.images is not None and len(output.images) > 0 and isinstance(output.images[0], Image.Image): |
| 481 | return attach_audio(output.images, audio) |
| 482 | model = shared.sd_model if not is_refiner_enabled(p) else shared.sd_refiner |
| 483 | if not hasattr(model, 'vae'): |
| 484 | if hasattr(model, 'pipe') and hasattr(model.pipe, 'vae'): |
| 485 | model = model.pipe |
| 486 | if (hasattr(model, "vae") or hasattr(model, "vqgan")) and (output.images is not None) and (len(output.images) > 0): |
| 487 | if p.hr_resize_mode > 0 and (p.hr_upscaler != 'None' or p.hr_resize_mode == 5): |
| 488 | width = max(getattr(p, 'width', 0), getattr(p, 'hr_upscale_to_x', 0)) |
| 489 | height = max(getattr(p, 'height', 0), getattr(p, 'hr_upscale_to_y', 0)) |
| 490 | else: |
| 491 | width = getattr(p, 'width', 0) |
| 492 | height = getattr(p, 'height', 0) |
| 493 | frames = p.task_args.get('num_frames', None) or getattr(p, 'frames', None) |
| 494 | if isinstance(output.images, list): |
| 495 | results = [] |
| 496 | for i in range(len(output.images)): |
| 497 | result_batch = processing_vae.vae_decode( |
| 498 | latents = output.images[i], |
| 499 | model = model, |
| 500 | vae_type = p.vae_type, |
| 501 | width = width, |
| 502 | height = height, |
| 503 | frames = frames, |
| 504 | ) |
| 505 | for result in list(result_batch): |
| 506 | results.append(result) |
| 507 | else: |
| 508 | results = processing_vae.vae_decode( |
| 509 | latents = output.images, |
| 510 | model = model, |
| 511 | vae_type = p.vae_type, |
| 512 | width = width, |
| 513 | height = height, |
| 514 | frames = frames, |
| 515 | ) |
| 516 | if not isinstance(results, list): |
| 517 | results = list(results) |
| 518 | elif hasattr(output, 'images'): |
| 519 | results = output.images |
| 520 | else: |
| 521 | log.warning('Processing: no results') |
| 522 | results = [] |
| 523 | else: |
| 524 | log.warning('Processing: no results') |
| 525 | audio = None |
| 526 | results = [] |
| 527 | return attach_audio(results, audio) |
no test coverage detected