abidlabs HF staff commited on
Commit
b60a13a
·
1 Parent(s): 1e6650f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,4 +1,12 @@
 
1
  import gradio as gr
2
- name_list = ['models/gpt2']
3
- interfaces = [gr.Interface.load(name) for name in name_list]
4
- gr.mix.Parallel(*interfaces, title="GPT2 tester", description="GPT2 tester GPT2 tester").launch()
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
  import gradio as gr
3
+
4
+ # First define a prediction function that takes in a text prompt and returns the text completion
5
+ model = pipeline('text-generation')
6
+
7
+ def predict(prompt):
8
+ completion = model(prompt)[0]['generated_text']
9
+ return completion
10
+
11
+ # Now create the interface
12
+ gr.Interface(fn=predict, inputs="text", outputs="text").launch()