From 0d2119ea2fa9bcd787e6e666744c445d7c10574b Mon Sep 17 00:00:00 2001 From: UnderSampled Date: Fri, 25 Nov 2022 16:24:02 -0500 Subject: [PATCH] Don't download BLIP model in to memory before saving; Download directly to file. --- scripts/auto_caption.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/auto_caption.py b/scripts/auto_caption.py index 4b3daf5..015e99e 100644 --- a/scripts/auto_caption.py +++ b/scripts/auto_caption.py @@ -109,9 +109,9 @@ async def main(opt): async with aiohttp.ClientSession() as session: async with session.get(BLIP_MODEL_URL) as res: - result = await res.read() with open(model_cache_path, 'wb') as f: - f.write(result) + async for chunk in res.content.iter_chunked(1024): + f.write(chunk) print(f"Model cached to: {model_cache_path}") else: print(f"Model already cached to: {model_cache_path}")