本文整理汇总了Python中visdom.server方法的典型用法代码示例。如果您正苦于以下问题:Python visdom.server方法的具体用法?Python visdom.server怎么用?Python visdom.server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类visdom
的用法示例。
在下文中一共展示了visdom.server方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, visdom_port=None, log_dir=None, use_nsml=False):
self.use_nsml = use_nsml
if use_nsml:
self.vis = nsml.Visdom(visdom=visdom)
self.last = None #python -m visdom.server
elif VISDOM and visdom_port:
self.vis = visdom.Visdom(port=visdom_port)
if not self.vis.check_connection():
print('No visdom server found on port {}. set visdom_port = None'.format(visdom_port))
self.vis = None
else:
self.vis = None
self.use_visdom = use_nsml or visdom_port
self.use_tensorboard = True if TENSORBOARD and log_dir is not None else False
if not use_nsml and self.use_tensorboard:
self.writer = tf.summary.FileWriter(log_dir)
示例2: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, plot_type, fields=None, win=None, env=None, opts={}, port=8097, server="localhost"):
'''
Args:
fields: Currently unused
plot_type: The name of the plot type, in Visdom
Examples:
>>> # Image example
>>> img_to_use = skimage.data.coffee().swapaxes(0,2).swapaxes(1,2)
>>> image_logger = VisdomLogger('image')
>>> image_logger.log(img_to_use)
>>> # Histogram example
>>> hist_data = np.random.rand(10000)
>>> hist_logger = VisdomLogger('histogram', , opts=dict(title='Random!', numbins=20))
>>> hist_logger.log(hist_data)
'''
super(VisdomLogger, self).__init__(fields, win, env, opts, port, server)
self.plot_type = plot_type
self.chart = getattr(self.viz, plot_type)
self.viz_logger = self._viz_prototype(self.chart)
示例3: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, plot_type, fields=None, win=None, env=None, opts={}, port=8097, server="localhost", log_to_filename=None):
'''
Args:
fields: Currently unused
plot_type: The name of the plot type, in Visdom
Examples:
>>> # Image example
>>> img_to_use = skimage.data.coffee().swapaxes(0,2).swapaxes(1,2)
>>> image_logger = VisdomLogger('image')
>>> image_logger.log(img_to_use)
>>> # Histogram example
>>> hist_data = np.random.rand(10000)
>>> hist_logger = VisdomLogger('histogram', , opts=dict(title='Random!', numbins=20))
>>> hist_logger.log(hist_data)
'''
super(VisdomLogger, self).__init__(fields, win, env, opts, port, server, log_to_filename)
self.plot_type = plot_type
self.chart = getattr(self.viz, plot_type)
self.viz_logger = self._viz_prototype(self.chart)
示例4: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, opt):
self.display_id = opt.display_id
self.use_html = opt.isTrain and not opt.no_html
self.win_size = opt.display_winsize
self.name = opt.name
self.port = opt.display_port
self.opt = opt
self.saved = False
if self.display_id > 0:
import visdom
self.ncols = opt.display_ncols
self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port, env=opt.display_env)
if not self.vis.check_connection():
self.create_visdom_connections()
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')
print('create web directory %s...' % self.web_dir)
util.mkdirs([self.web_dir, self.img_dir])
self.log_name = os.path.join(opt.checkpoints_dir, opt.name, 'loss_log.txt')
with open(self.log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Training Loss (%s) ================\n' % now)
示例5: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, opt):
"""Initialize the Visualizer class
Parameters:
opt -- stores all the experiment flags; needs to be a subclass of BaseOptions
Step 1: Cache the training/test options
Step 2: connect to a visdom server
Step 3: create an HTML object for saveing HTML filters
Step 4: create a logging file to store training losses
"""
self.opt = opt # cache the option
self.display_id = opt.display_id
self.use_html = opt.isTrain and not opt.no_html
self.win_size = opt.display_winsize
self.name = opt.name
self.port = opt.display_port
self.saved = False
if self.display_id > 0: # connect to a visdom server given <display_port> and <display_server>
import visdom
self.ncols = opt.display_ncols
self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port, env=opt.display_env)
if not self.vis.check_connection():
self.create_visdom_connections()
if self.use_html: # create an HTML object at <checkpoints_dir>/web/; images will be saved under <checkpoints_dir>/web/images/
self.web_dir = os.path.join(opt.checkpoints_dir, opt.name, 'web')
self.img_dir = os.path.join(self.web_dir, 'images')
print('create web directory %s...' % self.web_dir)
util.mkdirs([self.web_dir, self.img_dir])
# create a logging file to store training losses
self.log_name = os.path.join(opt.checkpoints_dir, opt.name, 'loss_log.txt')
with open(self.log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Training Loss (%s) ================\n' % now)
示例6: create_visdom_connections
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def create_visdom_connections(self):
"""If the program could not connect to Visdom server, this function will start a new server at port < self.port > """
cmd = sys.executable + ' -m visdom.server -p %d &>/dev/null &' % self.port
print('\n\nCould not connect to Visdom server. \n Trying to start a server....')
print('Command: %s' % cmd)
Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
示例7: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, opt):
"""Initialize the Visualizer class
Parameters:
opt -- stores all the experiment flags; needs to be a subclass of BaseOptions
Step 1: Cache the training/test options
Step 2: connect to a visdom server
Step 3: create an HTML object for saveing HTML filters
Step 4: create a logging file to store training losses
"""
self.opt = opt # cache the option
self.display_id = opt.display_id
self.use_html = opt.isTrain and not opt.no_html
self.win_size = opt.display_winsize
self.name = opt.name
self.port = opt.display_port
self.saved = False
if self.display_id > 0: # connect to a visdom server given <display_port> and <display_server>
import visdom
self.ncols = opt.display_ncols
self.vis = visdom.Visdom(server=opt.display_server, port=opt.display_port, env=opt.display_env)
if not self.vis.check_connection():
self.create_visdom_connections()
if self.use_html: # create an HTML object at <checkpoints_dir>/web/; images will be saved under <checkpoints_dir>/web/images/
self.web_dir = os.path.join(opt.checkpoints_dir, opt.name, 'web')
self.img_dir = os.path.join(self.web_dir, 'images')
print('create web directory %s...' % self.web_dir)
util.mkdirs([self.web_dir, self.img_dir])
# create a logging file to store training losses
self.log_name = os.path.join(opt.checkpoints_dir, opt.name, 'loss_log.txt')
with open(self.log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Training Loss (%s) ================\n' % now)
# create a logging file to store scores
self.score_log_name = os.path.join(opt.checkpoints_dir, opt.name, 'score_log.txt')
with open(self.score_log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Scores (%s) ================\n' % now)
示例8: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, opt):
"""Initialize the Visualizer class
Parameters:
opt -- stores all the experiment flags;
Step 1: Cache the training/test options
Step 2: connect to a visdom server
Step 3: create an HTML object for saveing HTML filters
Step 4: create a logging file to store training losses
"""
self.opt = opt # cache the option
self.display_id = opt['display_id']
self.use_html = opt['isTrain'] and not opt['no_html']
self.win_size = opt['display_winsize']
self.name = opt['name']
self.port = opt['display_port']
self.saved = False
if self.display_id > 0: # connect to a visdom server given <display_port> and <display_server>
import visdom
self.vis = visdom.Visdom(server=opt['display_server'], port=opt['display_port'], env=opt['display_env'])
if not self.vis.check_connection():
self.create_visdom_connections()
if self.use_html: # create an HTML object at <outputs_dir>/web/; images will be saved under <outputs_dir>/web/images/
self.web_dir = os.path.join(opt['outputs_dir'], opt['name'], 'web')
self.img_dir = os.path.join(self.web_dir, 'images')
print('create web directory %s...' % self.web_dir)
mkdirs([self.web_dir, self.img_dir])
# create a logging file to store training losses
self.log_name = os.path.join(opt['outputs_dir'], opt['name'], 'loss_log.txt')
with open(self.log_name, "a") as log_file:
now = time.strftime("%c")
log_file.write('================ Training Loss (%s) ================\n' % now)
示例9: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(
self,
vis=None, # type: visdom.Visdom
server=None, # type: str
env="main", # type: str
log_to_filename=None, # type: str
save_by_default=True, # type: bool
):
try:
import visdom
except ImportError:
raise RuntimeError("No visdom package is found. Please install it with command: \n pip install visdom")
if vis is None:
if server is None:
server = os.environ.get("VISDOM_SERVER_URL", 'http://localhost')
username = os.environ.get("VISDOM_USERNAME", None)
password = os.environ.get("VISDOM_PASSWORD", None)
vis = visdom.Visdom(
server=server,
log_to_filename=log_to_filename,
username=username,
password=password
)
if not vis.check_connection():
raise RuntimeError("Failed to connect to Visdom server at {}. "
"Did you run python -m visdom.server ?".format(server))
self.vis = vis
self.env = env
self.save_by_default = save_by_default
示例10: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, debug=0, ui_info=None, visdom_info=None):
self.debug = debug
self.visdom = visdom.Visdom(server=visdom_info.get('server', '127.0.0.1'), port=visdom_info.get('port', 8097))
self.registered_blocks = {}
self.blocks_list = []
self.visdom.properties(self.blocks_list, opts={'title': 'Block List'}, win='block_list')
self.visdom.register_event_handler(self.block_list_callback_handler, 'block_list')
if ui_info is not None:
self.visdom.register_event_handler(ui_info['handler'], ui_info['win_id'])
示例11: add
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def add(self, server, port, log_to_filename):
if (server, port) in self.connections:
assert self.log_connections[(server, port)] == log_to_filename, "Cannot set log for {} to {}. Already set to {}!".format(
(server, port), log_to_filename, self.log_connections[(server, port)])
else:
self.connections[(server, port)] = visdom.Visdom(server="http://" + server, port=port, log_to_filename=log_to_filename)
self.log_connections[(server, port)] = log_to_filename
return self.connections[(server, port)]
示例12: create_visdom_connections
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def create_visdom_connections(self):
"""If the program could not connect to Visdom server, this function will start a new server at port < self.port > """
cmd = sys.executable + ' -m visdom.server -p %d &>/dev/null &' % self.port
print('\n\nCould not connect to Visdom server. \n Trying to start a server....')
print('Command: %s' % cmd)
Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
# |visuals|: dictionary of images to display or save
示例13: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, visdom_port, env, http_port):
super(Visualizer, self).__init__()
# Create Visdom Server
try:
if not is_port_in_use(visdom_port):
print(f"Launching new visdom instance in port {visdom_port}")
cmd = f"{sys.executable} -m visdom.server -p {visdom_port} > /dev/null 2>&1"
CMD = f'TMUX=0 tmux new-session -d -s visdom_server \; send-keys "{cmd}" Enter'
print(CMD)
os.system(CMD)
time.sleep(2)
except:
print("coudn't set up visdom server.")
try:
# Create Http Server
if not is_port_in_use(http_port):
print(f"Launching new HTTP instance in port {http_port}")
cmd = f"{sys.executable} -m http.server -p {http_port} > /dev/null 2>&1"
CMD = f'TMUX=0 tmux new-session -d -s http_server \; send-keys "{cmd}" Enter'
print(CMD)
os.system(CMD)
except:
print("couldn't set up http server.")
self.visdom_port = visdom_port
self.http_port = http_port
vis = visdom.Visdom(port=visdom_port, env=env)
self.vis = vis
示例14: __init__
# 需要导入模块: import visdom [as 别名]
# 或者: from visdom import server [as 别名]
def __init__(self, server=None, port=None, num_workers=1, **kwargs):
try:
import visdom
except ImportError:
raise RuntimeError(
"This contrib module requires visdom package. "
"Please install it with command:\n"
"pip install git+https://github.com/facebookresearch/visdom.git"
)
if num_workers > 0:
# If visdom is installed, one of its dependencies `tornado`
# requires also `futures` to be installed.
# Let's check anyway if we can import it.
try:
import concurrent.futures
except ImportError:
raise RuntimeError(
"This contrib module requires concurrent.futures module"
"Please install it with command:\n"
"pip install futures"
)
if server is None:
server = os.environ.get("VISDOM_SERVER_URL", "localhost")
if port is None:
port = int(os.environ.get("VISDOM_PORT", 8097))
if "username" not in kwargs:
username = os.environ.get("VISDOM_USERNAME", None)
kwargs["username"] = username
if "password" not in kwargs:
password = os.environ.get("VISDOM_PASSWORD", None)
kwargs["password"] = password
self.vis = visdom.Visdom(server=server, port=port, **kwargs)
if not self.vis.check_connection():
raise RuntimeError(
"Failed to connect to Visdom server at {}. " "Did you run python -m visdom.server ?".format(server)
)
self.executor = _DummyExecutor()
if num_workers > 0:
from concurrent.futures import ThreadPoolExecutor
self.executor = ThreadPoolExecutor(max_workers=num_workers)