Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#for text generation
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
text_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
6 |
+
|
7 |
+
def generate_text(prompt):
|
8 |
+
generated_text = text_generator(prompt, max_length=200)[0]["generated_text"]
|
9 |
+
return generated_text
|
10 |
+
|
11 |
+
iface1 = gr.Interface(
|
12 |
+
generate_text,
|
13 |
+
inputs="text",
|
14 |
+
outputs="text",
|
15 |
+
title="Hugging Face Text Generation",
|
16 |
+
description="Generate text using Hugging Face's GPT-Neo 2.7B model.",
|
17 |
+
examples=[
|
18 |
+
["The quick brown fox",],
|
19 |
+
["Once upon a time",],
|
20 |
+
["In a galaxy far, far away",],
|
21 |
+
],
|
22 |
+
)
|
23 |
+
iface1.launch()
|