KyuDan1
commited on
Commit
โข
47e7ef9
1
Parent(s):
699409b
chatgpt
Browse files
app.py
CHANGED
@@ -1,20 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
def respond(text):
|
8 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("Kyudan/opus-mt-en-ro-finetuned-en-to-ro")
|
9 |
-
model.eval()
|
10 |
-
|
11 |
-
|
12 |
-
# ํ ํฌ๋์ด์ ๋ก๋
|
13 |
-
tokenizer = AutoTokenizer.from_pretrained("Kyudan/opus-mt-en-ro-finetuned-en-to-ro")
|
14 |
-
|
15 |
-
# ๋ฒ์ญํ ์
๋ ฅ ํ
์คํธ
|
16 |
-
text = text
|
17 |
-
|
18 |
# ์
๋ ฅ ํ
์คํธ๋ฅผ ํ ํฐํ
|
19 |
inputs = tokenizer.encode(text, return_tensors="pt")
|
20 |
|
@@ -25,14 +16,14 @@ def respond(text):
|
|
25 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
26 |
|
27 |
return translated_text
|
28 |
-
"""
|
29 |
-
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
30 |
-
"""
|
31 |
-
demo = gr.ChatInterface(
|
32 |
-
respond,
|
33 |
-
title = "translate English to Romanian"
|
34 |
-
)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
3 |
|
4 |
+
# ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ ํ ๋ฒ๋ง ๋ก๋๋๋๋ก ํจ์ ์ธ๋ถ์ ์ ์ธ
|
5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Kyudan/opus-mt-en-ro-finetuned-en-to-ro")
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("Kyudan/opus-mt-en-ro-finetuned-en-to-ro")
|
7 |
|
8 |
def respond(text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# ์
๋ ฅ ํ
์คํธ๋ฅผ ํ ํฐํ
|
10 |
inputs = tokenizer.encode(text, return_tensors="pt")
|
11 |
|
|
|
16 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
17 |
|
18 |
return translated_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
# Gradio ์ธํฐํ์ด์ค ์ค์
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=respond,
|
23 |
+
inputs="text",
|
24 |
+
outputs="text",
|
25 |
+
title="Translate English to Romanian"
|
26 |
+
)
|
27 |
|
28 |
if __name__ == "__main__":
|
29 |
+
demo.launch(share=True)
|