Spaces:
Sleeping
Sleeping
JJFrancisco
commited on
Commit
•
86a205f
1
Parent(s):
1bb1c0a
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,14 @@ import gradio as gr
|
|
2 |
|
3 |
import subprocess
|
4 |
|
5 |
-
|
|
|
|
|
6 |
|
7 |
# NOS-MT-en-gl.p
|
8 |
|
9 |
def translate(input_text):
|
10 |
-
command = f"onmt_translate -src {input_text} -model
|
11 |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
12 |
stdout, stderr = process.communicate()
|
13 |
if process.returncode != 0:
|
|
|
2 |
|
3 |
import subprocess
|
4 |
|
5 |
+
def download_model(repo_id, revision="main"):
|
6 |
+
return snapshot_download(repo_id=repo_id, revision=revision, local_dir=os.path.join(MODELS_PATH, repo_id), cache_dir=HF_CACHE_DIR)
|
7 |
+
model_dir_en_gl = download_model("proxectonos/Nos_MT-OpenNMT-en-gl", revision="main")
|
8 |
|
9 |
# NOS-MT-en-gl.p
|
10 |
|
11 |
def translate(input_text):
|
12 |
+
command = f"onmt_translate -src {input_text} -model model_dir_en_gl --output ./output_file.txt --replace_unk -gpu 0"
|
13 |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
14 |
stdout, stderr = process.communicate()
|
15 |
if process.returncode != 0:
|