Displaying Keras model.summary() table in Streamlit app

Dear Streamlit,
How do I display keras’ model.summary() on Streamlit app?
The table currently displays on the terminal.
Is there another way around it, like generating a report instead of table?

1 Like

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

@snehankekre ,
Thank you very much it worked fantastically.
I must commend the Streamlit crew. You guys are doing a fantastic job. I can’t wait to enjoy the benefits of your recent merger with Snowflake. God bless you guys. With Streamlit I can build or automate anything.
Thank you so much

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.