Haider1396 commited on
Commit
402cfd6
·
verified ·
1 Parent(s): 7229e3a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -1,21 +1,15 @@
1
- pip install transformers gradio
2
  import gradio as gr
3
- from transformers import pipeline
4
 
5
- # Load the GPT-2 model for text generation
6
- generator = pipeline('text-generation', model='gpt2')
 
7
 
8
- # Function to generate a story
9
- def generate_story(prompt):
10
- story = generator(prompt, max_length=200, num_return_sequences=1)[0]['generated_text']
11
- return story
12
-
13
- # Create a Gradio interface
14
  iface = gr.Interface(
15
- fn=generate_story,
16
- inputs=gr.Textbox(label="Enter a prompt for the story", placeholder="e.g. A mysterious adventure begins..."),
17
- outputs=gr.Textbox(label="Generated Story"),
18
  )
19
 
20
- # Launch the interface
21
  iface.launch()
 
 
1
  import gradio as gr
 
2
 
3
+ # Function to echo user input
4
+ def echo_input(user_input):
5
+ return user_input
6
 
7
+ # Create Gradio interface
 
 
 
 
 
8
  iface = gr.Interface(
9
+ fn=echo_input,
10
+ inputs=gr.Textbox(label="Enter some text", placeholder="Type something..."),
11
+ outputs=gr.Textbox(label="You entered")
12
  )
13
 
14
+ # Launch the app
15
  iface.launch()