Spaces:
Sleeping
Sleeping
leotrieu commited on
Commit ·
280728b
1
Parent(s): b7f3bcc
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
text_generator = pipeline(task="text-generation")
|
| 5 |
+
|
| 6 |
+
def generate_text(prompt):
|
| 7 |
+
output = text_generator(
|
| 8 |
+
prompt,
|
| 9 |
+
max_length=100,
|
| 10 |
+
num_return_sequences=1
|
| 11 |
+
)
|
| 12 |
+
return output[0]["generated_text"]
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=generate_text,
|
| 16 |
+
inputs="textbox",
|
| 17 |
+
outputs="label",
|
| 18 |
+
title="Text Generation",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Launch the Gradio app
|
| 22 |
+
iface.launch()
|