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


Python utils.get_file方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tensorflow.keras import utils [as 别名]
# 或者: from tensorflow.keras.utils import get_file [as 别名]
def __init__(self):

        proto_url = 'https://download.cvlib.net/config/gender_detection/gender_deploy.prototxt'
        model_url = 'https://github.com/arunponnusamy/cvlib-files/releases/download/v0.1/gender_net.caffemodel'
        save_dir = os.path.expanduser('~') + os.path.sep + '.cvlib' + os.path.sep + 'pre-trained'

        if not os.path.exists(save_dir):
            os.makedirs(save_dir)

        self.proto = get_file('gender_deploy.prototxt', proto_url,
                                cache_subdir=save_dir) 
        self.model = get_file('gender_net.caffemodel', model_url,
                              cache_subdir=save_dir)

        self.labels = ['male', 'female']
        self.mean = (78.4263377603, 87.7689143744, 114.895847746)

        print('[INFO] Initializing gender detection model ..')
        self.net = cv2.dnn.readNetFromCaffe(self.proto, self.model) 
开发者ID:arunponnusamy,项目名称:cvlib,代码行数:21,代码来源:gender_detection.py

示例2: _download_data

# 需要导入模块: from tensorflow.keras import utils [as 别名]
# 或者: from tensorflow.keras.utils import get_file [as 别名]
def _download_data():
    _ = get_file(
        'qm9.tar.gz', DATASET_URL,
        extract=True, cache_dir=DATA_PATH, cache_subdir=DATA_PATH
    )
    os.rename(DATA_PATH + 'gdb9.sdf', DATA_PATH + 'qm9.sdf')
    os.rename(DATA_PATH + 'gdb9.sdf.csv', DATA_PATH + 'qm9.sdf.csv')
    os.remove(DATA_PATH + 'qm9.tar.gz') 
开发者ID:danielegrattarola,项目名称:spektral,代码行数:10,代码来源:qm9.py

示例3: _get_data

# 需要导入模块: from tensorflow.keras import utils [as 别名]
# 或者: from tensorflow.keras.utils import get_file [as 别名]
def _get_data(cls, data: Union[str, np.ndarray, Iterable, Dict[str, Union[Iterable, np.ndarray]]], model: Model) \
            -> Union[np.ndarray, Iterable, Dict[str, Union[Iterable, np.ndarray]]]:
        if not isinstance(data, str):
            return data

        if data.startswith('http://') or data.startswith('https://'):
            filename = '{timestamp}_{filename}'.format(
                timestamp=datetime.now().timestamp(), filename=data.split('/')[-1])
            data_file = utils.get_file(filename, data)
        else:
            data_file = os.path.abspath(os.path.expanduser(data))

        extensions = [ext for ext in cls._supported_data_file_extensions if data_file.endswith('.' + ext)]

        if os.path.isfile(data_file):
            assert extensions, 'Unsupported type for file {}. Supported extensions: {}'.format(
                data_file, cls._supported_data_file_extensions
            )

            extension = extensions.pop()
            if extension in cls._csv_extensions:
                return cls._get_csv_data(data_file)
            if extension == 'npy':
                return cls._get_numpy_data(data_file)
            if extension == 'npz':
                return cls._get_numpy_compressed_data(data_file)
            if extension in cls._image_extensions:
                return cls._get_image(data_file, model)

            raise AssertionError('Unsupported file type: {}'.format(data_file))
        elif os.path.isdir(data_file):
            return cls._get_dir(data_file, model) 
开发者ID:BlackLight,项目名称:platypush,代码行数:34,代码来源:__init__.py

示例4: read_data

# 需要导入模块: from tensorflow.keras import utils [as 别名]
# 或者: from tensorflow.keras.utils import get_file [as 别名]
def read_data():
    # Get the file
    try:
        path = get_file(
            "babi-tasks-v1-2.tar.gz",
            origin="https://s3.amazonaws.com/text-datasets/"
            "babi_tasks_1-20_v1-2.tar.gz")
    except Exception:
        print(
            "Error downloading dataset, please download it manually:\n"
            "$ wget http://www.thespermwhale.com/jaseweston/babi/tasks_1-20_v1-2"  # noqa: E501
            ".tar.gz\n"
            "$ mv tasks_1-20_v1-2.tar.gz ~/.keras/datasets/babi-tasks-v1-2.tar.gz"  # noqa: E501
        )
        raise

    # Choose challenge
    challenges = {
        # QA1 with 10,000 samples
        "single_supporting_fact_10k": "tasks_1-20_v1-2/en-10k/qa1_"
        "single-supporting-fact_{}.txt",
        # QA2 with 10,000 samples
        "two_supporting_facts_10k": "tasks_1-20_v1-2/en-10k/qa2_"
        "two-supporting-facts_{}.txt",
    }
    challenge_type = "single_supporting_fact_10k"
    challenge = challenges[challenge_type]

    with tarfile.open(path) as tar:
        train_stories = get_stories(tar.extractfile(challenge.format("train")))
        test_stories = get_stories(tar.extractfile(challenge.format("test")))

    return train_stories, test_stories 
开发者ID:ray-project,项目名称:ray,代码行数:35,代码来源:pbt_memnn_example.py


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