update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import threading
|
| 4 |
import time
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def launch_streamlit():
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
def create_interface():
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
gr.HTML("""
|
| 20 |
-
<div style="text-align: center; padding:
|
| 21 |
-
<h1>๐ฎ๐ณ Corpus Collection Engine</h1>
|
| 22 |
-
<p>AI-powered platform for preserving Indian cultural heritage</p>
|
|
|
|
| 23 |
</div>
|
| 24 |
""")
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
|
|
|
| 31 |
demo = create_interface()
|
| 32 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Hugging Face Spaces Entry Point for Corpus Collection Engine
|
| 4 |
+
AI-powered platform for preserving Indian cultural heritage
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
import gradio as gr
|
| 8 |
import subprocess
|
| 9 |
import threading
|
| 10 |
import time
|
| 11 |
+
import sys
|
| 12 |
+
import os
|
| 13 |
|
| 14 |
def launch_streamlit():
|
| 15 |
+
"""Launch Streamlit app in background"""
|
| 16 |
+
try:
|
| 17 |
+
# Launch the Streamlit app from the corpus_collection_engine directory
|
| 18 |
+
subprocess.Popen([
|
| 19 |
+
sys.executable, "-m", "streamlit", "run",
|
| 20 |
+
"corpus_collection_engine/main.py",
|
| 21 |
+
"--server.port=7861",
|
| 22 |
+
"--server.address=0.0.0.0",
|
| 23 |
+
"--server.headless=true"
|
| 24 |
+
])
|
| 25 |
+
except Exception as e:
|
| 26 |
+
print(f"Error launching Streamlit: {e}")
|
| 27 |
|
| 28 |
def create_interface():
|
| 29 |
+
"""Create Gradio interface that embeds the Streamlit app"""
|
| 30 |
+
|
| 31 |
+
# Launch Streamlit in background
|
| 32 |
+
streamlit_thread = threading.Thread(target=launch_streamlit, daemon=True)
|
| 33 |
+
streamlit_thread.start()
|
| 34 |
|
| 35 |
+
# Wait for Streamlit to start
|
| 36 |
+
time.sleep(10)
|
| 37 |
+
|
| 38 |
+
# Create Gradio interface
|
| 39 |
+
with gr.Blocks(
|
| 40 |
+
title="๐ฎ๐ณ Corpus Collection Engine",
|
| 41 |
+
theme=gr.themes.Soft(),
|
| 42 |
+
css="""
|
| 43 |
+
.gradio-container {
|
| 44 |
+
max-width: 100% !important;
|
| 45 |
+
padding: 0 !important;
|
| 46 |
+
}
|
| 47 |
+
iframe {
|
| 48 |
+
border-radius: 10px !important;
|
| 49 |
+
}
|
| 50 |
+
"""
|
| 51 |
+
) as demo:
|
| 52 |
+
|
| 53 |
+
# Header
|
| 54 |
gr.HTML("""
|
| 55 |
+
<div style="text-align: center; padding: 25px; background: linear-gradient(135deg, #FF6B35, #F7931E); color: white; margin-bottom: 25px; border-radius: 15px; box-shadow: 0 4px 15px rgba(255,107,53,0.3);">
|
| 56 |
+
<h1 style="margin: 0; font-size: 2.8em; font-weight: bold;">๐ฎ๐ณ Corpus Collection Engine</h1>
|
| 57 |
+
<p style="margin: 15px 0 0 0; font-size: 1.3em; opacity: 0.95;">AI-powered platform for preserving Indian cultural heritage</p>
|
| 58 |
+
<p style="margin: 10px 0 0 0; font-size: 1em; opacity: 0.8;">No login required โข Start contributing immediately</p>
|
| 59 |
</div>
|
| 60 |
""")
|
| 61 |
|
| 62 |
+
# Main app iframe
|
| 63 |
+
gr.HTML("""
|
| 64 |
+
<div style="background: white; border-radius: 15px; overflow: hidden; box-shadow: 0 8px 25px rgba(0,0,0,0.1); margin-bottom: 25px;">
|
| 65 |
+
<iframe
|
| 66 |
+
src="http://localhost:7861"
|
| 67 |
+
width="100%"
|
| 68 |
+
height="850px"
|
| 69 |
+
frameborder="0"
|
| 70 |
+
style="border-radius: 15px;"
|
| 71 |
+
allow="camera; microphone; clipboard-write"
|
| 72 |
+
></iframe>
|
| 73 |
+
</div>
|
| 74 |
+
""")
|
| 75 |
|
| 76 |
+
# Features showcase
|
| 77 |
+
gr.HTML("""
|
| 78 |
+
<div style="background: linear-gradient(135deg, #f8f9fa, #e9ecef); padding: 25px; border-radius: 15px; margin-top: 20px;">
|
| 79 |
+
<h3 style="text-align: center; margin: 0 0 20px 0; color: #333; font-size: 1.5em;">๐ฏ Cultural Activities Available</h3>
|
| 80 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px;">
|
| 81 |
+
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
|
| 82 |
+
<div style="font-size: 3em; margin-bottom: 10px;">๐ญ</div>
|
| 83 |
+
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Meme Creator</h4>
|
| 84 |
+
<p style="margin: 0; color: #666; font-size: 0.9em;">Create culturally relevant memes in Indian languages</p>
|
| 85 |
+
</div>
|
| 86 |
+
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
|
| 87 |
+
<div style="font-size: 3em; margin-bottom: 10px;">๐</div>
|
| 88 |
+
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Recipe Collector</h4>
|
| 89 |
+
<p style="margin: 0; color: #666; font-size: 0.9em;">Share traditional family recipes with cultural context</p>
|
| 90 |
+
</div>
|
| 91 |
+
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
|
| 92 |
+
<div style="font-size: 3em; margin-bottom: 10px;">๐</div>
|
| 93 |
+
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Folklore Archive</h4>
|
| 94 |
+
<p style="margin: 0; color: #666; font-size: 0.9em;">Preserve stories, legends, and oral traditions</p>
|
| 95 |
+
</div>
|
| 96 |
+
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
|
| 97 |
+
<div style="font-size: 3em; margin-bottom: 10px;">๐๏ธ</div>
|
| 98 |
+
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Landmark Identifier</h4>
|
| 99 |
+
<p style="margin: 0; color: #666; font-size: 0.9em;">Document historical and cultural landmarks</p>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
|
| 103 |
+
<div style="text-align: center; margin-top: 25px; padding: 20px; background: rgba(255,107,53,0.1); border-radius: 10px;">
|
| 104 |
+
<h4 style="margin: 0 0 10px 0; color: #FF6B35;">๐ Platform Features</h4>
|
| 105 |
+
<p style="margin: 0; color: #555; line-height: 1.6;">
|
| 106 |
+
<strong>๐ 11 Indian Languages</strong> โข
|
| 107 |
+
<strong>๐ฑ Mobile Responsive</strong> โข
|
| 108 |
+
<strong>๐ Privacy-First Design</strong> โข
|
| 109 |
+
<strong>๐ Real-time Analytics</strong> โข
|
| 110 |
+
<strong>๐ Achievement System</strong> โข
|
| 111 |
+
<strong>โก Offline Support</strong>
|
| 112 |
+
</p>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
""")
|
| 116 |
+
|
| 117 |
+
# Footer
|
| 118 |
+
gr.HTML("""
|
| 119 |
+
<div style="text-align: center; padding: 20px; margin-top: 20px; color: #666; border-top: 1px solid #eee;">
|
| 120 |
+
<p style="margin: 0; font-size: 0.9em;">
|
| 121 |
+
Built with โค๏ธ for preserving Indian cultural heritage โข
|
| 122 |
+
<strong>Start contributing today!</strong>
|
| 123 |
+
</p>
|
| 124 |
+
</div>
|
| 125 |
+
""")
|
| 126 |
+
|
| 127 |
+
return demo
|
| 128 |
|
| 129 |
if __name__ == "__main__":
|
| 130 |
+
# Create and launch the Gradio interface
|
| 131 |
demo = create_interface()
|
| 132 |
+
demo.launch(
|
| 133 |
+
server_port=7860,
|
| 134 |
+
server_name="0.0.0.0",
|
| 135 |
+
share=False,
|
| 136 |
+
show_error=True,
|
| 137 |
+
show_api=False
|
| 138 |
+
)
|