Spaces:
Sleeping
Sleeping
Created app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load model directly from Hugging Face Hub
|
| 5 |
+
model_name = "EleutherAI/gpt-neo-125M" # Replace with your model
|
| 6 |
+
generator = pipeline("text-generation", model=model_name)
|
| 7 |
+
|
| 8 |
+
def generate_text(prompt):
|
| 9 |
+
result = generator(prompt, max_length=50)
|
| 10 |
+
return result[0]["generated_text"]
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(
|
| 13 |
+
fn=generate_text,
|
| 14 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."),
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="Custom Hugging Face Model UI",
|
| 17 |
+
description=f"This UI interacts with the {model_name} model."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
demo.launch()
|