mirror of
https://github.com/facefusion/facefusion.git
synced 2026-09-15 20:15:28 +02:00
* introduce content store for content analyser * introduce content store for content analyser part2 * guard content store as well * minor changes * minor changes * minor changes
33 lines
595 B
Python
33 lines
595 B
Python
from facefusion.types import ContentSet
|
|
|
|
CONTENT_STORE : ContentSet =\
|
|
{
|
|
'hit': 0,
|
|
'total': 0
|
|
}
|
|
|
|
|
|
def tick(step : int = 30) -> bool:
|
|
CONTENT_STORE['total'] += 1
|
|
|
|
return CONTENT_STORE.get('total') % step == 0
|
|
|
|
|
|
def get_hit() -> int:
|
|
return CONTENT_STORE.get('hit')
|
|
|
|
|
|
def set_hit() -> None:
|
|
CONTENT_STORE['hit'] += 1
|
|
|
|
|
|
def calculate_rate(step : int = 30) -> float:
|
|
if CONTENT_STORE.get('hit') and CONTENT_STORE.get('total'):
|
|
return CONTENT_STORE.get('hit') / CONTENT_STORE.get('total') * step * 100
|
|
return 0.0
|
|
|
|
|
|
def clear() -> None:
|
|
CONTENT_STORE['hit'] = 0
|
|
CONTENT_STORE['total'] = 0
|