maiurilorenzo commited on
Commit
b3e64c3
·
verified ·
1 Parent(s): 8d631a7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ def generate_text(prompt):
5
+ # load the model
6
+ generator = pipeline('text-generation', model='maiurilorenzo/dante-gpt')
7
+ result = generator(prompt, max_length=100, num_return_sequences=1)
8
+ return result[0]['generated_text']
9
+
10
+ demo = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Italian poetry generator in the style of Dante")
11
+
12
+ demo = gr.Interface(
13
+ fn=generate_text,
14
+ inputs="text",
15
+ outputs="text",
16
+ title="Italian poetry generator in the style of Dante",
17
+ description="Start with a prompt such as 'Nel mezzo del cammin di nostra vita,' and find out what Dante could say if he was alive in our epoch!",
18
+ article="The project is based on GPT-2 and is still in early development, different prompts can produce different outputs and errors are to be expected"
19
+ )
20
+
21
+ demo.launch()