-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add docs for text * fix image * fix image * fix image * fix text demo * fix grammer errors of text doc * fix grammer errors of text doc * fix grammer errors of text doc * fix grammer errors of text doc Co-authored-by: Peter Pan <littlepanzh@gmail.com>
- Loading branch information
1 parent
d556a76
commit 86ebdf4
Showing
5 changed files
with
249 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (c) 2021 VisualDL Authors. All Rights Reserve. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ======================================================================= | ||
|
||
# coding=utf-8 | ||
|
||
import numpy as np | ||
from PIL import Image | ||
from visualdl import LogWriter | ||
|
||
|
||
def random_crop(img): | ||
"""Get random block of img, which size is 100x100. | ||
""" | ||
img = Image.open(img) | ||
w, h = img.size | ||
random_w = np.random.randint(0, w - 100) | ||
random_h = np.random.randint(0, h - 100) | ||
r = img.crop((random_w, random_h, random_w + 100, random_h + 100)) | ||
return np.asarray(r) | ||
|
||
|
||
if __name__ == '__main__': | ||
imgs = [] | ||
# 获取8张图像 | ||
for step in range(8): | ||
img = random_crop("../../docs/images/dog.jpg") | ||
imgs.append(img) | ||
imgs = np.array(imgs) | ||
|
||
with LogWriter(logdir='./log/image_matrix_test/train') as writer: | ||
writer.add_image(tag='doges', step=0, img=imgs[0]) | ||
# 合成长宽尽量接近的图形矩阵,本例生成3X3的矩阵 | ||
writer.add_image_matrix(tag='doges', step=1, imgs=imgs, rows=-1) | ||
# 合成长为1的图形矩阵,本例生成1x8的矩阵 | ||
writer.add_image_matrix(tag='doges', step=2, scale=10, imgs=imgs, rows=1) | ||
# 合成长为2的图形矩阵,本例生成2X4的矩阵 | ||
writer.add_image_matrix(tag='doges', step=3, scale=10, imgs=imgs, rows=2) | ||
# 合成长为3的图形矩阵,本例生成3X3的矩阵 | ||
writer.add_image_matrix(tag='doges', step=4, imgs=imgs, rows=3) | ||
# 合成长为4的图形矩阵,本例生成4X2的矩阵 | ||
writer.add_image_matrix(tag='doges', step=5, imgs=imgs, rows=4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
python scalar_test.py | ||
python image_test.py | ||
python image_matrix_test.py | ||
python histogram_test.py | ||
python high_dimensional_test.py | ||
python audio_test.py | ||
python text_test.py | ||
python pr_curve_test.py | ||
python roc_curve_test.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2021 VisualDL Authors. All Rights Reserve. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ======================================================================= | ||
|
||
# coding=utf-8 | ||
|
||
from visualdl import LogWriter | ||
|
||
if __name__ == '__main__': | ||
texts = [ | ||
'上联: 众 佛 群 灵 光 圣 地 下联: 众 生 一 念 证 菩 提', | ||
'上联: 乡 愁 何 处 解 下联: 故 事 几 时 休', | ||
'上联: 清 池 荷 试 墨 下联: 碧 水 柳 含 情', | ||
'上联: 既 近 浅 流 安 笔 砚 下联: 欲 将 直 气 定 乾 坤', | ||
'上联: 日 丽 萱 闱 祝 无 量 寿 下联: 月 明 桂 殿 祝 有 余 龄', | ||
'上联: 一 地 残 红 风 拾 起 下联: 半 窗 疏 影 月 窥 来' | ||
] | ||
with LogWriter(logdir="./log/text_test/train") as writer: | ||
for step in range(len(texts)): | ||
writer.add_text(tag="output", step=step, text_string=texts[step]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters