Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
7b3e837b
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7b3e837b
编写于
1月 15, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
1月 15, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Feature/add scratch demo (#140)
上级
6f02954f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
74 addition
and
10 deletion
+74
-10
README.md
README.md
+4
-3
demo/vdl_scratch.py
demo/vdl_scratch.py
+64
-0
setup.py
setup.py
+3
-3
visualdl/python/test_storage.py
visualdl/python/test_storage.py
+1
-3
visualdl/server/lib.py
visualdl/server/lib.py
+1
-1
visualdl/server/visualDL
visualdl/server/visualDL
+1
-0
未找到文件。
README.md
浏览文件 @
7b3e837b
...
...
@@ -7,8 +7,9 @@ python setup.py bdist_wheel
pip install --upgrade dist/visualdl-0.0.1-py2-none-any.whl
```
### Step 3: run
### Run a demo from scratch
```
visualDL --logdir=<some log> --port=8888
vdl_scratch.py
visualDL --logdir=scratch_log
```
that will start a server locally.
demo/vdl_scratch.py
0 → 100644
浏览文件 @
7b3e837b
#!/user/bin/env python
import
os
from
visualdl
import
LogWriter
,
ROOT
import
subprocess
from
scipy.stats
import
norm
import
numpy
as
np
import
random
from
PIL
import
Image
logdir
=
'./scratch_log'
logw
=
LogWriter
(
logdir
,
sync_cycle
=
30
)
# create scalars in mode train and test.
with
logw
.
mode
(
'train'
)
as
logger
:
scalar0
=
logger
.
scalar
(
"scratch/scalar"
)
with
logw
.
mode
(
'test'
)
as
logger
:
scalar1
=
logger
.
scalar
(
"scratch/scalar"
)
# add scalar records.
for
step
in
range
(
200
):
scalar0
.
add_record
(
step
,
step
*
1.
/
200
)
scalar1
.
add_record
(
step
,
1.
-
step
*
1.
/
200
)
# create histogram
with
logw
.
mode
(
'train'
)
as
logger
:
histogram
=
logger
.
histogram
(
"scratch/histogram"
,
num_buckets
=
100
)
for
step
in
range
(
100
):
histogram
.
add_record
(
step
,
np
.
random
.
normal
(
0.1
+
step
*
0.01
,
size
=
1000
))
# create image
with
logw
.
mode
(
"train"
)
as
logger
:
image
=
logger
.
image
(
"scratch/dog"
,
4
,
1
)
# randomly sample 4 images one pass
dog_jpg
=
Image
.
open
(
os
.
path
.
join
(
ROOT
,
'python/dog.jpg'
))
shape
=
[
dog_jpg
.
size
[
1
],
dog_jpg
.
size
[
0
],
3
]
for
pass_
in
xrange
(
4
):
image
.
start_sampling
()
for
sample
in
xrange
(
10
):
# randomly crop a demo image.
target_shape
=
[
100
,
100
,
3
]
# width, height, channels(3 for RGB)
left_x
=
random
.
randint
(
0
,
shape
[
1
]
-
target_shape
[
1
])
left_y
=
random
.
randint
(
0
,
shape
[
0
]
-
target_shape
[
0
])
right_x
=
left_x
+
target_shape
[
1
]
right_y
=
left_y
+
target_shape
[
0
]
idx
=
image
.
is_sample_taken
()
# a more efficient way to sample images is
if
idx
>=
0
:
data
=
np
.
array
(
dog_jpg
.
crop
((
left_x
,
left_y
,
right_x
,
right_y
))).
flatten
()
image
.
set_sample
(
idx
,
target_shape
,
data
)
# you can also just write followig codes, it is more clear, but need to
# process image even if it will not be sampled.
# data = np.array(
# dog_jpg.crop((left_x, left_y, right_x,
# right_y))).flatten()
# image.add_sample(shape, data)
image
.
finish_sampling
()
setup.py
浏览文件 @
7b3e837b
...
...
@@ -26,7 +26,7 @@ def readlines(name):
VERSION_NUMBER
=
read
(
'VERSION_NUMBER'
)
LICENSE
=
readlines
(
'LICENSE'
)[
0
].
strip
()
install_requires
=
[
'Flask'
,
'numpy'
,
'Pillow'
,
'protobuf'
]
install_requires
=
[
'Flask'
,
'numpy'
,
'Pillow'
,
'protobuf'
,
'scipy'
]
execute_requires
=
[
'npm'
,
'node'
,
'bash'
]
...
...
@@ -94,7 +94,7 @@ setup(
install_requires
=
install_requires
,
package_data
=
{
'visualdl.server'
:
datas
,
'visualdl'
:[
'core.so'
],
'visualdl.python'
:[
'core.so'
]},
'visualdl.python'
:[
'core.so'
,
'dog.jpg'
]},
packages
=
packages
,
scripts
=
[
'visualdl/server/visualDL'
],
scripts
=
[
'visualdl/server/visualDL'
,
'demo/vdl_scratch.py'
],
cmdclass
=
cmdclass
)
visualdl/python/test_storage.py
浏览文件 @
7b3e837b
...
...
@@ -81,9 +81,7 @@ class StorageTest(unittest.TestCase):
with
self
.
reader
.
mode
(
"train"
)
as
reader
:
image_writer
.
start_sampling
()
index
=
image_writer
.
is_sample_taken
()
image_writer
.
set_sample
(
index
,
shape
,
list
(
origin_data
))
image_writer
.
finish_sampling
()
image_writer
.
add_sample
(
shape
,
list
(
origin_data
))
# read and check whether the original image will be displayed
image_reader
=
reader
.
image
(
tag
)
...
...
visualdl/server/lib.py
浏览文件 @
7b3e837b
...
...
@@ -150,7 +150,7 @@ def get_histogram_tags(storage):
return
get_tags
(
storage
,
'histogram'
)
def
get_histogram
(
storage
,
mode
,
tag
,
num_samples
=
2
00
):
def
get_histogram
(
storage
,
mode
,
tag
,
num_samples
=
1
00
):
with
storage
.
mode
(
mode
)
as
reader
:
histogram
=
reader
.
histogram
(
tag
)
res
=
[]
...
...
visualdl/server/visualDL
浏览文件 @
7b3e837b
...
...
@@ -100,6 +100,7 @@ def index():
@
app
.
route
(
'/static/<path:filename>'
)
def
serve_static
(
filename
):
print
'serve static '
,
filename
return
send_from_directory
(
os
.
path
.
join
(
server_path
,
static_file_path
),
filename
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录