Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
-
from transformers import
|
| 2 |
-
|
| 3 |
-
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
def gpt2(string):
|
| 7 |
-
text =
|
| 8 |
-
|
| 9 |
-
output = model(**encoded_input)
|
| 10 |
-
return output
|
| 11 |
-
|
| 12 |
iface = gr.Interface(fn=gpt2, inputs="text", outputs="text")
|
| 13 |
iface.launch()
|
|
|
|
| 1 |
+
from transformers import pipeline, set_seed
|
| 2 |
+
from random import seed, choice
|
| 3 |
+
generator = pipeline('text-generation', model='gpt2')
|
| 4 |
+
set_seed(seed())
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
def gpt2(string):
|
| 8 |
+
text = generator(text, max_length=250, num_return_sequences=1)
|
| 9 |
+
return text[0]['generated_text']
|
|
|
|
|
|
|
|
|
|
| 10 |
iface = gr.Interface(fn=gpt2, inputs="text", outputs="text")
|
| 11 |
iface.launch()
|