From 846ef7fc38e29fe185bdcc437a650964ddb1d16f Mon Sep 17 00:00:00 2001 From: awatuna <23447591+awatuna@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:17:52 +0800 Subject: [PATCH] Update model.py time model loading time --- common/model.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/model.py b/common/model.py index 87b06ad..5ba0fa4 100644 --- a/common/model.py +++ b/common/model.py @@ -9,6 +9,7 @@ from fastapi import HTTPException from loguru import logger from typing import Optional +import time from common.logger import get_loading_progress_bar from common.networking import handle_request_error @@ -74,6 +75,7 @@ async def load_model_gen(model_path: pathlib.Path, **kwargs): load_status = container.load_gen(load_progress, **kwargs) progress = get_loading_progress_bar() + model_loading_started = time.time() progress.start() try: @@ -95,6 +97,8 @@ async def load_model_gen(model_path: pathlib.Path, **kwargs): progress.stop() finally: progress.stop() + model_loading_time = time.time() - model_loading_started + logger.info("Model loading took {:.2f} seconds.".format(model_loading_time)) async def load_model(model_path: pathlib.Path, **kwargs):