Industry leading face manipulation platform
Fix list literal spacing to use [ x, y ] style (#1044)
Henry Ruhsc7976ec9d4de
diff --git a/facefusion/face_detector.py b/facefusion/face_detector.pyindex cabd6201..6b5cb351 100644--- a/facefusion/face_detector.py+++ b/facefusion/face_detector.py@@ -381,11 +381,11 @@ def detect_with_yunet(vision_frame : VisionFrame, face_detector_size : str) -> Tface_scores.extend(face_scores_raw[keep_indices])face_landmarks_5_raw = numpy.concatenate([- face_landmarks_5_raw[:, [0, 1]] * feature_stride + anchors,- face_landmarks_5_raw[:, [2, 3]] * feature_stride + anchors,- face_landmarks_5_raw[:, [4, 5]] * feature_stride + anchors,- face_landmarks_5_raw[:, [6, 7]] * feature_stride + anchors,- face_landmarks_5_raw[:, [8, 9]] * feature_stride + anchors+ face_landmarks_5_raw[:, [ 0, 1 ]] * feature_stride + anchors,+ face_landmarks_5_raw[:, [ 2, 3 ]] * feature_stride + anchors,+ face_landmarks_5_raw[:, [ 4, 5 ]] * feature_stride + anchors,+ face_landmarks_5_raw[:, [ 6, 7 ]] * feature_stride + anchors,+ face_landmarks_5_raw[:, [ 8, 9 ]] * feature_stride + anchors], axis = -1).reshape(-1, 5, 2)for face_landmark_raw_5 in face_landmarks_5_raw[keep_indices]:diff --git a/facefusion/face_helper.py b/facefusion/face_helper.pyindex 388ab9af..553b3e65 100644--- a/facefusion/face_helper.py+++ b/facefusion/face_helper.py@@ -81,7 +81,7 @@ def warp_face_by_face_landmark_5(temp_vision_frame : VisionFrame, face_landmark_def warp_face_by_bounding_box(temp_vision_frame : VisionFrame, bounding_box : BoundingBox, crop_size : Size) -> Tuple[VisionFrame, Matrix]:- source_points = numpy.array([ [ bounding_box[0], bounding_box[1] ], [bounding_box[2], bounding_box[1] ], [ bounding_box[0], bounding_box[3] ] ]).astype(numpy.float32)+ source_points = numpy.array([ [ bounding_box[0], bounding_box[1] ], [ bounding_box[2], bounding_box[1] ], [ bounding_box[0], bounding_box[3] ] ]).astype(numpy.float32)target_points = numpy.array([ [ 0, 0 ], [ crop_size[0], 0 ], [ 0, crop_size[1] ] ]).astype(numpy.float32)affine_matrix = cv2.getAffineTransform(source_points, target_points)if bounding_box[2] - bounding_box[0] > crop_size[0] or bounding_box[3] - bounding_box[1] > crop_size[1]:@@ -247,7 +247,7 @@ def get_nms_threshold(face_detector_model : FaceDetectorModel, face_detector_angdef merge_matrix(temp_matrices : List[Matrix]) -> Matrix:- matrix = numpy.vstack([temp_matrices[0], [0, 0, 1]])+ matrix = numpy.vstack([ temp_matrices[0], [ 0, 0, 1 ] ])for temp_matrix in temp_matrices[1:]:temp_matrix = numpy.vstack([ temp_matrix, [ 0, 0, 1 ] ])diff --git a/facefusion/ffmpeg_builder.py b/facefusion/ffmpeg_builder.pyindex 61bc5c5d..f62e5b26 100644--- a/facefusion/ffmpeg_builder.py+++ b/facefusion/ffmpeg_builder.py@@ -48,7 +48,7 @@ def set_input(input_path : str) -> List[Command]:def set_input_fps(input_fps : Fps) -> List[Command]:- return [ '-r', str(input_fps)]+ return [ '-r', str(input_fps) ]def set_output(output_path : str) -> List[Command]:diff --git a/facefusion/installer.py b/facefusion/installer.pyindex aec92b49..7e4e536f 100644--- a/facefusion/installer.py+++ b/facefusion/installer.py@@ -68,7 +68,7 @@ def run(program : ArgumentParser) -> None:onnxruntime_name, onnxruntime_version = ONNXRUNTIME_SET.get(args.onnxruntime)commands.append(onnxruntime_name + '==' + onnxruntime_version)- subprocess.call([shutil.which('pip'), 'uninstall', 'onnxruntime', onnxruntime_name, '-y', '-q' ])+ subprocess.call([ shutil.which('pip'), 'uninstall', 'onnxruntime', onnxruntime_name, '-y', '-q' ])subprocess.call(commands)diff --git a/facefusion/normalizer.py b/facefusion/normalizer.pyindex cb455ebd..1f7ae093 100644--- a/facefusion/normalizer.py+++ b/facefusion/normalizer.py@@ -19,9 +19,9 @@ def normalize_space(spaces : Optional[List[int]]) -> Optional[Padding]:if spaces and len(spaces) == 1:return tuple([spaces[0]] * 4) #type:ignore[return-value]if spaces and len(spaces) == 2:- return tuple([spaces[0], spaces[1], spaces[0], spaces[1]]) #type:ignore[return-value]+ return tuple([ spaces[0], spaces[1], spaces[0], spaces[1] ]) #type:ignore[return-value]if spaces and len(spaces) == 3:- return tuple([spaces[0], spaces[1], spaces[2], spaces[1]]) #type:ignore[return-value]+ return tuple([ spaces[0], spaces[1], spaces[2], spaces[1] ]) #type:ignore[return-value]if spaces and len(spaces) == 4:return tuple(spaces) #type:ignore[return-value]return Nonediff --git a/facefusion/processors/modules/expression_restorer/core.py b/facefusion/processors/modules/expression_restorer/core.pyindex 4892a18b..c6c4f963 100755--- a/facefusion/processors/modules/expression_restorer/core.py+++ b/facefusion/processors/modules/expression_restorer/core.py@@ -192,12 +192,12 @@ def restrict_expression_areas(temp_expression : LivePortraitExpression, target_eexpression_restorer_areas = state_manager.get_item('expression_restorer_areas')if 'upper-face' not in expression_restorer_areas:- target_expression[:, [1, 2, 6, 10, 11, 12, 13, 15, 16]] = temp_expression[:, [1, 2, 6, 10, 11, 12, 13, 15, 16]]+ target_expression[:, [ 1, 2, 6, 10, 11, 12, 13, 15, 16 ]] = temp_expression[:, [ 1, 2, 6, 10, 11, 12, 13, 15, 16 ]]if 'lower-face' not in expression_restorer_areas:- target_expression[:, [3, 7, 14, 17, 18, 19, 20]] = temp_expression[:, [3, 7, 14, 17, 18, 19, 20]]+ target_expression[:, [ 3, 7, 14, 17, 18, 19, 20 ]] = temp_expression[:, [ 3, 7, 14, 17, 18, 19, 20 ]]- target_expression[:, [0, 4, 5, 8, 9]] = temp_expression[:, [0, 4, 5, 8, 9]]+ target_expression[:, [ 0, 4, 5, 8, 9 ]] = temp_expression[:, [ 0, 4, 5, 8, 9 ]]return target_expressiondiff --git a/facefusion/uis/components/background_remover_options.py b/facefusion/uis/components/background_remover_options.pyindex e8ce10ab..69ef20aa 100644--- a/facefusion/uis/components/background_remover_options.py+++ b/facefusion/uis/components/background_remover_options.py@@ -81,7 +81,7 @@ def listen() -> None:processors_checkbox_group = get_ui_component('processors_checkbox_group')if processors_checkbox_group:- processors_checkbox_group.change(remote_update, inputs = processors_checkbox_group, outputs = [BACKGROUND_REMOVER_MODEL_DROPDOWN, BACKGROUND_REMOVER_COLOR_WRAPPER])+ processors_checkbox_group.change(remote_update, inputs = processors_checkbox_group, outputs = [ BACKGROUND_REMOVER_MODEL_DROPDOWN, BACKGROUND_REMOVER_COLOR_WRAPPER ])def remote_update(processors : List[str]) -> Tuple[gradio.Dropdown, gradio.Group]:diff --git a/facefusion/uis/components/output_options.py b/facefusion/uis/components/output_options.pyindex e8d35a13..bad92bd4 100644--- a/facefusion/uis/components/output_options.py+++ b/facefusion/uis/components/output_options.py@@ -132,7 +132,7 @@ def listen() -> None:'target_video']):for method in [ 'change', 'clear' ]:- getattr(ui_component, method)(remote_update, outputs = [OUTPUT_IMAGE_QUALITY_SLIDER, OUTPUT_IMAGE_SCALE_SLIDER, OUTPUT_AUDIO_ENCODER_DROPDOWN, OUTPUT_AUDIO_QUALITY_SLIDER, OUTPUT_AUDIO_VOLUME_SLIDER, OUTPUT_VIDEO_ENCODER_DROPDOWN, OUTPUT_VIDEO_PRESET_DROPDOWN, OUTPUT_VIDEO_QUALITY_SLIDER, OUTPUT_VIDEO_SCALE_SLIDER, OUTPUT_VIDEO_FPS_SLIDER])+ getattr(ui_component, method)(remote_update, outputs = [ OUTPUT_IMAGE_QUALITY_SLIDER, OUTPUT_IMAGE_SCALE_SLIDER, OUTPUT_AUDIO_ENCODER_DROPDOWN, OUTPUT_AUDIO_QUALITY_SLIDER, OUTPUT_AUDIO_VOLUME_SLIDER, OUTPUT_VIDEO_ENCODER_DROPDOWN, OUTPUT_VIDEO_PRESET_DROPDOWN, OUTPUT_VIDEO_QUALITY_SLIDER, OUTPUT_VIDEO_SCALE_SLIDER, OUTPUT_VIDEO_FPS_SLIDER ])def remote_update() -> Tuple[gradio.Slider, gradio.Slider, gradio.Dropdown, gradio.Slider, gradio.Slider, gradio.Dropdown, gradio.Dropdown, gradio.Slider, gradio.Slider, gradio.Slider]:diff --git a/tests/test_cli_background_remover.py b/tests/test_cli_background_remover.pyindex 5ee4b3f9..dab7f62d 100644--- a/tests/test_cli_background_remover.py+++ b/tests/test_cli_background_remover.py@@ -15,7 +15,7 @@ def before_all() -> None:'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg','https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'])- subprocess.run(['ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg')])+ subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ])@pytest.fixture(scope = 'function', autouse = True)diff --git a/tests/test_common_helper.py b/tests/test_common_helper.pyindex cec36821..12e78853 100644--- a/tests/test_common_helper.py+++ b/tests/test_common_helper.py@@ -20,8 +20,8 @@ def test_create_float_range() -> None:def test_calc_int_step() -> None:- assert calculate_int_step([0, 1]) == 1+ assert calculate_int_step([ 0, 1 ]) == 1def test_calc_float_step() -> None:- assert calculate_float_step([0.1, 0.2]) == 0.1+ assert calculate_float_step([ 0.1, 0.2 ]) == 0.1diff --git a/tests/test_sanitizer.py b/tests/test_sanitizer.pyindex fa06ed51..20f3b2c6 100644--- a/tests/test_sanitizer.py+++ b/tests/test_sanitizer.py@@ -3,6 +3,6 @@ from facefusion.sanitizer import sanitize_int_rangedef test_sanitize_int_range() -> None:assert sanitize_int_range(0, [ 0, 1, 2 ]) == 0- assert sanitize_int_range(2, [0, 1, 2]) == 2+ assert sanitize_int_range(2, [ 0, 1, 2 ]) == 2assert sanitize_int_range(-1, [ 0, 1 ]) == 0assert sanitize_int_range(3, [ 0, 1 ]) == 0