Skip to main content

visdom-wrapper

A wrapper to use visdom with python 'with' statement.

Setup

pip3 install visdom-wrapper

Example

import numpy as np
import time
import os.path
import getpass
from sys import platform as _platform
from six.moves import urllib

from visdom_wrapper import VizWrapper
from visdom import  Visdom

# Images
for i in range(5):
    var = np.random.randn(20, 3, 64, 64)
    with VizWrapper("random_images") as viz_wrapper:
        viz_wrapper.update_wins(
            viz_wrapper.viz.images(var,
                                   opts=dict(title=viz_wrapper.name),
                                   win=viz_wrapper.win)) # Indispensable
    time.sleep(1)

# Change server port
VizWrapper.viz = Visdom(port=8098, server="http://localhost")

for i in range(5):
    var = np.random.randn(10, 3, 64, 64)
    with VizWrapper("random_images_1") as viz_wrapper:
        viz_wrapper.update_wins(
            viz_wrapper.viz.images(var,
                                   opts=dict(title=viz_wrapper.name),
                                   win=viz_wrapper.win)) # Indispensable
    time.sleep(1)

# Histogram
for i in range(5):
    var = np.random.rand(10000)
    with VizWrapper("histogram") as viz_wrapper:
        viz_wrapper.update_wins(
            viz_wrapper.viz.histogram(X=var,
                                      opts=dict(numbins=20),
                                      win=viz_wrapper.win)) # Indispensable
    time.sleep(1)

# Line updates
X = np.column_stack((np.arange(0, 10), np.arange(0, 10)))
Y = np.column_stack((np.linspace(5, 10, 10), np.linspace(5, 10, 10) + 5))
with VizWrapper("line") as viz_wrapper:
    viz_wrapper.update_wins(
        viz_wrapper.viz.line(X=X,
                             Y=Y,
                             win=viz_wrapper.win)) # Indispensable
time.sleep(2)
X = np.column_stack((np.arange(10, 20), np.arange(10, 20)))
Y = np.column_stack((np.linspace(5, 10, 10), np.linspace(5, 10, 10) + 5))
with VizWrapper("line") as viz_wrapper:
    viz_wrapper.update_wins(
        viz_wrapper.viz.line(X=X,
                             Y=Y,
                             win=viz_wrapper.win, # Indispensable
                             update='append'))

# Video
video = np.empty([256, 250, 250, 3], dtype=np.uint8)
for n in range(256):
    video[n, :, :, :].fill(n)
with VizWrapper("vedio") as viz_wrapper:
    viz_wrapper.update_wins(
        viz_wrapper.viz.video(tensor=video,
                              win=viz_wrapper.win)) # Indispensable


video_url = 'http://media.w3.org/2010/05/sintel/trailer.ogv'
# linux
if _platform == "linux" or _platform == "linux2":
    videofile = '/home/%s/trailer.ogv' % getpass.getuser()
# MAC OS X
elif _platform == "darwin":
    videofile = '/Users/%s/trailer.ogv' % getpass.getuser()
# download video
urllib.request.urlretrieve(video_url, videofile)

if os.path.isfile(videofile):
    with VizWrapper("vedio_1") as viz_wrapper:
        viz_wrapper.update_wins(
            viz_wrapper.viz.video(videofile=videofile,
                                  win=viz_wrapper.win)) # Indispensable

With visdom-wrapper, you can use visdom in a more convinent way.

  1. you don't have to create Visdom object explicitly.
  2. you don't have to manage visdom windows explicitly. VizWrapper with the same name will be updated to the same visdom window implicitly.
  3. all visdom apis are still avaiable and you can still configure visdom in a flexiable way.

Release files for visdom-wrapper 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for visdom-wrapper 0.1.0
File Size Uploaded
visdom-wrapper-0.1.0.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for visdom-wrapper 0.1.0
File Interpreter ABI Platform
visdom_wrapper-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / visdom-wrapper-0.1.0.tar.gz

Download URL visdom-wrapper-0.1.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dd52049f06c305efd2c2cee61b58f5eb714cdc00a01b1c0a14218a7d48891af5
BLAKE2b-256 checksum
How to use checksums
8cc091bcdc7d41f892bf40833370159cba291073755b77381a779230e5a316d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

Release files / visdom_wrapper-0.1.0-py3-none-any.whl

Download URL visdom_wrapper-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68306667ad90fa58d6d4ae78292449e0048307022a0444d7beed4fe08813e5da
BLAKE2b-256 checksum
How to use checksums
3bdb6d12a4faeff327b97333347ac4f29eb6a1f8ec4801ab767e452917f0ffe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page