Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from fastapi import FastAPI, Depends, HTTPException, Request
|
2 |
from fastapi.security import APIKeyQuery
|
3 |
from pydantic import BaseModel
|
@@ -114,6 +116,34 @@ async def logo():
|
|
114 |
|
115 |
|
116 |
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
app = gr.mount_gradio_app(app, io, path=CUSTOM_PATH)
|
118 |
|
119 |
if __name__ == "__main__":
|
|
|
1 |
+
# attribution: code for demo is based on https://huggingface.co/spaces/Geonmo/nllb-translation-demo
|
2 |
+
|
3 |
from fastapi import FastAPI, Depends, HTTPException, Request
|
4 |
from fastapi.security import APIKeyQuery
|
5 |
from pydantic import BaseModel
|
|
|
116 |
|
117 |
|
118 |
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
119 |
+
lang_codes = list(flores_codes.keys())
|
120 |
+
#inputs = [gr.inputs.Radio(['nllb-distilled-600M', 'nllb-1.3B', 'nllb-distilled-1.3B'], label='NLLB Model'),
|
121 |
+
inputs = [gr.Dropdown(lang_codes, value='English', label='Source'),
|
122 |
+
gr.Dropdown(lang_codes, value='Crimean Tatar', label='Target'),
|
123 |
+
gr.Textbox(lines=5, label="Input text"),
|
124 |
+
]
|
125 |
+
|
126 |
+
outputs = gr.JSON()
|
127 |
+
|
128 |
+
title = "Crimean Tatar Translator based on NLLB distilled 600M demo"
|
129 |
+
|
130 |
+
|
131 |
+
description = f"Details: https://github.com/facebookresearch/fairseq/tree/nllb."
|
132 |
+
examples = [
|
133 |
+
['English', 'Korean', 'Hi. nice to meet you']
|
134 |
+
]
|
135 |
+
|
136 |
+
def translate_single(source_lang: str, target_lang: str, text: str) -> List[str]:):
|
137 |
+
return translate_text([text], source_lang, target_lang)[0]
|
138 |
+
|
139 |
+
gr.Interface(translate_single,
|
140 |
+
inputs,
|
141 |
+
outputs,
|
142 |
+
title=title,
|
143 |
+
description=description,
|
144 |
+
)
|
145 |
+
|
146 |
+
|
147 |
app = gr.mount_gradio_app(app, io, path=CUSTOM_PATH)
|
148 |
|
149 |
if __name__ == "__main__":
|