Spaces:
Sleeping
Sleeping
Download app.py from sphinxsolutions/Text_generation: direct link, hf CLI and curl.
- Browser
- Download file 593 Bytes
-
https://huggingface.co/spaces/sphinxsolutions/Text_generation/resolve/main/app.py
- Command line
-
hf download hf://spaces/sphinxsolutions/Text_generation/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sphinxsolutions/Text_generation/resolve/main/app.py
593 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load model directly from Hugging Face Hub | |
| model_name = "EleutherAI/gpt-neo-125M" # Replace with your model | |
| generator = pipeline("text-generation", model=model_name) | |
| def generate_text(prompt): | |
| result = generator(prompt, max_length=50) | |
| return result[0]["generated_text"] | |
| demo = gr.Interface( | |
| fn=generate_text, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."), | |
| outputs="text", | |
| title="Custom Hugging Face Model UI", | |
| description=f"This UI interacts with the {model_name} model." | |
| ) | |
| demo.launch() | |