Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
data.log
ADDED
|
File without changes
|
readme.md
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: testdeploy
|
| 3 |
+
app_file: test.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.36.1
|
| 6 |
+
---
|
test.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
'''
|
| 3 |
+
对话机器人demo
|
| 4 |
+
'''
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
'''
|
| 8 |
+
通过t5模型进行翻译demo
|
| 9 |
+
'''
|
| 10 |
+
import gradio as gr
|
| 11 |
+
from transformers import pipeline
|
| 12 |
+
|
| 13 |
+
# pipe = pipeline("translation", model="t5-base") # default is English to German
|
| 14 |
+
|
| 15 |
+
# pipe = pipeline("translation_en_to_fr", model="t5-base") # translate English to France
|
| 16 |
+
|
| 17 |
+
pipe = pipeline("translation_en_to_fr", model="/Users/wayne/.cache/huggingface/hub/models--t5-base-lwf/snapshots/fe6d9bf207cd3337512ca838a8b453f87a9178ef")
|
| 18 |
+
|
| 19 |
+
def translate(text):
|
| 20 |
+
return pipe(text)[0]['translation_text']
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
with gr.Blocks() as demo:
|
| 24 |
+
with gr.Row():
|
| 25 |
+
with gr.Column():
|
| 26 |
+
english = gr.Textbox(label="English text")
|
| 27 |
+
translate_btn = gr.Button(value="Translate")
|
| 28 |
+
with gr.Column():
|
| 29 |
+
german = gr.Textbox(label="German text")
|
| 30 |
+
|
| 31 |
+
translate_btn.click(fn=translate, inputs=[english], outputs=[german])
|
| 32 |
+
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."], inputs=[english])
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
demo.launch(server_port=8888)
|
| 36 |
+
|
| 37 |
+
|