|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
|
|
model_path = "umaru97/gpt2-product-review-generation" |
|
|
|
|
|
get_completion = pipeline("text-generation", model=model_path) |
|
|
|
def text_generation(input): |
|
output = get_completion(input) |
|
return output[0]['generated_text'] |
|
|
|
gr.close_all() |
|
demo = gr.Interface(fn=text_generation, |
|
inputs=[gr.Textbox(label="Text to start", lines=1)], |
|
outputs=[gr.Textbox(label="Result", lines=3)], |
|
title="Text generation with GPT-2", |
|
description="This demo would generate TV and tablet product reviews.", |
|
examples=['The TV', 'The tablet'] |
|
) |
|
demo.launch() |