NithyasriVllB commited on
Commit
02ddd69
·
verified ·
1 Parent(s): 3da7216

Create app,py

Browse files
Files changed (1) hide show
  1. app,py +21 -0
app,py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the story generation pipeline
5
+ generator = pipeline("text-generation", model="gpt2", max_length=200)
6
+
7
+ def generate_story(moral):
8
+ prompt = f"The moral of the story is: {moral}. Here's the story:"
9
+ story = generator(prompt, max_length=200, num_return_sequences=1)[0]['generated_text']
10
+ return story
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(
14
+ fn=generate_story,
15
+ inputs=gr.Textbox(label="Enter the moral of the story"),
16
+ outputs=gr.Textbox(label="Generated Story"),
17
+ title="Moral to Story Generator",
18
+ description="Input a moral, and this app will generate a story based on it using AI."
19
+ )
20
+
21
+ iface.launch()