brichett commited on
Commit
9526327
1 Parent(s): be28f29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -1,7 +1,22 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ generator = pipeline('text-generation', model='gpt2')
 
5
 
6
+ def generate(text):
7
+ result = generator(text, max_length=30, num_return_sequences=1)
8
+ return result[0]["generated_text"]
9
+
10
+ examples = [
11
+ ["The Moon's orbit around Earth has"],
12
+ ["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
13
+ ]
14
+
15
+ demo = gr.Interface(
16
+ fn=generate,
17
+ inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
18
+ outputs=gr.outputs.Textbox(label="Generated Text"),
19
+ examples=examples
20
+ )
21
+
22
+ demo.launch()