Spaces:
Sleeping
Sleeping
noumanjavaid
commited on
Update app.py
Browse files
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 |
-
|
25 |
-
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
26 |
}
|
|
|
27 |
.header {
|
28 |
-
background: #
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
34 |
-
margin-bottom: 2rem;
|
35 |
}
|
|
|
36 |
.logo {
|
37 |
-
|
38 |
-
|
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 |
-
|
52 |
-
margin: 0 auto;
|
53 |
-
padding: 0 2rem;
|
54 |
}
|
|
|
55 |
.main-content {
|
56 |
-
|
57 |
-
border-radius:
|
58 |
-
|
59 |
-
margin-bottom:
|
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:
|
74 |
-
height:
|
75 |
border: none;
|
76 |
}
|
|
|
77 |
.nav-grid {
|
78 |
display: grid;
|
79 |
-
grid-template-columns: repeat(auto-fit, minmax(
|
80 |
-
gap:
|
81 |
-
|
82 |
}
|
|
|
83 |
.nav-card {
|
84 |
-
background:
|
85 |
-
border:
|
86 |
-
border-radius:
|
87 |
-
padding:
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
}
|
|
|
90 |
.nav-card:hover {
|
91 |
-
transform: translateY(-5px);
|
92 |
-
box-shadow: 0 8px
|
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 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
margin: 0 !important;
|
119 |
-
padding: 0 !important;
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
|
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 |
-
|
140 |
-
|
141 |
-
|
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
|
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("
|
182 |
-
|
183 |
-
# Main content
|
184 |
with gr.Row(elem_classes=["container"]):
|
185 |
with gr.Column(elem_classes=["main-content"]):
|
186 |
-
gr.HTML(
|
187 |
-
|
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 |
-
|
|
|
207 |
</div>
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
with gr.Row(elem_classes=["nav-grid"]):
|
212 |
-
|
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 |
)
|