Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
generator = pipeline('text-generation', model = 'gpt2')
|
| 5 |
+
|
| 6 |
+
def text_generator(sample, max_length):
|
| 7 |
+
outputs = generator(sample, max_length = int(max_length), num_return_sequences=3)
|
| 8 |
+
return outputs[0]["generated_text"], outputs[1]["generated_text"], outputs[2]["generated_text"]
|
| 9 |
+
|
| 10 |
+
examples = [["Hello, I'm a language model", "45"], ["Hello, I'm a designer", "30"]]
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(fn=text_generator, inputs=["text", "text"], outputs=["text", "text", "text"], title="Question Generator", examples=examples)
|
| 13 |
+
demo.launch( debug = True )
|