Commit
·
6ba4966
1
Parent(s):
29b5690
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def get_model():
|
5 |
+
return pipeline('text-generation', model='gpt-2')
|
6 |
+
|
7 |
+
def ask_model(start_of_sentence):
|
8 |
+
model = get_model()
|
9 |
+
result = model(start_of_sentence, max_length=50, do_sample=True)[0]['generated_text']
|
10 |
+
return result
|
11 |
+
|
12 |
+
iface = gr.Interface(fn=ask_model, inputs=gr.inputs.Textbox(lines=2, placeholder='Start of Sentence Here...'), outputs="text")
|
13 |
+
iface.launch()
|