Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the story generation pipeline | |
| generator = pipeline("text-generation", model="gpt2", max_length=200) | |
| def generate_story(moral): | |
| prompt = f"The moral of the story is: {moral}. Here's the story:" | |
| story = generator(prompt, max_length=200, num_return_sequences=1)[0]['generated_text'] | |
| return story | |
| # Create a Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_story, | |
| inputs=gr.Textbox(label="Enter the moral of the story"), | |
| outputs=gr.Textbox(label="Generated Story"), | |
| title="Moral to Story Generator", | |
| description="Input a moral, and this app will generate a story based on it using AI." | |
| ) | |
| iface.launch() | |