(img, target_height, target_width)
| 682 | |
| 683 | |
| 684 | def resize_resampling_frames(frames, height, width, *, workers=4, parallel=True, device="cpu"): |
| 685 | """Lanczos-resize RGB frames, optionally sharing the work across ranks. |
| 686 | |
| 687 | Each rank decodes the same source, but resizes only its contiguous frame |
| 688 | slice. Gather uint8 pixels before the existing CPU float conversion so |
| 689 | interpolation, frame order and normalization match serial execution. |
| 690 | All ranks in the default process group must participate when parallel. |
| 691 | """ |
| 692 | if frames.ndim != 4 or frames.shape[-1] != 3 or frames.dtype != np.uint8 or not len(frames): |
| 693 | raise ValueError("Regeneration frames must be nonempty uint8 [F,H,W,3] RGB") |
| 694 | if isinstance(workers, bool) or not isinstance(workers, int) or workers < 1: |
| 695 | raise ValueError("resample_resize_workers must be a positive integer") |
| 696 | if height < 1 or width < 1: |
| 697 | raise ValueError("Regeneration target height and width must be positive") |
| 698 | if frames.shape[1:3] == (height, width): |
| 699 | return frames |
| 700 | |
| 701 | distributed = parallel and dist.is_initialized() and dist.get_world_size() > 1 |
| 702 | world_size = dist.get_world_size() if distributed else 1 |
| 703 | rank = dist.get_rank() if distributed else 0 |
| 704 | chunk_size = (len(frames) + world_size - 1) // world_size |
| 705 | start = rank * chunk_size |
no test coverage detected