README.md 5.1 KB
Newer Older
Q
Qiao Longfei 已提交
1 2 3 4 5
[![Build Status](https://travis-ci.org/PaddlePaddle/VisualDL.svg?branch=develop)](https://travis-ci.org/PaddlePaddle/VisualDL)
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://github.com/PaddlePaddle/VisualDL/tree/develop/docs)
[![Release](https://img.shields.io/github/release/PaddlePaddle/VisualDL.svg)](https://github.com/PaddlePaddle/VisualDL/releases)
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)

D
daminglu 已提交
6
<p align="center">
T
Thuan Nguyen 已提交
7
  <img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/docs/images/vs-logo.png" width="60%" />
D
daminglu 已提交
8 9
</p>

T
Thuan Nguyen 已提交
10
#
D
daminglu 已提交
11
## Introduction
Q
Qiao Longfei 已提交
12 13 14
VisualDL is a deep learning visualization tool that can help design deep learning jobs.
It includes features such as scalar, parameter distribution, model structure and image visualization.
Currently it is being developed at a high pace.
D
daminglu 已提交
15 16
New features will be continuously added.

Q
Qiao Longfei 已提交
17
At present, most DNN frameworks use Python as their primary language. VisualDL supports Python by nature.
D
daminglu 已提交
18
Users can get plentiful visualization results by simply add a few lines of Python code into their model before training.
Q
Qiao Longfei 已提交
19 20

Besides Python SDK, VisualDL was writen in C++ on the low level. It also provides C++ SDK that
D
daminglu 已提交
21 22 23 24 25 26 27 28 29 30 31 32
can be integrated into other platforms.  


## Component
VisualDL now provides 4 components:

- graph
- scalar
- image
- histogram

### Graph
33
Graph is compatible with ONNX ([Open Neural Network Exchange](https://github.com/onnx/onnx)),
Q
Qiao Longfei 已提交
34
Cooperated with Python SDK, VisualDL can be compatible with most major DNN frameworks, including
D
daminglu 已提交
35 36 37
PaddlePaddle, PyTorch and MXNet.

<p align="center">
T
Thuan Nguyen 已提交
38
  <img src="https://raw.githubusercontent.com/daming-lu/large_files/master/graph_demo.gif" width="60%" />
D
daminglu 已提交
39 40 41 42 43 44 45
</p>

### Scalar
Scalar can be used to show the trends of error during training.


<p align="center">
T
Thuan Nguyen 已提交
46
<img src="https://raw.githubusercontent.com/daming-lu/large_files/master/loss_scalar.gif" width="60%"/>
D
daminglu 已提交
47 48 49 50 51 52
</p>

### Image
Image can be used to visualize any tensor or intermediate generated image.

<p align="center">
T
Thuan Nguyen 已提交
53
<img src="https://raw.githubusercontent.com/daming-lu/large_files/master/loss_image.gif" width="60%"/>
D
daminglu 已提交
54 55 56 57 58 59
</p>

### Histogram
Histogram can be used to visualize parameter distribution and trends for any tensor.

<p align="center">
T
Thuan Nguyen 已提交
60
<img src="https://raw.githubusercontent.com/daming-lu/large_files/master/histogram.gif" width="60%"/>
D
daminglu 已提交
61 62
</p>

Q
Qiao Longfei 已提交
63
## Quick Start
64 65
To give the VisualDL a quick test, please use the following commands.

Q
Qiao Longfei 已提交
66
```
67
# Install the VisualDL. Preferably under a virtual environment.
Q
Qiao Longfei 已提交
68 69
pip install --upgrade visualdl

70 71
# run a demo, vdl_create_scratch_log will create logs for testing.
vdl_create_scratch_log
Q
Qiao Longfei 已提交
72 73 74 75 76
visualDL --logdir=scratch_log --port=8080

# visit http://127.0.0.1:8080
```

D
daminglu 已提交
77 78 79 80 81
## SDK
VisualDL provides both Python SDK and C++ SDK in order to fit more use cases.


### Python SDK
J
Jeff Wang 已提交
82
VisualDL now supports both Python 2 and Python 3.
D
daminglu 已提交
83 84 85 86 87 88 89
Below is an example of creating a simple Scalar component and inserting data from different timestamps:

```python
import random
from visualdl import LogWriter

logdir = "./tmp"
J
Jeff Wang 已提交
90
logger = LogWriter(logdir, sync_cycle=10000)
D
daminglu 已提交
91 92 93 94 95

# mark the components with 'train' label.
with logger.mode("train"):
    # create a scalar component called 'scalars/scalar0'
    scalar0 = logger.scalar("scalars/scalar0")
Q
Qiao Longfei 已提交
96

Y
Yan Chunwei 已提交
97 98 99
# add some records during DL model running.
for step in range(100):
    scalar0.add_record(step, random.random())
D
daminglu 已提交
100 101 102 103 104 105 106 107
```

### C++ SDK
Here is the C++ SDK identical to the Python SDK example above:

```c++
#include <cstdlib>
#include <string>
108
#include "visualdl/logic/sdk.h"
D
daminglu 已提交
109 110

namespace vs = visualdl;
111
namespace cp = visualdl::components;
D
daminglu 已提交
112 113 114

int main() {
  const std::string dir = "./tmp";
J
Jeff Wang 已提交
115
  vs::LogWriter logger(dir, 10000);
Q
Qiao Longfei 已提交
116

D
daminglu 已提交
117
  logger.SetMode("train");
118
  auto tablet = logger.AddTablet("scalars/scalar0");
Q
Qiao Longfei 已提交
119

D
daminglu 已提交
120
  cp::Scalar<float> scalar0(tablet);
Q
Qiao Longfei 已提交
121

D
daminglu 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  for (int step = 0; step < 1000; step++) {
    float v = (float)std::rand() / RAND_MAX;
    scalar0.AddRecord(step, v);
  }

  return 0;
}
```

## Launch Board
After some logs have been generated during training, users can launch board to see real-time data visualization.


```
visualDL --logdir <some log dir>
```

Board also supports the parameters below for remote access:

- `--host` set IP
- `--port` set port
- `--model_pb` specify ONNX format for model file
Q
qiaolongfei 已提交
144

J
Jeff Wang 已提交
145 146 147
The VisualDL Graphing system uses `GraphViz` to visualize the ONNX model. To enable the VisualDL Graph feature,
please install [GraphViz](https://www.graphviz.org/download/)

Q
Qiao Longfei 已提交
148 149 150 151
### How to install from pypi
```
pip install --upgrade visualdl
```
Q
qiaolongfei 已提交
152

Q
Qiao Longfei 已提交
153
### How to build and install locally
Q
qiaolongfei 已提交
154
```
Q
Qiao Longfei 已提交
155 156 157
git clone https://github.com/PaddlePaddle/VisualDL.git
cd VisualDL

Y
Yan Chunwei 已提交
158
python setup.py bdist_wheel
Q
Qiao Longfei 已提交
159
pip install --upgrade dist/visualdl-*.whl
Q
Qiao Longfei 已提交
160 161
```

Y
Yan Chunwei 已提交
162
### Run a demo from scratch
Q
qiaolongfei 已提交
163
```
J
Jeff Wang 已提交
164
# vdl_create_scratch_log is a helper commend that creates mock data.
J
Jeff Wang 已提交
165
vdl_create_scratch_log
Q
Qiao Longfei 已提交
166
visualDL --logdir=scratch_log --port=8080
Q
Qiao Longfei 已提交
167
```
Q
Qiao Longfei 已提交
168 169
that will start a server locally on port 8080, then
you can visit http://127.0.0.1:8080 the see the visualdl board.
D
daminglu 已提交
170 171 172 173


### Contribute

Q
Qiao Longfei 已提交
174 175
VisualDL is initially created by [PaddlePaddle](http://www.paddlepaddle.org/) and
[ECharts](http://echarts.baidu.com/).
D
daminglu 已提交
176
We welcome everyone to use, comment and contribute to Visual DL :)