DutchNomadCode's picture
Change to full sentence
5c7fdb7 verified
raw
history blame contribute delete
514 Bytes
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()