fmsfm commited on
Commit
2ff37ed
1 Parent(s): 820313d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -85,7 +85,7 @@ def single_scale_test(image):
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.array(output)
89
 
90
  model = RCF().cuda()
91
  checkpoint = torch.load("RCFPyTorch0/bsds500_pascal_model.pth")
@@ -102,7 +102,7 @@ def single_scale_test(image):
102
  for i in range(len(results)):
103
  all_res[i, 0, :, :] = results[i]
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)
@@ -143,4 +143,4 @@ os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
143
 
144
 
145
  interface = gr.Interface(fn=single_scale_test, inputs="image", outputs="image")
146
- interface.launch(share=True)
 
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()
91
  checkpoint = torch.load("RCFPyTorch0/bsds500_pascal_model.pth")
 
102
  for i in range(len(results)):
103
  all_res[i, 0, :, :] = results[i]
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)
 
143
 
144
 
145
  interface = gr.Interface(fn=single_scale_test, inputs="image", outputs="image")
146
+ interface.launch()