Wootang01 commited on
Commit
ce52f4d
·
1 Parent(s): b4a5a0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -1,18 +1,10 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- generator = pipeline('text-generation', model='Wootang01/distilgpt2-finetuned-hkdse-english-paper4')
 
5
 
6
- def generate(text):
7
- result = generator(text, max_length=100, num_return_sequences=1)
8
- return result[0]["generated_text"]
9
 
10
- examples = [
11
- ["Zoe Kwan is a 20-year old singer and songwriter who has taken Hong Kong’s music scene by storm."],
12
- ["Zoe only recently began writing songs."],
13
- ]
14
-
15
- demo = gr.Interface(fn=generate, inputs=gr.inputs.Textbox(lines=5, label="Input Text"), outputs=gr.outputs.Textbox(label="Generated Text"),
16
- title="Text Generator Distil GPT2 Finetuned on HKDSE English Language Paper 4", examples=examples)
17
-
18
- demo.launch()
 
1
  import gradio as gr
2
+ from gradio.mix import Series
3
 
4
+ title = "Chinese Text Generator and Translator"
5
+ description = "Input Chinese language text, submit and the machine will generate additional English language text"
6
 
7
+ translator = gr.Interface.load("huggingface/Helsinki-NLP/opus-mt-zh-en")
8
+ model1 = gr.Interface.load("huggingface/ckiplab/gpt2-base-chinese")
 
9
 
10
+ gr.Series(model1, translator, inputs=gr.Textbox(lines=5, label="Input Text"), title=title, description=description).launch()