rajeshthangaraj1 commited on
Commit
654c025
1 Parent(s): cbb9dac

create app

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 GPT-2 model
5
+ generator = pipeline('text-generation', model='gpt2')
6
+
7
+ def generate_text(prompt):
8
+ # Generate text based on the input prompt
9
+ results = generator(prompt, max_length=100, num_return_sequences=1)
10
+ return results[0]['generated_text']
11
+
12
+ # Set up the Gradio interface
13
+ interface = gr.Interface(
14
+ fn=generate_text,
15
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Type something here..."),
16
+ outputs='text',
17
+ title="Simple Generative AI",
18
+ description="Type in a prompt and get a continuation from GPT-2!"
19
+ )
20
+
21
+ if __name__ == "__main__":
22
+ interface.launch()