Spaces:
Runtime error
Runtime error
akshaytrikha
commited on
Commit
•
e3c9dd9
1
Parent(s):
30c8824
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
generator = pipeline('text-generation', model='pytorch_model.bin')
|
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 |
+
["Today I'll be"],
|
12 |
+
["Why does the lying news media"],
|
13 |
+
["The democrats have"]
|
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()
|