File size: 569 Bytes
20b752d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import pipeline
import gradio as gr
# Defining the pipeline and the model
pipe_flan = pipeline("text-generation", model="gpt2")
# Text generation
def generator(input):
output = pipe_flan(input, max_length=50, num_return_sequences=1)
return output[0]["generated_text"]
# Creating the Gradio Interface
demo = gr.Interface(
fn=generator,
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
outputs=gr.outputs.Textbox(label="Generated Text")
)
# Lauching the Gradio Interface
demo.launch(server_name="0.0.0.0", server_port=7860) |