infocusp / tf_cnnvis

CNN visualization tool in TensorFlow
MIT License
780 stars 208 forks source link

Buffer dtype mismatch, expected 'double' but got 'float' #76

Open HongyiDuanmu26 opened 6 years ago

HongyiDuanmu26 commented 6 years ago

In Example 3:

ValueError Traceback (most recent call last)

in () 4 layer=layer, classes = [1, 2, 3, 4, 5], 5 path_logdir=os.path.join("Log","Inception5"), ----> 6 path_outdir=os.path.join("Output","Inception5")) 7 start = time.time() - start 8 print("Total Time = %f" % (start)) /usr/local/lib/python2.7/dist-packages/tf_cnnvis-1.0.0-py2.7.egg/tf_cnnvis/tf_cnnvis.pyc in deepdream_visualization(sess_graph_path, value_feed_dict, layer, classes, input_tensor, path_logdir, path_outdir) 422 units = classes 423 is_success = _get_visualization(sess_graph_path, value_feed_dict, input_tensor = input_tensor, layers = layer, method = "deepdream", --> 424 path_logdir = path_logdir, path_outdir = path_outdir) 425 return is_success /usr/local/lib/python2.7/dist-packages/tf_cnnvis-1.0.0-py2.7.egg/tf_cnnvis/tf_cnnvis.pyc in _get_visualization(sess_graph_path, value_feed_dict, input_tensor, layers, path_logdir, path_outdir, method) 164 for layer in layers: 165 if layer != None and layer.lower() not in dict_layer.keys(): --> 166 is_success = _visualization_by_layer_name(g, value_feed_dict, input_tensor, layer, method, path_logdir, path_outdir) 167 elif layer != None and layer.lower() in dict_layer.keys(): 168 layer_type = dict_layer[layer.lower()] /usr/local/lib/python2.7/dist-packages/tf_cnnvis-1.0.0-py2.7.egg/tf_cnnvis/tf_cnnvis.pyc in _visualization_by_layer_name(graph, value_feed_dict, input_tensor, layer_name, method, path_logdir, path_outdir) 292 elif method == "deepdream": 293 # deepdream --> 294 is_success = _deepdream(graph, sess, op_tensor, X, feed_dict, layer_name, path_outdir, path_logdir) 295 is_deep_dream = False 296 /usr/local/lib/python2.7/dist-packages/tf_cnnvis-1.0.0-py2.7.egg/tf_cnnvis/tf_cnnvis.pyc in _deepdream(graph, sess, op_tensor, X, feed_dict, layer, path_outdir, path_logdir) 376 min_img = im.min() 377 max_img = im.max() --> 378 temp = denoise_tv_bregman((im - min_img) / (max_img - min_img), weight = config["TV_DENOISE_WEIGHT"]) 379 img[i] = (temp * (max_img - min_img) + min_img).reshape(img[i].shape) 380 /usr/local/lib/python2.7/dist-packages/skimage/restoration/_denoise.pyc in denoise_tv_bregman(image, weight, max_iter, eps, isotropic) 162 163 """ --> 164 return _denoise_tv_bregman(image, weight, max_iter, eps, isotropic) 165 166 skimage/restoration/_denoise_cy.pyx in skimage.restoration._denoise_cy._denoise_tv_bregman() ValueError: Buffer dtype mismatch, expected 'double' but got 'float' Thank you so much in advance!
ernestlishun commented 5 years ago

I got the same bug. Do you get the reasons? Thank you for telling me, if you have the solve method.

ernestlishun commented 5 years ago

I solve the problem by CHANGE: temp = denoise_tv_bregman((im - min_img) / (max_img - min_img), weight = config["TV_DENOISE_WEIGHT"]) TO: temp = denoise_tv_bregman(np.float64((im - min_img) / (max_img - min_img)), weight = config["TV_DENOISE_WEIGHT"])