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}%")