mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
de36820ef5
* fix demos * demos on landing page * make code interactive on playground * add changeset * try new secret * formatting * fix fake_gan * demo notebooks --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
23 lines
547 B
Python
23 lines
547 B
Python
import gradio as gr
|
|
from transformers import pipeline
|
|
|
|
generator = pipeline('text-generation', model='gpt2')
|
|
|
|
def generate(text):
|
|
result = generator(text, max_length=30, num_return_sequences=1)
|
|
return result[0]["generated_text"]
|
|
|
|
examples = [
|
|
["The Moon's orbit around Earth has"],
|
|
["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
|
|
]
|
|
|
|
demo = gr.Interface(
|
|
fn=generate,
|
|
inputs=gr.Textbox(lines=5, label="Input Text"),
|
|
outputs=gr.Textbox(label="Generated Text"),
|
|
examples=examples
|
|
)
|
|
|
|
demo.launch()
|