pranavrana98 commited on
Commit
871371d
1 Parent(s): c8d2134

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ generator = pipeline('text-generation', model='gpt2')
5
+
6
+
7
+ def generate(text):
8
+ result = generator(text, max_length=150, num_return_sequences=1)
9
+ return result[0]["generated_text"]
10
+
11
+
12
+ examples = [
13
+ ["Once upon a time in a mystical land, there lived a brave knight"],
14
+ ]
15
+
16
+ iface = gr.Interface(
17
+ fn=generate,
18
+ inputs=gr.inputs.Textbox(lines=2, label="Enter the story prompt..."),
19
+ outputs=gr.outputs.Textbox(label="Generated Story"),
20
+ examples=examples,
21
+ description="Generate creative stories with the AI storyteller!"
22
+ )
23
+
24
+ iface.launch(share=True)