Vibe coded benchmark command part5

This commit is contained in:
henryruhs
2025-06-16 10:32:31 +02:00
parent 293dff56ed
commit 26d0a5b9bb

View File

@@ -6,13 +6,12 @@ from time import perf_counter
from typing import Dict, Generator, List from typing import Dict, Generator, List
from facefusion import core, state_manager from facefusion import core, state_manager
from facefusion.types import BenchmarkSet
from facefusion.cli_helper import render_table from facefusion.cli_helper import render_table
from facefusion.download import conditional_download, resolve_download_url from facefusion.download import conditional_download, resolve_download_url
from facefusion.filesystem import get_file_extension from facefusion.filesystem import get_file_extension
from facefusion.types import BenchmarkSet
from facefusion.vision import count_video_frame_total, detect_video_fps, detect_video_resolution, pack_resolution from facefusion.vision import count_video_frame_total, detect_video_fps, detect_video_resolution, pack_resolution
BENCHMARKS : Dict[str, str] =\ BENCHMARKS : Dict[str, str] =\
{ {
'240p': '.assets/examples/target-240p.mp4', '240p': '.assets/examples/target-240p.mp4',
@@ -52,14 +51,14 @@ def run() -> Generator[List[BenchmarkSet], None, None]:
state_manager.set_item('output_video_preset', 'ultrafast') state_manager.set_item('output_video_preset', 'ultrafast')
state_manager.set_item('video_memory_strategy', 'tolerant') state_manager.set_item('video_memory_strategy', 'tolerant')
benchmark_results = [] benchmarks = []
target_paths = [ BENCHMARKS.get(benchmark_resolution) for benchmark_resolution in benchmark_resolutions if benchmark_resolution in BENCHMARKS ] target_paths = [ BENCHMARKS.get(benchmark_resolution) for benchmark_resolution in benchmark_resolutions if benchmark_resolution in BENCHMARKS ]
for target_path in target_paths: for target_path in target_paths:
state_manager.set_item('target_path', target_path) state_manager.set_item('target_path', target_path)
state_manager.set_item('output_path', suggest_output_path(state_manager.get_item('target_path'))) state_manager.set_item('output_path', suggest_output_path(state_manager.get_item('target_path')))
benchmark_results.append(cycle(benchmark_cycles)) benchmarks.append(cycle(benchmark_cycles))
yield benchmark_results yield benchmarks
def cycle(benchmark_cycles : int) -> BenchmarkSet: def cycle(benchmark_cycles : int) -> BenchmarkSet:
@@ -99,7 +98,7 @@ def suggest_output_path(target_path : str) -> str:
def render() -> None: def render() -> None:
benchmark_results = [] benchmarks = []
headers =\ headers =\
[ [
'target_path', 'target_path',
@@ -110,7 +109,7 @@ def render() -> None:
'relative_fps' 'relative_fps'
] ]
for cycle_result in run(): for benchmark in run():
benchmark_results = cycle_result benchmarks = benchmark
render_table(headers, benchmark_results) render_table(headers, benchmarks)