Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!pip install gradio transformers
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
generator = pipeline('text-generation', model='gpt2')
|
7 |
+
|
8 |
+
def generate_text(inp):
|
9 |
+
return generator(inp, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text']
|
10 |
+
|
11 |
+
iface = gr.Interface(fn=generate_text, inputs="textbox", outputs="text")
|
12 |
+
iface.launch()
|