File size: 772 Bytes
8407a59 7e0e058 8407a59 7e0e058 8407a59 7e0e058 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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()
|