revert and simplify

This commit is contained in:
harisreedhar
2026-06-09 15:57:12 +05:30
parent 69b576aed3
commit 93fff1a921
5 changed files with 19 additions and 31 deletions
+3 -5
View File
@@ -167,12 +167,10 @@ def analyse_video(video_path : str, trim_frame_start : int, trim_frame_end : int
for frame_number in frame_range:
if frame_number % int(video_fps) == 0:
vision_frame = read_video_frame(video_path, frame_number)
total += 1
if numpy.any(vision_frame):
total += 1
if analyse_frame(vision_frame):
counter += 1
if analyse_frame(vision_frame):
counter += 1
if counter > 0 and total > 0:
rate = counter / total * 100
+4 -4
View File
@@ -16,7 +16,6 @@ from facefusion.processors.core import get_processors_modules
from facefusion.program import create_program
from facefusion.program_helper import validate_args
from facefusion.types import Args, ErrorCode
from facefusion.vision import has_video_support
from facefusion.workflows import image_to_image, image_to_video
@@ -116,7 +115,7 @@ def common_pre_check() -> bool:
content_analyser_content = inspect.getsource(content_analyser).encode()
content_analyser_hash = hash_helper.create_hash(content_analyser_content)
return all(module.pre_check() for module in common_modules) and content_analyser_hash == '975d67d6'
return all(module.pre_check() for module in common_modules) and content_analyser_hash == '05843613'
def processors_pre_check() -> bool:
@@ -337,8 +336,9 @@ def conditional_process() -> ErrorCode:
if is_image(state_manager.get_item('target_path')):
return image_to_image.process(start_time)
if is_video(state_manager.get_item('target_path')) and has_video_support(state_manager.get_item('target_path')):
if is_video(state_manager.get_item('target_path')):
return image_to_video.process(start_time)
return 0
+9 -14
View File
@@ -51,13 +51,10 @@ def render() -> None:
if is_video(state_manager.get_item('target_path')):
temp_vision_frame = read_video_frame(state_manager.get_item('target_path'), state_manager.get_item('reference_frame_number'))
reference_vision_frame = read_video_frame(state_manager.get_item('target_path'), state_manager.get_item('reference_frame_number'))
if numpy.any(temp_vision_frame):
preview_vision_frame = process_preview_frame(reference_vision_frame, source_vision_frames, source_audio_frame, source_voice_frame, temp_vision_frame, uis_choices.preview_modes[0], uis_choices.preview_resolutions[-1])
preview_image_options['value'] = cv2.cvtColor(preview_vision_frame, cv2.COLOR_BGR2RGB)
preview_image_options['elem_classes'] = [ 'image-preview', 'is-' + detect_frame_orientation(preview_vision_frame) ]
preview_image_options['visible'] = True
preview_vision_frame = process_preview_frame(reference_vision_frame, source_vision_frames, source_audio_frame, source_voice_frame, temp_vision_frame, uis_choices.preview_modes[0], uis_choices.preview_resolutions[-1])
preview_image_options['value'] = cv2.cvtColor(preview_vision_frame, cv2.COLOR_BGR2RGB)
preview_image_options['elem_classes'] = [ 'image-preview', 'is-' + detect_frame_orientation(preview_vision_frame) ]
preview_image_options['visible'] = True
PREVIEW_IMAGE = gradio.Image(**preview_image_options)
register_ui_component('preview_image', PREVIEW_IMAGE)
@@ -212,13 +209,11 @@ def update_preview_image(preview_mode : PreviewMode, preview_resolution : str, f
if is_video(state_manager.get_item('target_path')):
reference_vision_frame = read_video_frame(state_manager.get_item('target_path'), state_manager.get_item('reference_frame_number'))
temp_vision_frame = read_video_frame(state_manager.get_item('target_path'), frame_number)
if numpy.any(temp_vision_frame):
temp_vision_mask = extract_vision_mask(temp_vision_frame)
temp_vision_frame = merge_vision_mask(temp_vision_frame, temp_vision_mask)
preview_vision_frame = process_preview_frame(reference_vision_frame, source_vision_frames, source_audio_frame, source_voice_frame, temp_vision_frame, preview_mode, preview_resolution)
preview_vision_frame = cv2.cvtColor(preview_vision_frame, cv2.COLOR_BGRA2RGBA)
return gradio.Image(value = preview_vision_frame, elem_classes = [ 'image-preview', 'is-' + detect_frame_orientation(preview_vision_frame) ])
temp_vision_mask = extract_vision_mask(temp_vision_frame)
temp_vision_frame = merge_vision_mask(temp_vision_frame, temp_vision_mask)
preview_vision_frame = process_preview_frame(reference_vision_frame, source_vision_frames, source_audio_frame, source_voice_frame, temp_vision_frame, preview_mode, preview_resolution)
preview_vision_frame = cv2.cvtColor(preview_vision_frame, cv2.COLOR_BGRA2RGBA)
return gradio.Image(value = preview_vision_frame, elem_classes = [ 'image-preview', 'is-' + detect_frame_orientation(preview_vision_frame) ])
return gradio.Image(value = None, elem_classes = None)
+1 -4
View File
@@ -95,10 +95,7 @@ def read_video_frame(video_path : str, frame_number : int = 0) -> Optional[Visio
def has_video_support(video_path : str) -> bool:
video_frame_total = count_video_frame_total(video_path)
if video_frame_total > 0:
return bool(numpy.any(read_video_frame(video_path, 1)) or numpy.any(read_video_frame(video_path, video_frame_total // 2)) or numpy.any(read_video_frame(video_path, video_frame_total)))
return False
return bool(numpy.any(read_video_frame(video_path, video_frame_total)))
def count_video_frame_total(video_path : str) -> int:
+2 -4
View File
@@ -28,8 +28,7 @@ def before_all() -> None:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=60', get_test_example_file('target-240p-60fps.mp4') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'transpose=0', get_test_example_file('target-240p-90deg.mp4') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-1080p.mp4'), '-vf', 'transpose=0', get_test_example_file('target-1080p-90deg.mp4') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-frames:v', '1', get_test_example_file('target-240p-1frame.mp4') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-frames:v', '2', get_test_example_file('target-240p-2frame.mp4') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-c:v', 'libsvtav1', get_test_example_file('target-240p-av1.mp4') ])
@pytest.fixture(scope = 'function', autouse = True)
@@ -72,8 +71,7 @@ def test_read_video_frame() -> None:
@pytest.mark.skipif(os.environ.get('CI') and is_linux(), reason = 'h264 codec not present')
def test_has_video_support() -> None:
assert has_video_support(get_test_example_file('target-240p.mp4')) is True
assert has_video_support(get_test_example_file('target-240p-1frame.mp4')) is True
assert has_video_support(get_test_example_file('target-240p-2frame.mp4')) is True
assert has_video_support(get_test_example_file('target-240p-av1.mp4')) is False
assert has_video_support('invalid') is False