NithyasriVllB commited on
Commit
403d059
·
verified ·
1 Parent(s): 851b41e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the text generation model
5
+ generator = pipeline("text-generation", model="gpt2", max_length=100)
6
+
7
+ def generate_description(topic):
8
+ # Prompt the model to describe the topic
9
+ prompt = f"Describe the following topic briefly: {topic}"
10
+ result = generator(prompt, max_length=100, num_return_sequences=1)
11
+ return result[0]["generated_text"]
12
+
13
+ # Create Gradio interface
14
+ interface = gr.Interface(
15
+ fn=generate_description,
16
+ inputs=gr.Textbox(label="Enter a Topic", placeholder="e.g., Heart"),
17
+ outputs=gr.Textbox(label="Description"),
18
+ title="Topic Describer",
19
+ description="Enter a topic, and the app will describe it briefly."
20
+ )
21
+
22
+ # Launch the app
23
+ interface.launch()