-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict.py
36 lines (30 loc) · 985 Bytes
/
predict.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
30
31
32
33
34
35
36
#--------------------------------------------------#
# 使用FCN做语义分割
#--------------------------------------------------#
import tensorflow as tf
import PIL.Image as Image
from fcn_main import FCN
'''
'''
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
#----------- 设置面板:全局变量 ---------------------------#
fcn = FCN()
detect_image = fcn.detect_image
#--------------------------------------------------------#
# 方式1:对单张图片做语义分割
while True:
img = input('Input image filename (to ESC, input "quit"): ')
if img == 'quit':
print('Programe ends.')
break
try:
image = Image.open(img)
image = image.convert('RGB')
except:
print('Open Error! Try again.')
continue
else:
r_image = detect_image(image)
r_image.show()