Welcome to this tutorial! We will learn how we can create a live streaming audio & video app, where we will plug our super deep learning models with a few lines of codes! 🔥
We are going to use Streamlit, and more specifically the amazing streamlit-webrtc component to do so.
We will create a new project directory for the code of our website.
This directory will be located inside of our projects directory: ~/code/<user.github_nickname>
.
We will first clone this repository. It can take some times (you are loading a 200 MB tensorflow model).
cd ~/code/<user.github_nickname>
gh repo clone Yanka13/live-streaming-app
cd live-streaming-app
Let's now install all the dependencies needed to run our app locally. Thenn we will launch example.py and streamlit_app.py to discover how it works.
pip install -r requirements.txt
streamlit run example.py
Easy he ? streamlit web-rtc did all the magic for us.
Now let's try with the full app and play with it (try to do some language signs on the webcam!)
streamlit run streamlit_app.py
When you are done looking at the code (you can have a look at this article if you wish to dig more and understand what's going on under the hood), you are now ready to push the app into production, we will do it directly on streamlit new cloud platform Streamlit Cloud is a new feature from streamlit that allows you to push any streamlit app very smoothly. You can have application up to 1GB of hard memory.
First, let's create a remote repository on your GitHub account (repo need to be public to use free streamlit cloud services):
git init
git remote remove origin
gh repo create
Install the very handy git-lfs tool, which will help us push for free heavy file > 100 mb to github remote servers (free until 1GB of storage per month)! To do that, follow the instruction here to install the package. Then type the command below to push to our heavy deep learning model located in the saved_models folder to our remote repository
git lfs install
git lfs track "*.h5"
git add models/model.h5
Add now every other files we need, commit and push!
git add .
git commit --m "App V0"
git push origin master
Now it's time to push our app into streamlit: Go here, create an account, link it to your github account, click on "create a new app", select your live-streaming-app repository, create you app and... voilà!