Spaces:
Runtime error
Runtime error
File size: 1,451 Bytes
1e0e625 5960f16 1e0e625 a53d92d 1e0e625 a53d92d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from transformers import pipeline, set_seed
import gradio as gr
classifier = pipeline('text-generation', model='gpt2')
set_seed(42)
def generate_text(text, gen_length):
gen_text = classifier(text, max_length=gen_length)[0]['generated_text']
return gen_text
Instructuction = "Browse the internet to download any unique image"
title="Text generation playground"
description = "Start writing a peice of text in the input box\
and see how well the text generation language model\
is able to generate new text that uniquely completes your sentences."
article = """
- Write a text in the input box and specify the length of text.
- Also you can select a quick example to continue.
- Click submit button to generate new text.
- Click clear button to try new text generation.
"""
# Gradio app design
interface = gr.Interface(
generate_text,
inputs = ['text', gr.Slider(20, 120, value=80, step=1)],
outputs='text',
title = title,
description = description,
article = article,
allow_flagging = "never",
#theme = "peach",
#live = False,
examples=[["Agriculture is very fundamental to",
50], ["I will tell a story about",
100]]
)
interface.launch()
|