Files
facefusion/facefusion/common_helper.py
Henry Ruhs e42f91dadf 3.0.0 Gold (#787)
* Replace audio whenever set via source

* use scale_face_landmark_5() in age_modifier

* Fix wording and ordering of options

* Adjust wording for face editor

* Fix wording for processors

* Switch order of frame colorizer options

* That condition is actual not needed

* Simplify UI layout API by removing pre_render()

* Clean args and safe cast ini values (#775)

* Clean args and safe cast ini values

* Clean args and safe cast ini values

* Clean args and safe cast ini values

* Introduce paths group

* Fix job list command and change order

* Add job list testing todo

* Fix spacing in typing

* Fix benchmark by ignoring audio

* Simplify and avoid knowing the provider values (#782)

* Fix logger table with empty value

* Complete Typing

---------

Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
2024-10-02 11:08:05 +02:00

73 lines
1.6 KiB
Python

import platform
from typing import Any, Optional, Sequence
def is_linux() -> bool:
return platform.system().lower() == 'linux'
def is_macos() -> bool:
return platform.system().lower() == 'darwin'
def is_windows() -> bool:
return platform.system().lower() == 'windows'
def create_int_metavar(int_range : Sequence[int]) -> str:
return '[' + str(int_range[0]) + '..' + str(int_range[-1]) + ':' + str(calc_int_step(int_range)) + ']'
def create_float_metavar(float_range : Sequence[float]) -> str:
return '[' + str(float_range[0]) + '..' + str(float_range[-1]) + ':' + str(calc_float_step(float_range)) + ']'
def create_int_range(start : int, end : int, step : int) -> Sequence[int]:
int_range = []
current = start
while current <= end:
int_range.append(current)
current += step
return int_range
def create_float_range(start : float, end : float, step : float) -> Sequence[float]:
float_range = []
current = start
while current <= end:
float_range.append(round(current, 2))
current = round(current + step, 2)
return float_range
def calc_int_step(int_range : Sequence[int]) -> int:
return int_range[1] - int_range[0]
def calc_float_step(float_range : Sequence[float]) -> float:
return round(float_range[1] - float_range[0], 2)
def cast_int(value : Any) -> Optional[Any]:
try:
return int(value)
except (ValueError, TypeError):
return None
def cast_float(value : Any) -> Optional[Any]:
try:
return float(value)
except (ValueError, TypeError):
return None
def get_first(__list__ : Any) -> Any:
return next(iter(__list__), None)
def get_last(__list__ : Any) -> Any:
return next(reversed(__list__), None)