File size: 685 Bytes
a7c67de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr

from transformers import AutoModel, AutoTokenizer
from transformers import TextGenerationPipeline 


tokenizer = AutoTokenizer.from_pretrained("Sigurdur/icebreaker")
model = AutoModel.from_pretrained("Sigurdur/icebreaker")
pipeline = TextGenerationPipeline(model=model, tokenizer=tokenizer)

def generate_text(inp):
    generated_text = pipeline(inp)

    output = generated_text[0]["generated_text"]
    return output

output_text = gr.outputs.Textbox()
gr.Interface(generate_text,"textbox",output_text,title="Text Generation machine ",description="Ask any question. Note: It can take 20-60 seconds to generate output based on your internet connection.").launch()