oMarquess commited on
Commit
7e0e058
1 Parent(s): 8407a59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,7 +1,24 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()