Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么单独去做测试?有单独的test.py文件吗 #55

Open
long123524 opened this issue Mar 2, 2022 · 2 comments
Open

怎么单独去做测试?有单独的test.py文件吗 #55

long123524 opened this issue Mar 2, 2022 · 2 comments

Comments

@long123524
Copy link

怎么单独去做测试一些照片?

@zhangxiao121
Copy link

您好,这个问题您解决了吗?怎么单独去测试一些图片?

@hahaha1230
Copy link

hahaha1230 commented Nov 10, 2022

我自己写了个单独测试的代码

import models
if name == 'main':
resume = 'RCFcheckpoint_epoch12.pth'
model = models.RCF()
model.eval()
checkpoint = torch.load(resume,map_location='cpu')
try:
model.load_state_dict(checkpoint)
except Exception:
model.load_state_dict(checkpoint['state_dict'],False)
img_path = r'D:\Work\line_extraction\RCF-pytorch-master\BSR\BSDS500\data\images\train\12003.jpg'
result_path = './examples/demo.png'

original_img = np.array(cv2.imread(img_path), dtype=np.float32)
h, w, _ = original_img.shape

img = prepare_image_cv2(original_img)
img = torch.from_numpy(img).unsqueeze(0)

outs = model(img)
result = outs[-1].squeeze().detach().cpu().numpy()

result = (result * 255).astype(np.uint8)
Image.fromarray(result).save(result_path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants