Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the model directly from Hugging Face Model Hub
|
| 5 |
+
generator = pipeline("text-generation", model="LiquidAI/LFM2-1.2B")
|
| 6 |
+
|
| 7 |
+
# Function to generate text from input prompt
|
| 8 |
+
def generate_text(prompt):
|
| 9 |
+
result = generator(prompt, max_length=50, num_return_sequences=1)
|
| 10 |
+
return result[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
# Create a Gradio interface
|
| 13 |
+
iface = gr.Interface(fn=generate_text,
|
| 14 |
+
inputs="text",
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="GPT-2 Text Generation",
|
| 17 |
+
description="Enter a prompt and see the text generated by GPT-2!")
|
| 18 |
+
|
| 19 |
+
# Launch the interface
|
| 20 |
+
iface.launch()
|