radinplaid commited on
Commit
640ff2e
·
verified ·
1 Parent(s): dfc3287

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -103,6 +103,12 @@ def server(input, output, session):
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,14 +130,10 @@ def server(input, output, session):
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
  ),
131
- ui.input_action_button(
132
- "quickmt_model_download", "Download Model", class_="btn-primary"
133
- ),
134
- ui.output_ui("model_download_output"),
135
  ]
136
 
137
  app = App(app_ui, server)
 
103
  def translate():
104
  global t
105
  model_path = Path("/tmp") / input.model()
106
+
107
+ if not model_path.exists():
108
+ model_download_output(
109
+ model_name="quickmt/" + input.model(),
110
+ output_dir=Path("/tmp") / input.model(),
111
+ )
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
  except:
131
  return [
132
  ui.value_box(
133
+ title=f"Unexpected error",
134
  value="Failed to load model",
135
  showcase=icon("bug"),
136
  ),
 
 
 
 
137
  ]
138
 
139
  app = App(app_ui, server)