Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model from Hugging Face
|
5 |
+
generator = pipeline('text-generation', model='JuanCabs/lapepav1')
|
6 |
+
|
7 |
+
# Define the function for text generation
|
8 |
+
def generate_text(prompt):
|
9 |
+
results = generator(prompt, max_length=100)
|
10 |
+
return results[0]['generated_text']
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
interface = gr.Interface(
|
14 |
+
fn=generate_text, # The function to execute
|
15 |
+
inputs="text", # Input type
|
16 |
+
outputs="text", # Output type
|
17 |
+
title="Text Generation Model", # Title of the app
|
18 |
+
description="Enter a prompt to generate text using a Hugging Face model" # App description
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the app
|
22 |
+
interface.launch()
|