KyuDan1 commited on
Commit
47e7ef9
โ€ข
1 Parent(s): 699409b
Files changed (1) hide show
  1. app.py +12 -21
app.py CHANGED
@@ -1,20 +1,11 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
3
 
4
- from transformers import AutoModelForSeq2SeqLM
5
- from transformers import AutoTokenizer
 
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)