Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,26 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Hugging Faceμ Helsinki-NLP Ko->Ru λ²μκΈ° μ¬μ©
|
| 5 |
+
translator = pipeline("translation_ko_to_ru", model="Helsinki-NLP/opus-mt-ko-ru")
|
| 6 |
|
| 7 |
+
def chat_translate(user_input):
|
| 8 |
+
if not user_input.strip():
|
| 9 |
+
return "μ
λ ₯μ ν΄μ£ΌμΈμ!"
|
| 10 |
+
|
| 11 |
+
# λ²μ
|
| 12 |
+
result = translator(user_input)
|
| 13 |
+
translated_text = result[0]['translation_text']
|
| 14 |
+
|
| 15 |
+
return translated_text
|
| 16 |
+
|
| 17 |
+
# κ°λ¨ν Gradio μ± μΈν°νμ΄μ€
|
| 18 |
+
iface = gr.ChatInterface(
|
| 19 |
+
fn=chat_translate,
|
| 20 |
+
chatbot_name="νκ΅μ΄->λ¬μμμ΄ λ²μ μ±λ΄",
|
| 21 |
+
title="νκ΅μ΄ μ
λ ₯μ λ¬μμμ΄ λ²μ μ±λ΄",
|
| 22 |
+
description="νκ΅μ΄λ‘ μ§λ¬Ένλ©΄ λ¬μμμ΄λ‘ λ²μν΄λ립λλ€."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
iface.launch()
|