GithubHelp home page GithubHelp logo

swanhubx / swanlab Goto Github PK

View Code? Open in Web Editor NEW
288.0 3.0 32.0 31.06 MB

⚡️SwanLab: your ML experiment notebook. 你的AI实验笔记本,跟踪与可视化你的机器学习全流程

Home Page: https://swanlab.cn

License: Apache License 2.0

Python 100.00%
data-science deep-learning jax machine-learning python pytorch tensorflow transformers mlops model-versioning

swanlab's Introduction

Overview

🔥SwanLab Cloud · 📃Document · WeChat · Report Issue · Feedback · Changelog

license license / pypi Download issues
Static Badge Static Badge

英文文档 中文文档
Table of contents

TOC


👋🏻 Introduction

SwanLab is an open-source, lightweight AI experiment tracking tool that provides a platform for tracking, comparing, and collaborating on experiments.

It offers a user-friendly API and a decent interface, combining features such as tracking hyperparameter, recording metric, online collaboration, and sharing experiment link.

Here is the English version of the core feature list for an AI platform:

1. 📊 Experimental Metrics and Tracking Hyperparameter: Embed your machine learning pipeline with minimalistic code and track key training metrics.

  • Flexible recording of hyperparameters and experiment configurations.
  • Supported metadata types: scalar metrics, images, audio, text, etc.
  • Supported chart types: line graphs, media charts (images, audio, text), etc.
  • Automatic logging: console logging, GPU hardware, Git information, Python interpreter, list of Python libraries, code directory.

2. ⚡️ Comprehensive Framework Integration: PyTorch、Tensorflow、PyTorch Lightning、🤗HuggingFace、Transformers、MMEngine、Ultralytics、fastai、Tensorboard、OpenAI、ZhipuAI、Hydra、...

3. 📦 Organizing Experiments: Centralized dashboard for efficiently managing multiple projects and experiments, providing an overview of training at a glance.

4. 🆚 Comparing Results: Use online tables and paired charts to compare the hyperparameters and outcomes of different experiments, developing iterative inspiration.

5. 👥 Online Collaboration: Collaborate with your team on training projects, supporting real-time synchronization of experiments under the same project, allowing you to synchronize training records of the team online and share insights and suggestions based on results.

6. ✉️ Sharing Results: Copy and send persistent URLs to share each experiment, efficiently send them to colleagues, or embed them in online notes.

7. 💻 Self-hosting Support: Supports offline mode with a self-hosted community version that also allows for dashboard viewing and experiment management.

Important

Star Us, You will receive all release notifications from GitHub without any delay ~ ⭐️

star-us


📃 Demo

Check out SwanLab's online demo:

ResNet50 Cats vs Dogs Yolov8-COCO128
Track the image classification task of training a simple ResNet50 model on the cats and dogs dataset. Perform object detection tasks using Yolov8 on the COCO128 dataset, tracking training hyperparameters and metrics.
Qwen2 Instruction Finetune LSTM Google Stock Prediction
Track the instruction fine-tuning training of the Qwen2 large language model, completing simple instruction following. Train a simple LSTM model on the Google stock price dataset to predict future stock prices.

More examples


🏁 Quick Start

1.Installation

pip install swanlab

2.Log in and get the API Key

  1. Free Sign Up

  2. Log in to your account, go to User Settings > API Key and copy your API Key.

  3. Open your terminal and enter:

swanlab login

When prompted, enter your API Key and press Enter to complete the login.

3. Integrate SwanLab with Your Code

import swanlab

# Create a new SwanLab experiment
swanlab.init(
    project="my-first-ml",
    config={'learning-rate': 0.003}
)

# Log metrics
for i in range(10):
    swanlab.log({"loss": i})

All set! Visit SwanLab to see your first SwanLab experiment.

MNIST


💻 Self-hosted

The community edition supports offline viewing of SwanLab dashboards.

Offline Experiment Tracking

Set the parameters logir and mode in swanlab.init to track experiments offline:

...

swanlab.init(
    logdir='./logs',
    mode='local',
)

...
  • The parameter mode is set to local, which disables synchronizing the experiment to the cloud.

  • The setting of the parameter logdir is optional, and it specifies the location for saving SwanLab log files (by default saved in the swanlog folder).

  • Log files will be created and updated during tracking of experiments, and launching offline dashboards will also be based on these log files.

Other parts are completely consistent with cloud usage.

Open Offline Board

Open the terminal and use the following command to open a SwanLab dashboard:

swanlab watch ./logs

After the operation is completed, SwanLab will provide you with a local URL link (default is http://127.0.0.1:5092).

Visit this link to view the experiment offline in the browser dashboard.


🚗 Integration

Combine your favorite framework with SwanLab, More Integration.

⚡️ PyTorch Lightning

Create an instance using SwanLabLogger and pass it into the logger parameter of Trainer to enable SwanLab to record training metrics.

from swanlab.integration.pytorch_lightning import SwanLabLogger
import importlib.util
import os
import pytorch_lightning as pl
from torch import nn, optim, utils
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor

encoder = nn.Sequential(nn.Linear(28 * 28, 128), nn.ReLU(), nn.Linear(128, 3))
decoder = nn.Sequential(nn.Linear(3, 128), nn.ReLU(), nn.Linear(128, 28 * 28))


class LitAutoEncoder(pl.LightningModule):
    def __init__(self, encoder, decoder):
        super().__init__()
        self.encoder = encoder
        self.decoder = decoder

    def training_step(self, batch, batch_idx):
        # training_step defines the train loop.
        # it is independent of forward
        x, y = batch
        x = x.view(x.size(0), -1)
        z = self.encoder(x)
        x_hat = self.decoder(z)
        loss = nn.functional.mse_loss(x_hat, x)
        # Logging to TensorBoard (if installed) by default
        self.log("train_loss", loss)
        return loss

    def test_step(self, batch, batch_idx):
        # test_step defines the test loop.
        # it is independent of forward
        x, y = batch
        x = x.view(x.size(0), -1)
        z = self.encoder(x)
        x_hat = self.decoder(z)
        loss = nn.functional.mse_loss(x_hat, x)
        # Logging to TensorBoard (if installed) by default
        self.log("test_loss", loss)
        return loss

    def configure_optimizers(self):
        optimizer = optim.Adam(self.parameters(), lr=1e-3)
        return optimizer


# init the autoencoder
autoencoder = LitAutoEncoder(encoder, decoder)

# setup data
dataset = MNIST(os.getcwd(), train=True, download=True, transform=ToTensor())
train_dataset, val_dataset = utils.data.random_split(dataset, [55000, 5000])
test_dataset = MNIST(os.getcwd(), train=False, download=True, transform=ToTensor())

train_loader = utils.data.DataLoader(train_dataset)
val_loader = utils.data.DataLoader(val_dataset)
test_loader = utils.data.DataLoader(test_dataset)

swanlab_logger = SwanLabLogger(
    project="swanlab_example",
    experiment_name="example_experiment",
    cloud=False,
)

trainer = pl.Trainer(limit_train_batches=100, max_epochs=5, logger=swanlab_logger)

trainer.fit(model=autoencoder, train_dataloaders=train_loader, val_dataloaders=val_loader)
trainer.test(dataloaders=test_loader)
🤗HuggingFace Transformers

Create an instance using SwanLabCallback and pass it into the callbacks parameter of Trainer to enable SwanLab to record training metrics.

import evaluate
import numpy as np
import swanlab
from swanlab.integration.huggingface import SwanLabCallback
from datasets import load_dataset
from transformers import AutoModelForSequenceClassification, AutoTokenizer, Trainer, TrainingArguments


def tokenize_function(examples):
    return tokenizer(examples["text"], padding="max_length", truncation=True)


def compute_metrics(eval_pred):
    logits, labels = eval_pred
    predictions = np.argmax(logits, axis=-1)
    return metric.compute(predictions=predictions, references=labels)


dataset = load_dataset("yelp_review_full")

tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")

tokenized_datasets = dataset.map(tokenize_function, batched=True)

small_train_dataset = tokenized_datasets["train"].shuffle(seed=42).select(range(1000))
small_eval_dataset = tokenized_datasets["test"].shuffle(seed=42).select(range(1000))

metric = evaluate.load("accuracy")

model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased", num_labels=5)

training_args = TrainingArguments(
    output_dir="test_trainer",
    report_to="none",
    num_train_epochs=3,
    logging_steps=50,
)

swanlab_callback = SwanLabCallback(experiment_name="TransformersTest", cloud=False)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=small_train_dataset,
    eval_dataset=small_eval_dataset,
    compute_metrics=compute_metrics,
    callbacks=[swanlab_callback],
)

trainer.train()
MMEngine(MMDetection etc.)

Integrate SwanlabVisBackend into MMEngine to enable automatic logging of training metrics by SwanLab.

Add the following code snippet to your MM config file to start training:

custom_imports = dict(imports=["swanlab.integration.mmengine"], allow_failed_imports=False)

vis_backends = [
    dict(
        type="SwanlabVisBackend",
        save_dir="runs/swanlab",
        init_kwargs={
            "project": "swanlab-mmengine",
        },
    ),
]

visualizer = dict(
    type="Visualizer",
    vis_backends=vis_backends,
)
Ultralytics

Integrating SwanLab into Ultralytics is very simple; you can use the add_swanlab_callback function:

from ultralytics import YOLO
from swanlab.integration.ultralytics import add_swanlab_callback

model = YOLO("yolov8n.yaml")
model.load()

add_swanlab_callback(model)

model.train(
    data="./coco.yaml",
    epochs=50,
    imgsz=320,
)

🆚 Comparison with familiar tools

Tensorboard vs SwanLab

  • ☁️ Online Usage Support: With SwanLab, training experiments can be conveniently synchronized and saved in the cloud, allowing for remote monitoring of training progress, managing historical projects, sharing experiment links, sending real-time notification messages, and viewing experiments across multiple devices. In contrast, TensorBoard is an offline experiment tracking tool.

  • 👥 Collaborative Multi-user Environment: SwanLab facilitates easy management of multi-person training projects and sharing of experiment links for collaborative machine learning across teams. It also enables cross-space communication and discussion. On the other hand, TensorBoard is primarily designed for individual use, making it difficult to collaborate and share experiments with multiple users.

  • 💻 Persistent, Centralized Dashboard: Regardless of where you are training your models, be it on a local computer, a lab cluster, or on public cloud GPU instances, your results are logged to the same centralized dashboard. Using TensorBoard, on the other hand, requires spending time copying and managing TFEvent files from different machines.

  • 💪 More Powerful Tables: SwanLab tables allow you to view, search, and filter results from various experiments, making it easy to review thousands of model versions to find the best-performing models for different tasks. TensorBoard is not well-suited for large-scale projects.

Weights and Biases vs SwanLab

  • Weights and Biases is an online-only, proprietary MLOps platform.

  • Not only does SwanLab support online usage, but it also offers an open-source, free, and self-hosted version.


👥 Community

Community and support

  • GitHub Issues:Errors and issues encountered when using SwanLab
  • Email support:Feedback on issues with using SwanLab
  • WeChat:Discuss issues using SwanLab, share the latest AI technology.

SwanLab README Badge

If you like to use SwanLab in your work, please add the SwanLab badge to your README:

swanlab

[![swanlab](https://img.shields.io/badge/powered%20by-SwanLab-438440)](https://github.com/swanhubx/swanlab)

Citing SwanLab in the paper

If you find SwanLab helpful for your research journey, please consider citing in the following format:

@software{Zeyilin_SwanLab_2023,
  author = {Zeyi Lin, Shaohong Chen, Kang Li, Qiushan Jiang, Zirui Cai,  Kaifang Ji and {The SwanLab team}},
  doi = {10.5281/zenodo.11100550},
  license = {Apache-2.0},
  title = {{SwanLab}},
  url = {https://github.com/swanhubx/swanlab},
  year = {2023}
}

Contribute to SwanLab

Considering contributing to SwanLab? First, please take some time to read the Contribution Guidelines.

At the same time, we warmly welcome support for SwanLab through social media, events, and conference sharing. Thank you!


Contributors

Download Icon

SwanLab-Icon-SVG


📃 License

This repository follows the Apache 2.0 License open source license.

swanlab's People

Contributors

clairdelunejs avatar feudalman avatar indevn avatar kashiwabyte avatar little1d avatar nexisato avatar pescn avatar puiching-memory avatar sakura-cat avatar shaohonchen avatar sweetdog123 avatar swpfy avatar zeyi-lin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swanlab's Issues

🤩 [FEATURE] 前端日志显示

🤩 Features description [Please make everyone to understand it]

在v0.1.0版本中,我们将允许在前端查看后台日志显示
日志显示将只捕获用户通过print打印的日志以及swanlab本身产生的日志

👍 What problem does this feature solve

日志可视化,可查看当前运行状态

🚑 Any additional [like screenshots]

image

🤩 [FEATURE] PR模板

🤩 Features description [Please make everyone to understand it]

我们将通过PR模板完成PR的准则制定

👍 What problem does this feature solve

完成PR的准则制定

🐛 [BUG] When the training is finished, the status of Chart is not updated to `Finish`

🐛 Bug description [Please make everyone to understand it]

When the training is finished, the status of the Chart page will not become "Finish", and the final chart does not appear.

Test Code:

import swanlab
import time

swanlab.init()

for i in range(10):
    swanlab.log({'loss': i})
    time.sleep(1)

# the final chart
swanlab.log({'acc': 0.99})

训练完成时的状态:

image

👾 Expected result

  • status -> Finish
  • the final chart appear.

🚑 Any additional [like screenshots]

  • SwanLab Version:v0.1.1

🐛 [BUG] windows下,广播ip给的地址不准确

🐛 Bug description [Please make everyone to understand it]

在windows下设置host为0.0.0.0,显示的地址有一些是错误的

🧑‍💻 Step to reproduce

运行swanlab watch -h 0.0.0.0即可复现错误

👾 Expected result

应该只保留一些可用的ip地址

🚑 Any additional [like screenshots]

  • SwanLab Version: 0.0.2

  • Platform: windows

image

[FEATURE] More elegant modified project/experimental information

🤩 Features description [Please make everyone to understand it]

  • Experiment name check: word count, format
  • Experimental information check: word count
  • Optimization for tips
  • Back-end verification

👍 What problem does this feature solve

More elegant modified project/experimental information

🚑 Any additional [like screenshots]

🤩 [FEATURE] 自动化SwanLab包的构建

🤩 Features description [Please make everyone to understand it]

我们需要将python包的构建、发布到pypi和github action结合,以完成更好的自动化流程

👍 What problem does this feature solve

自动化分发python包,减少重复劳动

🚑 Any additional [like screenshots]

相关细节还需做调研,后续会记录文档

暂时可以不用设置静态资源路由

image

目前,这里的 ASSETS 指的是,前端 vue 项目打包之后生成目录中,用于存放打包后的 css js 文件的目录

这个目录下的东西是加在页面时候需要的资源文件,而不是应该直接访问的静态资源,所以不应该将该目录绑定为静态资源

这个目录已经配置了单独的路由处理(其中可能需要根据资源类别加载不同的响应头)

[BUG] Internal server error: Failed to resolve import "tippy.js/dist/tippy.css" from "vue/src/main.js". Does the file exist?

🐛 Bug description [Please make everyone to understand it]

Error: The following dependencies are imported but could not be resolved:

  tippy.js/dist/tippy.css (imported by /Users/jqs/Desktop/Projects/BlackSwanXDU/SwanLab/vue/src/main.js)

Are they installed?
    at file:///Users/jqs/Desktop/Projects/BlackSwanXDU/SwanLab/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:65148:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/jqs/Desktop/Projects/BlackSwanXDU/SwanLab/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:64548:38
15:50:36 [vite] Pre-transform error: Failed to resolve import "tippy.js/dist/tippy.css" from "vue/src/main.js". Does the file exist?
15:50:37 [vite] Internal server error: Failed to resolve import "tippy.js/dist/tippy.css" from "vue/src/main.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/jqs/Desktop/Projects/BlackSwanXDU/SwanLab/vue/src/main.js:21:9
  19 |  // v-tippy
  20 |  import { directive } from 'vue-tippy'
  21 |  import 'tippy.js/dist/tippy.css'
     |          ^
  22 |  
  23 |  app.directive('tippy', directive)

🧑‍💻 Step to reproduce

pnpm install

👾 Expected result

pnpm is the best!

🚑 Any additional [like screenshots]

  • SwanLab Version:

  • Platform:

🐛 [BUG] When the port is occupied, `swanlab watch` does not prompt an error.

🐛 Bug description [Please make everyone to understand it]

When the port of swanlab watch is occupied, the process is terminated directly without displaying any error message.

image

🧑‍💻 Step to reproduce

Open swanlab watch on two terminals.

👾 Expected result

When detected occupation, give the user a prompt message.

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.1

  • Platform: MacOS M1Max

🐛 [BUG] windows下无法启动命令

🐛 Bug description [Please make everyone to understand it]

无法在windows操作系统下运行swanlab watch命令,报错Value Error:SO_REUSE PORT not supported on this platform

🧑‍💻 Step to reproduce

直接运行swanlab watch,就能出现此问题

👾 Expected result

Write down the results you expect

🚑 Any additional [like screenshots]

  • SwanLab Version: 0.0.2

  • Platform: windows11

img_v3_0268_06b700ac-4675-4499-8d3c-37051c98bfcg

🐛 [BUG] fsspec uninstall error when install swanlab using pip on pytorch env

🐛 Bug description

In a conda environment that includes PyTorch, I encountered the following error when attempting to install swanlab using pip: "torch 2.1.2 requires fsspec, which is not installed." It's worth noting that this error isn't caused by the installation of PyTorch itself. I tried installing other packages like tqdm after installing PyTorch, and there were no errors. However, this specific error only occurred after I attempted to install swanlab.

Screenshot 2023-12-23 at 17 06 52

🧑‍💻 Step to reproduce

First, create a new Conda environment in Ubuntu 22.04, specifying Python version 3.11, and install PyTorch version 2.1.2 following the official PyTorch installation tutorial.

Next, install tqdm(for test) using command: pip install tqdm. It appears that the installation was successful, and there were no error messages.

Screenshot 2023-12-23 at 17 18 59

Finally, when using the pip install swanlab command to install swanlab, an error message appeared stating "torch 2.1.2 requires fsspec, which is not installed." Additionally, the log indicated that the version of typing_extensions had been changed at some point.

The error can be fix by using the command "pip install fsspec."

🤔️Analysis

I checked the logs, and it seems that the issue may be related to the version of typing_extensions. After installing torch 2.1.2, the environment will contain typing_extensions version 4.7.1, which appears to be a dependency of torch 2.1.2. However, when installing swanlab, typing_extensions is replaced with version 4.9.0. This could potentially be the cause of the problem.

Furthermore, when I use the "pip install typing_extensions==4.7.1" command to forcefully install version 4.7.1 of typing_extensions, an error message tells me that fastapi version 0.105.0 requires typing_extensions version 4.8.0 or higher, and fastapi is a package that swanlab depends on.

Screenshot 2023-12-23 at 17 24 43

有关server部分优化的提议

  1. 引入SQLite数据库和ORM。由于涉及到项目信息的“增删查改”,将基础配置信息写入数据库然后操作会更方便一些,操作JSON文件比较麻烦而且没有关系映射。ORM库例如:PeeweeSQLAlchemyPrisma(python版本不成熟,不推荐使用)
  2. 将路由集中,将 Handler 分散。目前是将路由和 Handler 部分写在一起的,由于Handler部分的代码过多,会对排查造成影响。

[BUG] 记录的console中,logging内容与实际终端显示内容不符

Bug 描述

出现此问题的原因在于,SwanConsole通过重定向 sys.stdout 来进行日志输出的记录,而 logging 模块通常会使用 sys.stdout、sys.stderr 或者其他句柄(handler)来进行输出。
SwanConsole实例作为SwanLog初始化后的属性,在SwanLog进行数据打印到控制台的时候调用了SwanConsole实例的add方法来添加记录日志,但是我们没有考虑日志等级的问题

Some necessary features?

  1. multi nodes and multi gpus examples
  2. system information log(GPU/CPU memory,utilization, temperature, Disk io/utilization and so on
  3. different devices log synchronize?
  4. support yaml(hydra,omegaconf)/json config

🤔 [QUESTION] Table Components Optimization

🤔 Question description

There are some optimizations can be made for the table component SLTable.vue

Part 1

These are something about the code implementation methods.

  1. Tabe cell's width resizating
  2. Our custom colors definition
  3. Size calculation in JavaScript —— mouse events while dragging resizing line

Part 2

These are something more difficult and require some effort

  1. Dynamically load table content
  2. Organizational format of table data
  3. Api that we can use

🧑‍💻 Expected result

  1. More elegant code
  2. A smoother experience

🚑 Any additional

  • SwanLab Version: v0.1.1

[BUG] table resize

🐛 Bug description

Resetting the cell width of a table within its range will compress other cells

前端tag信息读取问题

现在的tag信息请求被封装在了Plotly组件中,当后面增加了多tag放在同一个表里的时候,可能会造成信息的多次重复读取(以及数据的不同步)的问题
这块需要优化

🐛 [BUG] Chart update issue:update rate decrease

🐛 Bug description [Please make everyone to understand it]

Compared to v0.1.0, the data update rate of thein Progress chart in v0.1.1 seems to have decreased significantly:

  • v0.1.0: Updated once every 1s
  • v0.1.1: Updated once every 3s

👾 Expected result

Updated once every 1s

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.1

  • Platform: macOS-14.1.2-arm64-arm-64bit

🐛 [BUG] When the value passed into `swanlab.log` is a string instead of an int/float type, the chart displays abnormal.

🐛 Bug description [Please make everyone to understand it]

This Issue was discovered by @NoFish-528
When executing the following code (complete code from...this):

  log_info = {
      "Average loss": "{:.4f}".format(test_loss), 
      "Accuracy": "{}/{} ({:.0f}%".format(correct, len(test_loader.dataset),100. * correct / len(test_loader.dataset))
      }
  print(log_info)
  swanlab.log(log_info)

Value is a string rather than a numerical value, resulting in the display of the chart becoming like this:

image

👾 Expected result

Need to perform type checking and conversion on the value of Value.

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.0

  • Platform: macOS-14.1.2-arm64-arm-64bit

🤩 [FEATURE] FONT类型封装

🤩 Features description [Please make everyone to understand it]

开发时会用到各种命令行高亮展示,这时会遇到一些编码格式
我们期望封装一个类,这个类支持各种字符串加工,将各种命令行样式添加到类中

👍 What problem does this feature solve

提高代码利用率

👾 What does the proposed API look like

类似如下样子:

class FONT:
    @staticmethod
    def bold(s: str) -> str:
        """在终端中加粗字符串

        Parameters
        ----------
        s : str
            需要加粗的字符串

        Returns
        -------
        str
            加粗后的字符串
        """
        # ANSI 转义码用于在终端中改变文本样式
        return f"\033[1m{s}\033[0m"

    @staticmethod
    def green(s: str) -> str:
        """在终端中将字符串着色为绿色

        Parameters
        ----------
        s : str
            需要着色的字符串

        Returns
        -------
        str
            着色后的字符串
        """
        # ANSI 转义码用于在终端中改变文本样式
        return f"\033[32m{s}\033[0m"

🚑 Any additional [like screenshots]

SwanLog类也需要使用这个类进行打印展示

[QUESTION] 前端日志渲染优化

🤔 Question description [Please make everyone to understand it]

目前前端是一下获取最多 max (默认6k)条数据,然后统一渲染。
可以优化一下,改成动态渲染,使用 render 函数对展示窗口的滚动监听再更新内容

🐛 [BUG] An error occurred when using the notation "train/loss" in `swan.log`

🐛 Bug description [Please make everyone to understand it]

When the key with "/" is passed into swan.log, an error will occur, such as:

swanlab.log({"train/loss": loss.item()})

My running path is /Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs
Error:

Error in sys.excepthook:
Traceback (most recent call last):
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/__init__.py", line 40, in except_handler
    raise tp(val)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/swanlog/vibrant-hemlock-7/logs/train/loss'

Original exception was:
Traceback (most recent call last):
  File "/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/load_datasets.py", line 102, in <module>
    swanlab.log({"train/loss": loss.item()})
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/__init__.py", line 105, in log
    sd.add(key, data[key])
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/main.py", line 105, in add
    self.__project.experiment.add(tag, data)
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/expriment.py", line 105, in add
    self.save_tag(tag, data, self.experiment_id, tag_index, step=step)
  File "/Users/zeyilin/miniforge3/envs/test_py310/lib/python3.10/site-packages/swanlab/database/table.py", line 163, in save_tag
    os.mkdir(save_folder)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/zeyilin/Desktop/Coding/examples/examples/resnet50-cats_vs_dogs/swanlog/vibrant-hemlock-7/logs/train/loss'

👾 Expected result

I hope to support this writing style, and the title in the chart is “train/loss”

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.0

  • Platform: macOS-14.1.2-arm64-arm-64bit

🤩 [FEATURE] New Table Component

🤩 Features description [Please make everyone to understand it]

New table component to complete more complex logic

👍 What problem does this feature solve

Provide SwanLab with a richer display of information

🐛 [BUG] When the experiment Finish, the status of `OverView/Experiment List` remains unchanged.

🐛 Bug description [Please make everyone to understand it]

When a experiment is completed, the status of the experiment in the Experiment List in Project OverView does not change until the Browser is refreshed, and then it will be normal.

image

👾 Expected result

Maybe refresh automatically when entering the Oview page?

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.1

  • Platform: macOS-14.1.2-arm64-arm-64bit

🐛 [BUG] `Logs` unrecorded full error

🐛 Bug description [Please make everyone to understand it]

When I get a "file not found" error, compare the IDE and logs;
the logs are missing some info:

image

image

🚑 Any additional [like screenshots]

  • SwanLab Version: v0.1.1

  • Platform: MacOS M1Max

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.