micrem73 commited on
Commit
6e772e7
1 Parent(s): 2e3cb27

Add application file

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/bolo2.0')
7
+ tokenizer = GPT2Tokenizer.from_pretrained(
8
+ 'LorenzoDeMattei/GePpeTto',
9
+ )
10
+
11
+ shroom_generator = pipeline("text-generation", model=AutoModelWithLMHead.from_pretrained('micrem73/bolo2.0'),
12
+ tokenizer='LorenzoDeMattei/GePpeTto',
13
+ do_sample=True,
14
+ max_length=100,
15
+ top_k=50,
16
+ top_p=0.95,
17
+ repetition_penalty=9.5,
18
+ temperature=100 )
19
+
20
+ def generator(inizia_la_storia = ''):
21
+ shroom_result = shroom_generator(inizia_la_storia, max_length=520)
22
+ return shroom_result[0]["generated_text"]
23
+
24
+
25
+ blog_inputs = gr.Textbox(lines=1, value="Mi è piaciuto molto entrare al museo che si raggiunge tramite uno stretto vicolo ")
26
+
27
+ iface = gr.Interface(fn=generator, inputs=blog_inputs, outputs="text")
28
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio