File size: 636 Bytes
27673fe
 
3304da1
27673fe
 
 
3304da1
 
4211515
3304da1
 
27673fe
 
3304da1
 
27673fe
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import transformers
from transformers import AutoModelForCausalLM, AutoModelWithLMHead, AutoTokenizer, pipeline
from transformers import GPT2Tokenizer, GPT2Model


general_model = AutoModelForCausalLM.from_pretrained('gpt2')
general_generator = pipeline("text-generation", model=general_model, tokenizer="gpt2")
general_result = general_generator("Today is ", max_length=200)
general_result[0]["generated_text"]


def generator(start_your_text = ''):
  result = general_generator(start_your_text) 
  return result[0]["generated_text"]

iface = gr.Interface(fn=generator, inputs="text", outputs="text")
iface.launch()