sreelekhaputta2 commited on
Commit
ff030c0
·
verified ·
1 Parent(s): f61efde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -62
app.py CHANGED
@@ -1,20 +1,7 @@
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"},
@@ -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
- # --- 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()
 
 
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=["."])