File size: 832 Bytes
48bc904 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
# Initialize the text generation pipeline using the google/flan-t5-base model
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
# Define a function to generate text using the Flan-T5 model
def generate_text(input_text):
response = pipe(input_text)
return response[0]['generated_text']
# Set up the Gradio interface
iface = gr.Interface(
fn=generate_text, # The function to generate text
inputs="text", # Input type is a text field
outputs="text", # Output is displayed as text
title="Flan-T5 Text Generation", # Title of the interface
description="Enter text to generate a response using the google/flan-t5-base model." # Description
)
# Launch the Gradio interface
if __name__ == "__main__":
iface.launch(share=True)
|