Quickly turn a Generative Adversarial Network model into a web application using Streamlit and deploy to Heroku. Previously I made a GAN model that colorizes black and white photos. It is working okay so I wish to share it with people. Coding in Jupyter notebook is very convenient for development but not that convenient for sharing, therefore I decide to make a web application and deploy it to Heroku.
Previously I made a GAN model that colorizes black and white photos. It is working okay so I wish to share it with people. Coding in Jupyter notebook is very convenient for development but not that convenient for sharing, therefore I decide to make a web application and deploy it to Heroku.
I did not have web development experience and skills so it took me some time to figure out how to do it. I found a useful tool Stremlit, which allows me to code in Python and quickly turn it into a web application.
There are several steps for me to make this app:
I trained the GAN model using fastai, so I simply export the model using
learner.export(export.pkl)
this exports the model as a pkl file.
The first thing for this app is to download the model. Because the size of the model is too big (>200MB), it is not convenient to push to Github or directly push to Heroku. Therefore I need the app to download the file from external url to make sure the model is ready.
I stored the model in my dropbox account and created a downloadable link.
EXTERNAL_DEPENDENCIES = {
"export_5.pkl": {
"url": "https://dl.dropboxusercontent.com/s/xxxxxxx/export_5.pkl?dl=0",
"size": 246698366}
}
Then I used the code from Streamlit’s demo (https://github.com/streamlit/streamlit) to create the download function with a progress bar
I can call the function and download the model
for filename in EXTERNAL_DEPENDENCIES.keys():
download_file(filename)
I want to have a tool that allows users to upload their B&W photos for analysis.
Streamlit provides a tool to make it: st.file_uploader
uploaded_file = st.file_uploader("upload a black&white photo", type=['jpg','png','jpeg'])
deep-learning artificial-intelligence programming machine-learning photography
Artificial Intelligence (AI) will and is currently taking over an important role in our lives — not necessarily through intelligent robots.
Enroll now at CETPA, the best Institute in India for Artificial Intelligence Online Training Course and Certification for students & working professionals & avail 50% instant discount.
Artificial Intelligence vs. Machine Learning vs. Deep Learning. We are going to discuss we difference between Artificial Intelligence, Machine Learning, and Deep Learning
Simple explanations of Artificial Intelligence, Machine Learning, and Deep Learning and how they’re all different
Learn the Difference between the most popular Buzzwords in today's tech. World — AI, Machine Learning and Deep Learning