Download app.py from multich/t2t: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/spaces/multich/t2t/resolve/main/app.py
- Command line
-
hf download hf://spaces/multich/t2t/app.py
-
curl -L -o app.py https://huggingface.co/spaces/multich/t2t/resolve/main/app.py
673 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a text rewriting model (T5-small for efficiency) | |
| rewrite_pipeline = pipeline("text2text-generation", model="t5-small") | |
| def rewrite_text(text): | |
| """Rewrites the input text using a fine-tuned T5 model.""" | |
| result = rewrite_pipeline(text, max_length=200, do_sample=True)[0]['generated_text'] | |
| return result | |
| # Create a simple Gradio interface | |
| iface = gr.Interface( | |
| fn=rewrite_text, | |
| inputs=gr.Textbox(lines=3, placeholder="Enter text to rewrite..."), | |
| outputs="text", | |
| title="Text Rewriter", | |
| description="Enter a sentence or paragraph, and the model will rewrite it.", | |
| ) | |
| iface.launch() | |