Amitesh007's picture
Update app.py
a3476e7
import gradio as gr
from transformers import pipeline
fine_tuned_model = "Amitesh007/text_generation-finetuned-gpt2"
def generate(text):
generator = pipeline('text-generation', model=fine_tuned_model)
result = generator(text, num_return_sequences=2,
max_length=100
)
return result[0]["generated_text"],result[1]["generated_text"]
Examples = [["A light snow had fallen the night before, and there were"],["The pig face had been smashed in with a mace, but Tyrion"]]
demo = gr.Interface(
fn=generate,
inputs=[gr.Textbox(lines=5, label="Input Text here....")],
outputs=[
gr.Textbox(label="Generated Text 1"),
gr.Textbox(label="Generated Text 2")
],
title = "Text Generator GPT2 Pipeline",
description = "this is a fine-tuned base gpt2 model inference, trained on a small 'game of thrones' dataset",
examples = Examples
)
demo.queue(concurrency_count=2)
demo.launch()