NameError: name 'predict_from_url' is not defined
NameError: name 'predict_from_url' is not defined
我正在尝试 http://mxnet.io/tutorials/embedded/wine_detector.html 中提到的 MXNet 教程(第 "Running the Model" 节在树莓派 pi3 上使用 python3.4,特别是脚本 "inception_predict.py"。我设法解决了几个问题,但我被这个错误难住了:
>> import inception_predict
[23:43:37] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[23:43:37] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!
>> predict_from_url("http://imgur.com/HzafyBA")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'predict_from_url' is not defined
函数 predict_from_url 在导入文件 inception_predict.py 中定义(如教程中所述)那么为什么 python 告诉我它没有定义?
我做错了什么?
本教程有一些错误,您需要更正它们才能完成 运行:
将时间添加到 inception_predict.py
中的导入列表
...
导入 cv2,os,urllib,时间
...
使用你可以直接下载的 URL(使用你最喜欢的图片搜索引擎来查找)
调用全名函数
inception_predict. predict_from_url("https://media.mnn.com/assets/images/2017/01/cow-in-pasture.jpg.838x0_q80.jpg")
经过这些小改动后,您将看到如下内容:
pre-processed image in 0.27312707901
MKL Build:20170209
forward pass in 0.131096124649
probability=0.784963, class=n02403003 ox
probability=0.099463, class=n03868242 oxcart
probability=0.035585, class=n03967562 plow, plough
probability=0.033620, class=n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
probability=0.015443, class=n02412080 ram, tup
[(0.78496253, 'n02403003 ox'), (0.09946309, 'n03868242 oxcart'), (0.035584591, 'n03967562 plow, plough'), (0.033620458, 'n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis'), (0.015442736, 'n02412080 ram, tup')]
我正在尝试 http://mxnet.io/tutorials/embedded/wine_detector.html 中提到的 MXNet 教程(第 "Running the Model" 节在树莓派 pi3 上使用 python3.4,特别是脚本 "inception_predict.py"。我设法解决了几个问题,但我被这个错误难住了:
>> import inception_predict
[23:43:37] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[23:43:37] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!>> predict_from_url("http://imgur.com/HzafyBA")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'predict_from_url' is not defined
函数 predict_from_url 在导入文件 inception_predict.py 中定义(如教程中所述)那么为什么 python 告诉我它没有定义? 我做错了什么?
本教程有一些错误,您需要更正它们才能完成 运行:
将时间添加到 inception_predict.py
中的导入列表... 导入 cv2,os,urllib,时间 ...
使用你可以直接下载的 URL(使用你最喜欢的图片搜索引擎来查找)
调用全名函数
inception_predict. predict_from_url("https://media.mnn.com/assets/images/2017/01/cow-in-pasture.jpg.838x0_q80.jpg")
经过这些小改动后,您将看到如下内容:
pre-processed image in 0.27312707901
MKL Build:20170209
forward pass in 0.131096124649
probability=0.784963, class=n02403003 ox
probability=0.099463, class=n03868242 oxcart
probability=0.035585, class=n03967562 plow, plough
probability=0.033620, class=n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
probability=0.015443, class=n02412080 ram, tup
[(0.78496253, 'n02403003 ox'), (0.09946309, 'n03868242 oxcart'), (0.035584591, 'n03967562 plow, plough'), (0.033620458, 'n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis'), (0.015442736, 'n02412080 ram, tup')]