Files
facefusion/facefusion/normalizer.py
T
Henry Ruhs c7976ec9d4 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>
2026-02-18 09:18:03 +01:00

34 lines
1.3 KiB
Python

from typing import List, Optional
from facefusion.types import Color, Fps, Padding
def normalize_color(channels : Optional[List[int]]) -> Optional[Color]:
if channels and len(channels) == 1:
return tuple([ channels[0], channels[0], channels[0], 255 ]) #type:ignore[return-value]
if channels and len(channels) == 2:
return tuple([ channels[0], channels[1], channels[0], 255 ]) #type:ignore[return-value]
if channels and len(channels) == 3:
return tuple([ channels[0], channels[1], channels[2], 255 ]) #type:ignore[return-value]
if channels and len(channels) == 4:
return tuple(channels) #type:ignore[return-value]
return None
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]
if spaces and len(spaces) == 3:
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
def normalize_fps(fps : Optional[float]) -> Optional[Fps]:
if isinstance(fps, (int, float)):
return max(1.0, min(fps, 60.0))
return None