首页 > 解决方案 > TypeError:在运行 caffe 示例期间需要一个类似字节的对象,而不是 python3 中的“str”

问题描述

当我运行这些代码时:

untrained_style_net = caffe.Net(style_net(train=False, subset='train'),'/content/caffe/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel', caffe.TEST)
untrained_style_net.forward()
style_data_batch = untrained_style_net.blobs['data'].data.copy()
style_label_batch = np.array(untrained_style_net.blobs['label'].data, dtype=np.int32)

我收到此错误:

TypeError Traceback (most recent call last)
in ()
----> 1 untrained_style_net = caffe.Net(style_net(train=False, subset='train'),'/content/caffe/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel', caffe.TEST)
2 untrained_style_net.forward()
3 style_data_batch = untrained_style_net.blobs['data'].data.copy()
4 style_label_batch = np.array(untrained_style_net.blobs['label'].data, dtype=np.int32)

2 frames
/usr/lib/python3.6/tempfile.py in func_wrapper(*args, **kwargs)
622 @_functools.wraps(func)
623 def func_wrapper(*args, **kwargs):
--> 624 return func(*args, **kwargs)
625 # Avoid closing the file as long as the wrapper is alive,
626 # see issue #18879.

TypeError: a bytes-like object is required, not 'str'

我该如何解决?

标签: python

解决方案


推荐阅读