代码拉取完成,页面将自动刷新
同步操作将从 我爱计算机视觉/FaceMaskDetection 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
import paddle.fluid as fluid
def load_model(params_file, model_file, use_gpu=False, use_mkl=False, mkl_thread_num=4):
config = fluid.core.AnalysisConfig(model_file, params_file)
if use_gpu:
# 设置GPU初始显存(单位M)和Device ID
config.enable_use_gpu(100, 0)
else:
config.disable_gpu()
if use_mkl and not use_gpu:
config.enable_mkldnn()
config.set_cpu_math_library_num_threads(mkl_thread_num)
config.disable_glog_info()
config.enable_memory_optim()
# 开启计算图分析优化,包括OP融合等
config.switch_ir_optim(True)
# 关闭feed和fetch OP使用,使用ZeroCopy接口必须设置此项
config.switch_use_feed_fetch_ops(False)
predictor = fluid.core.create_paddle_predictor(config)
return predictor
predictor = load_model('models/paddle/__params__', 'models/paddle/__model__', use_gpu=False)
import numpy as np
data = np.random.rand(1, 3, 260, 260).astype('float32')
input_names = predictor.get_input_names()
input_tensor = predictor.get_input_tensor(input_names[0])
input_tensor.copy_from_cpu(data)
predictor.zero_copy_run()
output_names = predictor.get_output_names()
output_tensor = predictor.get_output_tensor(output_names[0])
result = output_tensor.copy_to_cpu()
print(result.shape)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。