viz.heatmap( X=np.outer(np.arange(1, 6), np.arange(1, 11)), opts=dict( columnnames=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], rownames=['y1', 'y2', 'y3', 'y4', 'y5'], colormap='Electric', )) # contour x = np.tile(np.arange(1, 101), (100, 1)) y = x.transpose() X = np.exp((((x - 50)**2) + ((y - 50)**2)) / -(20.0**2)) viz.contour(X=X, opts=dict(colormap='Viridis')) # surface viz.surf(X=X, opts=dict(colormap='Hot')) # line plots viz.line(Y=np.random.rand(10), opts=dict(showlegend=True)) Y = np.linspace(-5, 5, 100) viz.line( Y=np.column_stack((Y * Y, np.sqrt(Y + 5))), X=np.column_stack((Y, Y)), opts=dict(markers=False), ) # line using WebGL webgl_num_points = 200000 webgl_x = np.linspace(-1, 0, webgl_num_points) webgl_y = webgl_x**3
X=np.abs(np.random.rand(5, 3)), # 5个列,每列有3部分组成 opts={ 'stacked': True, 'legend': ['A', 'B', 'C'], 'rownames': ['2012', '2013', '2014', '2015', '2016'] }) viz.bar(X=np.random.rand(20, 3), opts={ 'stacked': False, 'legend': ['America', 'Britsh', 'China'] }) # 热力图,地理图,表面图 viz.heatmap(X=np.outer(np.arange(1, 6), np.arange(1, 11)), opts={ 'columnnames': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], 'rownames': ['y1', 'y2', 'y3', 'y4', 'y5'], 'colormap': 'Electric' }) # 地表图 x = np.tile(np.arange(1, 101), (100, 1)) y = x.transpose() X = np.exp((((x - 50)**2) + ((y - 50)**2)) / -(20.0**2)) viz.contour(X=X, opts=dict(colormap='Viridis')) # 表面图 viz.surf(X=X, opts={'colormap': 'Hot'})
if __name__ == "__main__": import numpy as np import cv2 from PIL import Image from visdom import Visdom viz = Visdom() assert viz.check_connection() model = embednet().cuda() print(torch.load("test.pth")) model.load_state_dict(torch.load("test.pth")) # ~800kB model.eval() # inputs=torch.rand(2,3,256,256).cuda() image = np.zeros((512, 512, 3), np.uint8) cv2.circle(image, (100, 120), 30, (1, 1, 1), 2) inputs = torch.from_numpy(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)) outputs = model(inputs.unsqueeze(0)) print(outputs.shape) # torch.save(model.state_dict(),"test.pth") # ~800kB viz.surf(X=inputs[0][0], opts=dict(colormap='Hot')) viz.surf(X=inputs[0][1], opts=dict(colormap='Hot')) viz.surf(X=inputs[0][2], opts=dict(colormap='Hot')) viz.surf(X=outputs[0], opts=dict(colormap='Hot')) # print(inputs) # print(outputs)
X=np.outer(np.arange(1, 6), np.arange(1, 11)), opts=dict( columnnames=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], rownames=['y1', 'y2', 'y3', 'y4', 'y5'], colormap='Electric', ) ) # contour x = np.tile(np.arange(1, 101), (100, 1)) y = x.transpose() X = np.exp((((x - 50) ** 2) + ((y - 50) ** 2)) / -(20.0 ** 2)) viz.contour(X=X, opts=dict(colormap='Viridis')) # surface viz.surf(X=X, opts=dict(colormap='Hot')) # line plots viz.line(Y=np.random.rand(10)) Y = np.linspace(-5, 5, 100) viz.line( Y=np.column_stack((Y * Y, np.sqrt(Y + 5))), X=np.column_stack((Y, Y)), opts=dict(markers=False), ) # line updates win = viz.line( 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)),
}) viz.bar(X=np.random.rand(20, 3), win='bar2', opts={ 'stacked': False, 'legend': ['America', 'Britsh', 'China'] }) # 直方图 viz.histogram( X=np.random.randint(255, size=(100)), win='win_histogram', opts=dict( xlabel='gray_rank', ylabel='count', title='histogram', numbins=10 #利用numbins对数据单位进行划分,默认是30组 )) # 热力图,地理图,表面图 x = np.tile(np.arange(1, 101), (100, 1)) y = x.transpose() X = np.exp((((x - 50)**2) + ((y - 50)**2)) / -(20.0**2)) viz.heatmap(X=X, win='heatmap', opts=dict(colormap='Hot')) # 地表图 viz.contour(X=X, win='contour', opts=dict(colormap='Viridis')) # 表面图 viz.surf(X=X, win='surf', opts=dict(colormap='Hot'))