noumanjavaid commited on
Commit
7fa2fb1
Β·
verified Β·
1 Parent(s): 3cbb5d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +89 -147
app.py CHANGED
@@ -15,162 +15,99 @@ logger = logging.getLogger(__name__)
15
 
16
  # CSS Configuration
17
  css = """
18
- * {
19
- margin: 0;
20
- padding: 0;
21
- box-sizing: border-box;
22
- }
23
  body {
24
- background-color: #ffffff;
25
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
26
  }
 
27
  .header {
28
- background: #00000;
29
- border-bottom: 1px solid #e5e5e5;
30
- padding: 1.5rem 2rem;
31
- display: flex;
32
- align-items: center;
33
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
34
- margin-bottom: 2rem;
35
  }
 
36
  .logo {
37
- width: 100px;
38
- height: 45px;
39
- margin-right: 0px;
40
- transition: transform 0.3s ease;
41
- }
42
- .logo:hover {
43
- transform: scale(1.05);
44
- }
45
- .header-title {
46
- color: #000000;
47
- font-size: 24px;
48
- font-weight: 600;
49
  }
 
50
  .container {
51
- max-width: 1400px;
52
- margin: 0 auto;
53
- padding: 0 2rem;
54
  }
 
55
  .main-content {
56
- background: #00000;
57
- border-radius: 12px;
58
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
59
- margin-bottom: 2rem;
60
- overflow: hidden;
61
- border: 1px solid #e5e5e5;
62
  }
 
63
  .iframe-container {
 
64
  position: relative;
65
  width: 100%;
66
- height: 0;
67
- padding-bottom: 65%;
68
  }
 
69
  .iframe-container iframe {
70
  position: absolute;
71
  top: 0;
72
  left: 0;
73
- width: 1000px;
74
- height: 1000px;
75
  border: none;
76
  }
 
77
  .nav-grid {
78
  display: grid;
79
- grid-template-columns: repeat(auto-fit, minmax(1000px, 1fr));
80
- gap: 1.5rem;
81
- margin: 2rem 0;
82
  }
 
83
  .nav-card {
84
- background: #ffffff;
85
- border: 10px solid #e5e5e5;
86
- border-radius: 10px;
87
- padding: 1.5rem;
88
- transition: all 0.3s ease;
 
 
 
 
89
  }
 
90
  .nav-card:hover {
91
- transform: translateY(-5px);
92
- box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
93
- border-color: #000000;
94
- }
95
- .nav-card a {
96
- color: #000000;
97
- text-decoration: none;
98
- font-weight: 500;
99
- font-size: 1.1rem;
100
- display: flex;
101
- align-items: center;
102
- gap: 0.8rem;
103
- }
104
- .nav-card a::after {
105
- content: 'β†’';
106
- margin-left: auto;
107
- opacity: 0;
108
- transition: opacity 0.3s ease;
109
- }
110
- .nav-card:hover a::after {
111
- opacity: 1;
112
  }
113
- /* Hide Gradio elements */
114
- footer {
115
- display: none !important;
116
- }
117
- .gradio-container {
118
- margin: 0 !important;
119
- padding: 0 !important;
120
  }
121
- @media (max-width: 768px) {
122
- .nav-grid {
123
- grid-template-columns: 1fr;
124
- }
125
-
126
- .header {
127
- padding: 1rem;
128
- }
129
-
130
- .container {
131
- padding: 0 1rem;
132
- }
133
  }
 
134
  """
135
 
136
  # Navigation cards configuration
137
  NAVIGATION_CARDS = [
138
- {
139
- "icon": "πŸ”",
140
- "title": "DeepFake Detection",
141
- "url": "https://noumanjavaid-new-space.hf.space"
142
- },
143
- {
144
- "icon": "πŸ“„",
145
- "title": "Document Analysis",
146
- "url": "https://noumanjavaid-centurionv2.hf.space"
147
- },
148
- {
149
- "icon": "πŸŽ₯",
150
- "title": "Video Watermarking",
151
- "url": "https://noumanjavaid-watermark-demo-video.hf.space"
152
- },
153
- {
154
- "icon": "πŸ”",
155
- "title": "Image Authentication",
156
- "url": "https://noumanjavaid-centii.hf.space"
157
- }
158
  ]
159
 
160
- def create_navigation_cards():
161
- return "".join([
162
- f'''
163
- <div class="nav-card">
164
- <a href="{card['url']}" target="_blank" rel="noopener noreferrer">
165
- {card['icon']} {card['title']}
166
- </a>
167
- </div>
168
- ''' for card in NAVIGATION_CARDS
169
- ])
170
-
171
  def create_interface():
172
- with gr.Blocks(css=css, title="Centurion Analysis Platform") as demo:
173
- # Header
174
  with gr.Row(elem_classes=["header"]):
175
  gr.Image(
176
  "https://raw.githubusercontent.com/noumanjavaid96/ai-as-an-api/refs/heads/master/image%20(39).png",
@@ -178,44 +115,49 @@ def create_interface():
178
  show_label=False,
179
  container=False
180
  )
181
- gr.Markdown("## Centurion ")
182
-
183
- # Main content
184
  with gr.Row(elem_classes=["container"]):
185
  with gr.Column(elem_classes=["main-content"]):
186
- gr.HTML('''
187
- .iframe-container {
188
- position: relative;
189
- width: 100%;
190
- height: 100;
191
- padding-bottom: 53.33%; /* 450 / 850 * 100 */
192
- }
193
- .iframe-container iframe {
194
- position: absolute;
195
- top: 0;
196
- left: 0;
197
- width: 100%;
198
- height: 100%;
199
- border: 10px;
200
- }
201
-
202
  <div class="iframe-container">
203
- <iframe
204
- src="https://noumanjavaid-centii.hf.space"
205
  title="Centurion Main Platform"
206
- ></iframe>
 
207
  </div>
208
- ''')
209
-
210
- # Navigation grid
211
  with gr.Row(elem_classes=["nav-grid"]):
212
- gr.HTML(create_navigation_cards())
213
-
 
 
 
 
 
 
214
  return demo
215
 
 
 
 
 
 
 
 
 
 
 
216
  if __name__ == "__main__":
217
  demo = create_interface()
 
 
218
  demo.launch(
219
  show_error=False,
220
  show_api=False,
 
221
  )
 
15
 
16
  # CSS Configuration
17
  css = """
18
+ /* General styles */
 
 
 
 
19
  body {
20
+ font-family: sans-serif; /* Use a modern font */
 
21
  }
22
+
23
  .header {
24
+ background-color: #f0f0f0;
25
+ padding: 15px 25px;
26
+ display: flex;
27
+ align-items: center;
28
+ border-bottom: 2px solid #ddd;
 
 
29
  }
30
+
31
  .logo {
32
+ max-height: 70px;
33
+ margin-right: 25px;
 
 
 
 
 
 
 
 
 
 
34
  }
35
+
36
  .container {
37
+ padding: 25px;
 
 
38
  }
39
+
40
  .main-content {
41
+ border: 1px solid #ddd;
42
+ border-radius: 8px;
43
+ overflow: hidden;
44
+ margin-bottom: 20px; /* Add some spacing below the iframe */
 
 
45
  }
46
+
47
  .iframe-container {
48
+ padding-bottom: 56.25%; /* Maintain aspect ratio */
49
  position: relative;
50
  width: 100%;
51
+ height: 0;
 
52
  }
53
+
54
  .iframe-container iframe {
55
  position: absolute;
56
  top: 0;
57
  left: 0;
58
+ width: 100%;
59
+ height: 100%;
60
  border: none;
61
  }
62
+
63
  .nav-grid {
64
  display: grid;
65
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Adjusted minmax */
66
+ gap: 20px;
67
+ padding: 0 25px; /* Match container padding */
68
  }
69
+
70
  .nav-card {
71
+ background-color: white;
72
+ border: 1px solid #ddd;
73
+ border-radius: 8px;
74
+ padding: 25px; /* Increased padding */
75
+ display: flex;
76
+ align-items: center;
77
+ text-decoration: none; /* Remove underline from links */
78
+ color: #333; /* Darker text color */
79
+ transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out; /* Combined transitions */
80
  }
81
+
82
  .nav-card:hover {
83
+ transform: translateY(-5px);
84
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
+
87
+ .nav-card i {
88
+ font-size: 2.5em; /* Larger icons */
89
+ margin-right: 15px;
90
+ color: #4285f4; /* Google blue for icons (optional) */
 
 
91
  }
92
+
93
+ .nav-card span {
94
+ font-size: 1.4em; /* Larger text */
95
+ font-weight: 500;
 
 
 
 
 
 
 
 
96
  }
97
+
98
  """
99
 
100
  # Navigation cards configuration
101
  NAVIGATION_CARDS = [
102
+ {"icon": "πŸ”", "title": "DeepFake Detection", "url": "https://noumanjavaid-new-space.hf.space"},
103
+ {"icon": "πŸ“„", "title": "Document Analysis", "url": "https://noumanjavaid-centurionv2.hf.space"},
104
+ {"icon": "πŸŽ₯", "title": "Video Watermarking", "url": "https://noumanjavaid-watermark-demo-video.hf.space"},
105
+ {"icon": "πŸ”", "title": "Image Authentication", "url": "https://noumanjavaid-centii.hf.space"},
106
+ {"icon": "πŸ–ΌοΈ", "title": "Image Comparison", "url": "https://another-example.com"} # Added example
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  ]
108
 
 
 
 
 
 
 
 
 
 
 
 
109
  def create_interface():
110
+ with gr.Blocks(css=css, title="Centurion") as demo:
 
111
  with gr.Row(elem_classes=["header"]):
112
  gr.Image(
113
  "https://raw.githubusercontent.com/noumanjavaid96/ai-as-an-api/refs/heads/master/image%20(39).png",
 
115
  show_label=False,
116
  container=False
117
  )
118
+ gr.Markdown("<h2 style='margin:0;'>Centurion</h2>") # Improved title style
119
+
 
120
  with gr.Row(elem_classes=["container"]):
121
  with gr.Column(elem_classes=["main-content"]):
122
+ gr.HTML(
123
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  <div class="iframe-container">
125
+ <iframe
126
+ src="https://noumanjavaid-centii.hf.space" /* Set initial iframe URL */
127
  title="Centurion Main Platform"
128
+ id="main-iframe" /* Add id for targeting with JavaScript */
129
+ ></iframe>
130
  </div>
131
+ """
132
+ ) # Close HTML string properly
133
+
134
  with gr.Row(elem_classes=["nav-grid"]):
135
+ for card in NAVIGATION_CARDS:
136
+ gr.HTML(f"""
137
+ <a href="{card['url']}" onclick="updateIframe('{card['url']}'); return false;" class="nav-card"> {/* Add return false */}
138
+ <i>{card['icon']}</i> <span>{card['title']}</span>
139
+ </a>
140
+ """)
141
+
142
+
143
  return demo
144
 
145
+
146
+
147
+ # JavaScript function to update iframe source
148
+
149
+ js = """
150
+ function updateIframe(url) {
151
+ document.getElementById('main-iframe').src = url;
152
+ }
153
+ """
154
+
155
  if __name__ == "__main__":
156
  demo = create_interface()
157
+ demo.launch(show_error=False, show_api=False, _js=js)
158
+
159
  demo.launch(
160
  show_error=False,
161
  show_api=False,
162
+ _js=js # Include JavaScript for updating the iframe
163
  )