Spaces:
Running on Zero
Running on Zero
Start-up GPU warm-up (Triton kernel build and tuning before the first visitor)
Browse files106 unmodified lines107108109110111112106 unmodified linesreturn path, overlay(frames[first], subject[first]), depth_image(depth), msgHEADER = """<div id="header"><div class="title"><div><h1>FlashReFocus: Video Spotlight</h1><p>Keep one person sharp and blur everyone else, frame106 unmodified lines107108109110111112113114115116117118119120121122123124125126127128106 unmodified linesreturn path, overlay(frames[first], subject[first]), depth_image(depth), msg@spaces.GPU(duration=180)def warm_up(frames):"""Start-up run on the GPU worker: SAM 3, depth and the renderer once (the Triton kernel is built and tuned here),so the first visitor does not wait for it."""t0 = time.perf_counter()engine.process(frames, "person", None, 1.5, 0.6)print(f"warm-up done in {time.perf_counter() - t0:.1f} s", flush=True)try:for _side in (768, 512, 960): # the long sides offered, on a 16:9 example clipwarm_up(engine.read_clip(EXAMPLES[1], 0.5, _side)[0])except Exception as e: # never block the start of the Spaceprint(f"warm-up skipped ({type(e).__name__}: {e})", flush=True)HEADER = """<div id="header"><div class="title"><div><h1>FlashReFocus: Video Spotlight</h1><p>Keep one person sharp and blur everyone else, frame
app.py+16