Skip to content

Commit 5897596

Browse files
committed
fix: warmup issue fix
1 parent 126fb3a commit 5897596

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

server/app.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def offer(request):
107107
params = await request.json()
108108

109109
await pipeline.set_prompts(params["prompts"])
110-
await pipeline.warm()
110+
# await pipeline.warm()
111111

112112
offer_params = params["offer"]
113113
offer = RTCSessionDescription(sdp=offer_params["sdp"], type=offer_params["type"])
@@ -198,6 +198,11 @@ async def on_connectionstatechange():
198198

199199
await pc.setRemoteDescription(offer)
200200

201+
if "m=audio" in pc.remoteDescription.sdp:
202+
await pipeline.warm_audio()
203+
if "m=video" in pc.remoteDescription.sdp:
204+
await pipeline.warm_video()
205+
201206
answer = await pc.createAnswer()
202207
await pc.setLocalDescription(answer)
203208

server/pipeline.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ def __init__(self, **kwargs):
1616
self.video_futures = asyncio.Queue()
1717
self.audio_futures = asyncio.Queue()
1818

19-
async def warm(self):
19+
async def warm_video(self):
2020
dummy_video_inp = torch.randn(1, 512, 512, 3)
21-
dummy_audio_inp = np.random.randint(-32768, 32767, 48 * 20, dtype=np.int16) # TODO: might affect the workflow, due to buffering
2221

2322
for _ in range(WARMUP_RUNS):
2423
image_out_fut = self.client.put_video_input(dummy_video_inp)
2524
await image_out_fut
2625

26+
async def warm_audio(self):
27+
dummy_audio_inp = np.random.randint(-32768, 32767, 48 * 20, dtype=np.int16) # TODO: might affect the workflow, due to buffering
28+
2729
futs = []
2830
for _ in range(WARMUP_RUNS):
2931
audio_out_fut = self.client.put_audio_input(dummy_audio_inp)

0 commit comments

Comments
 (0)