Prathamesh1420 commited on
Commit
046137b
·
verified ·
1 Parent(s): 915ba3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -107,16 +107,28 @@ def process_video(uploaded_file):
107
  out.release()
108
  return output_path
109
 
 
 
 
 
 
 
 
110
  st.title("Bottle Label Checking using YOLO & Gemini AI")
111
  st.sidebar.header("Upload a video")
112
  uploaded_file = st.sidebar.file_uploader("Choose a video file", type=["mp4", "avi", "mov"])
113
 
114
  if uploaded_file:
115
- st.sidebar.write("Processing...")
116
  output_video_path = process_video(uploaded_file)
117
  st.sidebar.success("Processing completed!")
 
 
118
  st.video(output_video_path)
119
 
 
 
 
120
  st.subheader("AI Analysis Results")
121
  for track_id, response in st.session_state["responses"]:
122
  st.write(f"**Track ID {track_id}:** {response}")
 
107
  out.release()
108
  return output_path
109
 
110
+ def get_video_download_link(file_path):
111
+ """Generates a download link for the processed video."""
112
+ with open(file_path, "rb") as file:
113
+ video_bytes = file.read()
114
+ b64 = base64.b64encode(video_bytes).decode()
115
+ return f'<a href="data:video/mp4;base64,{b64}" download="output_video.mp4">Download Processed Video</a>'
116
+
117
  st.title("Bottle Label Checking using YOLO & Gemini AI")
118
  st.sidebar.header("Upload a video")
119
  uploaded_file = st.sidebar.file_uploader("Choose a video file", type=["mp4", "avi", "mov"])
120
 
121
  if uploaded_file:
122
+ st.sidebar.write("Processing... Please wait!")
123
  output_video_path = process_video(uploaded_file)
124
  st.sidebar.success("Processing completed!")
125
+
126
+ # Show processed video
127
  st.video(output_video_path)
128
 
129
+ # Provide download link for the video
130
+ st.markdown(get_video_download_link(output_video_path), unsafe_allow_html=True)
131
+
132
  st.subheader("AI Analysis Results")
133
  for track_id, response in st.session_state["responses"]:
134
  st.write(f"**Track ID {track_id}:** {response}")