Skip to content

Commit

Permalink
fix for cpu, fix the version of scikit-image
Browse files Browse the repository at this point in the history
  • Loading branch information
JizhiziLi committed Oct 28, 2021
1 parent b7cdfb0 commit 53b5791
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ tensorboard/*
*.json
core/data/*
core/temp.py
*.tar
*.tar
samples/*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="https://arxiv.org/abs/2107.07235"><img src="https://img.shields.io/badge/arXiv-Paper-<COLOR>.svg" ></a>
<a href=""><img src="https://img.shields.io/badge/license-MIT-blue"></a>
<a href="https://www.ijcai.org/proceedings/2021/111"><img src="https://img.shields.io/static/v1?label=inproceedings&message=Paper&color=orange"></a>

<a href="https://paperswithcode.com/sota/image-matting-on-aim-500?p=deep-automatic-natural-image-matting"><img src="https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/deep-automatic-natural-image-matting/image-matting-on-aim-500"></a>
</p>


Expand Down Expand Up @@ -300,7 +300,7 @@ This project is under the MIT license. For further questions, please contact <st

## Relevant Projects

[1] <strong>End-to-end Animal Image Matting, arxiv, 2020</strong> | [Paper](https://arxiv.org/pdf/2010.16188v1.pdf) | [Github](https://github.com/JizhiziLi/animal-matting)
[1] <strong>Bridging Composite and Real: Towards End-to-end Deep Image Mattin, IJCV, 2021g</strong> | [Paper](https://arxiv.org/pdf/2010.16188v1.pdf) | [Github](https://github.com/JizhiziLi/GFM)
<br><em>&ensp; &ensp; &ensp;Jizhizi Li, Jing Zhang, Stephen J. Maybank, Dacheng Tao</em>

[2] <strong>Privacy-Preserving Portrait Matting, ACM MM, 2021</strong> | [Paper](https://arxiv.org/pdf/2104.14222.pdf) | [Github](https://github.com/JizhiziLi/P3M)
Expand Down
12 changes: 9 additions & 3 deletions core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def get_args():

def inference_once(args, model, scale_img, scale_trimap=None):
pred_list = []
tensor_img = torch.from_numpy(scale_img.astype(np.float32)[:, :, :]).permute(2, 0, 1).cuda()

if args.cuda:
tensor_img = torch.from_numpy(scale_img.astype(np.float32)[:, :, :]).permute(2, 0, 1).cuda()
else:
tensor_img = torch.from_numpy(scale_img.astype(np.float32)[:, :, :]).permute(2, 0, 1)

input_t = tensor_img
input_t = input_t/255.0
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
Expand Down Expand Up @@ -185,7 +190,8 @@ def test_aim500(args, model):
alpha = alpha[:,:,0] if alpha.ndim>2 else alpha

with torch.no_grad():
torch.cuda.empty_cache()
if args.cuda:
torch.cuda.empty_cache()
predict = inference_img(args, model, img)
sad_trimap_diff, mse_trimap_diff, mad_trimap_diff = calculate_sad_mse_mad(predict, alpha, trimap)
sad_diff, mse_diff, mad_diff = calculate_sad_mse_mad_whole_img(predict, alpha)
Expand Down Expand Up @@ -288,7 +294,7 @@ def load_model_and_deploy(args):
print(f'Test stategy: {args.test_choice}')
print(f'Test dataset: {args.dataset_choice}')
model = AimNet()

if torch.cuda.device_count()==0:
print(f'Running on CPU...')
args.cuda = False
Expand Down
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
numpy==1.19.2
opencv-python==4.4.0.46
Pillow==8.0.0
scikit-image==0.17.2
scikit-image==0.14.5
scipy==1.5.3
torch==1.4.0
torchvision==0.5.0
tqdm==4.51.0
Binary file modified samples/result_alpha/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/result_alpha/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/result_alpha/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/result_color/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/result_color/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/result_color/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 53b5791

Please sign in to comment.