File size: 944 Bytes
d67b2ca
 
 
 
 
 
 
5dc70b2
d67b2ca
 
 
5dc70b2
d67b2ca
 
 
 
 
28a7f65
d67b2ca
 
 
28a7f65
8369d9c
28a7f65
8369d9c
d67b2ca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import transformers
from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline
from transformers import GPT2Tokenizer, GPT2Model

model = GPT2Model.from_pretrained('micrem73/GePpeTto-finetuned-ricettetrentine')
tokenizer = GPT2Tokenizer.from_pretrained(
    'LorenzoDeMattei/GePpeTto',
)

shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('micrem73/GePpeTto-finetuned-ricettetrentine'),
    tokenizer='LorenzoDeMattei/GePpeTto', 
    do_sample=True,
    max_length=100,
    top_k=50,
    top_p=0.95,)

def generator(inizia_la_storia = ''):
  shroom_result = shroom_generator(inizia_la_storia, max_length=520) 
  return shroom_result[0]["generated_text"]


blog_inputs = gr.Textbox(lines=1, value="Ingredienti: un litro di latte,  mezzo kilo di farina, due uova, 250 grammi di zucchero.")

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