I have a image processing script that converts video’s to frame and I want to turn it to a web service where user uploads a video then the system converts the video to frame and saves to a folder.
Is it possible to create a post request that takes a video from a user calls an endpoint which in turn processes the video and sends a response back to the user.
I am kind of familiar DL and ML and I have little knowledge of restful api
1. File_uploader
Streamlit offers a component for file uploading including video files (I belief):
import streamlit as st
import cv2 as cv
import tempfile
--> f = st.file_uploader("Upload file") <--
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(f.read())
vf = cv.VideoCapture(tfile.name)
2. Requests in python
You can than send a request to the API using:
import requests
url = 'https://www.w3schools.com/python/demopage.php'
myobj = {'somekey': 'somevalue'}
x = requests.post(url, data = myobj)
print(x.text)
3. API
Finally, you can implement an API with:
and smoothly process and return the data.
In case you are using streamlit sharing, you might not need to send the data somewhere to store files.
I have a similar question posted a few minutes ago:
Yes, you could do something like this, but it doesn’t necessarily have to be “in Streamlit”, since you have the full power of Python available as well. @chris_klose points out some thoughts, and it really is a matter of thinking through the pipeline you want and doing it.
Streamlit sharing isn’t going to provide you with a lot of RAM and disk space, so it might not be the best solution for this. But I can envision an app that calls out to Amazon S3 or Google Drive to post the modified video and returns a link to where someone can download it.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.