Displaying Keras model.summary() table in Streamlit app

Hi @Dominion_Gate, welcome to the community!! :wave: :partying_face:

If you take a look at the docstring of model.summary(), you’ll see that it has a print_fn argument that defaults to Python’s print statement. It takes each line of the output and passes it to print, which in turn pipes the output to stdout.

You can instead direct it to st.text like so:

model.summary(print_fn=lambda x: st.text(x))

Happy Streamlit-ing! :balloon:
Snehan

2 Likes