Spaces:
Paused
Paused
add a time tracker
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ from huggingface_hub import hf_hub_download
|
|
| 6 |
import glob
|
| 7 |
from moviepy.editor import VideoFileClip
|
| 8 |
from datetime import datetime
|
|
|
|
| 9 |
|
| 10 |
is_shared_ui = True if "fffiloni/X-Portrait" in os.environ['SPACE_ID'] else False
|
| 11 |
|
|
@@ -93,6 +94,8 @@ def extract_frames_with_labels(video_path, base_output_dir="frames"):
|
|
| 93 |
# Define a function to run your script with selected inputs
|
| 94 |
def run_xportrait(source_image, driving_video, seed, uc_scale, best_frame, out_frames, num_mix, ddim_steps, progress=gr.Progress(track_tqdm=True)):
|
| 95 |
|
|
|
|
|
|
|
| 96 |
# Create a unique output directory name based on current date and time
|
| 97 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 98 |
output_dir = f"output_{timestamp}"
|
|
@@ -126,11 +129,16 @@ def run_xportrait(source_image, driving_video, seed, uc_scale, best_frame, out_f
|
|
| 126 |
print(video_files)
|
| 127 |
if video_files:
|
| 128 |
final_vid = convert_video_to_h264_aac(video_files[0])
|
|
|
|
| 129 |
return f"Output video saved at: {final_vid}", final_vid
|
| 130 |
else:
|
| 131 |
return "No video file was found in the output directory.", None
|
| 132 |
except subprocess.CalledProcessError as e:
|
| 133 |
return f"An error occurred: {e}", None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
def convert_video_to_h264_aac(video_path):
|
| 136 |
# Get the directory and original filename
|
|
|
|
| 6 |
import glob
|
| 7 |
from moviepy.editor import VideoFileClip
|
| 8 |
from datetime import datetime
|
| 9 |
+
import time
|
| 10 |
|
| 11 |
is_shared_ui = True if "fffiloni/X-Portrait" in os.environ['SPACE_ID'] else False
|
| 12 |
|
|
|
|
| 94 |
# Define a function to run your script with selected inputs
|
| 95 |
def run_xportrait(source_image, driving_video, seed, uc_scale, best_frame, out_frames, num_mix, ddim_steps, progress=gr.Progress(track_tqdm=True)):
|
| 96 |
|
| 97 |
+
start_time = time.perf_counter()
|
| 98 |
+
|
| 99 |
# Create a unique output directory name based on current date and time
|
| 100 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 101 |
output_dir = f"output_{timestamp}"
|
|
|
|
| 129 |
print(video_files)
|
| 130 |
if video_files:
|
| 131 |
final_vid = convert_video_to_h264_aac(video_files[0])
|
| 132 |
+
|
| 133 |
return f"Output video saved at: {final_vid}", final_vid
|
| 134 |
else:
|
| 135 |
return "No video file was found in the output directory.", None
|
| 136 |
except subprocess.CalledProcessError as e:
|
| 137 |
return f"An error occurred: {e}", None
|
| 138 |
+
finally:
|
| 139 |
+
end_time = time.perf_counter()
|
| 140 |
+
elapsed = end_time - start_time
|
| 141 |
+
print(f"[LOG] Execution time: {elapsed:.4f} seconds")
|
| 142 |
|
| 143 |
def convert_video_to_h264_aac(video_path):
|
| 144 |
# Get the directory and original filename
|