paulcalzada commited on
Commit
21bcfa3
·
verified ·
1 Parent(s): b960f1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -49
app.py CHANGED
@@ -71,12 +71,12 @@ 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 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
  """)
@@ -120,7 +120,8 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
120
  fn=show_loading,
121
  inputs=[],
122
  outputs=[run_btn, loading_state],
123
- show_progress=False
 
124
  ).then(
125
  fn=generate_only,
126
  inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
@@ -128,7 +129,8 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
128
  ).then(
129
  fn=hide_loading,
130
  inputs=[],
131
- outputs=[run_btn, loading_state]
 
132
  )
133
 
134
  clear_btn.click(fn=lambda: "Ready", outputs=[])
@@ -171,20 +173,19 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
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
 
@@ -194,26 +195,26 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
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;
@@ -221,12 +222,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
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;
@@ -273,7 +268,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
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');
@@ -281,43 +275,20 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
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__":
 
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
  # Container for the logo to allow layered animations
77
  gr.HTML("""
78
  <div id="logo-container">
79
+ <img src="file=DeepV_logo.png" id="deepv-base-logo" alt="DeepV Logo">
80
  <div id="deep-part" class="logo-overlay"></div>
81
  </div>
82
  """)
 
120
  fn=show_loading,
121
  inputs=[],
122
  outputs=[run_btn, loading_state],
123
+ show_progress=False,
124
+ js="window.hopDeepAway()" # Call JS to start animation when button is clicked
125
  ).then(
126
  fn=generate_only,
127
  inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
 
129
  ).then(
130
  fn=hide_loading,
131
  inputs=[],
132
+ outputs=[run_btn, loading_state],
133
+ js="window.jumpDeepBackIn()" # Call JS to reset animation when generation finishes
134
  )
135
 
136
  clear_btn.click(fn=lambda: "Ready", outputs=[])
 
173
  /* Logo container for relative positioning of layers */
174
  #logo-container {
175
  position: relative;
176
+ width: 250px; /* Set a fixed size for the container */
177
+ height: 70px;
 
178
  display: flex;
179
  justify-content: center;
180
  align-items: center;
181
+ overflow: hidden;
182
  }
183
 
184
  #deepv-base-logo {
185
  position: absolute;
186
  width: 100%;
187
  height: 100%;
188
+ object-fit: contain;
189
  z-index: 1; /* Base logo layer */
190
  }
191
 
 
195
  left: 0;
196
  width: 100%;
197
  height: 100%;
198
+ /* CORRECTED: Use a URL that Gradio can resolve */
199
+ background-image: url('file=DeepV_logo.png');
200
  background-size: contain;
201
  background-repeat: no-repeat;
202
  background-position: center;
203
  z-index: 2; /* Layer on top for animation */
204
+
205
  /* Use clip-path to show only the "DEEP" blue part */
206
+ /* You may need to adjust these percentages based on your specific logo dimensions */
207
+ clip-path: inset(0% 40% 0% 0%);
 
208
  transform: translateY(0); /* Initial state */
209
  transition: transform 0.8s ease-in-out, opacity 0.8s ease-in-out;
210
  }
211
 
212
  /* Animation for DEEP part hopping away */
213
  .deep-hop-away {
214
+ transform: translateY(-150%) scale(0.8) !important;
215
  opacity: 0 !important;
216
  }
217
 
 
218
  #output-title {
219
  margin: 0;
220
  font-size: 1.2em;
 
222
  margin-left: 20px;
223
  }
224
 
 
 
 
 
 
 
225
  /* General UI element styling */
226
  #verilog-output > label > .label-wrap {
227
  position: relative;
 
268
  const deepPart = document.getElementById('deep-part');
269
 
270
  // Stage 1: DEEP hops away, V remains (triggered when generation starts)
 
271
  window.hopDeepAway = () => {
272
  if (deepPart) {
273
  deepPart.classList.add('deep-hop-away');
 
275
  };
276
 
277
  // Stage 2: DEEP letters jump back in (triggered when generation ends)
 
278
  window.jumpDeepBackIn = () => {
279
  if (deepPart) {
 
280
  deepPart.classList.remove('deep-hop-away');
281
+ // This line forces the browser to re-render, ensuring the animation resets
282
  void deepPart.offsetWidth;
283
  }
284
  };
285
 
286
+ // Call it once on load to ensure it's in place
287
+ window.jumpDeepBackIn();
 
 
 
288
  }
289
+ customLogoAnimation();
290
  """
291
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
 
293
 
294
  if __name__ == "__main__":