Spaces:
Sleeping
Sleeping
File size: 514 Bytes
613e1cf dd13ee8 613e1cf 5c7fdb7 62c4079 5c7fdb7 613e1cf 5c7fdb7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import gradio as gr
from transformers import pipeline
def text_gen(input):
generator = pipeline("text-generation", model="distilgpt2")
generated_text = generator(input)[0]['generated_text']
# Split the generated text into sentences and concatenate them
sentences = generated_text.split('.')
full_sentence = ' '.join(sentence.strip() for sentence in sentences if sentence.strip())
return f"'{full_sentence}'"
iface = gr.Interface(fn=text_gen, inputs="text", outputs="text")
iface.launch()
|