nalin0503 commited on
Commit
481aa8e
·
1 Parent(s): c811f4d

Try 2nd ver

Browse files
Files changed (1) hide show
  1. app.py +31 -28
app.py CHANGED
@@ -215,7 +215,8 @@ def main():
215
 
216
  # Add a restart button to clear the session state and start over
217
  if st.button("Start New Morphing Project", key="restart"):
218
- restart()
 
219
  except Exception as e:
220
  st.error(f"Error preparing video for download: {e}")
221
 
@@ -348,11 +349,9 @@ def main():
348
  st.subheader("3. Generate Morphing Video")
349
  st.markdown("Once satisfied with your inputs, click below to start the process.")
350
 
351
- # New checkbox for SLAB execution toggle
352
- # using_slab = st.checkbox("Using SLAB GPU Cluster?", value=False, help="If enabled, the pipeline command will be prefixed with SLAB cluster execution parameters.", disabled=st.session_state.processing)
353
-
354
  # Create a container for the run button and its status messages
355
  run_container = st.container()
 
356
  with run_container:
357
  # Button text changes based on processing state
358
  button_text = "Processing... Please Wait" if st.session_state.processing else "Run Morphing Pipeline"
@@ -365,7 +364,7 @@ def main():
365
  # Set the processing state to True to prevent multiple runs
366
  st.session_state.processing = True
367
 
368
- # Instead of using /tmp, create a folder in the repo for temporary processing.
369
  temp_dir = create_temp_folder()
370
  st.session_state.temp_dir = temp_dir
371
 
@@ -415,33 +414,37 @@ def main():
415
  # Add film recursion parameter
416
  cmd.extend(["--film_num_recursions", str(film_recursions)])
417
 
418
- subprocess.run(cmd, check=True)
419
-
420
- possible_outputs = [f for f in os.listdir(film_output_dir) if f.endswith(".mp4")]
421
- video_found = False
422
- if possible_outputs:
423
- final_video_path = os.path.join(film_output_dir, possible_outputs[0])
424
- video_found = True
425
-
426
- if not video_found:
427
- possible_outputs = [f for f in os.listdir(output_dir) if f.endswith(".mp4")]
428
  if possible_outputs:
429
- final_video_path = os.path.join(output_dir, possible_outputs[0])
430
  video_found = True
431
-
432
- if video_found:
433
- st.session_state.final_video_path = final_video_path
434
- st.session_state.process_complete = True
435
- st.rerun()
436
- else:
437
- st.error("No output video was generated. Check logs for details.")
 
 
 
 
 
 
 
 
 
 
 
438
  st.session_state.processing = False
439
  st.session_state.process_complete = False
440
-
441
- except subprocess.CalledProcessError as e:
442
- st.error(f"Error running morphing pipeline: {e}")
443
- st.session_state.processing = False
444
- st.session_state.process_complete = False
445
  except Exception as e:
446
  st.error(f"An error occurred during processing: {e}")
447
  st.session_state.processing = False
 
215
 
216
  # Add a restart button to clear the session state and start over
217
  if st.button("Start New Morphing Project", key="restart"):
218
+ restart() # Use the restart function
219
+
220
  except Exception as e:
221
  st.error(f"Error preparing video for download: {e}")
222
 
 
349
  st.subheader("3. Generate Morphing Video")
350
  st.markdown("Once satisfied with your inputs, click below to start the process.")
351
 
 
 
 
352
  # Create a container for the run button and its status messages
353
  run_container = st.container()
354
+
355
  with run_container:
356
  # Button text changes based on processing state
357
  button_text = "Processing... Please Wait" if st.session_state.processing else "Run Morphing Pipeline"
 
364
  # Set the processing state to True to prevent multiple runs
365
  st.session_state.processing = True
366
 
367
+ # Create a temporary folder for processing
368
  temp_dir = create_temp_folder()
369
  st.session_state.temp_dir = temp_dir
370
 
 
414
  # Add film recursion parameter
415
  cmd.extend(["--film_num_recursions", str(film_recursions)])
416
 
417
+ # Run the morphing process
418
+ try:
419
+ subprocess.run(cmd, check=True)
420
+
421
+ # Check for output video
422
+ video_found = False
423
+ possible_outputs = [f for f in os.listdir(film_output_dir) if f.endswith(".mp4")]
 
 
 
424
  if possible_outputs:
425
+ final_video_path = os.path.join(film_output_dir, possible_outputs[0])
426
  video_found = True
427
+
428
+ if not video_found:
429
+ possible_outputs = [f for f in os.listdir(output_dir) if f.endswith(".mp4")]
430
+ if possible_outputs:
431
+ final_video_path = os.path.join(output_dir, possible_outputs[0])
432
+ video_found = True
433
+
434
+ if video_found:
435
+ st.session_state.final_video_path = final_video_path
436
+ st.session_state.process_complete = True
437
+ st.rerun()
438
+ else:
439
+ st.error("No output video was generated. Check logs for details.")
440
+ st.session_state.processing = False
441
+ st.session_state.process_complete = False
442
+
443
+ except subprocess.CalledProcessError as e:
444
+ st.error(f"Error running morphing pipeline: {e}")
445
  st.session_state.processing = False
446
  st.session_state.process_complete = False
447
+
 
 
 
 
448
  except Exception as e:
449
  st.error(f"An error occurred during processing: {e}")
450
  st.session_state.processing = False