Spaces:
Sleeping
Sleeping
| """ | |
| Deploy Gradio Demo to Modal as a permanent web endpoint | |
| This creates a permanent URL at: https://your-workspace--media-optimization-gradio-web.modal.run | |
| """ | |
| import modal | |
| import os | |
| # Create Modal app | |
| app = modal.App("media-optimization-gradio") | |
| # Image with required packages | |
| image = modal.Image.debian_slim(python_version="3.11").pip_install( | |
| "gradio>=4.44.1", | |
| "modal>=0.60.0", | |
| "pandas>=2.0.0", | |
| "requests>=2.31.0", | |
| "mysql-connector-python>=8.0.0", | |
| "json-repair>=0.25.0", | |
| "boto3>=1.28.0", | |
| "python-dotenv>=1.0.0", | |
| ) | |
| # Mount the necessary files | |
| mounts = [ | |
| modal.Mount.from_local_file( | |
| local_path="gradio_demo.py", | |
| remote_path="/root/gradio_demo.py" | |
| ), | |
| modal.Mount.from_local_file( | |
| local_path="main_media.py", | |
| remote_path="/root/main_media.py" | |
| ), | |
| modal.Mount.from_local_file( | |
| local_path="qwen3_omni_asyncllm_modal_client.py", | |
| remote_path="/root/qwen3_omni_asyncllm_modal_client.py" | |
| ), | |
| modal.Mount.from_local_file( | |
| local_path="media_prompts.py", | |
| remote_path="/root/media_prompts.py" | |
| ), | |
| modal.Mount.from_local_file( | |
| local_path="s3Client.py", | |
| remote_path="/root/s3Client.py" | |
| ), | |
| ] | |
| def web(): | |
| """Serve Gradio app as a web endpoint""" | |
| import sys | |
| sys.path.insert(0, "/root") | |
| from gradio_demo import demo | |
| # Return the Gradio app configured for Modal | |
| return demo | |