First, let me apologize that I can’t share all my code due to proprietary and legal considerations. I will be as descriptive as I can.
So, I created an app for an object detection model I trained. I want to use the progress bar to show and track the progress as it processes images. I created the bar using the provided Streamlit example below:
import streamlit as st
import time
progress_text = "Operation in progress. Please wait."
my_bar = st.progress(0, text=progress_text)
for percent_complete in range(100):
time.sleep(0.1)
my_bar.progress(percent_complete + 1, text=progress_text)
What I can’t figure out is how to link it (sorry if my terminology is wrong) to the object detection function (again… terminology). I tried using a for loop and while loop but still get an error.
from dataclasses import dataclass
from time import sleep
import streamlit as st
@dataclass
class Program:
progress: int = 0
def increment(self):
self.progress += 1
sleep(0.1)
my_bar = st.progress(0, text="Operation in progress. Please wait...")
p = Program()
while p.progress < 100:
p.increment()
my_bar.progress(p.progress, text=f"Progress: {p.progress}%")
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.