deep-visualization-toolbox icon indicating copy to clipboard operation
deep-visualization-toolbox copied to clipboard

Resize shape error

Open cw1204772 opened this issue 7 years ago • 2 comments

While I'm testing caffe model from here: https://drive.google.com/drive/u/0/folders/0B67_d0rLRTQYZnB5ZUZpdTlxM0k (prototxt: jstl_dgd_deploy_inference.prototxt caffemodel: jstl_dgd_inference.caffemodel)

I encounter the following error message no matter my input image is 144 * 56 or 56 * 144 or 227 * 227(default ilvsrc2012 image):

InputImageFetcher: bind_camera finished
Starting app: CaffeVisApp
  Prettified layer name: "pool1" -> "p1"
  Prettified layer name: "pool1_pool1_0_split_0" -> "p1_p1_0_split_0"
  Prettified layer name: "pool1_pool1_0_split_1" -> "p1_p1_0_split_1"
  Prettified layer name: "pool1_pool1_0_split_2" -> "p1_p1_0_split_2"
  Prettified layer name: "pool1_pool1_0_split_3" -> "p1_p1_0_split_3"
  Prettified layer name: "inception_1a/pool" -> "inception_1a/p"
  Prettified layer name: "inception_1a/pool_proj" -> "inception_1a/p_proj"
  Prettified layer name: "inception_1b/pool" -> "inception_1b/p"
  Prettified layer name: "inception_2a/pool" -> "inception_2a/p"
  Prettified layer name: "inception_2a/pool_proj" -> "inception_2a/p_proj"
  Prettified layer name: "inception_2b/pool" -> "inception_2b/p"
  Prettified layer name: "inception_3a/pool" -> "inception_3a/p"
  Prettified layer name: "inception_3a/pool_proj" -> "inception_3a/p_proj"
  Prettified layer name: "inception_3b/pool" -> "inception_3b/p"
  Prettified layer name: "global_pool" -> "global_p"
CaffeProcThread.run called
CaffeVisApp mode (in CaffeProcThread): GPU
JPGVisLoadingThread.run called
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/cw1204772/Research/deepVis/deep-visualization-toolbox/caffevis/caffe_proc_thread.py", line 85, in run
    net_preproc_forward(self.net, im_small, self.input_dims)
  File "/home/cw1204772/Research/deepVis/deep-visualization-toolbox/caffevis/caffevis_helper.py", line 9, in net_preproc_forward
    assert img.shape == appropriate_shape, 'img is wrong size (got %s but expected %s)' % (img.shape, appropriate_shape)
AssertionError: img is wrong size (got (56, 144, 3) but expected (144, 56, 3))

After looking into the source code of this toolbox, it seems that resize function is causing the unmatched shape. Any solution to this problem??

Btw, the setting_local.py I use is as follow:

# Set this to point to your compiled checkout of caffe
caffevis_caffe_root      = '/home/cw1204772/Caffe/caffe'

# Load model: caffenet-yos
# Path to caffe deploy prototxt file. Minibatch size should be 1.
caffevis_deploy_prototxt = '/home/cw1204772/Research/Baseline_System/jstl_dgd_deploy_inference.prototxt'

# Path to network weights to load.
caffevis_network_weights = '/home/cw1204772/Research/Baseline_System/jstl_dgd_inference.caffemodel'

# Other optional settings; see complete documentation for each in settings.py.
caffevis_data_mean       = (102,102,101)
#caffevis_labels          = '%DVT_ROOT%/models/caffenet-yos/ilsvrc_2012_labels.txt'
#caffevis_label_layers    = ('fc8', 'prob')
#caffevis_prob_layer      = 'prob'
caffevis_unit_jpg_dir    = '%DVT_ROOT%/models/caffenet-yos/unit_jpg_vis'
#caffevis_jpgvis_layers   = ['conv1', 'conv2', 'conv3', 'conv4', 'conv5', 'fc6', 'fc7', 'fc8', 'prob']
#caffevis_jpgvis_remap    = {'pool1': 'conv1', 'pool2': 'conv2', 'pool5': 'conv5'}
def caffevis_layer_pretty_name_fn(name):
    name = name.replace('conv','c').replace('pool','p').replace('norm','n')
    name = name.replace('inception_','i').replace('output','o').replace('reduce','r').replace('split_','s')
    name = name.replace('__','_').replace('__','_')
    return name

cw1204772 avatar Dec 13 '16 16:12 cw1204772

So I find that it's a cv2.resize() problem Change line83 in caffe_proc_thread.py to

im_small = cv2.resize(frame, self.input_dims[::-1])

will solve the problem if caffe input rectangle image instead of square

cw1204772 avatar Dec 14 '16 02:12 cw1204772

@cw1204772 I've substantially refactored the tool, fixed many bugs, among them the tool ability to work on rectangular inputs instead of squares

Latest version is in https://github.com/arikpoz/deep-visualization-toolbox

arikpoz avatar Oct 16 '17 07:10 arikpoz