Spaces:
Runtime error
Runtime error
import os | |
import sys | |
import warnings | |
from pathlib import Path | |
# Setup environment | |
os.environ['GRADIO_ANALYTICS_ENABLED'] = '0' | |
os.environ['SYSTEM_VERSION_COMPAT'] = '0' | |
os.environ['OMP_NUM_THREADS'] = '1' | |
# Initialize paths | |
REPO_DIR = Path(__file__).parent | |
sys.path.append(str(REPO_DIR)) | |
import gradio as gr | |
from facefusion import core, metadata, state_manager, wording | |
from facefusion.uis.layouts import default | |
from facefusion.uis.components import ( | |
source, preview, output_options, webcam_options | |
) | |
# Suppress warnings | |
warnings.filterwarnings('ignore', category=UserWarning, module='gradio') | |
def create_facefusion_app(): | |
"""Creates the FaceFusion Gradio application with all features""" | |
# Set initial state | |
state_manager.set_item('ui_layouts', ['default']) | |
# Configure gradio temp directory | |
os.environ['GRADIO_TEMP_DIR'] = os.path.join( | |
state_manager.get_item('temp_path'), | |
'gradio' | |
) | |
# Create interface using the theme from core | |
with gr.Blocks( | |
theme=core.get_theme(), | |
css=core.get_css(), | |
title=f"{metadata.get('name')} {metadata.get('version')}", | |
analytics_enabled=False | |
) as app: | |
# Pre-check and render the default layout | |
default.pre_check() | |
default.render() | |
default.listen() | |
# Run layout setup | |
default.run(app) | |
return app | |
# Create the app | |
app = create_facefusion_app() | |
# For local testing | |
if __name__ == "__main__": | |
app.launch() |