Skip to content

Commit

Permalink
'prepare for release v2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lanpa committed Jul 5, 2020
1 parent 6cffc95 commit 5d5b5fc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,36 @@

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`

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
Expand Down
19 changes: 13 additions & 6 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tensorboardX/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5d5b5fc

Please sign in to comment.