Update app.py
Browse files
app.py
CHANGED
|
@@ -71,24 +71,27 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 71 |
)
|
| 72 |
|
| 73 |
with gr.Column(scale=3):
|
| 74 |
-
#
|
| 75 |
-
gr.
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
lines=28,
|
| 85 |
-
interactive=False,
|
| 86 |
-
placeholder="// Your Verilog code will appear here",
|
| 87 |
-
elem_id="verilog-output"
|
| 88 |
-
)
|
| 89 |
-
|
| 90 |
-
copy_button = gr.Button("📋", variant="secondary", elem_id="copy-button")
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
with gr.Row():
|
| 93 |
clear_btn = gr.ClearButton(
|
| 94 |
value="Clear All",
|
|
@@ -107,25 +110,43 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 107 |
def copy_to_clipboard_fn(text):
|
| 108 |
return text
|
| 109 |
|
| 110 |
-
def
|
| 111 |
return [gr.update(visible=False), gr.update(visible=True)]
|
| 112 |
|
| 113 |
-
def
|
| 114 |
return [gr.update(visible=True), gr.update(visible=False)]
|
| 115 |
|
| 116 |
run_btn.click(
|
| 117 |
-
fn=
|
| 118 |
inputs=[],
|
| 119 |
outputs=[run_btn, loading_state],
|
| 120 |
show_progress=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
).then(
|
| 122 |
fn=generate_only,
|
| 123 |
inputs=[spec, use_rag, top_k, model_choice, api_key, temperature_tb, top_p_tb, max_new_tokens_tb],
|
| 124 |
outputs=[out_code],
|
| 125 |
).then(
|
| 126 |
-
fn=
|
| 127 |
inputs=[],
|
| 128 |
outputs=[run_btn, loading_state],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
)
|
| 130 |
|
| 131 |
clear_btn.click(fn=lambda: "Ready", outputs=[])
|
|
@@ -137,12 +158,13 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 137 |
outputs=[],
|
| 138 |
js="""
|
| 139 |
(text) => {
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
| 146 |
}
|
| 147 |
"""
|
| 148 |
)
|
|
@@ -156,32 +178,78 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)", theme=gr.themes.Soft()) a
|
|
| 156 |
letter-spacing: 1px;
|
| 157 |
}
|
| 158 |
|
| 159 |
-
/*
|
| 160 |
-
#output-
|
| 161 |
display: flex;
|
| 162 |
-
justify-content: center;
|
| 163 |
align-items: center;
|
|
|
|
| 164 |
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
position: relative;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
}
|
| 172 |
|
| 173 |
/* General UI element styling */
|
| 174 |
-
#verilog-output {
|
| 175 |
position: relative;
|
| 176 |
-
padding-top: 50px; /* Add space for the copy button */
|
| 177 |
}
|
| 178 |
-
|
| 179 |
#copy-button {
|
| 180 |
position: absolute;
|
| 181 |
-
top:
|
| 182 |
-
right:
|
| 183 |
z-index: 1000;
|
| 184 |
-
background-color:
|
| 185 |
color: #333;
|
| 186 |
border-radius: 5px;
|
| 187 |
border: none;
|
|
|
|
| 71 |
)
|
| 72 |
|
| 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(
|
| 97 |
value="Clear All",
|
|
|
|
| 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 |
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 |
)
|
|
|
|
| 178 |
letter-spacing: 1px;
|
| 179 |
}
|
| 180 |
|
| 181 |
+
/* Logo and Output Row Layout */
|
| 182 |
+
#logo-and-output-row {
|
| 183 |
display: flex;
|
|
|
|
| 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 {
|
| 236 |
+
margin: 0;
|
| 237 |
+
font-size: 1.2em;
|
| 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;
|