import gradio as gr from transformers import pipeline # Initialize the text generation pipeline pipe = pipeline("text-generation", model="oMarquess/trained-2k10-v4-model-merged", trust_remote_code=True) # Define the function to generate text based on user input def generate_text(input_text): generated_text = pipe(input_text, max_length=50, num_return_sequences=1)[0]['generated_text'] return generated_text # Create the Gradio interface iface = gr.Interface( fn=generate_text, inputs=gr.Textbox(label="Input Text"), outputs=gr.Textbox(label="Generated Text"), layout="vertical", title="Text Generation App", description="Generate text using a pretrained model.", ) # Start the Gradio app if __name__ == "__main__": iface.launch()