-
-
Save 79212/6834093cef56115084c31f70da98f36b to your computer and use it in GitHub Desktop.
Gist for showcasing how to add Streamlit function calls to the existing python code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import streamlit as st | |
| # regular imports for the model | |
| st.write('# Sketch to Color Image Generation using Conditional GANs') | |
| # to store the model creation to cache | |
| @st.cache() | |
| def load_model(): | |
| # load the generator model | |
| return generator | |
| # blank placeholder for inserting image | |
| my_placeholder = st.empty() | |
| # add 2 buttons in sidebar | |
| show_original_image = st.sidebar.button('Show Original Image') | |
| generate_color_image = st.sidebar.button('Generate Color Image') | |
| def load_image(): | |
| # load image and preprocess it | |
| my_placeholder.pyplot(width=200, height=200) | |
| return input_img | |
| if show_original_image: # if button is pressed | |
| load_image() | |
| if generate_color_image: # if button is pressed | |
| with st.spinner('Generating Color Image...'): # loader widget | |
| # make predictions and load colored image | |
| my_placeholder.pyplot() | |
| st.success('Color Image Generated Successfully!') # success widget | |
| st.balloons() # just for fun, shows balloon animations on the page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment