Spaces:
Sleeping
Sleeping
Commit
Β·
01ac9fe
1
Parent(s):
3301bab
fix torch load
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ model.load_state_dict(state['model'], strict=True)
|
|
46 |
model.eval()
|
47 |
ling_disc.eval()
|
48 |
|
49 |
-
state = torch.load(args.sem_ckpt)
|
50 |
sem_emb.load_state_dict(state['model'], strict=True)
|
51 |
sem_emb.eval()
|
52 |
|
@@ -267,11 +267,17 @@ body {
|
|
267 |
--input-background: --neutral-50;
|
268 |
}
|
269 |
|
270 |
-
.separator {
|
271 |
width: 100%;
|
272 |
height: 3px; /* Adjust the height for boldness */
|
273 |
background-color: #000; /* Adjust the color as needed */
|
274 |
-
margin: 20px
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
}
|
276 |
"""
|
277 |
|
@@ -286,7 +292,7 @@ with gr.Blocks(
|
|
286 |
with gr.Accordion("π Quick Start Guide", open=False, elem_id='guide'):
|
287 |
gr.Markdown(guide)
|
288 |
|
289 |
-
with gr.Group(elem_classes='separator'):
|
290 |
pass
|
291 |
with gr.Group(elem_id='mode'):
|
292 |
mode = gr.Radio(
|
@@ -311,7 +317,7 @@ with gr.Blocks(
|
|
311 |
with gr.Column():
|
312 |
sent2 = gr.Textbox(label='Generated text')
|
313 |
interpolation = gr.Textbox(label='Quality control interpolation', visible=False, lines=5)
|
314 |
-
with gr.Group(elem_classes='separator'):
|
315 |
pass
|
316 |
#####################
|
317 |
with gr.Row():
|
@@ -329,16 +335,16 @@ with gr.Blocks(
|
|
329 |
#####################
|
330 |
generate_btn = gr.Button("Generate", variant='primary', visible=False)
|
331 |
with gr.Accordion("Tools to assist in the setting of linguistic indices...", open=False, visible=False) as ling_tools:
|
332 |
-
with gr.Row():
|
333 |
-
estimate_tgt_btn = gr.Button("Estimate linguistic indices of this sentence", visible=False)
|
334 |
-
sent_ling_est = gr.Textbox(label='Text to estimate linguistic indices', scale=2, visible=False)
|
335 |
-
estimate_src_btn = gr.Button("Estimate linguistic indices of source sentence", visible=False)
|
336 |
-
# rand_btn = gr.Button("Random target")
|
337 |
rand_ex_btn = gr.Button("Random target", size='lg', visible=False)
|
338 |
-
|
|
|
|
|
339 |
with gr.Row():
|
340 |
sub_btn = gr.Button('Subtract \u03B5 from target linguistic indices', visible=False)
|
341 |
add_btn = gr.Button('Add \u03B5 to target linguistic indices', visible=False)
|
|
|
|
|
|
|
342 |
ling.render()
|
343 |
#####################
|
344 |
|
|
|
46 |
model.eval()
|
47 |
ling_disc.eval()
|
48 |
|
49 |
+
state = torch.load(args.sem_ckpt, map_location=torch.device('cpu'))
|
50 |
sem_emb.load_state_dict(state['model'], strict=True)
|
51 |
sem_emb.eval()
|
52 |
|
|
|
267 |
--input-background: --neutral-50;
|
268 |
}
|
269 |
|
270 |
+
.top-separator {
|
271 |
width: 100%;
|
272 |
height: 3px; /* Adjust the height for boldness */
|
273 |
background-color: #000; /* Adjust the color as needed */
|
274 |
+
margin-top: 20px; /* Adjust the margin as needed */
|
275 |
+
}
|
276 |
+
.bottom-separator {
|
277 |
+
width: 100%;
|
278 |
+
height: 3px; /* Adjust the height for boldness */
|
279 |
+
background-color: #000; /* Adjust the color as needed */
|
280 |
+
margin-bottom: 20px; /* Adjust the margin as needed */
|
281 |
}
|
282 |
"""
|
283 |
|
|
|
292 |
with gr.Accordion("π Quick Start Guide", open=False, elem_id='guide'):
|
293 |
gr.Markdown(guide)
|
294 |
|
295 |
+
with gr.Group(elem_classes='top-separator'):
|
296 |
pass
|
297 |
with gr.Group(elem_id='mode'):
|
298 |
mode = gr.Radio(
|
|
|
317 |
with gr.Column():
|
318 |
sent2 = gr.Textbox(label='Generated text')
|
319 |
interpolation = gr.Textbox(label='Quality control interpolation', visible=False, lines=5)
|
320 |
+
with gr.Group(elem_classes='bottom-separator'):
|
321 |
pass
|
322 |
#####################
|
323 |
with gr.Row():
|
|
|
335 |
#####################
|
336 |
generate_btn = gr.Button("Generate", variant='primary', visible=False)
|
337 |
with gr.Accordion("Tools to assist in the setting of linguistic indices...", open=False, visible=False) as ling_tools:
|
|
|
|
|
|
|
|
|
|
|
338 |
rand_ex_btn = gr.Button("Random target", size='lg', visible=False)
|
339 |
+
with gr.Row():
|
340 |
+
estimate_src_btn = gr.Button("Estimate linguistic indices of source sentence", visible=False)
|
341 |
+
copy_btn = gr.Button("Copy linguistic indices of source to target", size='lg', visible=False)
|
342 |
with gr.Row():
|
343 |
sub_btn = gr.Button('Subtract \u03B5 from target linguistic indices', visible=False)
|
344 |
add_btn = gr.Button('Add \u03B5 to target linguistic indices', visible=False)
|
345 |
+
with gr.Row():
|
346 |
+
estimate_tgt_btn = gr.Button("Estimate linguistic indices of this sentence β", visible=False)
|
347 |
+
sent_ling_est = gr.Textbox(label='Text to estimate linguistic indices', scale=2, visible=False, container=False)
|
348 |
ling.render()
|
349 |
#####################
|
350 |
|