Spaces:
Runtime error
Runtime error
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the Hugging Face model
|
| 5 |
+
model = pipeline("text-generation", model="distilgpt2")
|
| 6 |
+
|
| 7 |
+
def generate_text(prompt):
|
| 8 |
+
generated_text = model(prompt, max_length=50)[0]['generated_text']
|
| 9 |
+
return generated_text
|
| 10 |
+
|
| 11 |
+
textbox = gr.inputs.Textbox(lines=7, label="Enter a prompt")
|
| 12 |
+
output_text = gr.outputs.Textbox(label="Generated Text")
|
| 13 |
+
|
| 14 |
+
gr.Interface(fn=generate_text, inputs=textbox, outputs=output_text, title="Hugging Face Text Generation", description="Generate text using a Hugging Face model").launch()
|