Watch 3 Star 4 Fork 2

东南大学-王雁刚 / CVPR2020-OOHPythonApache-2.0

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This is the repository of the implemantation of cvpr 2020. spread retract

Clone or download
process.py 1.10 KB
Copy Edit Web IDE Raw Blame History
boycehbz authored 2020-05-26 14:52 . init
import torch
from torch.autograd import Variable
import numpy as np
def demo(model, loader, viz=False, device=torch.device('cpu')):
print('-' * 10 + 'evaluation' + '-' * 10)
model.model.eval()
model.inpainting.eval()
with torch.no_grad():
for i, data in enumerate(loader):
if torch.cuda.is_available():
img = Variable(data['img']).to(device)
else:
print('CUDA error')
sys.exit(0)
# forward
m0, m1, m2, m3, mask, encoded = model.model(img)
decoded = model.inpainting.head(encoded)
# visualize
if viz:
model.viz_result(img, mask, decoded)
# save results
results = {}
results.update(img=img.detach().cpu().numpy().astype(np.float32))
results.update(mask=mask.detach().cpu().numpy().astype(np.float32))
results.update(pred=decoded.detach().cpu().numpy().astype(np.float32))
model.save_results(results, i)
print('batch: %d/%d ' %(i, len(loader)))

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/seuvcl/CVPR2020-OOH.git
git@gitee.com:seuvcl/CVPR2020-OOH.git
seuvcl
CVPR2020-OOH
CVPR2020-OOH
master

Search