RicetteTrentine / app.py
micrem73's picture
Create app.py
d67b2ca
raw
history blame
843 Bytes
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(
'micrem73/GePpeTto-finetuned-ricettetrentine',
)
shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('micrem73/GePpeTto-finetuned-ricettetrentine'),
tokenizer='micrem73/GePpeTto-finetuned-ricettetrentine',
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"]
iface = gr.Interface(fn=generator, inputs="text", outputs="text")
iface.launch()