ganeshkamath89 commited on
Commit
ba5952d
·
verified ·
1 Parent(s): 95e2df7

Updating the code to use Hugging Face Text Generation pipeline

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
2
-
3
- description = "Story generation with GPT-2"
4
-
5
- interface = gr.Interface(fn=None, title="Story Generation with GPT-2", inputs=[gr.Textbox(lines=7, label="Story")], description=description, examples=[["Adventurer is approached by a mysterious stranger in the tavern for a new quest"]])
6
-
 
7
  interface.launch()
 
1
  import gradio as gr
2
+ transformers import pipeline
3
+ def generate_story(story):
4
+ story_gen = pipeline("text-generation", "pranavpsv/gpt2-genre-story-generator")
5
+ generated_story = story_gen("<BOS> <superhero> Batman")
6
+ return generated_story
7
+ interface = gr.Interface(fn=generate_story, title="Story Generation with GPT-2", inputs=[gr.Textbox(lines=7, label="Story")], description="Story generation with GPT-2", examples=[["Adventurer is approached by a mysterious stranger in the tavern for a new quest"]])
8
  interface.launch()