File size: 3,333 Bytes
8427f0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import gradio as gr
import sys
import os

# Add the dist directory to Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'dist'))

# Import obfuscated module
try:
    from core_logic import (
        generate_speedpainting_secure,
        get_company_info,
        get_example_images,
        create_footer,
        get_custom_css
    )
except ImportError as e:
    print(f"Error: Obfuscated module not found: {e}")
    print("Current directory:", os.getcwd())
    print("Files in dist:", os.listdir('dist') if os.path.exists('dist') else 'dist not found')
    sys.exit(1)

# Create Gradio interface
with gr.Blocks(title="Miragic Speed-Painting", theme=gr.themes.Ocean(), css=get_custom_css()) as demo:
    gr.Markdown("""
    <div style="display: flex; align-items: center;">
        <img src="https://avatars.githubusercontent.com/u/211682198?s=200&v=4" style="width: 80px; margin-right: 20px;"/>
        <div>
            <h1 style="margin-bottom: 0;">Miragic Speed-Painting 🎨</h1>
            <p>Upload an image to see AI create speedpainting animations!</p>
        </div>
    </div>
    """)
    
    gr.Markdown(get_company_info())
    
    with gr.Row():
        with gr.Column():
            image_input = gr.Image(
                label="Upload Image",
                type="pil",
                sources=["upload", "clipboard"],
                height=300
            )
            
            gr.Examples(
                examples=get_example_images(),
                inputs=image_input,
                label="Try these examples!",
                examples_per_page=5
            )
            
            submit_btn = gr.Button("Generate Speedpainting πŸš€", elem_classes="button-gradient")
        
        with gr.Column():
            video_output = gr.Video(
                label="Speedpainting Result",
                autoplay=True,
                height=300
            )
            
            gr.HTML("""
            <div class="interaction-section">
                <p style="margin: 5px 0;">If you like our Speed Painting results, please give us a ⭐ into our space!</p>
            </div>
            """)

            signup_prompt = gr.HTML(
                visible=True,
                value="""<div class="signup-container">
                    <h3>πŸš€ Want unlimited generations?</h3>
                    <p>Please sign up at Miragic.ai for unlimited access to all our AI tools!</p>
                    <a href='https://miragic.ai/products/speed-painting' target='_blank' class="signup-button">
                        SignUp for Free πŸš€
                    </a>
                </div>"""
            )
    
    # Handle generation - Only calls the secure function, no logic here
    submit_btn.click(
        fn=generate_speedpainting_secure,
        inputs=[image_input],
        outputs=video_output
    )

    gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiragic-AI%2FMiragic-Speed-Painting"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiragic-AI%2FMiragic-Speed-Painting&label=VISITORS&labelColor=%2337d67a&countColor=%23f47373&style=plastic&labelStyle=upper" /></a>')

    # Footer
    gr.HTML(create_footer())
    
if __name__ == "__main__":
    demo.launch()