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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -63
app.py CHANGED
@@ -1,113 +1,104 @@
1
  import gradio as gr
 
2
  import os
3
 
4
- # --- 1. DATA CONFIGURATION ---
 
 
 
 
 
 
 
 
 
 
 
 
5
  projects = [
6
- {"name": "Idealyze", "desc": "AI-powered content optimization platform", "skills": ["NLP", "Transformers", "FastAPI"], "live": "https://huggingface.co/spaces/sreelekhaputta2/Idealyze", "video": "Idealyze.mp4"},
7
- {"name": "DivineLoop", "desc": "Real-time audio-visual looping generator", "skills": ["Audio Processing", "Computer Vision", "WebRTC"], "live": "https://huggingface.co/spaces/sreelekhaputta2/DivineLoop", "video": "Divineloop.mp4"},
8
- {"name": "GenDoc_AI", "desc": "Intelligent PDF document generation", "skills": ["LLMs", "PDF Generation", "LangChain"], "live": "https://huggingface.co/spaces/sreelekhaputta2/GenDoc_AI", "video": "GendocAI.mp4"},
9
- {"name": "LinkShield", "desc": "Advanced URL security threat detection", "skills": ["Cybersecurity", "API Integration", "FastAPI"], "live": "https://huggingface.co/spaces/sreelekhaputta2/LinkShield", "video": "Linkshield.mp4"},
10
- {"name": "Chatbot", "desc": "Multi-modal conversational AI with memory", "skills": ["LLMs", "RAG", "Vector DB"], "live": "https://huggingface.co/spaces/sreelekhaputta2/Chatbot", "video": "Wiseverse.mp4"},
11
- {"name": "AvatarVerse", "desc": "Photorealistic AI avatar generator", "skills": ["Stable Diffusion", "ControlNet", "GANs"], "live": "https://huggingface.co/spaces/sreelekhaputta2/AvatarVerse", "video": "Avatarverse.mp4"}
12
  ]
13
 
14
- # --- 2. CSS STYLING ---
15
  css = """
16
- /* Make the Gradio background transparent */
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
- /* Background Video Styling */
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
- .video-overlay {
44
- position: absolute;
45
  top: 0;
46
  left: 0;
47
  width: 100%;
48
  height: 100%;
49
- background: linear-gradient(rgba(10, 10, 30, 0.8), rgba(20, 10, 50, 0.8));
50
- z-index: -5;
51
  }
52
 
53
  .glass-card {
54
- background: rgba(255, 255, 255, 0.07) !important;
55
- backdrop-filter: blur(15px) !important;
56
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
57
  border-radius: 20px !important;
58
- padding: 25px !important;
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
- font-weight: bold !important;
74
- padding: 12px 24px !important;
75
  text-decoration: none !important;
76
  display: inline-block !important;
77
- margin: 10px 0 !important;
 
78
  }
79
  """
80
 
81
- # --- 3. GRADIO INTERFACE ---
82
- # Note: allowed_paths is crucial for Hugging Face to let the browser access local files
83
- with gr.Blocks(css=css, theme=gr.themes.Soft(), delete_cache=(60, 60)) as demo:
84
-
85
- # Background Video HTML
86
- # We use /file= to tell Gradio to serve the local file
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 class="video-overlay"></div>
93
- </div>
94
- """)
 
 
95
 
96
- with gr.Column(elem_classes="center-content"):
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 center-content"):
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=300, interactive=False)
110
 
111
- # --- 4. LAUNCH ---
112
- # IMPORTANT: allowed_paths allows the app to serve the .mp4 files correctly
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()