Spaces:
Runtime error
Runtime error
import gradio as gr | |
import transformers | |
from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline | |
from transformers import GPT2Tokenizer, GPT2Model | |
#model = GPT2Model.from_pretrained('LorenzoDeMattei/GePpeTto') | |
#tokenizer = GPT2Tokenizer.from_pretrained( | |
#'LorenzoDeMattei/GePpeTto', | |
#) | |
text_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('azaninello/GPT2-icc-new'), | |
tokenizer='LorenzoDeMattei/GePpeTto', | |
do_sample=True, | |
max_length=200, | |
top_k=50, | |
top_p=0.95, | |
repetition_penalty=9.5) | |
def generator(scrivi_qualcosa = ''): | |
result = text_generator(scrivi_qualcosa, max_length=150) | |
return result[0]["generated_text"] | |
iface = gr.Interface(fn=generator, inputs="text", outputs="text") | |
iface.launch() |