关于java:图灵学院JAVA高级架构师第四期最新完结无密asfsaf

2次阅读

共计 1987 个字符,预计需要花费 5 分钟才能阅读完成。

download: 图灵学院 JAVA 高级架构师【第四期】最新完结无密

筹备工作
既然要装逼,筹备工作是少不了的。所谓“站在凡人的肩膀上,做事事倍功半”,咱们这里的“凡人”就是 paddlepaddle 了,中文名称叫“飞桨”,那么这个 paddlepaddle 是什么呢?

它是“源于产业实践的开源深度学习平台,致力于让深度学习技术的翻新与利用更简略”,直白点就是我帮你实现了深度学习底层框架,你只需有创意就可能在我平台上使用大量简略代码轻松实现。它的官网是 https://www.paddlepaddle.org.cn/。

它的安装也比较简略,官网首页就有安装指引,咱们这里根据官网的安装指引,使用 pip 形式来安装 CPU 版本。

咱们首先执行语句:

python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi…

安装胜利后,咱们在 python 环境中测试一下是否安装胜利(这个也是按照官网指引来做),咱们切换到 python 环境,运行如下代码:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import paddle.fluid
paddle.fluid.install_check.run_check()
Running Verify Paddle Program …
Your Paddle works well on SINGLE GPU or CPU.
I0506 21:47:48.657404 2923565952 parallel_executor.cc:440] The Program will be executed on CPU using ParallelExecutor, 2 cards are used, so 2 programs are executed in parallel.
W0506 21:47:48.658407 2923565952 fuse_all_reduce_op_pass.cc:74] Find all_reduce operators: 2. To make the speed faster, some all_reduce ops are fused during training, after fusion, the number of all_reduce ops is 1.
I0506 21:47:48.658516 2923565952 build_strategy.cc:365] SeqOnlyAllReduceOps:0, num_trainers:1
I0506 21:47:48.659137 2923565952 parallel_executor.cc:307] Inplace strategy is enabled, when build_strategy.enable_inplace = True
I0506 21:47:48.659595 2923565952 parallel_executor.cc:375] Garbage collection strategy is enabled, when FLAGS_eager_delete_tensor_gb = 0
Your Paddle works well on MUTIPLE GPU or CPU.
Your Paddle is installed successfully! Let’s start deep Learning with Paddle now

看到 Your Paddle is installed successfully 就示意安装胜利了。

咱们接下来需要使用的是这个平台的 paddlehub 工具,所以咱们还需要安装 paddlehub:

pip install -i https://mirror.baidu.com/pypi… paddlehub

安装实现后,咱们就可能开始使用了。

代码实现
咱们的实现步骤很简略:导入模块 -> 加载模型 -> 获取图片文件 -> 调用模块抠图。

上面咱们看代码实现:

import os, paddlehub as hub
huseg = hub.Module(name=’deeplabv3p_xception65_humanseg’) # 加载模型
path = ‘./imgs/’ # 文件目录
files = [path + i for i in os.listdir(path)] # 获取文件列表
results = huseg.segmentation(data={‘image’: files}) # 抠图
我将图片放在代码文件夹的同级目录 imgs 文件夹下,运行代码后,输入的抠图图片会主动放在代码同级目录的 humanseg_output 目录下,文件名称跟原图片的名称雷同,然而文件格式是 png。

正文完
 0