File size: 1,513 Bytes
a834fe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1adc7c1
 
a834fe2
1adc7c1
a834fe2
1adc7c1
 
 
a834fe2
 
 
 
1adc7c1
 
 
 
 
 
 
 
a834fe2
1adc7c1
 
 
 
 
 
 
 
 
 
 
a834fe2
1adc7c1
 
a834fe2
 
 
1adc7c1
a834fe2
 
1adc7c1
a834fe2
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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()