import gradio as gr from transformers import pipeline # Load model directly from Hugging Face Hub model_name = "EleutherAI/gpt-neo-125M" # Replace with your model generator = pipeline("text-generation", model=model_name) def generate_text(prompt): result = generator(prompt, max_length=50) return result[0]["generated_text"] demo = gr.Interface( fn=generate_text, inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."), outputs="text", title="Custom Hugging Face Model UI", description=f"This UI interacts with the {model_name} model." ) demo.launch()