Ashrafb commited on
Commit
af53559
·
verified ·
1 Parent(s): 13d1a40

Update vtoonify_model.py

Browse files
Files changed (1) hide show
  1. vtoonify_model.py +3 -1
vtoonify_model.py CHANGED
@@ -211,7 +211,9 @@ class Model():
211
  print('*** Toonify %dx%d image with style of %s'%(y_tilde.shape[2], y_tilde.shape[3], style_type))
212
 
213
  return ((y_tilde[0].cpu().numpy().transpose(1, 2, 0) + 1.0) * 127.5).astype(np.uint8), 'Successfully toonify the image with style of %s' % (self.style_name)
214
-
 
 
215
  def tensor2cv2(self, img):
216
  """Convert a tensor image to OpenCV format."""
217
  tmp = ((img.cpu().numpy().transpose(1, 2, 0) + 1.0) * 127.5).astype(np.uint8).copy()
 
211
  print('*** Toonify %dx%d image with style of %s'%(y_tilde.shape[2], y_tilde.shape[3], style_type))
212
 
213
  return ((y_tilde[0].cpu().numpy().transpose(1, 2, 0) + 1.0) * 127.5).astype(np.uint8), 'Successfully toonify the image with style of %s' % (self.style_name)
214
+ except Exception as e:
215
+ logging.error(f"Error during model execution: {e}")
216
+ return np.zeros((256, 256, 3), np.uint8), f"Error during processing: {str(e)}"
217
  def tensor2cv2(self, img):
218
  """Convert a tensor image to OpenCV format."""
219
  tmp = ((img.cpu().numpy().transpose(1, 2, 0) + 1.0) * 127.5).astype(np.uint8).copy()