paulcalzada commited on
Commit
c9f21d4
·
verified ·
1 Parent(s): c8a96f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -96
app.py CHANGED
@@ -73,24 +73,18 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
73
  with gr.Column(scale=3):
74
  # --- DeepV Logo and "Output" text ---
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
- """)
83
  gr.Markdown("**Output**", elem_id="output-title")
 
 
 
 
 
 
 
 
84
 
85
- with gr.Group():
86
- out_code = gr.Textbox(
87
- label="Generated Verilog",
88
- lines=28,
89
- interactive=False,
90
- placeholder="// Your Verilog code will appear here",
91
- elem_id="verilog-output"
92
- )
93
- copy_button = gr.Button("📋", variant="secondary", elem_id="copy-button")
94
 
95
  with gr.Row():
96
  clear_btn = gr.ClearButton(
@@ -110,43 +104,25 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
110
  def copy_to_clipboard_fn(text):
111
  return text
112
 
113
- def show_loading():
114
  return [gr.update(visible=False), gr.update(visible=True)]
115
 
116
- def hide_loading():
117
  return [gr.update(visible=True), gr.update(visible=False)]
118
 
119
  run_btn.click(
120
- fn=show_loading,
121
  inputs=[],
122
  outputs=[run_btn, loading_state],
123
  show_progress=False,
124
- js="""
125
- (e) => {
126
- var deepPart = document.getElementById('deep-part');
127
- if (deepPart) {
128
- deepPart.classList.add('deep-hop-away');
129
- }
130
- }
131
- """ # Call JS to start animation when button is clicked
132
  ).then(
133
  fn=generate_only,
134
  inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
135
  outputs=[out_code],
136
  ).then(
137
- fn=hide_loading,
138
  inputs=[],
139
  outputs=[run_btn, loading_state],
140
- js="""
141
- (e) => {
142
- var deepPart = document.getElementById('deep-part');
143
- if (deepPart) {
144
- deepPart.classList.remove('deep-hop-away');
145
- // This line forces the browser to re-render, ensuring the animation resets
146
- void deepPart.offsetWidth;
147
- }
148
- }
149
- """ # Call JS to reset animation when generation finishes
150
  )
151
 
152
  clear_btn.click(fn=lambda: "Ready", outputs=[])
@@ -158,13 +134,12 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
158
  outputs=[],
159
  js="""
160
  (text) => {
161
- (function(el) {
162
- el.value = text;
163
- document.body.appendChild(el);
164
- el.select();
165
- document.execCommand('copy');
166
- document.body.removeChild(el);
167
- })(document.createElement('textarea'));
168
  }
169
  """
170
  )
@@ -184,52 +159,14 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
184
  align-items: center;
185
  justify-content: center;
186
  margin-bottom: 10px;
187
- height: 80px; /* Give space for animation */
188
- }
189
-
190
- /* Logo container for relative positioning of layers */
191
- #logo-container {
192
- position: relative;
193
- width: 250px; /* Set a fixed size for the container */
194
- height: 70px;
195
- display: flex;
196
- justify-content: center;
197
- align-items: center;
198
- overflow: hidden;
199
- }
200
-
201
- #deepv-base-logo {
202
- position: absolute;
203
- width: 100%;
204
- height: 100%;
205
- object-fit: contain;
206
- z-index: 1; /* Base logo layer */
207
  }
208
-
209
- #deep-part {
210
- position: absolute;
211
- top: 0;
212
- left: 0;
213
- width: 100%;
214
- height: 100%;
215
- /* CORRECTED: Use a URL that Gradio can resolve */
216
- background-image: url('file=DeepV_logo.png');
217
- background-size: contain;
218
- background-repeat: no-repeat;
219
- background-position: center;
220
- z-index: 2; /* Layer on top for animation */
221
-
222
- /* Use clip-path to show only the "DEEP" blue part */
223
- /* You may need to adjust these percentages based on your specific logo dimensions */
224
- clip-path: inset(0% 40% 0% 0%);
225
- transform: translateY(0); /* Initial state */
226
- transition: transform 0.8s ease-in-out, opacity 0.8s ease-in-out;
227
- }
228
-
229
- /* Animation for DEEP part hopping away */
230
- .deep-hop-away {
231
- transform: translateY(-150%) scale(0.8) !important;
232
- opacity: 0 !important;
233
  }
234
 
235
  #output-title {
@@ -238,22 +175,24 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
238
  font-weight: bold;
239
  margin-left: 20px;
240
  }
241
-
242
- /* General UI element styling */
243
- #verilog-output > label > .label-wrap {
244
  position: relative;
245
  }
246
-
247
  #copy-button {
248
  position: absolute;
249
- top: 20px;
250
- right: 10px;
251
  z-index: 1000;
252
  background-color: #F0F0F0;
253
  color: #333;
254
  border-radius: 5px;
255
  border: none;
256
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
 
 
 
257
  }
258
 
259
  #loading-state {
 
73
  with gr.Column(scale=3):
74
  # --- DeepV Logo and "Output" text ---
75
  with gr.Row(elem_id="logo-and-output-row"):
76
+ gr.Image("DeepV_logo.png", width=250, height=70, show_label=False, elem_id="deepv-logo")
 
 
 
 
 
 
77
  gr.Markdown("**Output**", elem_id="output-title")
78
+
79
+ out_code = gr.Textbox(
80
+ label="Generated Verilog",
81
+ lines=28,
82
+ interactive=False,
83
+ placeholder="// Your Verilog code will appear here",
84
+ elem_id="verilog-output"
85
+ )
86
 
87
+ copy_button = gr.Button("📋", variant="secondary", elem_id="copy-button")
 
 
 
 
 
 
 
 
88
 
89
  with gr.Row():
90
  clear_btn = gr.ClearButton(
 
104
  def copy_to_clipboard_fn(text):
105
  return text
106
 
107
+ def show_loading_no_anim():
108
  return [gr.update(visible=False), gr.update(visible=True)]
109
 
110
+ def hide_loading_no_anim():
111
  return [gr.update(visible=True), gr.update(visible=False)]
112
 
113
  run_btn.click(
114
+ fn=show_loading_no_anim,
115
  inputs=[],
116
  outputs=[run_btn, loading_state],
117
  show_progress=False,
 
 
 
 
 
 
 
 
118
  ).then(
119
  fn=generate_only,
120
  inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
121
  outputs=[out_code],
122
  ).then(
123
+ fn=hide_loading_no_anim,
124
  inputs=[],
125
  outputs=[run_btn, loading_state],
 
 
 
 
 
 
 
 
 
 
126
  )
127
 
128
  clear_btn.click(fn=lambda: "Ready", outputs=[])
 
134
  outputs=[],
135
  js="""
136
  (text) => {
137
+ const el = document.createElement('textarea');
138
+ el.value = text;
139
+ document.body.appendChild(el);
140
+ el.select();
141
+ document.execCommand('copy');
142
+ document.body.removeChild(el);
 
143
  }
144
  """
145
  )
 
159
  align-items: center;
160
  justify-content: center;
161
  margin-bottom: 10px;
162
+ height: 80px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
+
165
+ #deepv-logo {
166
+ padding: 0;
167
+ margin: 0;
168
+ border: none;
169
+ box-shadow: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
 
172
  #output-title {
 
175
  font-weight: bold;
176
  margin-left: 20px;
177
  }
178
+
179
+ #verilog-output {
 
180
  position: relative;
181
  }
182
+
183
  #copy-button {
184
  position: absolute;
185
+ top: 40px;
186
+ right: 20px;
187
  z-index: 1000;
188
  background-color: #F0F0F0;
189
  color: #333;
190
  border-radius: 5px;
191
  border: none;
192
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
193
+ width: 30px;
194
+ height: 30px;
195
+ padding: 0;
196
  }
197
 
198
  #loading-state {