Merge pull request #98 from Meisoftcoltd/perf-concurrent-image-loading-13430517007901480050
⚡ [Performance] Concurrent image loading in Video Stitcher
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from contextlib import redirect_stdout, redirect_stderr
|
||||
from tqdm import tqdm
|
||||
import comfy.utils
|
||||
@@ -703,10 +704,13 @@ class IncrementalVideoStitcher:
|
||||
_log(f" -> 🧩 Reservando bloque en RAM para {total_frames} frames de vídeo...")
|
||||
final_tensor = torch.empty((total_frames, H, W, 3), dtype=torch.float32, device="cpu")
|
||||
|
||||
for i, f in enumerate(png_files):
|
||||
img = Image.open(os.path.join(cache_dir, f)).convert("RGB")
|
||||
def load_and_process(idx, filename):
|
||||
img = Image.open(os.path.join(cache_dir, filename)).convert("RGB")
|
||||
img_np = np.array(img).astype(np.float32) / 255.0
|
||||
final_tensor[i] = torch.from_numpy(img_np)
|
||||
final_tensor[idx] = torch.from_numpy(img_np)
|
||||
|
||||
with ThreadPoolExecutor() as executor:
|
||||
list(executor.map(lambda p: load_and_process(*p), enumerate(png_files)))
|
||||
|
||||
# 2. ENSAMBLAR AUDIO
|
||||
audio_files = sorted([f for f in os.listdir(cache_dir) if f.startswith('audio_') and f.endswith('.pt')])
|
||||
|
||||
Reference in New Issue
Block a user