Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline, set_seed
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
model_name = "distilgpt2"
|
| 5 |
+
gpt2_pipeline = pipeline("text-generation", model=model_name)
|
| 6 |
+
set_seed(42)
|
| 7 |
+
|
| 8 |
+
def generate(text):
|
| 9 |
+
response = gpt2_pipeline(text, max_length=20, num_return_sequences=5)
|
| 10 |
+
return response
|
| 11 |
+
|
| 12 |
+
in_text = gr.Textbox(lines=1, label="English", placeholder="English text here")
|
| 13 |
+
out = gr.Textbox(lines=1, label="Generated text")
|
| 14 |
+
|
| 15 |
+
gr.Interface(generate, inputs=in_text, outputs=out).launch()
|