Spaces:
Runtime error
Runtime error
Commit ·
10d53e4
1
Parent(s): ca8c9eb
first commit
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def blog_gen(txt):
|
| 7 |
+
generator=pipeline(task='text-generation',model='gpt2')
|
| 8 |
+
gen_blog=generator(txt,max_length=300,num_return_sequences=2)
|
| 9 |
+
remove_gen_text = list(map(lambda x: x["generated_text"], gen_blog))
|
| 10 |
+
clean_text = list(map(lambda x: x.replace("\n\n", " "), remove_gen_text))
|
| 11 |
+
return clean_text
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(fn=blog_gen,
|
| 15 |
+
inputs=[
|
| 16 |
+
gr.inputs.Textbox(
|
| 17 |
+
lines=2, placeholder=None, label='Sentence'),
|
| 18 |
+
],
|
| 19 |
+
outputs=[gr.outputs.JSON(label=None)])
|
| 20 |
+
iface.launch(
|