gradio/demo/unified_demo_text_generation/run.py
Abubakar Abid f3b3736596
Guide on 4 kinds of interfaces (#3003)
* guide on 4 kinds of interfaces

* interfaces

* changelog

* added demo

* added demos and edited markdown

Added standard and unified interface demos, along with updates to the markdown.

* updated notebooks

Updated notebooks with markdown changes and bug fixes

* interfaces

* moved location of guide

* ranemd

* renamed

* removed demo

* updated blocks code to interfaces

* upload requirements.txt file

* Delete run.ipynb to add another notebook file

upload and replace

* Add run.ipynb via upload option

Notebook for unified interface demo

* fixed typo

* fixes

* update demos

* notebooks

---------

Co-authored-by: yuvraj sharma <48665385+yvrjsharma@users.noreply.github.com>
2023-02-02 07:58:29 -08:00

16 lines
384 B
Python

import gradio as gr
from transformers import pipeline
generator = pipeline('text-generation', model = 'gpt2')
def generate_text(text_prompt):
response = generator(text_prompt, max_length = 30, num_return_sequences=5)
return response[0]['generated_text']
textbox = gr.Textbox()
demo = gr.Interface(generate_text, textbox, textbox)
if __name__ == "__main__":
demo.launch()