Spaces:
Running
Running
import gradio as gr | |
from transformers import pipeline | |
# Load your AI model | |
# Replace 'model_name' with the name of your chosen model from Hugging Face | |
model_name = "EleutherAI/gpt-neo-1.3B" # Example: GPT-Neo 1.3B | |
generator = pipeline('text-generation', model=model_name) | |
# Define a function to generate text | |
def generate_text(prompt): | |
# Generate text using the model | |
output = generator(prompt, max_length=50, num_return_sequences=1) | |
return output[0]['generated_text'] | |
# Create a Gradio interface | |
iface = gr.Interface( | |
fn=generate_text, # Function to call | |
inputs="text", # Input type (text box) | |
outputs="text", # Output type (text box) | |
title="Text Generation with GPT-Neo", # Title of the interface | |
description="Enter a prompt and let the AI generate text for you!" | |
) | |
# Launch the interface | |
iface.launch() |