TobyPDE / FRRN

Full Resolution Residual Networks for Semantic Image Segmentation
MIT License
278 stars 93 forks source link

Trying to evaluation with non cityscape image #32

Closed rnunziata closed 6 years ago

rnunziata commented 7 years ago

Trying to evaluation with my own image....not sure how to set the inputs correctly. Can you offer some correction.

        im = cv2.imread('./eagle.jpg')
        im     = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)         
        imgray = cv2.cvtColor(im, cv2.COLOR_RGB2GRAY)
        imgray =  cv2.normalize(imgray, dst=imgray, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)[0:-1]
        imgray = imgray[np.newaxis,...]

        batch1 = [im]
        batch2 = [imgray] 
        predictions, loss = val_fn(batch1, batch2)

ERROR:

Traceback (most recent call last):
  File "cam_predict.py", line 90, in <module>
    main()
  File "cam_predict.py", line 74, in main
    predictions, loss = val_fn([batch1], [batch2])
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 917, in __call__
    storage_map=getattr(self.fn, 'storage_map', None))
  File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 325, in raise_with_op
    reraise(exc_type, exc_value, exc_trace)
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 903, in __call__
    self.fn() if output_subset is None else\
ValueError: images and kernel must have the same stack size

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
  File "cam_predict.py", line 90, in <module>
    main()
  File "cam_predict.py", line 62, in main
    val_fn = train.compile_validation_function(network, BATCH_SIZE)
  File "/home/rjn/opencv3-p3-code/classification_and_boxing/newstuff/FRRN/train.py", line 153, in compile_validation_function
    network.output_layers, deterministic=True)[0]
  File "/usr/local/lib/python2.7/dist-packages/lasagne/layers/helper.py", line 197, in get_output
    all_outputs[layer] = layer.get_output_for(layer_inputs, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lasagne/layers/conv.py", line 333, in get_output_for
    conved = self.convolve(input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/lasagne/layers/conv.py", line 611, in convolve
    filter_flip=self.flip_filters)
daicoolb commented 6 years ago

Just as the author said .

You can feed any image into the network as follows:

Load the image into an RGB numpy tensor Rescale the intensity values to [0, 1] Make sure that the channel ordering is RGB and not BGR (opencv standard) Reshape and dimshuffle the tensor to [1, 3, H, W] where H and W are the image height (rows) and width (cols), respectively. Feed the tensor into the network.

rnunziata commented 6 years ago

can you supply a code block showing how process the inputs to call val_fn. I will close this since this is out of scope here. But if you feel like you could a code example would be helpful.