Spaces:
Build error
Build error
File size: 1,086 Bytes
a1da63c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from typing import Any, Union
from facefusion.app_context import detect_app_context
from facefusion.processors.typing import ProcessorState, ProcessorStateKey
from facefusion.typing import State, StateKey, StateSet
STATES : Union[StateSet, ProcessorState] =\
{
'cli': {}, #type:ignore[typeddict-item]
'ui': {} #type:ignore[typeddict-item]
}
UnionState = Union[State, ProcessorState]
UnionStateKey = Union[StateKey, ProcessorStateKey]
def get_state() -> UnionState:
app_context = detect_app_context()
return STATES.get(app_context) #type:ignore
def init_item(key : UnionStateKey, value : Any) -> None:
STATES['cli'][key] = value #type:ignore
STATES['ui'][key] = value #type:ignore
def get_item(key : UnionStateKey) -> Any:
return get_state().get(key) #type:ignore
def set_item(key : UnionStateKey, value : Any) -> None:
app_context = detect_app_context()
STATES[app_context][key] = value #type:ignore
def sync_item(key : UnionStateKey) -> None:
STATES['cli'][key] = STATES['ui'][key] #type:ignore
def clear_item(key : UnionStateKey) -> None:
set_item(key, None)
|