question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add TensorBoard server to Flask endpoint

See original GitHub issue

I have a Flask App and a Tensorboad server. Is there a way by which I can map the Tensorboard server to one of the endpoints of Flask so that as soon as I hit that endpoint it triggers the Tensorboard server?

Flask application

from flask import Flask, jsonify, request
app = Flask(__name__)

@app.route('/hello-world', methods=['GET', 'POST'])
def say_hello():
    return jsonify({'result': 'Hello world'})

if __name__ == "__main__":
    app.run(host=host, port=5000)

Tensorboard server code:

from tensorboard.program import TensorBoard, setup_environment
def tensorboard_main(host, port, logdir):
    configuration = list([""])
    configuration.extend(["--host", host])
    configuration.extend(["--port", port])
    configuration.extend(["--logdir", logdir])

    tensorboard = TensorBoard()
    tensorboard.configure(configuration)
    tensorboard.main()

if __name__ == "__main__":
    host = "0.0.0.0"
    port = "7070"
    logdir = '/tmp/logdir'
    tensorboard_main(host, port, logdir)

I tried creating an endpoint in Flask app and then added tensorboard_main(host, port, logdir) in the hope that if I hit the endpoint then the server will start but I got no luck.

I had posted this issue on StackOverflow but didn’t get a valid reply hence posting it here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wchargincommented, Jun 5, 2020

Could you post the full code that you’re using? The code that I posted works for me with TensorBoard 2.2.2 and Flask 1.1.2:

Screenshot of working TensorBoard-in-WSGI

0reactions
eddieparkercommented, Feb 15, 2022

I also appreciate this starter code, it’s fantastic for what I need. Is there any way to get this to work with flask’s reloader? I tried adding ‘use_reloader=True’ to the run_simple but then it complains about signal handlers being installed outside the main thread. I can’t find anything that indicates that tensorboard has similar reload facilities on file change detection?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Tensorboard server to Flask endpoint - Stack Overflow
I found out that to integrate a TensorBoard server into a larger Flask app, the best way would be to compose the applications...
Read more >
Developers - Add TensorBoard server to Flask endpoint -
I have a Flask App and a Tensorboad server. Is there a way by which I can map the Tensorboard server to one...
Read more >
Deploying Keras models using TensorFlow Serving and Flask
Learn how to use Keras to download InceptionV3 image classifier CNN and deploy it using TensorFlow Serving. Manage multiple servers, their ...
Read more >
Using TensorFlow with Flask and React | by Tarric Sookdeo
TensorFlow is a popular machine learning framework maintained by the Google Brain Team. TensorFlow gives you access to high-level functions to train, analyze, ......
Read more >
Deploy ML tensorflow model using Flask(backend+frontend)
a. Create an html file named predict. · hasan-haider/Deploy-ML-tensorflow-model-using-Flask · b. Add route function for predict page · c. Modify ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found