美文网首页我爱编程
在Mac平台上配置Conda+Tensorflow+Google

在Mac平台上配置Conda+Tensorflow+Google

作者: JomarWu | 来源:发表于2018-04-23 21:54 被阅读0次

背景

BrainPad公司在2017年的Google开发者大会上用DobotMagician做了一个深度学习相关的Demo。在该演示Demo中能进行图像分类的机器学习,并基于学习完的模型听懂你说的话,最后配合DobotMagician机械臂给你符合你口味的糖果。
作为Dobot的开发者,我是必须搞一搞这个Demo,还是蛮有趣的。下面是整理出来的一些一些关键点。

坏境

  1. MacBookAir(13-inch, 2017)
  2. MacOS 10.13.3
  3. Conda 4.3.30
  4. Python 2.7.13
  5. Flask 0.12.2
  6. google-cloud 0.23.0
  7. Tensorflow 1.0.1
  8. OpenCV 3.14.1

配置注意点

  1. 详情参照工程的配置教程,下面列出我不一样的环境配置
  2. 安装Conda,创建python2.7.13环境,切换到python2.7.13环境
  3. 找到FinYourCandy里面的requirements文件,将webapp/requirements.txt里面的Tensorflow包注释掉
  4. 安装依赖。选用Tensorflow1.0.1是为了兼容GoogleCloudML的默认环境,这样需要修改Tensorflow的接口,因为默认是用0.12.1
sudo pip install -r robot-arm/requirements.txt
sudo pip install -r webapp/requirements.txt
pip install pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.1-py2-none-any.whl
conda install -c conda-forge uwsgi
conda install -c anaconda nginx
conda install -c menpo opencv3
  1. 注意WebAPP的启动时间比较长是应为加载词向量耗时大,不是卡住了
  2. sit-package不添加到bash_profile否则conda报错
  3. 使用ShadowsocksX-NG科学上网,具体百度。
  4. 在Terminal中输入如下代码,则当前页面会将HTTP数据转到ShadowsocksX-NG
export http_proxy="http://127.0.0.1:1087"
export https_proxy="http://127.0.0.1:1087"

遇到的问题

Failed to detect markers and found no successful record

解决办法:重新完成相机标定。相机标定程序是setup/script/camera_tune.py

W tensorflow/core/platform/cloud/google_auth_provider.cc:151] All attempts to get a Google authentication bearer token failed, returning an empty token. Retrieving token from files failed with "Failed precondition: Could not initialize the libcurl library. Please make sure that libcurl is installed in the OS or statically linked to the TensorFlow binary.". Retrieving token from GCE failed with "Failed precondition: Could not initialize the libcurl library. Please make sure that libcurl is installed in the OS or statically linked to the TensorFlow binary.".

解决办法:Tensorflow1.6.0的bug,使用另外的版本。

Traceback (most recent call last):
File "run.py", line 26, in <module>
app = create_app()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/app.py", line 38, in create_app
_configure_blueprints(app)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/app.py", line 57, in _configure_blueprints
app.register_blueprint(api)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
return f(self, *args, *kwargs)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 951, in register_blueprint
blueprint.register(self, options, first_registration)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/blueprints.py", line 154, in register
deferred(state)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 68, in record
candy_classifier.init()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/classify.py", line 48, in init
self._load_transfer_model()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/classify.py", line 63, in _load_transfer_model
self.model = TransferModel.from_model_params(params)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/../../train/trainer/model.py", line 109, in from_model_params
hidden_size=model_params.hidden_size
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/../../train/trainer/model.py", line 88, in init
tf.nn.softmax_cross_entropy_with_logits(logits, one_hot)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/util/deprecation.py", line 250, in new_func
return func(
args, **kwargs)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1953, in softmax_cross_entropy_with_logits
logits)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1779, in _ensure_xent_args
"named arguments (labels=..., logits=..., ...)" % name)
ValueError: Only call softmax_cross_entropy_with_logits with named arguments (labels=..., logits=..., ...)

解决办法:softmax_cross_entropy_with_logits接口改了,加上labels和logits两个参数的指定。另外还有几处接口的适配问题需要解决,不再叙述。

WebAPP启动后出现不可预知错误。Segmentation fault: 11

使用了proxychains4来走代理,改用ShadowsocksX-NG

Traceback (most recent call last):
File "/Users/wubinbin/Developer/FindYourCandy/webapp/run.py", line 26, in <module>
app = create_app()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/app.py", line 41, in create_app
_configure_blueprints(app)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/app.py", line 56, in _configure_blueprints
app.register_blueprint(api)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 64, in wrapper_func
return f(self, *args, **kwargs)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 951, in register_blueprint
blueprint.register(self, options, first_registration)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/blueprints.py", line 154, in register
deferred(state)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 77, in record
image_calibrator = ImageCalibrator.from_config(Config)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/calibrate.py", line 40, in from_config
scale=config.IMAGE_CALIBRATOR_SCALE)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/calibrate.py", line 25, in init
self.dictionary = cv2.aruco.Dictionary_get(dictionary)
AttributeError: 'module' object has no attribute 'Dictionary_get'

解决办法:重装opencv

192.168.0.119 - - [29/Mar/2018 18:22:06] "POST /api/capture HTTP/1.1" 500 -
2018-03-29 18:22:20,127 - candysorter.views.api - INFO - === Capture step 1: id=5264220933829695, session=20180329_182220_5264220933829695 ===
2018-03-29 18:22:20,127 - candysorter.views.api - INFO - Capturing image.
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp, line 11111
2018-03-29 18:22:20,127 - candysorter.views.api - WARNING - Retrying: 1 times.
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp, line 11111
2018-03-29 18:22:20,233 - candysorter.views.api - WARNING - Retrying: 2 times.
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp, line 11111
2018-03-29 18:22:20,339 - candysorter.views.api - WARNING - Retrying: 3 times.
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp, line 11111
2018-03-29 18:22:20,447 - candysorter.views.api - WARNING - Retrying: 4 times.
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp, line 11111
2018-03-29 18:22:20,552 - candysorter.views.api - WARNING - Retrying: 5 times.
2018-03-29 18:22:20,662 - candysorter.views.api - ERROR - Unexpected error.
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 101, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 277, in capture
img = _capture_image()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 431, in _capture_image
raise Exception('Failed to capture image.')
Exception: Failed to capture image.

解决办法:1. 确保项目正在使用prd模式,而不是dev模式;2. conda install -c menpo opencv3重装opencv。参照该stackoverflow问题;3. 相机串口系统资源能被opencv正确识别;4. 通过相机调试程序

Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 100, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 336, in train
candy_trainer.create_labels_file(job_id, labels)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/train.py", line 76, in create_labels_file
f.write(json.dumps(labels, separators=(',', ':')))
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 203, in exit
self.close()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 235, in close
pywrap_tensorflow.Set_TF_Status_from_Status(status, ret_status)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit
c_api.TF_GetCode(self.status.status))
PermissionDeniedError: Error executing an HTTP request (HTTP response code 403, error code 0, error message ''), response '{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "dobot-318@dobot-180508.iam.gserviceaccount.com does not have storage.objects.create access to bucket candy20180322."
}
],
"code": 403,
"message": "dobot-318@dobot-180508.iam.gserviceaccount.com does not have storage.objects.create access to bucket candy20180322."
}
}
'
when initiating an upload to gs://candy20180322/dobot-180508/features/labels.json

解决办法:Google接口权限问题,使用项目自带的服务账号申请的凭证

2018-04-11 11:21:10,084 - candysorter.views.api - INFO - Saving candy images.
2018-04-11 11:21:41,134 - candysorter.views.api - INFO - === Start training: id=8065305243577681, session=20180411_112046_8065305243577681 ===
2018-04-11 11:21:41,134 - candysorter.views.api - INFO - Creating labels file: job_id=candy_sorter_20180411_112046_8065305243577681
2018-04-11 11:21:44,849 - candysorter.views.api - INFO - Creating features file: job_id=candy_sorter_20180411_112046_8065305243577681
2018-04-11 11:21:54,168 - candysorter.views.api - INFO - Starting training: job_id=candy_sorter_20180411_112046_8065305243577681
2018-04-11 11:21:56,927 - candysorter.views.api - ERROR - Unexpected error.
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 100, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 349, in train
candy_trainer.start_training(job_id)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/train.py", line 105, in start_training
job.create()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/ext/google/cloud/ml/job.py", line 102, in create
client._connection.api_request(method='POST', path=path, data=self.to_api_repr())
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google/cloud/_http.py", line 303, in api_request
error_info=method + ' ' + url)
NotFound: 404 <!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px} > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/v1beta1/projects/dobot-180508/jobs</code> was not found on this server. <ins>That’s all we know.</ins>
(POST https://ml.googleapis.com/v1beta1/projects/dobot-180508/jobs)

解决办法:更新项目的GoogleCloudAPI版本


GoogleCloudAPI

2018-04-11 11:37:27,258 - candysorter.views.api - INFO - Saving candy images.
2018-04-11 11:37:30,722 - candysorter.views.api - INFO - === Start training: id=6604066877834309, session=20180411_113702_6604066877834309 ===
2018-04-11 11:37:30,722 - candysorter.views.api - INFO - Creating labels file: job_id=candy_sorter_20180411_113702_6604066877834309
2018-04-11 11:37:34,818 - candysorter.views.api - INFO - Creating features file: job_id=candy_sorter_20180411_113702_6604066877834309
2018-04-11 11:37:44,135 - candysorter.views.api - INFO - Starting training: job_id=candy_sorter_20180411_113702_6604066877834309
2018-04-11 11:37:47,413 - candysorter.views.api - ERROR - Unexpected error.
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 100, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 349, in train
candy_trainer.start_training(job_id)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/train.py", line 105, in start_training
job.create()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/ext/google/cloud/ml/job.py", line 102, in create
client._connection.api_request(method='POST', path=path, data=self.to_api_repr())
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google/cloud/_http.py", line 303, in api_request
error_info=method + ' ' + url)
BadRequest: 400 Field: package_uris Error: The provided GCS paths [gs://candy20180322/package/trainer-0.0.0.tar.gz] cannot be read. Please make sure that the objects exist and you have read access to it. (POST https://ml.googleapis.com/v1/projects/dobot-180508/jobs)

解决办法:CloudML的运行代码是一个压缩文件,保存在GoogleCloud。重新制作并上传到正确的路径即可。

Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 100, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 349, in train
candy_trainer.start_training(job_id)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/models/images/train.py", line 105, in start_training
job.create()
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/ext/google/cloud/ml/job.py", line 102, in create
client._connection.api_request(method='POST', path=path, data=self.to_api_repr())
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google/cloud/_http.py", line 299, in api_request
headers=headers, target_object=_target_object)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google/cloud/_http.py", line 193, in _make_request
return self._do_request(method, url, headers, data, target_object)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google/cloud/_http.py", line 223, in _do_request
body=data)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/google_auth_httplib2.py", line 198, in request
uri, method, body=body, headers=request_headers, **kwargs)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/httplib2/init.py", line 1659, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/httplib2/init.py", line 1399, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/httplib2/init.py", line 1355, in _conn_request
response = conn.getresponse()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/httplib.py", line 1121, in getresponse
response.begin()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/httplib.py", line 438, in begin
version, status, reason = self._read_status()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/httplib.py", line 394, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/ssl.py", line 766, in recv
return self.read(buflen)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/ssl.py", line 653, in read
v = self._sslobj.read(len)
error: [Errno 54] Connection reset by peer

解决办法:查看WebAPP的config文件是不是搞错了{job_id}字段。该字段不需要替换,是程序生成的。


Config配置
CloudML日志: CloudML日志

解决办法:1. 上传上CloudML的脚本代码,应该使用Tensorflow1.0.1的接口;

Exception happened during processing of request from ('127.0.0.1', 59401)
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/SocketServer.py", line 654, in init
self.finish()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/SocketServer.py", line 713, in finish
self.wfile.close()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/socket.py", line 283, in close
self.flush()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe

解决办法:科学上网

wubinbindeMacBook-Air:~ wubinbin$ curl -XPOST -d'{"x":150, "y":150}' --header "Content-Type: application/json" 127.0.0.1:18001/api/pickup
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
wubinbindeMacBook-Air:~ wubinbin$ curl -XPOST -d'{"x":-0.03, "y":1.21}' --header "Content-Type: application/json" 127.0.0.1:18001/api/pickup
{}

解决办法:不使用privoxy代理程序,使用ShadowsocksX-NG

2018-04-12 15:52:32,209 - candysorter.views.api - ERROR - Unexpected error.
Traceback (most recent call last):
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 100, in wrapper
return f(*args, **kwargs)
File "/Users/wubinbin/Developer/FindYourCandy/webapp/candysorter/views/api.py", line 188, in similarities
nearest_idx = np.argmax([speech_sim.dot(s) for s in candy_sims])
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 1004, in argmax
return _wrapfunc(a, 'argmax', axis=axis, out=out)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 62, in _wrapfunc
return _wrapit(obj, method, *args, *kwds)
File "/Users/wubinbin/anaconda3/envs/candy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 42, in _wrapit
result = getattr(asarray(obj), method)(
args, **kwds)
ValueError: attempt to get argmax of an empty sequence

解决办法:程序容错性差,在相机没有识别到任何抓取物的时候会出现这个错误,要不调试相机,要不在代码上加上防护。

相关文章

网友评论

    本文标题:在Mac平台上配置Conda+Tensorflow+Google

    本文链接:https://www.haomeiwen.com/subject/hpdrlftx.html