Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import base64
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
# --- 1.
|
| 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"},
|
|
@@ -24,81 +11,77 @@ projects = [
|
|
| 24 |
{"name": "AvatarVerse", "desc": "Photorealistic AI avatars", "live": "https://huggingface.co/spaces/sreelekhaputta2/AvatarVerse", "video": "Avatarverse.mp4"}
|
| 25 |
]
|
| 26 |
|
| 27 |
-
# ---
|
|
|
|
| 28 |
css = """
|
| 29 |
-
|
| 30 |
-
|
| 31 |
background: transparent !important;
|
| 32 |
border: none !important;
|
| 33 |
}
|
| 34 |
|
| 35 |
-
#
|
| 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 |
-
|
| 46 |
position: fixed;
|
| 47 |
top: 0;
|
| 48 |
left: 0;
|
| 49 |
width: 100%;
|
| 50 |
height: 100%;
|
| 51 |
-
background:
|
| 52 |
z-index: -90;
|
| 53 |
}
|
| 54 |
|
| 55 |
.glass-card {
|
| 56 |
-
background: rgba(255, 255, 255, 0.
|
| 57 |
-
backdrop-filter: blur(
|
| 58 |
-
border: 1px solid rgba(255, 255, 255, 0.
|
| 59 |
-
border-radius: 20px
|
| 60 |
-
padding:
|
| 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 |
-
# ---
|
| 78 |
-
with gr.Blocks(css=css) as demo:
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
</video>
|
| 84 |
-
<div
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
# Debug message if path is wrong
|
| 88 |
-
gr.Markdown("### ❌ Error: `bg.mp4` not found in root directory.")
|
| 89 |
|
| 90 |
-
gr.
|
|
|
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# --- 1. DATA ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
projects = [
|
| 6 |
{"name": "Idealyze", "desc": "AI-powered content optimization", "live": "https://huggingface.co/spaces/sreelekhaputta2/Idealyze", "video": "Idealyze.mp4"},
|
| 7 |
{"name": "DivineLoop", "desc": "Audio-visual looping generator", "live": "https://huggingface.co/spaces/sreelekhaputta2/DivineLoop", "video": "Divineloop.mp4"},
|
|
|
|
| 11 |
{"name": "AvatarVerse", "desc": "Photorealistic AI avatars", "live": "https://huggingface.co/spaces/sreelekhaputta2/AvatarVerse", "video": "Avatarverse.mp4"}
|
| 12 |
]
|
| 13 |
|
| 14 |
+
# --- 2. THE NUCLEAR CSS OPTION ---
|
| 15 |
+
# This forces EVERYTHING in Gradio to be transparent
|
| 16 |
css = """
|
| 17 |
+
body, .gradio-container, .main, #root, .flex-col, .tabs, .tabitem, footer {
|
| 18 |
+
background-color: transparent !important;
|
| 19 |
background: transparent !important;
|
| 20 |
border: none !important;
|
| 21 |
}
|
| 22 |
|
| 23 |
+
#bg-container {
|
| 24 |
position: fixed;
|
| 25 |
top: 0;
|
| 26 |
left: 0;
|
| 27 |
+
width: 100vw;
|
| 28 |
+
height: 100vh;
|
| 29 |
+
z-index: -100;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
video#bg-video {
|
| 33 |
width: 100%;
|
| 34 |
height: 100%;
|
| 35 |
object-fit: cover;
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
+
.overlay {
|
| 39 |
position: fixed;
|
| 40 |
top: 0;
|
| 41 |
left: 0;
|
| 42 |
width: 100%;
|
| 43 |
height: 100%;
|
| 44 |
+
background: rgba(0, 0, 0, 0.65); /* Darken for readability */
|
| 45 |
z-index: -90;
|
| 46 |
}
|
| 47 |
|
| 48 |
.glass-card {
|
| 49 |
+
background: rgba(255, 255, 255, 0.1) !important;
|
| 50 |
+
backdrop-filter: blur(15px);
|
| 51 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 52 |
+
border-radius: 20px;
|
| 53 |
+
padding: 20px;
|
| 54 |
color: white !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
"""
|
| 57 |
|
| 58 |
+
# --- 3. INTERFACE ---
|
| 59 |
+
with gr.Blocks(css=css, theme=gr.themes.Default()) as demo:
|
| 60 |
+
|
| 61 |
+
# Using the standard /file= syntax which is faster than Base64
|
| 62 |
+
gr.HTML("""
|
| 63 |
+
<div id="bg-container">
|
| 64 |
+
<video autoplay muted loop playsinline id="bg-video">
|
| 65 |
+
<source src="file/bg.mp4" type="video/mp4">
|
| 66 |
</video>
|
| 67 |
+
<div class="overlay"></div>
|
| 68 |
+
</div>
|
| 69 |
+
""")
|
|
|
|
|
|
|
| 70 |
|
| 71 |
+
with gr.Column():
|
| 72 |
+
gr.Markdown("# ✨ AI/ML Portfolio", elem_classes="glass-card")
|
| 73 |
|
| 74 |
+
with gr.Tabs():
|
| 75 |
+
for proj in projects:
|
| 76 |
+
with gr.TabItem(proj["name"]):
|
| 77 |
+
with gr.Column(elem_classes="glass-card"):
|
| 78 |
+
gr.Markdown(f"## {proj['name']}")
|
| 79 |
+
gr.Markdown(proj['desc'])
|
| 80 |
+
gr.HTML(f'<a href="{proj["live"]}" target="_blank" style="color: cyan;">🎮 Live Demo</a>')
|
| 81 |
+
|
| 82 |
+
if os.path.exists(proj["video"]):
|
| 83 |
+
gr.Video(value=proj["video"], height=300)
|
| 84 |
|
| 85 |
+
# --- 4. LAUNCH ---
|
| 86 |
+
# allowed_paths is KEY. It tells Gradio it's allowed to serve these files.
|
| 87 |
+
demo.launch(allowed_paths=["."])
|