Skip to content

Commit

Permalink
Display helpful error message and exits when the visdom server is not on
Browse files Browse the repository at this point in the history
  • Loading branch information
taesungp committed Jun 8, 2018
1 parent 7891385 commit 08f4de1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions util/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __init__(self, opt):
if self.display_id > 0:
import visdom
self.ncols = opt.display_ncols
self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port)

self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port, raise_exceptions=True)
if self.use_html:
self.web_dir = os.path.join(opt.checkpoints_dir, opt.name, 'web')
self.img_dir = os.path.join(self.web_dir, 'images')
Expand Down Expand Up @@ -91,11 +91,16 @@ def display_current_results(self, visuals, epoch, save_result):
if label_html_row != '':
label_html += '<tr>%s</tr>' % label_html_row
# pane col = image row
self.vis.images(images, nrow=ncols, win=self.display_id + 1,
padding=2, opts=dict(title=title + ' images'))
label_html = '<table>%s</table>' % label_html
self.vis.text(table_css + label_html, win=self.display_id + 2,
opts=dict(title=title + ' labels'))
try:
self.vis.images(images, nrow=ncols, win=self.display_id + 1,
padding=2, opts=dict(title=title + ' images'))
label_html = '<table>%s</table>' % label_html
self.vis.text(table_css + label_html, win=self.display_id + 2,
opts=dict(title=title + ' labels'))
except ConnectionError:
print('\n\nCould not connect to Visdom server (https://github.com/facebookresearch/visdom) for displaying training progress.\nYou can suppress connection to Visdom using the option --display_id -1. To install visdom, run \n$ pip install visdom\n, and start the server by \n$ python -m visdom.server.\n\n')
exit(1)

else:
idx = 1
for label, image in visuals.items():
Expand Down

0 comments on commit 08f4de1

Please sign in to comment.