Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
generator = pipeline('text-generation', model='distilgpt2', device=-1)
|
5 |
+
|
6 |
+
def generate_text(prompt, max_length):
|
7 |
+
result = generator(prompt, max_length=max_length, num_return_sequences=1)
|
8 |
+
return result[0]['generated_text']
|
9 |
+
|
10 |
+
iface = gr.Interface(
|
11 |
+
fn=generate_text,
|
12 |
+
inputs=[
|
13 |
+
gr.Textbox(label="γγγ³γγ"),
|
14 |
+
gr.Slider(minimum=10, maximum=100, step=1, label="ζ倧ι·")
|
15 |
+
],
|
16 |
+
outputs=gr.Textbox(label="ηζγγγγγγΉγ")
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|