Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Loading the 124M version for lightning speed on CPU
|
| 5 |
+
generator = pipeline('text-generation', model='gpt2')
|
| 6 |
+
|
| 7 |
+
def predict(prompt):
|
| 8 |
+
# GPT-2 needs a bit of 'length' to show its true colors
|
| 9 |
+
output = generator(prompt, max_length=150, num_return_sequences=1)
|
| 10 |
+
return output[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
gr.Interface(fn=predict, inputs="text", outputs="text").launch()
|