Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,113 +1,104 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
# --- 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
projects = [
|
| 6 |
-
{"name": "Idealyze", "desc": "AI-powered content optimization
|
| 7 |
-
{"name": "DivineLoop", "desc": "
|
| 8 |
-
{"name": "GenDoc_AI", "desc": "Intelligent PDF
|
| 9 |
-
{"name": "LinkShield", "desc": "
|
| 10 |
-
{"name": "Chatbot", "desc": "Multi-modal
|
| 11 |
-
{"name": "AvatarVerse", "desc": "Photorealistic AI
|
| 12 |
]
|
| 13 |
|
| 14 |
-
# ---
|
| 15 |
css = """
|
| 16 |
-
/* Make the Gradio
|
| 17 |
-
.gradio-container {
|
| 18 |
-
background: transparent !important;
|
| 19 |
-
}
|
| 20 |
-
|
| 21 |
-
/* Ensure the main container doesn't have a white background */
|
| 22 |
-
#root, .main, .gradio-container-5-4-1 {
|
| 23 |
background: transparent !important;
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
#bg-video-container {
|
| 28 |
position: fixed;
|
| 29 |
top: 0;
|
| 30 |
left: 0;
|
| 31 |
-
width: 100vw;
|
| 32 |
-
height: 100vh;
|
| 33 |
-
z-index: -10;
|
| 34 |
-
overflow: hidden;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
#bg-video-container video {
|
| 38 |
width: 100%;
|
| 39 |
height: 100%;
|
| 40 |
object-fit: cover;
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
-
|
| 44 |
-
position:
|
| 45 |
top: 0;
|
| 46 |
left: 0;
|
| 47 |
width: 100%;
|
| 48 |
height: 100%;
|
| 49 |
-
background: linear-gradient(rgba(10,
|
| 50 |
-
z-index: -
|
| 51 |
}
|
| 52 |
|
| 53 |
.glass-card {
|
| 54 |
-
background: rgba(255, 255, 255, 0.
|
| 55 |
-
backdrop-filter: blur(
|
| 56 |
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 57 |
border-radius: 20px !important;
|
| 58 |
-
padding:
|
| 59 |
color: white !important;
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
.center-content {
|
| 63 |
-
display: flex !important;
|
| 64 |
-
flex-direction: column !important;
|
| 65 |
-
align-items: center !important;
|
| 66 |
-
text-align: center !important;
|
| 67 |
}
|
| 68 |
|
| 69 |
.demo-btn {
|
| 70 |
background: linear-gradient(135deg, #6366f1, #a855f7) !important;
|
| 71 |
-
border-radius: 12px !important;
|
| 72 |
color: white !important;
|
| 73 |
-
|
| 74 |
-
|
| 75 |
text-decoration: none !important;
|
| 76 |
display: inline-block !important;
|
| 77 |
-
|
|
|
|
| 78 |
}
|
| 79 |
"""
|
| 80 |
|
| 81 |
-
# ---
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
gr.HTML("""
|
| 88 |
-
<div id="bg-video-container">
|
| 89 |
-
<video autoplay muted loop playsinline>
|
| 90 |
-
<source src="file=bg.mp4" type="video/mp4">
|
| 91 |
</video>
|
| 92 |
-
<div
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
|
| 97 |
-
gr.Markdown("# ✨ **AI/ML Portfolio**", elem_classes="glass-card")
|
| 98 |
|
| 99 |
with gr.Tabs():
|
| 100 |
for proj in projects:
|
| 101 |
with gr.TabItem(proj["name"]):
|
| 102 |
-
with gr.Column(elem_classes="glass-card
|
| 103 |
gr.Markdown(f"## {proj['name']}")
|
| 104 |
gr.Markdown(proj['desc'])
|
| 105 |
-
|
| 106 |
gr.HTML(f'<a href="{proj["live"]}" target="_blank" class="demo-btn">🎮 Live Demo</a>')
|
| 107 |
|
| 108 |
if os.path.exists(proj["video"]):
|
| 109 |
-
gr.Video(value=proj["video"], height=
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
demo.launch(allowed_paths=["."])
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import base64
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# --- 1. ENCODE VIDEO FUNCTION ---
|
| 6 |
+
def get_base64_video(file_path):
|
| 7 |
+
# This looks for bg.mp4 in the same folder as app.py
|
| 8 |
+
if os.path.exists(file_path):
|
| 9 |
+
with open(file_path, "rb") as f:
|
| 10 |
+
data = f.read()
|
| 11 |
+
return base64.b64encode(data).decode()
|
| 12 |
+
return None
|
| 13 |
+
|
| 14 |
+
# Load the video from the root path
|
| 15 |
+
bg_video_base64 = get_base64_video("bg.mp4")
|
| 16 |
+
|
| 17 |
+
# --- 2. DATA ---
|
| 18 |
projects = [
|
| 19 |
+
{"name": "Idealyze", "desc": "AI-powered content optimization", "live": "https://huggingface.co/spaces/sreelekhaputta2/Idealyze", "video": "Idealyze.mp4"},
|
| 20 |
+
{"name": "DivineLoop", "desc": "Audio-visual looping generator", "live": "https://huggingface.co/spaces/sreelekhaputta2/DivineLoop", "video": "Divineloop.mp4"},
|
| 21 |
+
{"name": "GenDoc_AI", "desc": "Intelligent PDF generation", "live": "https://huggingface.co/spaces/sreelekhaputta2/GenDoc_AI", "video": "GendocAI.mp4"},
|
| 22 |
+
{"name": "LinkShield", "desc": "URL security detection", "live": "https://huggingface.co/spaces/sreelekhaputta2/LinkShield", "video": "Linkshield.mp4"},
|
| 23 |
+
{"name": "Chatbot", "desc": "Multi-modal AI with memory", "live": "https://huggingface.co/spaces/sreelekhaputta2/Chatbot", "video": "Wiseverse.mp4"},
|
| 24 |
+
{"name": "AvatarVerse", "desc": "Photorealistic AI avatars", "live": "https://huggingface.co/spaces/sreelekhaputta2/AvatarVerse", "video": "Avatarverse.mp4"}
|
| 25 |
]
|
| 26 |
|
| 27 |
+
# --- 3. CSS (Modified for HF Iframe) ---
|
| 28 |
css = """
|
| 29 |
+
/* Make the Gradio UI transparent to see the video */
|
| 30 |
+
.gradio-container, .main, #root, .tabs, .tabitem {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
background: transparent !important;
|
| 32 |
+
border: none !important;
|
| 33 |
}
|
| 34 |
|
| 35 |
+
#video-bg {
|
|
|
|
| 36 |
position: fixed;
|
| 37 |
top: 0;
|
| 38 |
left: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
width: 100%;
|
| 40 |
height: 100%;
|
| 41 |
object-fit: cover;
|
| 42 |
+
z-index: -100;
|
| 43 |
}
|
| 44 |
|
| 45 |
+
#overlay {
|
| 46 |
+
position: fixed;
|
| 47 |
top: 0;
|
| 48 |
left: 0;
|
| 49 |
width: 100%;
|
| 50 |
height: 100%;
|
| 51 |
+
background: linear-gradient(135deg, rgba(10,10,30,0.85), rgba(40,20,80,0.85));
|
| 52 |
+
z-index: -90;
|
| 53 |
}
|
| 54 |
|
| 55 |
.glass-card {
|
| 56 |
+
background: rgba(255, 255, 255, 0.05) !important;
|
| 57 |
+
backdrop-filter: blur(20px) !important;
|
| 58 |
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 59 |
border-radius: 20px !important;
|
| 60 |
+
padding: 30px !important;
|
| 61 |
color: white !important;
|
| 62 |
+
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
.demo-btn {
|
| 66 |
background: linear-gradient(135deg, #6366f1, #a855f7) !important;
|
|
|
|
| 67 |
color: white !important;
|
| 68 |
+
padding: 12px 28px !important;
|
| 69 |
+
border-radius: 12px !important;
|
| 70 |
text-decoration: none !important;
|
| 71 |
display: inline-block !important;
|
| 72 |
+
font-weight: bold !important;
|
| 73 |
+
margin: 15px 0 !important;
|
| 74 |
}
|
| 75 |
"""
|
| 76 |
|
| 77 |
+
# --- 4. INTERFACE ---
|
| 78 |
+
with gr.Blocks(css=css) as demo:
|
| 79 |
+
if bg_video_base64:
|
| 80 |
+
gr.HTML(f"""
|
| 81 |
+
<video autoplay muted loop playsinline id="video-bg">
|
| 82 |
+
<source src="data:video/mp4;base64,{bg_video_base64}" type="video/mp4">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
</video>
|
| 84 |
+
<div id="overlay"></div>
|
| 85 |
+
""")
|
| 86 |
+
else:
|
| 87 |
+
# Debug message if path is wrong
|
| 88 |
+
gr.Markdown("### ❌ Error: `bg.mp4` not found in root directory.")
|
| 89 |
|
| 90 |
+
gr.Markdown("# ✨ AI/ML Portfolio", elem_classes="glass-card")
|
|
|
|
| 91 |
|
| 92 |
with gr.Tabs():
|
| 93 |
for proj in projects:
|
| 94 |
with gr.TabItem(proj["name"]):
|
| 95 |
+
with gr.Column(elem_classes="glass-card"):
|
| 96 |
gr.Markdown(f"## {proj['name']}")
|
| 97 |
gr.Markdown(proj['desc'])
|
|
|
|
| 98 |
gr.HTML(f'<a href="{proj["live"]}" target="_blank" class="demo-btn">🎮 Live Demo</a>')
|
| 99 |
|
| 100 |
if os.path.exists(proj["video"]):
|
| 101 |
+
gr.Video(value=proj["video"], height=320, interactive=False)
|
| 102 |
|
| 103 |
+
if __name__ == "__main__":
|
| 104 |
+
demo.launch()
|
|
|