Download app.py from Sunder34/text_text: direct link, hf CLI and curl.
- Browser
- Download file 832 Bytes
-
https://huggingface.co/spaces/Sunder34/text_text/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sunder34/text_text/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sunder34/text_text/resolve/main/app.py
832 Bytes
| 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) | |