amanpreet7 commited on
Commit
06f9405
·
verified ·
1 Parent(s): a28a0f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -296,10 +296,14 @@ def process_video(api, drive_service, video_file):
296
  st.session_state['bvh_data'] = bvh_data
297
  st.session_state['bvh_filename'] = bvh_filename or "motion_capture.bvh"
298
 
 
 
 
299
  return {
300
  'bvh_data': bvh_data,
301
  'bvh_path': bvh_path,
302
- 'bvh_filename': bvh_filename or "motion_capture.bvh"
 
303
  }
304
 
305
  if execution_started and current_status in ['complete', 'error']:
@@ -404,32 +408,39 @@ def main():
404
  if uploaded_file := st.session_state.get('uploaded_file'):
405
  st.video(uploaded_file)
406
 
 
 
407
  if st.session_state.get('uploaded_file'):
408
  st.markdown('<h3 class="section-title">Processing Options</h3>', unsafe_allow_html=True)
409
 
410
- if st.button("Start Motion Capture"):
411
  result = process_video(api, drive_service, st.session_state['uploaded_file'])
412
 
413
  if result and 'bvh_data' in result:
414
  # The BVH file has already been downloaded and deleted from Drive
415
  # Now just offer it for download to the user
416
- st.download_button(
417
- label="Download BVH",
418
- data=result['bvh_data'],
419
- file_name=result['bvh_filename'],
420
- mime="application/octet-stream"
421
- )
 
 
422
  else:
423
  st.error("Failed to generate BVH file.")
424
 
425
  # If BVH data is in session state (from a previous run), offer it for download
426
  if 'bvh_data' in st.session_state and 'bvh_filename' in st.session_state:
427
- st.download_button(
428
- label="Download BVH",
429
- data=st.session_state['bvh_data'],
430
- file_name=st.session_state['bvh_filename'],
431
- mime="application/octet-stream"
432
- )
 
 
 
433
 
434
  st.markdown('</div>', unsafe_allow_html=True)
435
 
 
296
  st.session_state['bvh_data'] = bvh_data
297
  st.session_state['bvh_filename'] = bvh_filename or "motion_capture.bvh"
298
 
299
+ # Generate a unique timestamp for this result
300
+ st.session_state['bvh_timestamp'] = int(time.time())
301
+
302
  return {
303
  'bvh_data': bvh_data,
304
  'bvh_path': bvh_path,
305
+ 'bvh_filename': bvh_filename or "motion_capture.bvh",
306
+ 'timestamp': st.session_state['bvh_timestamp']
307
  }
308
 
309
  if execution_started and current_status in ['complete', 'error']:
 
408
  if uploaded_file := st.session_state.get('uploaded_file'):
409
  st.video(uploaded_file)
410
 
411
+ download_container = st.container()
412
+
413
  if st.session_state.get('uploaded_file'):
414
  st.markdown('<h3 class="section-title">Processing Options</h3>', unsafe_allow_html=True)
415
 
416
+ if st.button("Start Motion Capture", key="start_capture_button"):
417
  result = process_video(api, drive_service, st.session_state['uploaded_file'])
418
 
419
  if result and 'bvh_data' in result:
420
  # The BVH file has already been downloaded and deleted from Drive
421
  # Now just offer it for download to the user
422
+ with download_container:
423
+ st.download_button(
424
+ label="Download BVH",
425
+ data=result['bvh_data'],
426
+ file_name=result['bvh_filename'],
427
+ mime="application/octet-stream",
428
+ key=f"download_new_{result['timestamp']}"
429
+ )
430
  else:
431
  st.error("Failed to generate BVH file.")
432
 
433
  # If BVH data is in session state (from a previous run), offer it for download
434
  if 'bvh_data' in st.session_state and 'bvh_filename' in st.session_state:
435
+ with download_container:
436
+ timestamp = st.session_state.get('bvh_timestamp', int(time.time()))
437
+ st.download_button(
438
+ label="Download BVH",
439
+ data=st.session_state['bvh_data'],
440
+ file_name=st.session_state['bvh_filename'],
441
+ mime="application/octet-stream",
442
+ key=f"download_saved_{timestamp}"
443
+ )
444
 
445
  st.markdown('</div>', unsafe_allow_html=True)
446