README.md 20.1 KB
Newer Older
1 2
[**中文**](./README_CN.md)

Y
YixinKristy 已提交
3

D
daminglu 已提交
4
<p align="center">
Y
YixinKristy 已提交
5
  <img src="https://raw.githubusercontent.com/PaddlePaddle/VisualDL/develop/frontend/packages/core/public/images/logo-visualdl.svg?sanitize=true" width="70%"/>
D
daminglu 已提交
6 7
</p>

L
LaraStuStu 已提交
8

9

P
Peter Pan 已提交
10
<p align="center">
P
Peter Pan 已提交
11
<a href="https://actions-badge.atrox.dev/PaddlePaddle/VisualDL/goto?ref=develop"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FPaddlePaddle%2FVisualDL%2Fbadge%3Fref%3Ddevelop&style=flat-square" alt="Build Status" /></a>
P
Peter Pan 已提交
12 13 14 15 16
<a href="https://pypi.org/project/visualdl/"><img src="https://img.shields.io/pypi/v/visualdl?style=flat-square" alt="PyPI" /></a>
<a href="https://pypi.org/project/visualdl/#files"><img src="https://img.shields.io/pypi/dm/visualdl?style=flat-square" alt="Downloads" /></a>
<a href="https://github.com/PaddlePaddle/VisualDL/blob/develop/LICENSE"><img src="https://img.shields.io/github/license/paddlepaddle/visualdl?style=flat-square" alt="License" /></a>
</p>

17

P
Peter Pan 已提交
18
<p align="center">
19
<a href="javascript:void(0)"><img src="https://img.shields.io/badge/QQ_Group-1045783368-52B6EF?style=social&logo=tencent-qq&logoColor=000&logoWidth=20" alt="QQ Group" /></a>
P
Peter Pan 已提交
20
</p>
Y
YixinKristy 已提交
21

D
daminglu 已提交
22

23 24
## Introduction

25
VisualDL, a visualization analysis tool of PaddlePaddle, provides a variety of charts to show the trends of parameters, and visualizes model structures, data samples, histograms of tensors, PR curves , ROC curves and high-dimensional data distributions. It enables users to understand the training process and the model structure more clearly and intuitively so as to optimize models efficiently.
Q
Qiao Longfei 已提交
26

27
VisualDL provides various visualization functions, including **tracking metrics in real-time, visualizing the model structure, displaying the data sample, visualizing the relationship between hyperparameters and model metrics, presenting the changes of distributions of tensors, showing the pr curves, projecting high-dimensional data to a lower dimensional space and more.** Additionally, VisualDL provides VDL.service, which enables developers easily to save, track and share visualization results of experiments. For specific guidelines of each function, please refer to  [**VisualDL User Guide**](./docs/components/README.md). For up-to-date experience, please feel free to try our [**Online Demo**](https://www.paddlepaddle.org.cn/paddle/visualdl/demo). Currently, VisualDL iterates rapidly and new functions will be continuously added.
28 29

Browsers supported by VisualDL are:
Y
YixinKristy 已提交
30

P
Peter Pan 已提交
31 32 33 34 35
- Google Chrome ≥ 79
- Firefox ≥ 67
- Microsoft Edge ≥ 79
- Safari ≥ 11.1

36
VisualDL natively supports the use of Python. Developers can retrieve plentiful visualization results by simply adding a few lines of Python code into the model before training.
D
daminglu 已提交
37

38 39


40
## Contents
D
daminglu 已提交
41

42 43 44 45
* [Key Highlights](#Key-Highlights)
* [Installation](#Installation)
* [Usage Guideline](#Usage-Guideline)
* [Function Preview](#Function-Preview)
M
monika19950721 已提交
46
* [Frequently Asked Questions](#Frequently-Asked-Questions)
47 48 49
* [Contribution](#Contribution)
* [More Details](#More-Details)
* [Technical Communication](#Technical-Communication)
D
daminglu 已提交
50 51


52

53
## Key Highlights
D
daminglu 已提交
54

55
### Easy to Use
56

57
The high-level design of API makes it easy to use. Only one click can initiate the visualization of model structures.
D
daminglu 已提交
58

59

60
### Various Functions
Q
Qiao Longfei 已提交
61

M
monika19950721 已提交
62
The function contains the visualization of training parameters, data samples, graph structures, histograms of tensors, PR curves and high-dimensional data distributions.
Y
YixinKristy 已提交
63

64
### High Compatibility
Y
YixinKristy 已提交
65

66
VisualDL provides the visualization of the mainstream model structures such as Paddle, ONNX, Caffe, widely supporting visual analysis for diverse users.
Y
YixinKristy 已提交
67

68
### Fully Support
Y
YixinKristy 已提交
69

M
monika19950721 已提交
70
By Integrating into PaddlePaddle and related modules, VisualDL allows developers to use different components without obstructions, and thus to have the best experience in the PaddlePaddle ecosystem.
Q
Qiao Longfei 已提交
71

72
## Installation
73 74


75
### Install by PiP
76

77
```shell
Y
YixinKristy 已提交
78
python -m pip install visualdl -i https://mirror.baidu.com/pypi/simple
79
```
80 81

### Install by Code
Y
YixinKristy 已提交
82 83 84 85 86 87 88 89 90

```
git clone https://github.com/PaddlePaddle/VisualDL.git
cd VisualDL

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

91 92 93 94
Please note that Python 2 is no longer maintained officially since January 1, 2020. VisualDL now only supports Python 3 in order to ensure the usability of codes.


## Usage Guideline
Y
YixinKristy 已提交
95

96
VisualDL stores the data, parameters and other information of the training process in a log file. Users can launch the panel to observe the visualization results.
Y
YixinKristy 已提交
97

98
### 1. Log
Y
YixinKristy 已提交
99

100
The Python SDK is provided at the back end of VisualDL, and a logger can be customized through LogWriter. The interface description is shown as follows:
101

Y
YixinKristy 已提交
102
```python
103
class LogWriter(logdir=None,
Y
YixinKristy 已提交
104 105 106
                max_queue=10,
                flush_secs=120,
                filename_suffix='',
107
                **kwargs)
108 109
```

110
#### Interface Parameters
Y
YixinKristy 已提交
111

112 113 114
| parameters      | type    | meaning                                                      |
| --------------- | ------- | ------------------------------------------------------------ |
| logdir          | string  | The path location of log file. VisualDL will create a log file under this path to record information generated by the training process. If not specified, the path will be  `runs/${CURRENT_TIME}`as default. |
115 116
| max_queue       | int     | The maximum capacity of the data generated before recording in a log file. Default value is 10. If the capacity is reached, the data are immediately written into the log file. |
| flush_secs      | int     | The maximum cache time of the data generated before recording in a log file. Default value is 120. When this time is reached, the data are immediately written to the log file. (When the log message queue reaches the maximum cache time or maximum capacity, it will be written to the log file immediately)|
117
| filename_suffix | string  | Add a suffix to the default log file name.                   |
118
| display_name    | string  | This parameter is displayed in the location of `Select Data Stream` in the panel. If not set, the default name is `logdir`.(When `logdir` is too long or needed to be hidden). |
M
monika19950721 已提交
119
| file_name    | string  | Set the name of the log file. If the file_name already exists, setting the file_name will be new records in the same log file, which will continue to be used. Note that the name should include 'vdlrecords'. |
120 121 122 123 124 125 126 127
<p align="center">
  <img src="https://user-images.githubusercontent.com/48054808/103187556-b9714280-48ff-11eb-9052-008e02a21199.png" width="100%"/>
</p>

<p align="center">
  <img src="https://user-images.githubusercontent.com/48054808/103187552-b4ac8e80-48ff-11eb-998a-57d5a1bc7ee6.png" width="100%"/>
</p>

Y
YixinKristy 已提交
128

129
#### Example
Y
YixinKristy 已提交
130

131
Create a log file and record scalar values:
D
daminglu 已提交
132 133 134 135

```python
from visualdl import LogWriter

136
# create a log file under `./log/scalar_test/train`
Y
YixinKristy 已提交
137
with LogWriter(logdir="./log/scalar_test/train") as writer:
138
    # use `add_scalar` to record scalar values
Y
YixinKristy 已提交
139 140 141
    writer.add_scalar(tag="acc", step=1, value=0.5678)
    writer.add_scalar(tag="acc", step=2, value=0.6878)
    writer.add_scalar(tag="acc", step=3, value=0.9878)
走神的阿圆's avatar
走神的阿圆 已提交
142 143 144 145 146 147 148 149 150 151
# you can also use the following method without using context manager `with`:
"""
writer = LogWriter(logdir="./log/scalar_test/train")

writer.add_scalar(tag="acc", step=1, value=0.5678)
writer.add_scalar(tag="acc", step=2, value=0.6878)
writer.add_scalar(tag="acc", step=3, value=0.9878)

writer.close()
"""
D
daminglu 已提交
152 153
```

154
### 2. Launch Panel
D
daminglu 已提交
155

M
monika19950721 已提交
156
In the above example, the log has recorded three sets of scalar values. Developers can view the visualization results of the log file through launching the visualDL panel. There are two ways to launch the log file:
Z
Zeyu Chen 已提交
157

158
#### Launch by Command Line
Z
Zeyu Chen 已提交
159

160
Use the command line to launch the VisualDL panel:
D
daminglu 已提交
161

Y
YixinKristy 已提交
162
```python
P
Peter Pan 已提交
163
visualdl --logdir <dir_1, dir_2, ... , dir_n> --model <model_file> --host <host> --port <port> --cache-timeout <cache_timeout> --language <language> --public-path <public_path> --api-only
D
daminglu 已提交
164
```
Y
YixinKristy 已提交
165

166
Parameter details:
Y
YixinKristy 已提交
167

168 169
| parameters      | meaning                                                      |
| --------------- | ------------------------------------------------------------ |
170
| --logdir        | Set one or more directories of the log. All the logs in the paths or subdirectories will be displayed on the VisualDL Board indepentently. |
走神的阿圆's avatar
走神的阿圆 已提交
171
| --model         | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. PaddlePaddle、ONNX、Keras、Core ML、Caffe and other model formats are supported. Please refer to [Graph - Functional Instructions](./docs/components/README.md#functional-instructions-2). |
172
| --host          | Specify IP address. The default value is `127.0.0.1`. Specify it as `0.0.0.0` or public IP address so that other machines can visit VisualDL Board.       |
173
| --port          | Set the port. The default value is `8040`.                   |
M
monika19950721 已提交
174
| --cache-timeout | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. |
175 176 177
| --language      | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| --public-path   | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| --api-only      | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the public_path parameter is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
Y
YixinKristy 已提交
178

179
To visualize the log file generated in the previous step, developers can launch the panel through the command:
Y
YixinKristy 已提交
180 181 182

```
visualdl --logdir ./log
D
daminglu 已提交
183 184
```

185
#### Launch in Python Script
Y
YixinKristy 已提交
186

187 188

Developers can start the VisualDL panel in Python script as follows:
D
daminglu 已提交
189

190
```python
Y
YixinKristy 已提交
191
visualdl.server.app.run(logdir,
P
Peter Pan 已提交
192
                        model="path/to/model",
Y
YixinKristy 已提交
193 194 195 196
                        host="127.0.0.1",
                        port=8080,
                        cache_timeout=20,
                        language=None,
197 198
                        public_path=None,
                        api_only=False,
Y
YixinKristy 已提交
199 200 201
                        open_browser=False)
```

202
Please note: since all parameters are indefinite except `logdir`, developers should specify parameter names when using them.
Y
YixinKristy 已提交
203

204
The interface parameters are as follows:
Y
YixinKristy 已提交
205

206 207
| parameters    | type                                               | meaning                                                      |
| ------------- | -------------------------------------------------- | ------------------------------------------------------------ |
208
| logdir        | string or list[string_1, string_2, ... , string_n] | Set one or more directories of the log. All the logs in the paths or subdirectories will be displayed on the VisualDL Board indepentently.|
M
monika19950721 已提交
209
| model         | string                                             | Set a path to the model file (not a directory). VisualDL will visualize the model file in Graph page. |
210
| host          | string                                             | Specify IP address. The default value is `127.0.0.1`. Specify it as `0.0.0.0` or public IP address so that other machines can visit VisualDL Board.       |
211
| port          | int                                                | Set the port. The default value is `8040`.                   |
M
monika19950721 已提交
212
| cache_timeout | int                                                | Cache time of the backend. During the cache time, the front end requests the same URL multiple times, and then the returned data are obtained from the cache. The default cache time is 20 seconds. |
213 214 215 216
| language      | string                                             | The language of the VisualDL panel. Language can be specified as 'en' or 'zh', and the default is the language used by the browser. |
| public_path   | string                                             | The URL path of the VisualDL panel. The default path is '/app', meaning that the access address is 'http://&lt;host&gt;:&lt;port&gt;/app'. |
| api_only      | boolean                                            | Decide whether or not to provide only API. If this parameter is set, VisualDL will only provides API service without displaying the web page, and the API address is 'http://&lt;host&gt;:&lt;port&gt;/&lt;public_path&gt;/api'. Additionally, If the parameter public_path is not specified, the default address is 'http://&lt;host&gt;:&lt;port&gt;/api'. |
| open_browser  | boolean                                            | Whether or not to open the browser. If this parameter is set as True, the browser will be opened automatically and VisualDL panel will be launched at the same time. If parameter api_only is specified as True,  parameter open_browser can be ignored. |
217

218
To visualize the log file generated in the previous step, developers can launch the panel through the command:
Y
YixinKristy 已提交
219 220 221 222 223

```python
from visualdl.server import app

app.run(logdir="./log")
224
```
D
daminglu 已提交
225

226
After launching the panel by one of the above methods, developers can see the visualization results on the browser shown as blow:
Y
YixinKristy 已提交
227 228

<p align="center">
229
  <img src="https://user-images.githubusercontent.com/48054808/90868674-ba321f00-e3c9-11ea-83c1-f03c6dd19187.png" width="70%"/>
Y
YixinKristy 已提交
230 231
</p>

232 233
### 3. Read data in log files using LogReader

M
monika19950721 已提交
234
VisualDL also provides `LogReader` interface to read any data from log files.
235 236 237 238

```python
class LogReader(file_path='')
```
M
monika19950721 已提交
239
#### Interface Parameters
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
| parameters | type   | meaning                              |
| ---------- | ------ | ------------------------------------ |
| file_path  | string | File path of the log file. Required. |
#### Example
If there is a log file named `vdlrecords.1605533348.log` in the directory of `./log`, we can retrieve the data under the 'loss' tag in the scalar by:
```python
from visualdl import LogReader
reader = LogReader(file_path='./vdlrecords.1605533348.log')
data = reader.get_data('scalar', 'loss')
print(data)
```
The result will be a list shown as below:
```python
...
id: 5
tag: "Metrics/Training(Step): loss"
timestamp: 1605533356039
value: 3.1297709941864014
...
```

For more information of `LogReader`, please refer to [LogReader](./docs/io/LogReader.md).


264
## Function Preview
Y
YixinKristy 已提交
265 266 267

### Scalar

M
monika19950721 已提交
268
**Scalar** makes use of various charts to display how the parameters, such as accuracy, loss and learning rate, changes during the training process. In this case, developers can observe not only the single but also the multiple groups of parameters in order to understand the training process and thus speed up the process of model tuning.
Y
YixinKristy 已提交
269

270 271 272
#### Dynamic Display

After the launch of VisualDL Board, the LogReader will continuously record the data to display in the front-end. Hence, the changes of parameters can be visualized in real-time, as shown below:
Y
YixinKristy 已提交
273 274

<p align="center">
275
  <img src="https://visualdl.bj.bcebos.com/images/dynamic_display.gif" width="60%"/>
Y
YixinKristy 已提交
276 277 278 279
</p>



280 281
#### Comparison of Multiple Experiments

M
monika19950721 已提交
282
Developers can compare multiple experiments by specifying and uploading the path of each experiment at the same time so as to visualize the same parameters in the same chart.
Y
YixinKristy 已提交
283 284

<p align="center">
285
  <img src="https://user-images.githubusercontent.com/48054808/90869567-fdd95880-e3ca-11ea-9855-6c97ad5c8ae7.gif" width="100%"/>
Y
YixinKristy 已提交
286 287 288
</p>


289

Y
YixinKristy 已提交
290
### Image
291

M
monika19950721 已提交
292
**Image** provides real-time visualizations of the image data during the training process, allowing developers to observe the changes of images at different training stages and  to deeply understand the effects of the training process.
Y
YixinKristy 已提交
293 294

<p align="center">
295
<img src="https://user-images.githubusercontent.com/48054808/90869677-22353500-e3cb-11ea-9830-2334bdd8e52e.gif" width="55%"/>
Y
YixinKristy 已提交
296 297
</p>

298

Y
YixinKristy 已提交
299
### Audio
300 301

**Audio** aims to allow developers to listen to the audio data in real-time during the training process, helping developers to monitor the process of speech recognition and text-to-speech.
Y
YixinKristy 已提交
302 303

<p align="center">
304
<img src="https://user-images.githubusercontent.com/48054808/90869771-47c23e80-e3cb-11ea-8b2a-a38b6c33d64b.png" width="85%"/>
Y
YixinKristy 已提交
305 306
</p>

307

走神的阿圆's avatar
走神的阿圆 已提交
308 309 310 311 312 313 314 315
### Text
**Text** visualizes the text output of NLP models within any stage, aiding developers to compare the changes of outputs so as to deeply understand the training process and simply evaluate the performance of the model.

<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/106248340-cdd09400-624b-11eb-8ea9-5a07a239c365.png" width="85%"/>
</p>


Y
YixinKristy 已提交
316 317
### Graph

C
chenjian 已提交
318 319 320 321 322 323 324 325 326
**Graph** enables developers to visualize model structures by only one click. Moreover, **Graph** allows developers to explore model attributes, node information, node input and output. aiding them analyze model structures quickly and understand the direction of data flow easily. Additionally, Graph supports the visualization of dynamic and static model graph respectively.

- dynamic graph

<p align="center">
<img src="https://user-images.githubusercontent.com/22424850/175811841-64b44d99-7d48-4fe9-a679-01156d15af74.gif" width="85%"/>
</p>

- static graph
327

Y
YixinKristy 已提交
328
<p align="center">
C
chenjian 已提交
329
<img src="https://user-images.githubusercontent.com/22424850/175811795-1fd21737-06f0-42fc-bea3-ef7a17216fc9.gif" width="85%"/>
Y
YixinKristy 已提交
330 331
</p>

332

Y
YixinKristy 已提交
333 334
### Histogram

M
monika19950721 已提交
335
**Histogram** displays how the trend of tensor (weight, bias, gradient, etc.) changes during the training process in the form of histogram. Developers can adjust the model structures accurately by having an in-depth understanding of the effect of each layer.
Y
YixinKristy 已提交
336

337
- Offset Mode
Y
YixinKristy 已提交
338 339

<p align="center">
340
<img src="https://user-images.githubusercontent.com/48054808/90870121-bd2e0f00-e3cb-11ea-89cf-6622cb607b89.png" width="85%"/>
Y
YixinKristy 已提交
341 342
</p>

Y
YixinKristy 已提交
343

Y
YixinKristy 已提交
344

345
- Overlay Mode
Y
YixinKristy 已提交
346 347

<p align="center">
348
<img src="https://user-images.githubusercontent.com/48054808/90870194-cfa84880-e3cb-11ea-8a66-bebcad267a10.png" width="85%"/>
Y
YixinKristy 已提交
349 350
</p>

351 352 353 354 355 356 357 358 359 360
### PR Curve

**PR Curve** displays the precision and recall values under different thresholds, helping developers to find the best threshold efficiently.

<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/103274647-1ef72900-49fd-11eb-9284-2a5b63bdf2e3.png" width="85%"/>
</p>

### ROC Curve

M
monika19950721 已提交
361
**ROC Curve** shows the performance of a classification model at all classification thresholds; the larger the area under the curve, the better the model performs, aiding developers in evaluating the model performance and choosing an appropriate threshold.
362 363

<p align="center">
Y
YixinKristy 已提交
364
<img src="https://user-images.githubusercontent.com/48054808/103344081-8928d000-4ac8-11eb-84d0-28f249886172.gif" width="85%"/>
365 366
</p>

367

Y
YixinKristy 已提交
368 369
### High Dimensional

370
**High Dimensional** provides three approaches--T-SNE, PCA and UMAP--to do the dimensionality reduction, allowing developers to have an in-depth analysis of the relationship between high-dimensional data and to optimize algorithms based on the analysis.
Y
YixinKristy 已提交
371 372

<p align="center">
373
<img src="https://user-images.githubusercontent.com/48054808/103188111-1b32ac00-4902-11eb-914e-c2368bdb8373.gif" width="85%"/>
Y
YixinKristy 已提交
374 375
</p>

376

走神的阿圆's avatar
走神的阿圆 已提交
377 378 379 380 381 382 383 384 385
### Hyper Parameters

**Hyper Parameters** visualize the relationship between hyperparameters and model metrics (such as accuracy and loss) in a rich view, helping you identify the best hyperparameters in an efficient way.

<p align="center">
<img src="https://user-images.githubusercontent.com/28444161/119247155-e9c0c280-bbb9-11eb-8175-58a9c7657a9c.gif" width="85%"/>
</p>


386 387
### VDL.service

388
**VDL.service** enables developers to easily save, track and share visualization results with anyone for free.
389 390

<p align="center">
391
<img src=https://user-images.githubusercontent.com/48054808/93731055-fbeafb00-fbfd-11ea-80f4-bbfd08a0fc35.png width="85%"/>
392 393
</p>

394

M
monika19950721 已提交
395 396
## Frequently Asked Questions

走神的阿圆's avatar
走神的阿圆 已提交
397
If you are confronted with some problems when using VisualDL, please refer to [our FAQs](./docs/faq.md).
M
monika19950721 已提交
398

399
## Contribution
Y
YixinKristy 已提交
400

401
VisualDL, in which Graph is powered by [Netron](https://github.com/lutzroeder/netron), is an open source project supported by [PaddlePaddle](https://www.paddlepaddle.org/) and [ECharts](https://echarts.apache.org/).
W
wuzewu 已提交
402

403
Developers are warmly welcomed to use, comment and contribute.
W
wuzewu 已提交
404

405
## More Details
W
wuzewu 已提交
406

走神的阿圆's avatar
走神的阿圆 已提交
407
For more details related to the use of VisualDL, please refer to [**VisualDL User Guide**](./docs/components/README.md)
Y
YixinKristy 已提交
408

409
## Technical Communication
Y
YixinKristy 已提交
410

Y
YixinKristy 已提交
411
Welcome to join the official QQ group 1045783368 to communicate with PaddlePaddle team and other developers.
Y
YixinKristy 已提交
412 413 414 415

<p align="center">
<img src="https://user-images.githubusercontent.com/48054808/82522691-c2758680-9b5c-11ea-9aee-fca994aba175.png" width="20%"/>
</p>
416