Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit bb6d595
Author: Zirui Cai <74649535+Feudalman@users.noreply.github.com>
Date:   Wed Feb 28 21:25:42 2024 +0800

    Feature/text chart (#337)

    * feat: create text tag

    * feat: init

    * feat: text data

    * feat: zoom

    * feat: text detail

    * feat: step

    * style

    * fix: width

    * fix: change

    * fix: change

    * feat: modal title

    * fix: line clamp

    * test: text log

    * Squashed commit of the following:

    commit 6ec7f6d
    Author: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com>
    Date:   Thu Feb 22 16:13:17 2024 +0800

        record max step and min step (#341)

    commit ce48cd8
    Author: KAAANG <cunykang@gmail.com>
    Date:   Thu Feb 22 15:51:42 2024 +0800

        delete Video

    commit a11a7ed
    Author: Bote Huang <106975133+KashiwaByte@users.noreply.github.com>
    Date:   Thu Feb 22 15:36:32 2024 +0800

        Feat/video chart (#338)

        * feat:create class Video

        * feat:add __init__,add video chart

        * feat:add function for saving video

        * feat:add function for getting list of video

        * feat:add function get_data

        * feat:add function __save and __prepare_video

        * feat:add function load_from_str and load_from_BytesIO

        * bugfix: fix __save function

        * del test file

    commit 6b5b9c3
    Author: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com>
    Date:   Wed Feb 21 15:25:33 2024 +0800

        Feat/new line chart (#334)

        * add type——linear

        * label formatter

        * update tick

    commit 788d8c1
    Author: Ze-Yi LIN <58305964+xiaolin199912@users.noreply.github.com>
    Date:   Tue Feb 20 21:07:39 2024 +0800

        Feat/image-add-parameters-boxes-masks (#329)

        * add BoundingBoxes class

        * update something

        * Update transfer_logfile_0.1.4.py

        * add ImageMask class

        * bugfix

    commit 65a6378
    Author: Ze-Yi LIN <58305964+xiaolin199912@users.noreply.github.com>
    Date:   Mon Feb 19 18:42:11 2024 +0800

        Readme v0.2.0 (#326)

    commit 7b964e9
    Author: Zirui Cai <74649535+Feudalman@users.noreply.github.com>
    Date:   Mon Feb 19 18:29:05 2024 +0800

        Fixbug/tag sort (#327)

    * use hash name to filename

    * feat: get text

    * feat: get text

    * feat: caption

    * fix: log page layout

    * ui: color

    * feat: skeleton

    * fix: detail caption

    * fix: length

    * feat: log height

    * feat: page index

    * fix: flash

    * fix: skeleton

    * fix: flash

    * fix: some bug

    * fix:wrap

    * ui: color

    * Squashed commit of the following:

    commit b328478
    Author: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com>
    Date:   Mon Feb 26 22:12:23 2024 +0800

        Update/line chart styles (#351)

        * hover active

        * hover top

        * optimize hover top

        * Update LineChart.vue

        * update hover

        * allow hover while running

        * Limit height when zooming in

        * fix slidebar bug

        * thickenByTag

        * Logic to distinguish between multiple data charts and single data charts

        * allow config crosshair

        * update crosshairsColor

        * update doc

        * update thickerLineWidth

        ---------

        Co-authored-by: ZeYi Lin <944270057@qq.com>

    * refactor: click to turn page

    * feat: enter and blur

    * doc: comments

    * fix: bg height

    * Update launch.json

    * refactor: get texts

    * refactor: script to create experiment

    ---------

    Co-authored-by: ZeYi Lin <944270057@qq.com>
    Co-authored-by: KAAANG <cunykang@gmail.com>

commit 113d4bc
Author: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com>
Date:   Wed Feb 28 00:01:25 2024 +0800

    legend component (#354)

commit b328478
Author: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com>
Date:   Mon Feb 26 22:12:23 2024 +0800

    Update/line chart styles (#351)

    * hover active

    * hover top

    * optimize hover top

    * Update LineChart.vue

    * update hover

    * allow hover while running

    * Limit height when zooming in

    * fix slidebar bug

    * thickenByTag

    * Logic to distinguish between multiple data charts and single data charts

    * allow config crosshair

    * update crosshairsColor

    * update doc

    * update thickerLineWidth

    ---------

    Co-authored-by: ZeYi Lin <944270057@qq.com>
  • Loading branch information
Feudalman committed Feb 28, 2024
1 parent a5b2120 commit 4d9988e
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 147 deletions.
20 changes: 16 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
//sys.path 会加入顶层目录,影响模块导入查询路径
"env": { "PYTHONPATH": "${workspaceFolder}" }
},
// 打包命令
// 开发调试
{
"name": "构建项目",
"name": "开发调试",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/build_pypi.py",
"program": "${workspaceFolder}/test/test_create_experiment.py",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}"
"cwd": "${workspaceFolder}",
//sys.path 会加入顶层目录,影响模块导入查询路径
"env": { "PYTHONPATH": "${workspaceFolder}" }
},
// 模拟实验开启
{
Expand Down Expand Up @@ -69,6 +71,16 @@
"cwd": "${workspaceFolder}",
//sys.path 会加入顶层目录,影响模块导入查询路径
"env": { "PYTHONPATH": "${workspaceFolder}" }
},
// 打包命令
{
"name": "构建项目",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/build_pypi.py",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}"
}
]
}
11 changes: 10 additions & 1 deletion swanlab/server/controller/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,16 @@ def get_tag_data(experiment_id: int, tag: str) -> dict:
# 获取最大值和最小值
max_value = max(data_values)
min_value = min(data_values)
return SUCCESS_200(data={"sum": len(tag_data), "max": max_value, "min": min_value, "list": tag_data})
return SUCCESS_200(
data={
"sum": len(tag_data),
"max": max_value,
"min": min_value,
"list": tag_data,
# 标注此数据隶属于哪个实验
"experiment_id": experiment_id,
}
)


# 获取实验状态
Expand Down
58 changes: 20 additions & 38 deletions test/create_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
import numpy as np

epochs = 100
epochs = 50
lr = 0.01
offset = random.random() / 5

Expand All @@ -19,46 +19,28 @@
logggings=True,
)
for epoch in range(2, epochs):
# if epoch % 10 == 0:
# # 测试audio
# sample_rate = 44100
# test_audio_arr = np.random.randn(2, 100000)
# swanlab.log(
# {
# "test/audio": [swanlab.Audio(test_audio_arr, sample_rate, caption="test")] * (epoch // 10),
# },
# step=epoch,
# )

test_image = "/home/swan/桌面/jojo.jpg"
swanlab.log(
{
"test/image": [swanlab.Image(test_image, caption="test")] * 4,
"test/text": swanlab.Text("this is a test text", caption="test"),
},
step=epoch,
)
acc = 1 - 2**-epoch - random.random() / epoch - offset
loss = 2**-epoch + random.random() / epoch + offset
loss2 = 3**-epoch + random.random() / epoch + offset * 3
print("epoch", epoch)
print(f"hello world {epoch}")
print(f"hello world {epoch}")
print(f"hello world {epoch}")
print(f"hello world {epoch}")
print(f"hello world {epoch}")
print(f"hello world {epoch}")
if epoch % 863 == 0:
if epoch % 10 == 0:
# # 测试audio
# sample_rate = 44100
# test_audio_arr = np.random.randn(2, 100000)
# swanlab.log(
# {
# "test/audio": [swanlab.Audio(test_audio_arr, sample_rate, caption="test")] * (epoch // 10),
# },
# step=epoch,
# )
# 测试image
test_image = np.random.randint(0, 255, (100, 100, 3))
swanlab.log(
{
# "test/image": swanlab.Image(test_image, caption="test"),
"hello": [
swanlab.Text("test test test"),
]
* 10,
"test/image": swanlab.Image(test_image, caption="test"),
"test/text": swanlab.Text("hello swanlab!", caption="swanlab official"),
},
step=epoch,
)
acc = 1 - 2**-epoch - random.random() / epoch - offset
loss = 2**-epoch + random.random() / epoch + offset
loss2 = 3**-epoch + random.random() / epoch + offset * 3
print(f"epoch={epoch}, accuracy={acc}, loss={loss}")
# swanlab.log({"t/accuracy": acc, "loss": loss, "loss2": loss2})
time.sleep(0.1)
swanlab.log({"t/accuracy": acc, "loss": loss, "loss2": loss2})
time.sleep(0.2)
68 changes: 68 additions & 0 deletions vue/src/charts/components/LineChartLegend.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<div class="lc-legend">
<div
class="lc-legend-item"
:style="{ color: item.color }"
v-for="item in items"
:key="item.name"
@mouseenter="handelMouseenter(item)"
@mouseleave="handelMouseleave(item)"
@click="handelClick(item)"
>
<RouterLink :to="'/experiment/' + item.experiment_id">
{{ item.name }}
</RouterLink>
</div>
</div>
</template>

<script setup>
/**
* @description: 折线图图例组件
* @file: LineChartLegend.vue
* @since: 2024-02-27 15:02:13
**/
defineProps({
items: {
type: Array,
default: () => []
}
})
// console.log('items', props.items)
const emit = defineEmits(['hoverin', 'hoverout'])
// ---------------------------------- 悬浮事件 ----------------------------------
const handelMouseenter = (item) => {
emit('hoverin', item)
}
const handelMouseleave = (item) => {
emit('hoverout', item)
}
// ---------------------------------- 点击事件 ----------------------------------
const handelClick = (item) => {
emit('click', item)
}
</script>

<style lang="scss" scoped>
.lc-legend {
max-height: 28px;
min-height: 16px;
@apply overflow-y-auto flex flex-wrap px-3 mb-1 gap-y-0.5 gap-x-2 leading-none text-[12px];
@apply justify-center;
.lc-legend-item {
@apply flex flex-shrink-0 items-center hover:brightness-75;
&:before {
content: '';
display: inline-block;
width: 8px;
height: 2px;
margin-right: 4px;
background-color: currentColor;
}
}
}
</style>
Loading

0 comments on commit 4d9988e

Please sign in to comment.