simeneide commited on
Commit
c1a92cd
1 Parent(s): e8954f9

Create new file

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load model (dont really know what this is doing under the hood)
5
+ generator = pipeline('text-generation', model='pere/norwegian-gpt2-social')
6
+
7
+
8
+ # Create function that outputs generated text
9
+ def complete_prompt(prompt):
10
+ output = generator(prompt, max_length=30, num_return_sequences=5)
11
+ return "\n \n".join([l['generated_text'] for l in output])
12
+
13
+ demo = gr.Interface(fn=complete_prompt, inputs="text", outputs="text", examples=["Hvor var du når oddvar","god dag mann, "])
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown(
17
+ """
18
+ # Hello AI Academy!
19
+ Ive made a very simple sentence completion app based on the norwegian-gpt2-social model on huggingface made by the user pere.
20
+ It is trained on wikipedia, twitter, some news corpus, reddit and even VG debatt(!!), so prepare to be morally shocked by its results (I take no responsibility).
21
+
22
+ """)
23
+ gr.Interface(fn=complete_prompt, inputs="text", outputs="text", examples=["Hvor var du når oddvar","god dag mann, ", "moderatoren er", "svensker", "The worst thing about norway"])
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()