TheKnight115 commited on
Commit
a2e51ed
·
verified ·
1 Parent(s): 99d8cd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -40,8 +40,9 @@ def process_video(uploaded_file):
40
  total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) # Get the total number of frames
41
  frames = []
42
 
43
- # Create a Streamlit progress bar
44
  progress_bar = st.progress(0)
 
45
 
46
  current_frame = 0
47
 
@@ -58,9 +59,11 @@ def process_video(uploaded_file):
58
  frames.append(processed_frame) # Save the processed frame
59
 
60
  current_frame += 1
61
- # Update the progress bar
62
- progress_percentage = current_frame / total_frames
63
- progress_bar.progress(progress_percentage)
 
 
64
 
65
  video.release()
66
 
@@ -73,12 +76,12 @@ def process_video(uploaded_file):
73
 
74
  out.release()
75
 
76
- # Complete the progress bar
77
- progress_bar.progress(1)
 
78
  st.success('Video processing complete!')
79
 
80
 
81
-
82
  def main():
83
  st.title("Motorbike Violation Detection")
84
 
 
40
  total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) # Get the total number of frames
41
  frames = []
42
 
43
+ # Create a Streamlit progress bar and text for percentage
44
  progress_bar = st.progress(0)
45
+ progress_text = st.empty() # Placeholder for percentage text
46
 
47
  current_frame = 0
48
 
 
59
  frames.append(processed_frame) # Save the processed frame
60
 
61
  current_frame += 1
62
+
63
+ # Calculate and display the progress
64
+ progress_percentage = (current_frame / total_frames) * 100
65
+ progress_bar.progress(progress_percentage / 100) # Update the progress bar
66
+ progress_text.text(f'Processing: {progress_percentage:.2f}%') # Update the percentage text
67
 
68
  video.release()
69
 
 
76
 
77
  out.release()
78
 
79
+ # Complete the progress bar and show final message
80
+ progress_bar.progress(100)
81
+ progress_text.text('Processing: 100%')
82
  st.success('Video processing complete!')
83
 
84
 
 
85
  def main():
86
  st.title("Motorbike Violation Detection")
87