@@ -75,7 +75,9 @@ def __init__(self, opt):
75
75
if self .display_id > 0 : # connect to a visdom server given <display_port> and <display_server>
76
76
import visdom
77
77
self .ncols = opt .display_ncols
78
- self .vis = visdom .Visdom (server = opt .display_server , port = opt .display_port , env = opt .display_env , raise_exceptions = True )
78
+ self .vis = visdom .Visdom (server = opt .display_server , port = opt .display_port , env = opt .display_env )
79
+ if not self .vis .check_connection ():
80
+ self .create_visdom_connections ()
79
81
80
82
if self .use_html : # create an HTML object at <checkpoints_dir>/web/; images will be saved under <checkpoints_dir>/web/images/
81
83
self .web_dir = os .path .join (opt .checkpoints_dir , opt .name , 'web' )
@@ -148,11 +150,14 @@ def display_current_results(self, visuals, epoch, save_result):
148
150
149
151
else : # show each image in a separate visdom panel;
150
152
idx = 1
151
- for label , image in visuals .items ():
152
- image_numpy = util .tensor2im (image )
153
- self .vis .image (image_numpy .transpose ([2 , 0 , 1 ]), opts = dict (title = label ),
154
- win = self .display_id + idx )
155
- idx += 1
153
+ try :
154
+ for label , image in visuals .items ():
155
+ image_numpy = util .tensor2im (image )
156
+ self .vis .image (image_numpy .transpose ([2 , 0 , 1 ]), opts = dict (title = label ),
157
+ win = self .display_id + idx )
158
+ idx += 1
159
+ except VisdomExceptionBase :
160
+ self .create_visdom_connections ()
156
161
157
162
if self .use_html and (save_result or not self .saved ): # save images to an HTML file if they haven't been saved.
158
163
self .saved = True
0 commit comments