import gradio as gr import transformers from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline from transformers import GPT2Tokenizer, GPT2Model model = GPT2Model.from_pretrained('micrem73/GePpeTto-finetuned-gastro-finetuned-bolo') tokenizer = GPT2Tokenizer.from_pretrained( 'LorenzoDeMattei/GePpeTto', ) shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('micrem73/GePpeTto-finetuned-gastro-finetuned-bolo'), tokenizer='LorenzoDeMattei/GePpeTto', do_sample=True, max_length=100, top_k=50, top_p=0.95, repetition_penalty=9.5, temperature=1.3 ) def generator(inizia_la_storia = ''): shroom_result = shroom_generator(inizia_la_storia, max_length=100) return shroom_result[0]["generated_text"] blog_inputs = gr.Textbox(lines=1, value="Mi รจ piaciuto molto entrare al museo che si raggiunge tramite uno stretto vicolo ") iface = gr.Interface(fn=generator, inputs=blog_inputs, outputs="text") iface.launch()