Spaces:
Running
Running
Upload with huggingface_hub
Browse files
README.md
CHANGED
@@ -6,7 +6,6 @@ colorFrom: indigo
|
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.4.1
|
9 |
-
|
10 |
-
app_file: app.py
|
11 |
pinned: false
|
12 |
---
|
|
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 3.4.1
|
9 |
+
app_file: run.py
|
|
|
10 |
pinned: false
|
11 |
---
|
run.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
generator = pipeline('text-generation', model='gpt2')
|
5 |
+
|
6 |
+
def generate(text):
|
7 |
+
result = generator(text, max_length=30, num_return_sequences=1)
|
8 |
+
return result[0]["generated_text"]
|
9 |
+
|
10 |
+
examples = [
|
11 |
+
["The Moon's orbit around Earth has"],
|
12 |
+
["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
|
13 |
+
]
|
14 |
+
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=generate,
|
17 |
+
inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
|
18 |
+
outputs=gr.outputs.Textbox(label="Generated Text"),
|
19 |
+
examples=examples
|
20 |
+
)
|
21 |
+
|
22 |
+
demo.launch()
|