diff --git a/HISTORY.rst b/HISTORY.rst index 3be87853..efc1d3d0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,5 +1,13 @@ History ======= +2.1 (2020-07-05) +----------------- +* Global SummaryWriter that mimics python's default logger class, concurrent write is supported. +* 200x speed up for add_audio. Please install the soundfile package for this feature. +* Supports jax tensors. +* The add_graph function is delegated to the one in torch.utils.tensorboard. +* Bug fixes, see the commit log in Github. + 2.0 (2019-12-31) ----------------- * Now you can tag Hparams trials with custom name instead of the default epoch time diff --git a/README.md b/README.md index d5ceec9d..81c01362 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,15 @@ Write TensorBoard events with simple function call. +The current release (v2.1) is tested on anaconda3, with PyTorch 1.5.1 / torchvision 0.6.1 / tensorboard 2.2.2. + * Support `scalar`, `image`, `figure`, `histogram`, `audio`, `text`, `graph`, `onnx_graph`, `embedding`, `pr_curve`, `mesh`, `hyper-parameters` and `video` summaries. -* requirement for `demo_graph.py` is tensorboardX>=1.9 and pytorch>=1.3 - * [FAQ](https://github.com/lanpa/tensorboardX/wiki) -## Install -Tested on anaconda2 / anaconda3, with PyTorch 1.3.1 / torchvision 0.4.1 / tensorboard 2.0.0 +## Install `pip install tensorboardX` @@ -25,15 +24,20 @@ or build from source: `pip install 'git+https://github.com/lanpa/tensorboardX'` +You can optionally install [`crc32c`](https://github.com/ICRAR/crc32c) to speed up. + +`pip install crc32c` -You can optionally install [`crc32c`](https://github.com/ICRAR/crc32c) to speed up saving a large amount of data. +Starting from tensorboardX 2.1, You need to install `soundfile` for the `add_audio()` function (200x speedup). +`pip install soundfile` ## Example * Clone the files in https://github.com/lanpa/tensorboardX/tree/master/examples * Run the demo script: e.g. `python examples/demo.py` -* Use TensorBoard with `tensorboard --logdir runs` (needs to install TensorFlow) +* Start TensorBoard with `tensorboard --logdir runs` + ```python # demo.py diff --git a/examples/demo.py b/examples/demo.py index b0ebc1bf..ff589d06 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -6,6 +6,12 @@ from tensorboardX import SummaryWriter import datetime +try: + import soundfile + skip_audio = False +except ImportError: + skip_audio = True + resnet18 = models.resnet18(False) writer = SummaryWriter() sample_rate = 44100 @@ -37,12 +43,13 @@ torch.Tensor([[10, 10, 100, 100], [101, 101, 200, 200]]), n_iter, labels=['abcde' + str(n_iter), 'fgh' + str(n_iter)]) - x = torch.zeros(sample_rate * 2) - for i in range(x.size(0)): - # sound amplitude should in [-1, 1] - x[i] = np.cos(freqs[n_iter // 10] * np.pi * - float(i) / float(sample_rate)) - writer.add_audio('myAudio', x, n_iter) + if not skip_audio: + x = torch.zeros(sample_rate * 2) + for i in range(x.size(0)): + # sound amplitude should in [-1, 1] + x[i] = np.cos(freqs[n_iter // 10] * np.pi * + float(i) / float(sample_rate)) + writer.add_audio('myAudio', x, n_iter) writer.add_text('Text', 'text logged at step:' + str(n_iter), n_iter) writer.add_text('markdown Text', '''a|b\n-|-\nc|d''', n_iter) for name, param in resnet18.named_parameters(): diff --git a/setup.py b/setup.py index 190fadaf..77781a34 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ import subprocess import os +import sys from setuptools import setup, find_packages from setuptools.command.develop import develop from setuptools.command.install import install @@ -30,16 +31,16 @@ def run(self): with open('HISTORY.rst') as history_file: history = history_file.read() -preparing_PyPI_package = False -version_git = version = '2.0' +preparing_PyPI_package = 'sdist' in sys.argv or 'bdist_wheel' in sys.argv +version_git = version = '2.1' if not preparing_PyPI_package: if os.path.exists('.git'): sha = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() version_git = version_git + '+' + sha[:7] - with open('tensorboardX/__init__.py', 'a') as f: - f.write('\n__version__ = "{}"\n'.format(version_git)) +with open('tensorboardX/__init__.py', 'a') as f: + f.write('\n__version__ = "{}"\n'.format(version_git)) requirements = [ 'numpy', @@ -88,10 +89,9 @@ def run(self): # checklist: update History.rst readme.md -# change preparing_PyPI_package to True, and update version_git to new version -# remove __version__ = "1.old" in __init__.py, update the version number +# update the version number in this file. # python setup.py sdist bdist_wheel --universal -# check the generated tar.gz file +# check the generated tar.gz file (the version, no *.pyc) # git add [files] # git commit -m 'prepare for release' # add tag diff --git a/tensorboardX/__init__.py b/tensorboardX/__init__.py index 40867323..18025721 100644 --- a/tensorboardX/__init__.py +++ b/tensorboardX/__init__.py @@ -5,4 +5,7 @@ from .torchvis import TorchVis from .writer import FileWriter, SummaryWriter from .global_writer import GlobalSummaryWriter -__version__ = "2.0" # will be overwritten if run setup.py +__version__ = "dev" +# will be overwritten if run setup.py +# specifically, `python setup.py install` creates [version in setup.py + git SHA hash] +# python setup.py sdist creates a decimal version number \ No newline at end of file