fmsfm commited on
Commit
1731cb5
1 Parent(s): 2ff37ed

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -83,8 +83,7 @@ def single_scale_test(image):
83
 
84
  foreground = im_org * matte_org + np.full(im_org.shape, 255) * (1 - matte_org) # 计算前景,获得抠像
85
  # fg_name = im_name.split('.')[0] + '_fg.png'
86
- Image.fromarray(((foreground).astype('uint8')), mode='RGB').save(os.path.join('MODNet/output-img', 'fg_name.png'))
87
- output = Image.open(os.path.join('MODNet/output-img', 'fg_name.png'))
88
  image = np.asarray(output)
89
 
90
  model = RCF().cuda()
@@ -104,11 +103,13 @@ def single_scale_test(image):
104
  #filename = osp.splitext(test_list[idx])[0]
105
  #torchvision.utils.save_image(1 - all_res, osp.join('RCFPyTorch0/results/RCF', 'result.jpg'))
106
  fuse_res = torch.squeeze(results[1].detach()).cpu().numpy()
107
- fuse_res = ((1 - fuse_res) * 255).astype(np.uint8)
108
  cv2.imwrite(osp.join("RCFPyTorch0/results/RCF", 'result_ss.png'), fuse_res)
109
  #print('\rRunning single-scale test [%d/%d]' % (idx + 1, len(test_loader)), end='')
110
  #print('Running single-scale test done')
111
  output = Image.open(os.path.join('RCFPyTorch0/results/RCF', 'result_ss.png'))
 
 
112
  return output
113
 
114
  parser = argparse.ArgumentParser(description='PyTorch Testing')
 
83
 
84
  foreground = im_org * matte_org + np.full(im_org.shape, 255) * (1 - matte_org) # 计算前景,获得抠像
85
  # fg_name = im_name.split('.')[0] + '_fg.png'
86
+ output = Image.fromarray(((foreground).astype('uint8')), mode='RGB')
 
87
  image = np.asarray(output)
88
 
89
  model = RCF().cuda()
 
103
  #filename = osp.splitext(test_list[idx])[0]
104
  #torchvision.utils.save_image(1 - all_res, osp.join('RCFPyTorch0/results/RCF', 'result.jpg'))
105
  fuse_res = torch.squeeze(results[1].detach()).cpu().numpy()
106
+ fuse_res = ((1 - fuse_res) * 255).astype('uint8')
107
  cv2.imwrite(osp.join("RCFPyTorch0/results/RCF", 'result_ss.png'), fuse_res)
108
  #print('\rRunning single-scale test [%d/%d]' % (idx + 1, len(test_loader)), end='')
109
  #print('Running single-scale test done')
110
  output = Image.open(os.path.join('RCFPyTorch0/results/RCF', 'result_ss.png'))
111
+ #output = Image.fromarray(((fuse_res).astype('uint8')), mode='RGB')
112
+ print(type(output))
113
  return output
114
 
115
  parser = argparse.ArgumentParser(description='PyTorch Testing')