title: Use SSIM loss function with Keras
body: <p>I need to use the SSIM from Sewar as a loss function in order to compare images for my model.</p>
  
  <p>I am getting errors when I try to compile my model. I import the function and compile the model like this:</p>
  
  <pre><code>from sewar.full_ref import ssim
  ...
  model.compile('ssim', optimizer=my_optimizer, metrics=[ssim])
  </code></pre>
  
  <p>and I get this:</p>
  
  <pre><code>File "/media/merry/merry32/train.py", line 19, in train
  model.compile(loss='ssim', optimizer=opt, metrics=[ssim])
  File "/home/merry/anaconda3/envs/merry_env/lib/python3.7/site-packages/keras/engine/training.py", line 451, in compile
  handle_metrics(output_metrics)
  File "/home/merry/anaconda3/envs/merry_env/lib/python3.7/site-packages/keras/engine/training.py", line 420, in handle_metrics
  mask=masks[i])
  File "/home/merry/anaconda3/envs/merry_env/lib/python3.7/site-packages/keras/engine/training_utils.py", line 404, in weighted
  score_array = fn(y_true, y_pred)
  File "/home/merry/anaconda3/envs/merry_env/lib/python3.7/site-packages/sewar/full_ref.py", line 143, in ssim
  MAX = np.iinfo(GT.dtype).max
  File "/home/merry/anaconda3/envs/merry_env/lib/python3.7/site-packages/numpy/core/getlimits.py", line 506, in __init__
  raise ValueError("Invalid integer data type %r." % (self.kind,))
  ValueError: Invalid integer data type 'O'.
  </code></pre>
  
  <p>I could also write something like this:</p>
  
  <pre><code>model.compile(ssim(), optimizer=my_optimizer, metrics=[ssim()])
  </code></pre>
  
  <p>But then I get this error (obviously):</p>
  
  <pre><code>TypeError: ssim() missing 2 required positional arguments: 'GT' and 'P'
  </code></pre>
  
  <p>I just wanted to do the same I was doing with mean_sqeared_error but with SSIM, like this (which works perfectly with no need of passing parameters to it):</p>
  
  <pre><code>model.compile('mean_squared_error', optimizer=my_optimizer, metrics=['mse'])
  </code></pre>
  
  <p>Any idea on how should I use this function to compile?</p>