Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the text-to-text generation pipeline using the FLAN-T5 model | |
| pipe = pipeline("text2text-generation", model="google/flan-t5-large") | |
| # Function to generate text based on user input | |
| def generate_text(input_text): | |
| # Generate output text using the pipeline | |
| generated = pipe(input_text) | |
| return generated[0]['generated_text'] | |
| # Set up the Gradio interface | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Text Generation using FLAN-T5 (google/flan-t5-large)") | |
| # Input for user to provide text | |
| text_input = gr.Textbox(label="Enter Text Prompt", placeholder="Type your prompt here...", value="Translate English to French: 'Hello, how are you?'") | |
| # Output to display the generated text | |
| output_text = gr.Textbox(label="Generated Text", interactive=False) | |
| # Button to trigger text generation | |
| generate_button = gr.Button("Generate Text") | |
| # Link button click to text generation function | |
| generate_button.click(fn=generate_text, inputs=text_input, outputs=output_text) | |
| # Launch the Gradio app | |
| demo.launch() | |