Spaces:
Runtime error
Runtime error
File size: 794 Bytes
be63c93 a8d925c c412150 be63c93 70b313e 1bde40f bf856c8 0125db6 bf856c8 6cf0c2b 81d2dea be63c93 0125db6 be63c93 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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',
)
shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('LorenzoDeMattei/GePpeTto'),
tokenizer='LorenzoDeMattei/GePpeTto',
do_sample=True,
max_length=120,
top_k=50,
top_p=0.95,
repetition_penalty=9.5)
def generator(inizia_la_storia = ''):
shroom_result = shroom_generator(inizia_la_storia, max_length=120)
return shroom_result[0]["generated_text"]
iface = gr.Interface(fn=generator, inputs="text", outputs="text")
iface.launch() |