所以当从以下repo https://github.com/eldar/pose-tensorflow运行test.py代码时 我收到这个错误:
[jalal@goku pose-tensorflow]$ TF_CUDNN_USE_AUTOTUNE=0 python demo/demo_multiperson.py
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
ImportError: numpy.core.multiarray failed to import
ImportError: numpy.core.umath failed to import
ImportError: numpy.core.umath failed to import
2018-04-08 17:09:02.321666: F tensorflow/python/lib/core/bfloat16.cc:664] Check failed: PyBfloat16_Type.tp_base != nullptr
Aborted
test.py
代码为:
import argparse
import logging
import os
import numpy as np
import scipy.io
import scipy.ndimage
from config import load_config
from dataset.factory import create as create_dataset
from dataset.pose_dataset import Batch
from nnet.predict import setup_pose_prediction, extract_cnn_output, argmax_pose_predict
from util import visualize
def test_net(visualise, cache_scoremaps):
logging.basicConfig(level=logging.INFO)
cfg = load_config()
dataset = create_dataset(cfg)
dataset.set_shuffle(False)
dataset.set_test_mode(True)
sess, inputs, outputs = setup_pose_prediction(cfg)
if cache_scoremaps:
out_dir = cfg.scoremap_dir
if not os.path.exists(out_dir):
os.makedirs(out_dir)
num_images = dataset.num_images
predictions = np.zeros((num_images,), dtype=np.object)
for k in range(num_images):
print('processing image {}/{}'.format(k, num_images-1))
batch = dataset.next_batch()
outputs_np = sess.run(outputs, feed_dict={inputs: batch[Batch.inputs]})
scmap, locref, pairwise_diff = extract_cnn_output(outputs_np, cfg)
pose = argmax_pose_predict(scmap, locref, cfg.stride)
pose_refscale = np.copy(pose)
pose_refscale[:, 0:2] /= cfg.global_scale
predictions[k] = pose_refscale
if visualise:
img = np.squeeze(batch[Batch.inputs]).astype('uint8')
visualize.show_heatmaps(cfg, img, scmap, pose)
visualize.waitforbuttonpress()
if cache_scoremaps:
base = os.path.basename(batch[Batch.data_item].im_path)
raw_name = os.path.splitext(base)[0]
out_fn = os.path.join(out_dir, raw_name + '.mat')
scipy.io.savemat(out_fn, mdict={'scoremaps': scmap.astype('float32')})
out_fn = os.path.join(out_dir, raw_name + '_locreg' + '.mat')
if cfg.location_refinement:
scipy.io.savemat(out_fn, mdict={'locreg_pred': locref.astype('float32')})
scipy.io.savemat('predictions.mat', mdict={'joints': predictions})
sess.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--novis', default=False, action='store_true')
parser.add_argument('--cache', default=False, action='store_true')
args, unparsed = parser.parse_known_args()
test_net(not args.novis, args.cache)
我有以下几点:
$ conda list tensorflow
# packages in environment at /scratch/sjn/anaconda:
#
tensorflow 1.5.0 py36_0 conda-forge
tensorflow-gpu 1.3.0 0
tensorflow-gpu-base 1.3.0 py36cuda8.0cudnn6.0_1
tensorflow-tensorboard 0.1.5 py36_0
和
$ conda list numpy
# packages in environment at /scratch/sjn/anaconda:
#
msgpack-numpy 0.4.1 <pip>
numpy 1.13.3 py36_blas_openblas_201 [blas_openblas] conda-forge
numpydoc 0.7.0 py36h18f165f_0