Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,12 +58,6 @@ app_ui = ui.page_navbar(
|
|
| 58 |
),
|
| 59 |
"QuickMT model to use. quickmt-fr-en will translate from French (fr) to English (en)",
|
| 60 |
),
|
| 61 |
-
ui.tooltip(
|
| 62 |
-
ui.input_text(
|
| 63 |
-
"model_folder", "Model Folder", value="/tmp"
|
| 64 |
-
),
|
| 65 |
-
"Folder where QuickMT models are (or will be) stored.",
|
| 66 |
-
),
|
| 67 |
ui.tooltip(
|
| 68 |
ui.input_slider(
|
| 69 |
"beam_size", "Beam size", min=1, max=8, step=1, value=2
|
|
@@ -97,10 +91,10 @@ def server(input, output, session):
|
|
| 97 |
@render.ui
|
| 98 |
@reactive.event(input.quickmt_model_download) # Take a dependency on the button
|
| 99 |
def model_download_output():
|
| 100 |
-
print(f"Downloading {input.model()} to {input.model_folder()}")
|
| 101 |
hf_download(
|
| 102 |
model_name="quickmt/" + input.model(),
|
| 103 |
-
output_dir=Path(
|
| 104 |
)
|
| 105 |
return "Model downloaded"
|
| 106 |
|
|
@@ -108,7 +102,7 @@ def server(input, output, session):
|
|
| 108 |
@reactive.event(input.translate_button) # Take a dependency on the button
|
| 109 |
def translate():
|
| 110 |
global t
|
| 111 |
-
model_path = Path(
|
| 112 |
try:
|
| 113 |
if t is None or str(input.model()) != str(Path(t.model_path).name):
|
| 114 |
print(f"Loading model {input.model()}")
|
|
@@ -130,7 +124,7 @@ def server(input, output, session):
|
|
| 130 |
except:
|
| 131 |
return [
|
| 132 |
ui.value_box(
|
| 133 |
-
title=f"Ensure model is downloaded
|
| 134 |
value="Failed to load model",
|
| 135 |
showcase=icon("bug"),
|
| 136 |
),
|
|
|
|
| 58 |
),
|
| 59 |
"QuickMT model to use. quickmt-fr-en will translate from French (fr) to English (en)",
|
| 60 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
ui.tooltip(
|
| 62 |
ui.input_slider(
|
| 63 |
"beam_size", "Beam size", min=1, max=8, step=1, value=2
|
|
|
|
| 91 |
@render.ui
|
| 92 |
@reactive.event(input.quickmt_model_download) # Take a dependency on the button
|
| 93 |
def model_download_output():
|
| 94 |
+
#print(f"Downloading {input.model()} to {input.model_folder()}")
|
| 95 |
hf_download(
|
| 96 |
model_name="quickmt/" + input.model(),
|
| 97 |
+
output_dir=Path("/tmp") / input.model(),
|
| 98 |
)
|
| 99 |
return "Model downloaded"
|
| 100 |
|
|
|
|
| 102 |
@reactive.event(input.translate_button) # Take a dependency on the button
|
| 103 |
def translate():
|
| 104 |
global t
|
| 105 |
+
model_path = Path("/tmp") / input.model()
|
| 106 |
try:
|
| 107 |
if t is None or str(input.model()) != str(Path(t.model_path).name):
|
| 108 |
print(f"Loading model {input.model()}")
|
|
|
|
| 124 |
except:
|
| 125 |
return [
|
| 126 |
ui.value_box(
|
| 127 |
+
title=f"Ensure model is downloaded",
|
| 128 |
value="Failed to load model",
|
| 129 |
showcase=icon("bug"),
|
| 130 |
),
|