Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| def generate_story(prompt): | |
| pipe = pipeline("text-generation", model="Fathi7ma/tiny-stories-gpt2") | |
| story = pipe( | |
| prompt, | |
| max_length=150, | |
| num_return_sequences=1, | |
| do_sample=True, | |
| temperature=0.8 | |
| ) | |
| return story[0]["generated_text"] | |
| demo = gr.Interface( | |
| fn=generate_story, | |
| inputs=gr.Textbox(label="Enter a story prompt",lines=3), | |
| outputs=gr.Textbox(label="Generated Story",lines=10), | |
| title="Tiny Story Generator", | |
| description="A fine-tuned GPT-2 model that writes short creative stories." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |