Yao211's picture
Upload 4 files
8427f0d verified
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()