Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
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')
|
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(
|
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')
|