justin-shopcapsule commited on
Commit
9e8ae60
·
1 Parent(s): 61e019f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -8
handler.py CHANGED
@@ -308,7 +308,7 @@ class RealESRGAN:
308
 
309
  input_batch = torch.concat(list_of_inputs)
310
 
311
- print('input_batch.shape', input_batch.shape)
312
 
313
  start2 = time.time()
314
  with torch.no_grad():
@@ -316,8 +316,8 @@ class RealESRGAN:
316
 
317
  # okay what does the input size really need to be?
318
 
319
- print('input_batch.shape', input_batch.shape)
320
- print('input_batch[0:batch_size].shape', input_batch[0:batch_size].shape)
321
  # 1/0
322
  res = self.model(input_batch[0:batch_size])
323
 
@@ -327,7 +327,7 @@ class RealESRGAN:
327
  for i in range(batch_size, img.shape[0], batch_size):
328
  print('i is', i)
329
  res = torch.cat((res, self.model(img[i:i+batch_size])), 0)
330
- print('res.shape 2', res.shape)
331
  print('inference alone takes', time.time() - start2)
332
  # print('res.shape 3', res.shape)
333
 
@@ -479,14 +479,14 @@ class RRDBNet(nn.Module):
479
  self.lrelu = nn.LeakyReLU(negative_slope=0.2, inplace=True)
480
 
481
  def forward(self, x):
482
- print('IN FORWARD, X.shape is', x.shape)
483
  if self.scale == 2:
484
  feat = pixel_unshuffle(x, scale=2)
485
  elif self.scale == 1:
486
  feat = pixel_unshuffle(x, scale=4)
487
  else:
488
  feat = x
489
- print('feat shape', feat.shape)
490
  # breaks here ...
491
  feat = self.conv_first(feat)
492
  body_feat = self.conv_body(self.body(feat))
@@ -511,13 +511,13 @@ def pad_reflect(image, pad_size):
511
  print('imsize', imsize)
512
  new_img = np.zeros([height+pad_size*2, width+pad_size*2, imsize[2]]).astype(np.uint8)
513
  new_img[pad_size:-pad_size, pad_size:-pad_size, :] = image
514
- print('new_img.shape 1', new_img.shape)
515
 
516
  new_img[0:pad_size, pad_size:-pad_size, :] = np.flip(image[0:pad_size, :, :], axis=0) #top
517
  new_img[-pad_size:, pad_size:-pad_size, :] = np.flip(image[-pad_size:, :, :], axis=0) #bottom
518
  new_img[:, 0:pad_size, :] = np.flip(new_img[:, pad_size:pad_size*2, :], axis=1) #left
519
  new_img[:, -pad_size:, :] = np.flip(new_img[:, -pad_size*2:-pad_size, :], axis=1) #right
520
- print('new_img.shape 2', new_img.shape)
521
 
522
  return new_img
523
 
 
308
 
309
  input_batch = torch.concat(list_of_inputs)
310
 
311
+ # print('input_batch.shape', input_batch.shape)
312
 
313
  start2 = time.time()
314
  with torch.no_grad():
 
316
 
317
  # okay what does the input size really need to be?
318
 
319
+ # print('input_batch.shape', input_batch.shape)
320
+ # print('input_batch[0:batch_size].shape', input_batch[0:batch_size].shape)
321
  # 1/0
322
  res = self.model(input_batch[0:batch_size])
323
 
 
327
  for i in range(batch_size, img.shape[0], batch_size):
328
  print('i is', i)
329
  res = torch.cat((res, self.model(img[i:i+batch_size])), 0)
330
+ # print('res.shape 2', res.shape)
331
  print('inference alone takes', time.time() - start2)
332
  # print('res.shape 3', res.shape)
333
 
 
479
  self.lrelu = nn.LeakyReLU(negative_slope=0.2, inplace=True)
480
 
481
  def forward(self, x):
482
+ # print('IN FORWARD, X.shape is', x.shape)
483
  if self.scale == 2:
484
  feat = pixel_unshuffle(x, scale=2)
485
  elif self.scale == 1:
486
  feat = pixel_unshuffle(x, scale=4)
487
  else:
488
  feat = x
489
+ # print('feat shape', feat.shape)
490
  # breaks here ...
491
  feat = self.conv_first(feat)
492
  body_feat = self.conv_body(self.body(feat))
 
511
  print('imsize', imsize)
512
  new_img = np.zeros([height+pad_size*2, width+pad_size*2, imsize[2]]).astype(np.uint8)
513
  new_img[pad_size:-pad_size, pad_size:-pad_size, :] = image
514
+ # print('new_img.shape 1', new_img.shape)
515
 
516
  new_img[0:pad_size, pad_size:-pad_size, :] = np.flip(image[0:pad_size, :, :], axis=0) #top
517
  new_img[-pad_size:, pad_size:-pad_size, :] = np.flip(image[-pad_size:, :, :], axis=0) #bottom
518
  new_img[:, 0:pad_size, :] = np.flip(new_img[:, pad_size:pad_size*2, :], axis=1) #left
519
  new_img[:, -pad_size:, :] = np.flip(new_img[:, -pad_size*2:-pad_size, :], axis=1) #right
520
+ # print('new_img.shape 2', new_img.shape)
521
 
522
  return new_img
523