paulcalzada commited on
Commit
b960f1d
·
verified ·
1 Parent(s): 87774d4

Update app.py

Browse files

logo animation testing

Files changed (1) hide show
  1. app.py +94 -121
app.py CHANGED
@@ -71,19 +71,15 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
71
  )
72
 
73
  with gr.Column(scale=3):
74
- # --- DeepV Logo with CSS Background Image and animation ---
75
  with gr.Row(elem_id="logo-and-output-row"):
76
- gr.Markdown(
77
- """
78
- <div id="animated-deepv-logo">
79
- <span class="deepv-char" id="deepv-D">D</span>
80
- <span class="deepv-char" id="deepv-E1">E</span>
81
- <span class="deepv-char" id="deepv-E2">E</span>
82
- <span class="deepv-char" id="deepv-P">P</span>
83
- <span class="deepv-char" id="deepv-V">V</span>
84
  </div>
85
- """
86
- )
87
  gr.Markdown("**Output**", elem_id="output-title")
88
 
89
  with gr.Group():
@@ -157,13 +153,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
157
  demo.css = """
158
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
159
 
160
- /* Define CSS Variables for colors */
161
- :root {
162
- --deep-blue: #007bff; /* A nice bright blue */
163
- --v-orange: #ffa500; /* An orange for the V */
164
- --text-color: #333;
165
- }
166
-
167
  #main-title {
168
  font-family: 'Poppins', sans-serif;
169
  font-weight: 600;
@@ -176,71 +165,69 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
176
  align-items: center;
177
  justify-content: center;
178
  margin-bottom: 10px;
179
- height: 80px;
180
- position: relative;
181
  }
182
 
183
- /* Styling for the animated logo container */
184
- #animated-deepv-logo {
185
  position: relative;
186
- width: 150px;
187
- height: 70px;
 
188
  display: flex;
189
  justify-content: center;
190
  align-items: center;
191
- font-family: 'Poppins', sans-serif;
192
- font-weight: 800;
193
- font-size: 4em;
194
- line-height: 1;
195
- overflow: hidden;
196
- padding-right: 15px;
197
  }
198
 
199
- .deepv-char {
200
  position: absolute;
201
- opacity: 0;
202
- transition: all 0.3s ease-out;
203
- white-space: nowrap;
204
- }
205
-
206
- #deepv-V {
207
- color: var(--v-orange);
208
- font-size: 1.5em;
209
- opacity: 1;
210
- top: 50%;
211
- left: 50%;
212
- transform: translate(-50%, -50%);
213
- z-index: 1;
214
  }
215
 
216
- /* Positioning for DEEP letters relative to V */
217
- #deepv-D { top: 50%; left: 30%; color: var(--deep-blue); transform: translate(-50%, -50%); z-index: 2; }
218
- #deepv-E1 { top: 50%; left: 45%; color: var(--deep-blue); transform: translate(-50%, -50%); z-index: 2; }
219
- #deepv-E2 { top: 50%; left: 60%; color: var(--deep-blue); transform: translate(-50%, -50%); z-index: 2; }
220
- #deepv-P { top: 50%; left: 75%; color: var(--deep-blue); transform: translate(-50%, -50%); z-index: 2; }
221
-
222
- /* Animation Keyframes */
223
- @keyframes charAppear {
224
- 0% { opacity: 0; transform: translate(-50%, -100%) scale(0.5); }
225
- 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
226
- 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
 
 
 
 
 
 
227
  }
228
 
229
- @keyframes charHopAway {
230
- 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
231
- 50% { opacity: 1; transform: translate(-50%, -100%) scale(1.1); }
232
- 100% { opacity: 0; transform: translate(-50%, -200%) scale(0.5); }
233
  }
234
 
235
-
236
  #output-title {
237
  margin: 0;
238
  font-size: 1.2em;
239
  font-weight: bold;
240
  margin-left: 20px;
241
- animation: fadeInScale 1.5s ease-out forwards;
242
  }
243
 
 
 
 
 
 
 
 
244
  #verilog-output > label > .label-wrap {
245
  position: relative;
246
  }
@@ -276,75 +263,61 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
276
  }
277
  """
278
 
279
- # --- JavaScript to run on page load ---
280
  demo.load(
281
- fn=None,
282
- inputs=None,
283
- outputs=None,
284
  js="""
285
- () => {
286
- const chars = ['deepv-D', 'deepv-E1', 'deepv-E2', 'deepv-P'];
287
- const V_char = document.getElementById('deepv-V');
288
- let charIndex = 0;
289
-
290
- const animateLogo = () => {
291
- // Reset all DEEP characters
292
- chars.forEach(id => {
293
- const char = document.getElementById(id);
294
- if (char) {
295
- char.style.opacity = '0';
296
- char.style.transform = 'translate(-50%, -50%)';
297
- char.classList.remove('hop-away'); // Remove previous animation class
298
- }
299
- });
300
-
301
- // Animate V's position slightly
302
- if (V_char) {
303
- V_char.style.transform = 'translate(-50%, -50%) scale(1.1)'; // Slight scale up
304
- setTimeout(() => {
305
- V_char.style.transform = 'translate(-50%, -50%) scale(1)'; // Scale back down
306
- }, 500);
307
  }
 
308
 
309
-
310
- // Animate DEEP characters one by one
311
- charIndex = 0;
312
- const appearInterval = setInterval(() => {
313
- if (charIndex < chars.length) {
314
- const char = document.getElementById(chars[charIndex]);
315
- if (char) {
316
- char.style.opacity = '1';
317
- char.style.transform = 'translate(-50%, -50%)'; // Reset position
318
- char.style.animation = 'charAppear 0.5s ease-out forwards';
319
- }
320
- charIndex++;
321
- } else {
322
- clearInterval(appearInterval);
323
- // After all DEEP letters appear, wait a bit then make them hop away
324
- setTimeout(() => {
325
- let hopIndex = 0;
326
- const hopInterval = setInterval(() => {
327
- if (hopIndex < chars.length) {
328
- const char = document.getElementById(chars[hopIndex]);
329
- if (char) {
330
- char.style.animation = 'charHopAway 0.8s ease-in forwards';
331
- }
332
- hopIndex++;
333
- } else {
334
- clearInterval(hopInterval);
335
- }
336
- }, 150); // Delay between each letter hopping away
337
- }, 1000); // Delay before letters start hopping away
338
- }
339
- }, 200); // Delay between each letter appearing
340
  };
341
 
342
- // Run the animation every few seconds
343
- setInterval(animateLogo, 4000); // Total animation time ~3s, so repeat every 4s
344
- animateLogo(); // Run once immediately on load
 
 
345
  }
 
346
  """
347
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
 
349
 
350
  if __name__ == "__main__":
 
71
  )
72
 
73
  with gr.Column(scale=3):
74
+ # --- DeepV Logo and "Output" text (Correctly configured gr.Image) ---
75
  with gr.Row(elem_id="logo-and-output-row"):
76
+ # Container for the logo to allow layered animations
77
+ gr.HTML("""
78
+ <div id="logo-container">
79
+ <img src="DeepV_logo.png" id="deepv-base-logo" alt="DeepV Logo">
80
+ <div id="deep-part" class="logo-overlay"></div>
 
 
 
81
  </div>
82
+ """)
 
83
  gr.Markdown("**Output**", elem_id="output-title")
84
 
85
  with gr.Group():
 
153
  demo.css = """
154
  @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap');
155
 
 
 
 
 
 
 
 
156
  #main-title {
157
  font-family: 'Poppins', sans-serif;
158
  font-weight: 600;
 
165
  align-items: center;
166
  justify-content: center;
167
  margin-bottom: 10px;
168
+ height: 80px; /* Give space for animation */
 
169
  }
170
 
171
+ /* Logo container for relative positioning of layers */
172
+ #logo-container {
173
  position: relative;
174
+ width: 150px; /* Set desired width for the logo */
175
+ height: 70px; /* Set desired height for the logo */
176
+ overflow: hidden; /* Hide parts that move out */
177
  display: flex;
178
  justify-content: center;
179
  align-items: center;
180
+ animation: fadeInScale 1.5s ease-out forwards; /* Initial fade-in animation */
 
 
 
 
 
181
  }
182
 
183
+ #deepv-base-logo {
184
  position: absolute;
185
+ width: 100%;
186
+ height: 100%;
187
+ object-fit: contain; /* Ensures the image fits within the container */
188
+ z-index: 1; /* Base logo layer */
 
 
 
 
 
 
 
 
 
189
  }
190
 
191
+ #deep-part {
192
+ position: absolute;
193
+ top: 0;
194
+ left: 0;
195
+ width: 100%;
196
+ height: 100%;
197
+ background-image: url('DeepV_logo.png'); /* Use the same logo as background */
198
+ background-size: contain;
199
+ background-repeat: no-repeat;
200
+ background-position: center;
201
+ z-index: 2; /* Layer on top for animation */
202
+ /* Use clip-path to show only the "DEEP" blue part */
203
+ /* These values are highly dependent on the exact dimensions and layout of your logo */
204
+ /* You might need to adjust these percentages/pixels based on your logo's content area */
205
+ clip-path: inset(0% 40% 0% 0%); /* Example: covers left 60% of image */
206
+ transform: translateY(0); /* Initial state */
207
+ transition: transform 0.8s ease-in-out, opacity 0.8s ease-in-out;
208
  }
209
 
210
+ /* Animation for DEEP part hopping away */
211
+ .deep-hop-away {
212
+ transform: translateY(-150%) scale(0.8) !important; /* Move up and shrink */
213
+ opacity: 0 !important;
214
  }
215
 
216
+ /* Output Title Styling */
217
  #output-title {
218
  margin: 0;
219
  font-size: 1.2em;
220
  font-weight: bold;
221
  margin-left: 20px;
 
222
  }
223
 
224
+ /* Initial fade-in for the whole logo container */
225
+ @keyframes fadeInScale {
226
+ 0% { opacity: 0; transform: scale(0.8); }
227
+ 100% { opacity: 1; transform: scale(1); }
228
+ }
229
+
230
+ /* General UI element styling */
231
  #verilog-output > label > .label-wrap {
232
  position: relative;
233
  }
 
263
  }
264
  """
265
 
266
+ # --- JavaScript to trigger animations based on generation status ---
267
  demo.load(
268
+ None,
269
+ None,
270
+ None,
271
  js="""
272
+ function customLogoAnimation() {
273
+ const deepPart = document.getElementById('deep-part');
274
+
275
+ // Stage 1: DEEP hops away, V remains (triggered when generation starts)
276
+ // This function will be called by run_btn.click (before actual generation)
277
+ window.hopDeepAway = () => {
278
+ if (deepPart) {
279
+ deepPart.classList.add('deep-hop-away');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  }
281
+ };
282
 
283
+ // Stage 2: DEEP letters jump back in (triggered when generation ends)
284
+ // This function will be called by run_btn.click (after generation completes)
285
+ window.jumpDeepBackIn = () => {
286
+ if (deepPart) {
287
+ // Remove class to revert to original state
288
+ deepPart.classList.remove('deep-hop-away');
289
+ // Force reflow for re-animation if needed, though remove/add should work
290
+ void deepPart.offsetWidth;
291
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  };
293
 
294
+ // Initial state: ensure DEEP is visible
295
+ window.jumpDeepBackIn(); // Call it once on load to ensure it's in place
296
+
297
+ // IMPORTANT: Gradio's js event system needs functions defined globally
298
+ // or accessible through window. This is how the python side will call them.
299
  }
300
+ customLogoAnimation(); // Call the setup function immediately
301
  """
302
  )
303
+
304
+ # Modify the run_btn.click to trigger the JS animation functions
305
+ run_btn.click(
306
+ fn=show_loading,
307
+ inputs=[],
308
+ outputs=[run_btn, loading_state],
309
+ show_progress=False,
310
+ js="window.hopDeepAway()" # Call JS to start animation when button is clicked
311
+ ).then(
312
+ fn=generate_only,
313
+ inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
314
+ outputs=[out_code],
315
+ ).then(
316
+ fn=hide_loading,
317
+ inputs=[],
318
+ outputs=[run_btn, loading_state],
319
+ js="window.jumpDeepBackIn()" # Call JS to reset animation when generation finishes
320
+ )
321
 
322
 
323
  if __name__ == "__main__":