from transformers import pipeline import gradio as gr # Path to our model on Hugging Face Hub model_path = "umaru97/gpt2-product-review-generation" # Load model from hub and create a text-generation pipeline 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()