pip3 install -r requirements.txt
python -m visdom.server
from Visualizer import Visualizer
#simple init env will set to default value:'main'
vis = Visualizer()
#set up new environment call 'demo'
vis = Visualizer(env='demo')
- name: name for the graph (string)
- value: logging value
- (optional) step: logging step (default is 1)
put the vis.plot
inside the loop
# simple plot with default logging step
for i in range(0,10,1):
vis.plot('Single Value Plot Step 1',i/10)
# simple plot with logging step 10
for i in range(0,10,1):
vis.plot('Single Value Plot Step 10',i/10, 10)
- dict: dictionary contains each name and value
vis.plot_all({'Acc':0.9,'Loss':0.1})
- (optional) step: logging step (default is 1)
# Plot Acc graph and Loss graph at the same time with default logging step
for i in range(0,10,1):
loss = {'Acc':i/10,
'Loss':1-i/10}
vis.plot_all(loss)
- name: name for the graph (string)
- dict: dictionary contains each name and value
vis.plot_combine('Combine Plot',{'Acc':0.9,'Loss':0.1})
- (optional) step: logging step (default is 1)
# Plot acc value and loss value in one graph with default logging step
for i in range(0,10,1):
loss = {'Acc':i/10,
'Loss':1-i/10}
vis.plot_combine('Combine Plot',loss)
- info: logging info
- name: name for the visdom window
for i in range(0,10,1):
loss = {'Acc':i/10,
'Loss':1-i/10}
vis.log(loss)
- name: name for the image (strinf)
- img_: pytorch tensors: single image or multi-images
t.Tensor(64,64)
t.Tensor(3,64,64)
t.Tensor(100,1,64,64)
t.Tensor(100,3,64,64)
- (optional) nrow: number of image per row (integer)
#Plot Single Images
import torch
from PIL import Image
import numpy as np
img = Image.open('imgs/Lenna.png')
arr = np.array(img).transpose((2, 0, 1))
tensor = torch.from_numpy(arr)
vis.img('SingleImage',tensor)
#Plot Multi Images (4D tensor)
img = Image.open('imgs/Lenna.png')
arr = np.array(img).transpose((2, 0, 1))
tensor = torch.from_numpy(arr)
tensor4D = tensor.unsqueeze(0)
for i in range(5):
tensor4D=torch.cat((tensor4D,tensor.unsqueeze(0)),0)
vis.img('MultiImage',tensor4D, nrow=3)
vis.check_connection()
True