Spaces:
Sleeping
Sleeping
Download app.py from NithyasriVllB/Explore_Topic: direct link, hf CLI and curl.
- Browser
- Download file 747 Bytes
-
https://huggingface.co/spaces/NithyasriVllB/Explore_Topic/resolve/main/app.py
- Command line
-
hf download hf://spaces/NithyasriVllB/Explore_Topic/app.py
-
curl -L -o app.py https://huggingface.co/spaces/NithyasriVllB/Explore_Topic/resolve/main/app.py
747 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the text generation model | |
| generator = pipeline("text-generation", model="gpt2", max_length=100) | |
| def generate_description(topic): | |
| # Prompt the model to describe the topic | |
| prompt = f"Describe the following topic briefly: {topic}" | |
| result = generator(prompt, max_length=100, num_return_sequences=1) | |
| return result[0]["generated_text"] | |
| # Create Gradio interface | |
| interface = gr.Interface( | |
| fn=generate_description, | |
| inputs=gr.Textbox(label="Enter a Topic", placeholder="e.g., Heart"), | |
| outputs=gr.Textbox(label="Description"), | |
| title="Topic Describer", | |
| description="Enter a topic, and the app will describe it briefly." | |
| ) | |
| # Launch the app | |
| interface.launch() |