README.md 7.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 10
</p>

## Introduction
Q
Qiao Longfei 已提交
11 12 13
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 已提交
14 15
New features will be continuously added.

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

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


## Component
VisualDL now provides 4 components:

- graph
- scalar
- image
- histogram

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

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

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


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

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

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

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

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

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

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

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

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

76 77 78 79 80 81 82 83 84 85 86 87 88 89
If you run into issues in above steps, it could be error caused by environmental issues by different python or pip versions.
Following installation methods might fix the issues.

## Install with Virtualenv

[Virtualenv](https://virtualenv.pypa.io/en/stable/) creates isolated Python environment that prevents interfering
by other Python programs on the same machine and make sure Python and pip are located properly.

On macOS, install pip and virtualenv by:
```
sudo easy_install pip
pip install --upgrade virtualenv
```

90
On Linux, install pip and virtualenv by:
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
```
sudo apt-get install python3-pip python3-dev python-virtualenv
```

Then create a Virtualenv environment by one of following command:
```
virtualenv ~/vdl  # for Python2.7
virtualenv -p python3 ~/vdl for Python 3.x
```

```~/vdl``` will be your Virtualenv directory, you may choose to install anywhere.

Activate your Virtualenv environment by:
```
source ~/vdl/bin/activate
```

Now you should be able to install VisualDL and run our demo:

```
pip install --upgrade visualdl

# run a demo, vdl_create_scratch_log will create logs for testing.
vdl_create_scratch_log
115
visualdl --logdir=scratch_log --port=8080
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

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

If you still have issues installing VisualDL from Virtualenv, try following installation method.


## Install with Anaconda

Anaconda is a python distribution, with installation and package management tools. Also it is an environment manager,
which provides the facility to create different python environments, each with their own settings.

Follow the instructions on the [Anaconda download site](https://www.anaconda.com/download) to download and install Anaconda.
Download Python 3.6 version command-Line installer.

Create a conda environment named ```vdl``` or anything you want by:
```
conda create -n vdl pip python=2.7 # or python=3.3, etc.
```

Activate the conda environment by:
```
source activate vdl
```

Now you should be able to install VisualDL and run our demo:

```
pip install --upgrade visualdl

# run a demo, vdl_create_scratch_log will create logs for testing.
vdl_create_scratch_log
148
visualdl --logdir=scratch_log --port=8080
149 150 151 152

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

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
If you still have issues installing VisualDL, try installing from sources as in following section.


### Install from source
```
#Preferably under a virtualenv or anaconda.
git clone https://github.com/PaddlePaddle/VisualDL.git
cd VisualDL

python setup.py bdist_wheel
pip install --upgrade dist/visualdl-*.whl
```

If there are still issues regarding the ```pip install```, you can still start Visual DL by starting the dev server
[here](https://github.com/PaddlePaddle/VisualDL/blob/develop/docs/how_to_dev_frontend_en.md)

169

D
daminglu 已提交
170 171 172 173 174
## SDK
VisualDL provides both Python SDK and C++ SDK in order to fit more use cases.


### Python SDK
J
Jeff Wang 已提交
175
VisualDL now supports both Python 2 and Python 3.
D
daminglu 已提交
176 177 178 179 180 181 182
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 已提交
183
logger = LogWriter(logdir, sync_cycle=10000)
D
daminglu 已提交
184 185 186 187 188

# 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 已提交
189

Y
Yan Chunwei 已提交
190 191 192
# add some records during DL model running.
for step in range(100):
    scalar0.add_record(step, random.random())
D
daminglu 已提交
193 194 195 196 197 198 199 200
```

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

```c++
#include <cstdlib>
#include <string>
201
#include "visualdl/logic/sdk.h"
D
daminglu 已提交
202 203

namespace vs = visualdl;
204
namespace cp = visualdl::components;
D
daminglu 已提交
205 206 207

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

D
daminglu 已提交
210
  logger.SetMode("train");
211
  auto tablet = logger.AddTablet("scalars/scalar0");
Q
Qiao Longfei 已提交
212

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

D
daminglu 已提交
215 216 217 218 219 220 221 222 223
  for (int step = 0; step < 1000; step++) {
    float v = (float)std::rand() / RAND_MAX;
    scalar0.AddRecord(step, v);
  }

  return 0;
}
```

224 225
## Launch Visual DL
After some logs have been generated during training, users can launch Visual DL application to see real-time data visualization by:
D
daminglu 已提交
226 227 228


```
229
visualdl --logdir <some log dir>
D
daminglu 已提交
230 231
```

232
visualDL also supports following optional parameters:
D
daminglu 已提交
233 234 235

- `--host` set IP
- `--port` set port
236
- `--model_pb` specify ONNX format for model file to view graph
D
daminglu 已提交
237 238 239 240


### Contribute

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