-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
29 lines (25 loc) · 1.02 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from utils import *
import logging
from aux_utils import compute_params
import re
def test_mode():
args = get_arguments()
args.enc_pretrained = True
logger = logging.getLogger(__name__)
torch.backends.cudnn.deterministic = True
segmenter = create_segmenter(args.enc, args.enc_pretrained, args.num_classes[0]).cuda()
segmenter.eval()
logger.info(" Loaded Segmenter {}, ImageNet-Pre-Trained={}, #PARAMS={:3.2f}M"
.format(args.enc, args.enc_pretrained, compute_params(segmenter) / 1e6))
logger.info("Now you can do some test")
while True:
img_path = input("请输入文件名:") # 'D:/VOCdata/VOC2012AUG/JPEGImages/2007_000027.jpg'
if img_path == 'exit':
break
result = test_img(segmenter, img_path, args.num_classes[0], args.normalise_params)
cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
test_mode()