mindspore_hub

MindSpore Hub是MindSpore生态系统的预训练模型应用工具,作为模型开发者和应用开发者的通道。

mindspore_hub.load(name, *args, source='gitee', pretrained=True, force_reload=False, **kwargs)[源代码]

用于加载指定网络。加载完成后,可用于推理验证、迁移学习等。如果 sourcelocal,会先检查本地是否存在对应模型文件,如果存在 就加载本地的,反之会自动下载模型文件并加载;如果 pretrainedTrue,会先检查本地是否存在对应的ckpt文件,存在就会直接加载, 不存在就会自动下载到本地并加载。

参数:

  • name (str) - 网络的 uidurl ,或者md文件的本地路径。

  • args (tuple) - 网络初始化的参数。

  • source (str) - 是否将 name 解析为gitee模型URI、github模型URI或本地资源。默认值:gitee。

  • pretrained (bool) - 是否加载预训练模型。 默认值:True。

  • force_reload (bool) - 是否从 url 重新加载网络和ckpt。 默认值:False。

  • kwargs (dict) - 网络初始化的关键字参数。

返回:

Cell,网络。

样例:

>>> import mindspore_hub
>>> net = mindspore_hub.load('mindspore/1.3/alexnet_cifar10', 10, pretrained=True)
>>> # For details about how to call the parameters of the network,
>>> # please refer to the "Usage" in the md file of the network.
>>> #
>>> # 1. To find the corresponding md file, there are two methods:
>>> #
>>> # 1.1. Find the corresponding md file from the local hub source code.
>>> # 1.1.1. Use 'git clone' command to copy the hub repository from
>>> # Mindspore/hub<https://gitee.com/mindspore/hub.git>. Assume that the hub repository is cloned to <D:\hub\>.
>>> # 1.1.2. The preceding address is <D:\hub\mshub_res\assets\mindspore\1.3\alexnet_cifar10.md>.
>>> #
>>> # 1.2. Find the corresponding md file from the website.
>>> # 1.2.1. The prefix is fixed: <https://gitee.com/mindspore/hub/tree/master/mshub_res/assets/>
>>> # + <address where you want to load the md file>.
>>> # 1.2.2. The preceding address is
>>> # <https://gitee.com/mindspore/hub/tree/master/mshub_res/assets/
>>> # mindspore/1.3/alexnet_cifar10.md>.
>>> #
>>> # 2. Want to find more information about this network?
>>> # 2.1. Go to the corresponding website to learn more.
>>> # 2.2. To obtain the corresponding website, perform the following steps:
>>> # 2.2.1. After you have found the md file, there is a repo-link in the md file that allows
>>> # you to directly access the web page of the corresponding network.
>>> # 2.2.2. The web page corresponding to the preceding code is
>>> # <https://gitee.com/mindspore/models/tree/r1.3/official/cv/alexnet>.
>>> #
>>> # 2.3. The web page of operation 2.2 contains a "mindspore_hub_conf.py",
>>> # which is invoked by the load function. Therefore, to call more parameters,
>>> # or if you want to DIY interfaces to be called, you can modify this file.
>>> # It is recommended that you back up the mindspore_hub_conf.py file.
>>> # 2.4. In addition to the function of mindspore_hub_conf.py, you can also call files in the src files of the
>>> # corresponding web page. More Alexnet network information can be obtained from here.
mindspore_hub.hub_list(version=None, force_reload=False)[源代码]

列出MindSpore Hub支持的所有asset。

参数:

  • version (str) - 指定要列出的版本。None 表示最新版本。默认值:None。

  • force_reload (bool) - 是否从 url 重新加载网络。 默认值:False。

返回:

list,MindSpore Hub支持的asset列表。

样例:

>>> import mindspore_hub as ms_hub
>>> hub_list = ms_hub.hub_list()
>>> hub_list[:5]
>>> ['3dcnn_brast2017', '3ddensenet_iseg2017', 'adnet_vot2013vot2014', 'advancedeast_icpr2018',
'aecrnet_reside']