| import gradio as gr | |
| from transformers import pipeline | |
| # Load your Hugging Face model (change the model name) | |
| model_name = "abrotech/lora_model" | |
| pipe = pipeline("text-generation", model=model_name) | |
| # Define the function for Gradio | |
| def generate_text(prompt): | |
| result = pipe(prompt, max_length=100) | |
| return result[0]["generated_text"] | |
| # Create the Gradio Interface | |
| demo = gr.Interface( | |
| fn=generate_text, | |
| inputs="text", | |
| outputs="text", | |
| title="Text Generation with Hugging Face", | |
| description="Enter a prompt, and the model will generate text." | |
| ) | |
| # Launch the Gradio app | |
| demo.launch() | |