mirror of
https://github.com/facefusion/facefusion.git
synced 2026-04-23 18:06:08 +02:00
Fix list literal spacing to use [ x, y ] style (#1044)
Enforce consistent space inside square brackets for all list literals across source and test files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -381,11 +381,11 @@ def detect_with_yunet(vision_frame : VisionFrame, face_detector_size : str) -> T
|
||||
face_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]:
|
||||
|
||||
@@ -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_ang
|
||||
|
||||
|
||||
def 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 ] ])
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 None
|
||||
|
||||
@@ -192,12 +192,12 @@ def restrict_expression_areas(temp_expression : LivePortraitExpression, target_e
|
||||
expression_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_expression
|
||||
|
||||
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ]) == 1
|
||||
|
||||
|
||||
def test_calc_float_step() -> None:
|
||||
assert calculate_float_step([0.1, 0.2]) == 0.1
|
||||
assert calculate_float_step([ 0.1, 0.2 ]) == 0.1
|
||||
|
||||
@@ -3,6 +3,6 @@ from facefusion.sanitizer import sanitize_int_range
|
||||
|
||||
def 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 ]) == 2
|
||||
assert sanitize_int_range(-1, [ 0, 1 ]) == 0
|
||||
assert sanitize_int_range(3, [ 0, 1 ]) == 0
|
||||
|
||||
Reference in New Issue
Block a user