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