File size: 667 Bytes
b2eb1ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import gradio as gr
from transformers import pipeline


def blog_gen(txt):
    generator=pipeline(task='text-generation',model='gpt2')
    gen_blog=generator(txt,max_length=300,num_return_sequences=2)
    remove_gen_text = list(map(lambda x: x["generated_text"], gen_blog))
    clean_text = list(map(lambda x: x.replace("\n\n", " "), remove_gen_text))
    return clean_text


iface = gr.Interface(fn=blog_gen,
                     inputs=[
                         gr.inputs.Textbox(
                             lines=2, placeholder=None, label='Sentence'),
                     ],
                     outputs=[gr.outputs.JSON(label=None)])
iface.launch()