Spaces:
Sleeping
Sleeping
Pradeep M.
commited on
Commit
·
77afd40
1
Parent(s):
91d5f3d
initial commit1
Browse files
app.py
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
title = "Generate your own story"
|
| 5 |
-
examples = [["Adventurer is approached by a mysterious stranger in the tavern for a new quest."]]
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
)
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
generator = pipeline("text-generation", model="pranavpsv/gpt2-genre-story-generator")
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def generate_story(prompt):
|
| 7 |
+
result = generator(prompt, max_length=200, do_sample=True)
|
| 8 |
+
return result[0]["generated_text"]
|
|
|
|
| 9 |
|
| 10 |
+
gr.Interface(
|
| 11 |
+
fn=generate_story,
|
| 12 |
+
inputs=gr.Textbox(label="Prompt"),
|
| 13 |
+
outputs=gr.Textbox(label="Generated Story"),
|
| 14 |
+
title="Generate your own story",
|
| 15 |
+
description="Story generation with GPT-2",
|
| 16 |
+
examples=[["Adventurer is approached by a mysterious stranger in the tavern for a new quest."]],
|
| 17 |
+
).launch()
|