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)