Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the text generation pipeline
|
5 |
+
pipe = pipeline("text-generation", model="oMarquess/trained-2k10-v4-model-merged", trust_remote_code=True)
|
6 |
|
7 |
+
# Define the function to generate text based on user input
|
8 |
+
def generate_text(input_text):
|
9 |
+
generated_text = pipe(input_text, max_length=50, num_return_sequences=1)[0]['generated_text']
|
10 |
+
return generated_text
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=generate_text,
|
15 |
+
inputs=gr.Textbox(label="Input Text"),
|
16 |
+
outputs=gr.Textbox(label="Generated Text"),
|
17 |
+
layout="vertical",
|
18 |
+
title="Text Generation App",
|
19 |
+
description="Generate text using a pretrained model.",
|
20 |
+
)
|
21 |
+
|
22 |
+
# Start the Gradio app
|
23 |
+
if __name__ == "__main__":
|
24 |
+
iface.launch()
|