vlm: optimize tensor transport (#6003)
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import traceback
|
||||
import urllib.request
|
||||
import weakref
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from functools import wraps
|
||||
from io import BytesIO
|
||||
from json import dumps
|
||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union
|
||||
@@ -28,6 +29,24 @@ from tqdm import tqdm
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def execute_once(func):
|
||||
has_run = None
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
nonlocal has_run
|
||||
if not has_run:
|
||||
func(*args, **kwargs)
|
||||
has_run = True
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@execute_once
|
||||
def info_once(message: str):
|
||||
logger.info(message)
|
||||
|
||||
|
||||
def convert_json_schema_to_str(json_schema: Union[dict, str, Type[BaseModel]]) -> str:
|
||||
"""Convert a JSON schema to a string.
|
||||
Parameters
|
||||
|
||||
Reference in New Issue
Block a user