ZenithBrew commited on
Commit
51b35bd
·
verified ·
1 Parent(s): a155fd5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the text generation model
5
+ generator = pipeline('text-generation', model='gpt2')
6
+
7
+ # Function to generate text
8
+ def generate_text(prompt):
9
+ output = generator(prompt, max_length=50, num_return_sequences=1)
10
+ return output[0]['generated_text']
11
+
12
+ # Build the interface
13
+ iface = gr.Interface(
14
+ fn=generate_text,
15
+ inputs=gr.Textbox(lines=2, placeholder="Enter a prompt here..."),
16
+ outputs="text",
17
+ title="AI Text Generator",
18
+ description="Generate text with AI!"
19
+ )
20
+
21
+ # Launch it
22
+ iface.launch()