Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize Hugging Face pipeline
|
5 |
+
nlp = pipeline('text-generation', model='gpt2')
|
6 |
+
|
7 |
+
def generate_text(input_text):
|
8 |
+
# Generate text using Hugging Face's GPT-2 model
|
9 |
+
output_text = nlp(input_text)[0]['generated_text']
|
10 |
+
return output_text
|
11 |
+
|
12 |
+
# Create Gradio Interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_text,
|
15 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder='Enter Text Here...', maxlength=3000),
|
16 |
+
outputs='text'
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|