Code Monkey home page Code Monkey logo

streamlit-tensorboard's Introduction

streamlit-tensorboard

Streamlit App

This is a work-in-progress, providing a function to embed TensorBoard, TensorFlow's visualization toolkit, in Streamlit apps.

Installation ๐ŸŽˆ

pip install --upgrade streamlit-tensorboard

Example Usage ๐Ÿ’ป

import streamlit as st
from streamlit_tensorboard import st_tensorboard
import tensorflow as tf

import datetime
import random

mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

def create_model():
    return tf.keras.models.Sequential(
        [
            tf.keras.layers.Flatten(input_shape=(28, 28)),
            tf.keras.layers.Dense(512, activation="relu"),
            tf.keras.layers.Dropout(0.2),
            tf.keras.layers.Dense(10, activation="softmax"),
        ]
    )

model = create_model()
model.compile(
    optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"]
)

logdir = "logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=logdir, histogram_freq=1)

model.fit(
    x=x_train,
    y=y_train,
    epochs=5,
    validation_data=(x_test, y_test),
    callbacks=[tensorboard_callback],
)

# Start TensorBoard
st_tensorboard(logdir=logdir, port=6006, width=1080)

st_tensorboard

Contributing ๐Ÿ› ๏ธ

Please file a new GitHub issue (if one doesn't already exist) for bugs, feature requests, suggestions for improvements, etc. If you have solutions to any open issues, feel free to open a Pull Request!

Supported Platforms

  1. Ubuntu
  2. Debian GNU/Linux
  3. macOS (โš ๏ธ unverified)

This component will not work on Streamlit Cloud. Due to security reasons, Streamlit Cloud does not allow users expose ports (as required by streamlit-tensorboard).

streamlit-tensorboard's People

Contributors

ansonnn07 avatar snehankekre 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

Watchers

 avatar  avatar  avatar  avatar

streamlit-tensorboard's Issues

Reuse TensorBoard on port {port} (pid {pid}) if opened previously

Each widget interaction with Streamlitt causes the script to rerun from top to bottom. This execution model leads to the creation of a new TensorBoard server for every interaction and new connection to the Streamlit app.

Desired behavior:

  1. If a TensorBoard server is running, connect to it instead of opening a new one.
  2. Reuse cached connection for viewers of the app. Do not open a new TensorBoard for each viewer.

Works on MacOS

I read in the readme that Streamlit-tensorboard is unverified on macOS.
Upon trying, I noticed a delay in the TensorBoard loading. Opening the port 6006 on another tab, helped solve this issue of the delay.

Create a simple example app

Create a simple example app that demonstrates how to use streamlit-tensorboard. Host on Streamlit sharing.

Support several comma-separated paths in logdir

Hi @snehankekre
Many thanks for the contribution. Just wondering whether it would be possible to support passing to the logdir argument of st_tensorboard a list of comma-separated paths to render several specific experiments, e.g. in the original tensorboard call you can specify it as follows:

tensorboard --logdir=name1:/path/to/logs/1,name2:/path/to/logs/2

Regards

Add a --host argument

Add a --host <host> argument. It currently starts a TensorBoard server on localhost. Allow for user-defined hosts.

Refuses to connect on Streamlit sharing

image

The issue has to do with network permissions on the remote host. Port 6006 should be opened on the remote host and incoming/outgoing connections should be allowed at remote host:6006.

Suggestion: Seperate the tensorboard viewer from the process spawn

It would be nice to separate the tensorboard viewer and the process spawning, as some workflows prefer handling the spawning of the tensorboard process. It also makes it easier to implement logic for having seperate viewer address & tensorboard host binding address

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.