当前位置: 首页>>代码示例>>Python>>正文


Python model_zoo.tqdm方法代码示例

本文整理汇总了Python中torch.utils.model_zoo.tqdm方法的典型用法代码示例。如果您正苦于以下问题:Python model_zoo.tqdm方法的具体用法?Python model_zoo.tqdm怎么用?Python model_zoo.tqdm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torch.utils.model_zoo的用法示例。


在下文中一共展示了model_zoo.tqdm方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stream_url

# 需要导入模块: from torch.utils import model_zoo [as 别名]
# 或者: from torch.utils.model_zoo import tqdm [as 别名]
def stream_url(url: str,
               start_byte: Optional[int] = None,
               block_size: int = 32 * 1024,
               progress_bar: bool = True) -> Iterable:
    """Stream url by chunk

    Args:
        url (str): Url.
        start_byte (int, optional): Start streaming at that point (Default: ``None``).
        block_size (int, optional): Size of chunks to stream (Default: ``32 * 1024``).
        progress_bar (bool, optional): Display a progress bar (Default: ``True``).
    """

    # If we already have the whole file, there is no need to download it again
    req = urllib.request.Request(url, method="HEAD")
    url_size = int(urllib.request.urlopen(req).info().get("Content-Length", -1))
    if url_size == start_byte:
        return

    req = urllib.request.Request(url)
    if start_byte:
        req.headers["Range"] = "bytes={}-".format(start_byte)

    with urllib.request.urlopen(req) as upointer, tqdm(
        unit="B",
        unit_scale=True,
        unit_divisor=1024,
        total=url_size,
        disable=not progress_bar,
    ) as pbar:

        num_bytes = 0
        while True:
            chunk = upointer.read(block_size)
            if not chunk:
                break
            yield chunk
            num_bytes += len(chunk)
            pbar.update(len(chunk)) 
开发者ID:pytorch,项目名称:audio,代码行数:41,代码来源:utils.py

示例2: gen_bar_updater

# 需要导入模块: from torch.utils import model_zoo [as 别名]
# 或者: from torch.utils.model_zoo import tqdm [as 别名]
def gen_bar_updater():
    pbar = tqdm(total=None)

    def bar_update(count, block_size, total_size):
        if pbar.total is None and total_size:
            pbar.total = total_size
        progress_bytes = count * block_size
        pbar.update(progress_bytes - pbar.n)

    return bar_update 
开发者ID:LikeLy-Journey,项目名称:SegmenTron,代码行数:12,代码来源:utils.py

示例3: _save_response_content

# 需要导入模块: from torch.utils import model_zoo [as 别名]
# 或者: from torch.utils.model_zoo import tqdm [as 别名]
def _save_response_content(response, destination, chunk_size=32768):
    with open(destination, "wb") as f:
        pbar = tqdm(total=None)
        progress = 0
        for chunk in response.iter_content(chunk_size):
            if chunk:  # filter out keep-alive new chunks
                f.write(chunk)
                progress += len(chunk)
                pbar.update(progress - pbar.n)
        pbar.close() 
开发者ID:paperswithcode,项目名称:torchbench,代码行数:12,代码来源:utils.py

示例4: gen_bar_updater

# 需要导入模块: from torch.utils import model_zoo [as 别名]
# 或者: from torch.utils.model_zoo import tqdm [as 别名]
def gen_bar_updater():
    """@TODO: Docs. Contribution is welcome."""
    pbar = tqdm(total=None)

    def bar_update(count, block_size, total_size):
        if pbar.total is None and total_size:
            pbar.total = total_size
        progress_bytes = count * block_size
        pbar.update(progress_bytes - pbar.n)

    return bar_update 
开发者ID:catalyst-team,项目名称:catalyst,代码行数:13,代码来源:utils.py


注:本文中的torch.utils.model_zoo.tqdm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。