micrem73 commited on
Commit
d67b2ca
1 Parent(s): 32d0d15

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import transformers
3
+ from transformers import AutoModelWithLMHead, AutoTokenizer, pipeline
4
+ from transformers import GPT2Tokenizer, GPT2Model
5
+
6
+ model = GPT2Model.from_pretrained('micrem73/GePpeTto-finetuned-ricettetrentine')
7
+ tokenizer = GPT2Tokenizer.from_pretrained(
8
+ 'micrem73/GePpeTto-finetuned-ricettetrentine',
9
+ )
10
+
11
+ shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('micrem73/GePpeTto-finetuned-ricettetrentine'),
12
+ tokenizer='micrem73/GePpeTto-finetuned-ricettetrentine',
13
+ do_sample=True,
14
+ max_length=100,
15
+ top_k=50,
16
+ top_p=0.95,)
17
+
18
+ def generator(inizia_la_storia = ''):
19
+ shroom_result = shroom_generator(inizia_la_storia, max_length=520)
20
+ return shroom_result[0]["generated_text"]
21
+
22
+ iface = gr.Interface(fn=generator, inputs="text", outputs="text")
23
+ iface.launch()